This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Update DefaultNoBound derive macro #12723
Merged
bkchr
merged 2 commits into
paritytech:master
from
benluelo:ben/update-default-no-bound-derive
Nov 25, 2022
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
4 changes: 4 additions & 0 deletions
4
frame/support/test/tests/derive_no_bound_ui/default_empty_enum.rs
This file contains hidden or 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,4 @@ | ||
#[derive(frame_support::DefaultNoBound)] | ||
enum Empty {} | ||
|
||
fn main() {} |
5 changes: 5 additions & 0 deletions
5
frame/support/test/tests/derive_no_bound_ui/default_empty_enum.stderr
This file contains hidden or 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: cannot derive Default for an empty enum | ||
--> tests/derive_no_bound_ui/default_empty_enum.rs:2:6 | ||
| | ||
2 | enum Empty {} | ||
| ^^^^^ |
11 changes: 11 additions & 0 deletions
11
frame/support/test/tests/derive_no_bound_ui/default_no_attribute.rs
This file contains hidden or 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,11 @@ | ||
trait Config { | ||
type C; | ||
} | ||
|
||
#[derive(frame_support::DefaultNoBound)] | ||
enum Foo<T: Config> { | ||
Bar(T::C), | ||
Baz, | ||
} | ||
|
||
fn main() {} |
5 changes: 5 additions & 0 deletions
5
frame/support/test/tests/derive_no_bound_ui/default_no_attribute.stderr
This file contains hidden or 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: no default declared, make a variant default by placing `#[default]` above it | ||
--> tests/derive_no_bound_ui/default_no_attribute.rs:6:6 | ||
| | ||
6 | enum Foo<T: Config> { | ||
| ^^^ |
13 changes: 13 additions & 0 deletions
13
frame/support/test/tests/derive_no_bound_ui/default_too_many_attributes.rs
This file contains hidden or 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,13 @@ | ||
trait Config { | ||
type C; | ||
} | ||
|
||
#[derive(frame_support::DefaultNoBound)] | ||
enum Foo<T: Config> { | ||
#[default] | ||
Bar(T::C), | ||
#[default] | ||
Baz, | ||
} | ||
|
||
fn main() {} |
21 changes: 21 additions & 0 deletions
21
frame/support/test/tests/derive_no_bound_ui/default_too_many_attributes.stderr
This file contains hidden or 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 @@ | ||
error: multiple declared defaults | ||
--> tests/derive_no_bound_ui/default_too_many_attributes.rs:5:10 | ||
| | ||
5 | #[derive(frame_support::DefaultNoBound)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this error originates in the derive macro `frame_support::DefaultNoBound` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: first default | ||
--> tests/derive_no_bound_ui/default_too_many_attributes.rs:7:2 | ||
| | ||
7 | / #[default] | ||
8 | | Bar(T::C), | ||
| |_____________^ | ||
|
||
error: additional default | ||
--> tests/derive_no_bound_ui/default_too_many_attributes.rs:9:2 | ||
| | ||
9 | / #[default] | ||
10 | | Baz, | ||
| |_______^ |
This file contains hidden or 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,7 @@ | ||
#[derive(frame_support::DefaultNoBound)] | ||
union Foo { | ||
field1: u32, | ||
field2: (), | ||
} | ||
|
||
fn main() {} |
5 changes: 5 additions & 0 deletions
5
frame/support/test/tests/derive_no_bound_ui/default_union.stderr
This file contains hidden or 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: Union type not supported by `derive(DefaultNoBound)` | ||
--> tests/derive_no_bound_ui/default_union.rs:2:1 | ||
| | ||
2 | union Foo { | ||
| ^^^^^ |
This file contains hidden or 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 |
---|---|---|
|
@@ -97,6 +97,7 @@ pub(crate) type ChargeAssetLiquidityOf<T> = | |
#[derive(Encode, Decode, DefaultNoBound, TypeInfo)] | ||
pub enum InitialPayment<T: Config> { | ||
/// No initial fee was payed. | ||
#[default] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you change this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh it was just deriving default using the first variant... |
||
Nothing, | ||
/// The initial fee was payed in the native currency. | ||
Native(LiquidityInfoOf<T>), | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.