diff --git a/substrate/frame/support/src/dispatch.rs b/substrate/frame/support/src/dispatch.rs index f6f42a28ca..3d12d7cf95 100644 --- a/substrate/frame/support/src/dispatch.rs +++ b/substrate/frame/support/src/dispatch.rs @@ -1075,7 +1075,6 @@ macro_rules! decl_module { // Declare a `Call` variant parameter that should be encoded `compact`. (@create_call_enum - $( #[$attr:meta] )* $call_type:ident; <$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path $(= $module_default_instance:path)?)?> { $( $other_where_bounds:tt )* } @@ -1089,7 +1088,6 @@ macro_rules! decl_module { ) => { $crate::decl_module! { @create_call_enum - $( #[$attr] )* $call_type; <$trait_instance: $trait_name $(, $instance: $instantiable $(= $module_default_instance)? )?> { $( $other_where_bounds )* } @@ -1107,7 +1105,6 @@ macro_rules! decl_module { // Declare a `Call` variant parameter. (@create_call_enum - $( #[$attr:meta] )* $call_type:ident; <$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path $(= $module_default_instance:path)?)?> { $( $other_where_bounds:tt )* } @@ -1120,7 +1117,6 @@ macro_rules! decl_module { ) => { $crate::decl_module! { @create_call_enum - $( #[$attr] )* $call_type; <$trait_instance: $trait_name $(, $instance: $instantiable $(= $module_default_instance)? )?> { $( $other_where_bounds )* } @@ -1136,7 +1132,6 @@ macro_rules! decl_module { }; (@create_call_enum - $( #[$attr:meta] )* $call_type:ident; <$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path $(= $module_default_instance:path)?)?> { $( $other_where_bounds:tt )* } @@ -1151,7 +1146,6 @@ macro_rules! decl_module { ) => { $crate::decl_module! { @create_call_enum - $( #[$attr] )* $call_type; <$trait_instance: $trait_name $(, $instance: $instantiable $(= $module_default_instance)? )?> { $( $other_where_bounds )* } @@ -1172,15 +1166,16 @@ macro_rules! decl_module { }; (@create_call_enum - $( #[$attr:meta] )* $call_type:ident; <$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path $(= $module_default_instance:path)?)?> { $( $other_where_bounds:tt )* } { $( $generated_variants:tt )* } {} ) => { + /// Dispatchable calls. + /// + /// Each variant of this enum maps to a dispatchable function from the associated module. #[derive($crate::codec::Encode, $crate::codec::Decode)] - $( #[$attr] )* pub enum $call_type<$trait_instance: $trait_name$(, $instance: $instantiable $( = $module_default_instance)?)?> where $( $other_where_bounds )* { @@ -1221,6 +1216,7 @@ macro_rules! decl_module { // Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted. #[derive(Clone, Copy, PartialEq, Eq, $crate::RuntimeDebug)] + $( #[$attr] )* pub struct $mod_type< $trait_instance: $trait_name $(, $instance: $instantiable $( = $module_default_instance)?)? @@ -1286,7 +1282,6 @@ macro_rules! decl_module { $crate::decl_module! { @create_call_enum - $( #[$attr] )* $call_type; <$trait_instance: $trait_name $(, $instance: $instantiable $(= $module_default_instance)? )?> { $( $other_where_bounds )* } diff --git a/substrate/frame/support/test/src/lib.rs b/substrate/frame/support/test/src/lib.rs index c6a93e1b77..ec78a8c400 100644 --- a/substrate/frame/support/test/src/lib.rs +++ b/substrate/frame/support/test/src/lib.rs @@ -16,3 +16,20 @@ //! Test crate for frame_support. Allow to make use of `frame_support::decl_storage`. //! See tests directory. + +// Make sure we fail compilation on warnings +#![warn(missing_docs)] +#![deny(warnings)] + +/// The configuration trait +pub trait Trait { + /// The runtime origin type. + type Origin; + /// The block number type. + type BlockNumber; +} + +frame_support::decl_module! { + /// Some test module + pub struct Module for enum Call where origin: T::Origin {} +} diff --git a/substrate/frame/support/test/tests/system.rs b/substrate/frame/support/test/tests/system.rs index 83786538e6..5dff9eef9a 100644 --- a/substrate/frame/support/test/tests/system.rs +++ b/substrate/frame/support/test/tests/system.rs @@ -1,3 +1,19 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + use frame_support::codec::{Encode, Decode, EncodeLike}; pub trait Trait: 'static + Eq + Clone { @@ -12,13 +28,11 @@ pub trait Trait: 'static + Eq + Clone { } frame_support::decl_module! { - pub struct Module for enum Call where origin: T::Origin { - } + pub struct Module for enum Call where origin: T::Origin {} } impl Module { - pub fn deposit_event(_event: impl Into) { - } + pub fn deposit_event(_event: impl Into) {} } frame_support::decl_event!(