-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add error checks for duplicate attributes
- Loading branch information
Showing
3 changed files
with
135 additions
and
5 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
compatibility-tests/compile-fail/tests/ui/attribute-duplication.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,28 @@ | ||
mod enum_duplication { | ||
use snafu::Snafu; | ||
|
||
#[derive(Debug, Snafu)] | ||
enum EnumError { | ||
#[snafu(display("an error variant"))] | ||
AVariant { | ||
#[snafu(source(from(EnumError, Box::new)))] | ||
#[snafu(backtrace(delegate))] | ||
source: Box<EnumError>, | ||
#[snafu(source)] | ||
#[snafu(backtrace(delegate))] | ||
source2: String, | ||
#[snafu(source)] | ||
#[snafu(backtrace(delegate))] | ||
source3: String, | ||
|
||
#[snafu(backtrace)] | ||
backtrace1: String, | ||
#[snafu(backtrace)] | ||
backtrace2: String, | ||
#[snafu(backtrace)] | ||
backtrace3: String, | ||
}, | ||
} | ||
} | ||
|
||
fn main() {} |
47 changes: 47 additions & 0 deletions
47
compatibility-tests/compile-fail/tests/ui/attribute-duplication.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,47 @@ | ||
error: Only one field can be designated as 'source'; found a duplicate here: | ||
--> $DIR/attribute-duplication.rs:16:13 | ||
| | ||
16 | source3: String, | ||
| ^^^^^^^ | ||
|
||
error: Only one field can be designated as 'source'; found a duplicate here: | ||
--> $DIR/attribute-duplication.rs:13:13 | ||
| | ||
13 | source2: String, | ||
| ^^^^^^^ | ||
|
||
error: Only one field can be designated as 'backtrace'; found a duplicate here: | ||
--> $DIR/attribute-duplication.rs:23:13 | ||
| | ||
23 | backtrace3: String, | ||
| ^^^^^^^^^^ | ||
|
||
error: Only one field can be designated as 'backtrace'; found a duplicate here: | ||
--> $DIR/attribute-duplication.rs:21:13 | ||
| | ||
21 | backtrace2: String, | ||
| ^^^^^^^^^^ | ||
|
||
error: Only one field can be designated as 'backtrace(delegate)'; found a duplicate here: | ||
--> $DIR/attribute-duplication.rs:16:13 | ||
| | ||
16 | source3: String, | ||
| ^^^^^^^ | ||
|
||
error: Only one field can be designated as 'backtrace(delegate)'; found a duplicate here: | ||
--> $DIR/attribute-duplication.rs:13:13 | ||
| | ||
13 | source2: String, | ||
| ^^^^^^^ | ||
|
||
error: Cannot have 'backtrace' and 'backtrace(delegate)' fields in the same enum | ||
--> $DIR/attribute-duplication.rs:19:13 | ||
| | ||
19 | backtrace1: String, | ||
| ^^^^^^^^^^ | ||
|
||
error: Cannot have 'backtrace' and 'backtrace(delegate)' fields in the same enum | ||
--> $DIR/attribute-duplication.rs:10:13 | ||
| | ||
10 | source: Box<EnumError>, | ||
| ^^^^^^ |
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