forked from paritytech/substrate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Forbid stray tokens in call index (paritytech#13036)
* Check for call_index * fixes * pallet ui test for weight attribute * Update frame/support/procedural/src/pallet/parse/call.rs Co-authored-by: Bastian Köcher <git@kchr.de> * fix * small fix * wrong return type * ... * . * final fix * update .stderr * commit * udpate * Update frame/support/procedural/src/pallet/parse/call.rs Co-authored-by: Bastian Köcher <git@kchr.de> * update .stderr Co-authored-by: Bastian Köcher <git@kchr.de>
- Loading branch information
Showing
5 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
frame/support/test/tests/pallet_ui/call_index_has_suffix.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#[frame_support::pallet] | ||
mod pallet { | ||
use frame_support::pallet_prelude::DispatchResultWithPostInfo; | ||
use frame_system::pallet_prelude::OriginFor; | ||
|
||
#[pallet::config] | ||
pub trait Config: frame_system::Config {} | ||
|
||
#[pallet::pallet] | ||
pub struct Pallet<T>(core::marker::PhantomData<T>); | ||
|
||
#[pallet::call] | ||
impl<T: Config> Pallet<T> { | ||
#[pallet::call_index(0something)] | ||
pub fn foo(origin: OriginFor<T>) -> DispatchResultWithPostInfo {} | ||
} | ||
} | ||
|
||
fn main() { | ||
} |
5 changes: 5 additions & 0 deletions
5
frame/support/test/tests/pallet_ui/call_index_has_suffix.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
error: Number literal must not have a suffix | ||
--> tests/pallet_ui/call_index_has_suffix.rs:14:30 | ||
| | ||
14 | #[pallet::call_index(0something)] | ||
| ^^^^^^^^^^ |
21 changes: 21 additions & 0 deletions
21
frame/support/test/tests/pallet_ui/weight_argument_has_suffix.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#[frame_support::pallet] | ||
mod pallet { | ||
use frame_support::pallet_prelude::DispatchResultWithPostInfo; | ||
use frame_system::pallet_prelude::OriginFor; | ||
|
||
#[pallet::config] | ||
pub trait Config: frame_system::Config {} | ||
|
||
#[pallet::pallet] | ||
pub struct Pallet<T>(core::marker::PhantomData<T>); | ||
|
||
#[pallet::call] | ||
impl<T: Config> Pallet<T> { | ||
#[pallet::call_index(0)] | ||
#[pallet::weight(10_000something)] | ||
pub fn foo(origin: OriginFor<T>) -> DispatchResultWithPostInfo { Ok(().into()) } | ||
} | ||
} | ||
|
||
fn main() { | ||
} |
41 changes: 41 additions & 0 deletions
41
frame/support/test/tests/pallet_ui/weight_argument_has_suffix.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
error: invalid suffix `something` for number literal | ||
--> tests/pallet_ui/weight_argument_has_suffix.rs:15:26 | ||
| | ||
15 | #[pallet::weight(10_000something)] | ||
| ^^^^^^^^^^^^^^^ invalid suffix `something` | ||
| | ||
= help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) | ||
|
||
error[E0308]: mismatched types | ||
--> tests/pallet_ui/weight_argument_has_suffix.rs:12:12 | ||
| | ||
12 | #[pallet::call] | ||
| ^^^^ | ||
| | | ||
| expected trait `frame_support::dispatch::ClassifyDispatch`, found trait `frame_support::dispatch::WeighData` | ||
| arguments to this function are incorrect | ||
| | ||
= note: expected reference `&dyn frame_support::dispatch::ClassifyDispatch<()>` | ||
found reference `&dyn frame_support::dispatch::WeighData<()>` | ||
note: associated function defined here | ||
--> $WORKSPACE/frame/support/src/dispatch.rs | ||
| | ||
| fn classify_dispatch(&self, target: T) -> DispatchClass; | ||
| ^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0308]: mismatched types | ||
--> tests/pallet_ui/weight_argument_has_suffix.rs:12:12 | ||
| | ||
12 | #[pallet::call] | ||
| ^^^^ | ||
| | | ||
| expected trait `frame_support::dispatch::PaysFee`, found trait `frame_support::dispatch::WeighData` | ||
| arguments to this function are incorrect | ||
| | ||
= note: expected reference `&dyn frame_support::dispatch::PaysFee<()>` | ||
found reference `&dyn frame_support::dispatch::WeighData<()>` | ||
note: associated function defined here | ||
--> $WORKSPACE/frame/support/src/dispatch.rs | ||
| | ||
| fn pays_fee(&self, _target: T) -> Pays; | ||
| ^^^^^^^^ |