-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create E0774 #76406
Merged
Merged
Create E0774 #76406
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 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 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,24 @@ | ||
`derive` was applied on something which is not a struct, a union or an enum. | ||
|
||
Erroneous code example: | ||
|
||
```compile_fail,E0774 | ||
trait Foo { | ||
#[derive(Clone)] // error! | ||
type Bar; | ||
} | ||
``` | ||
|
||
As said above, the `derive` attribute is only allowed on structs, unions or | ||
enums: | ||
|
||
``` | ||
#[derive(Clone)] // ok! | ||
struct Bar { | ||
field: u32, | ||
} | ||
``` | ||
|
||
You can find more information about `derive` in the [Rust Book]. | ||
|
||
[Rust Book]: https://doc.rust-lang.org/book/appendix-03-derivable-traits.html |
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
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 |
---|---|---|
@@ -1,14 +1,15 @@ | ||
error: `derive` may only be applied to structs, enums and unions | ||
error[E0774]: `derive` may only be applied to structs, enums and unions | ||
--> $DIR/derive-on-trait-item-or-impl-item.rs:2:5 | ||
| | ||
LL | #[derive(Clone)] | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: `derive` may only be applied to structs, enums and unions | ||
error[E0774]: `derive` may only be applied to structs, enums and unions | ||
--> $DIR/derive-on-trait-item-or-impl-item.rs:10:5 | ||
| | ||
LL | #[derive(Clone)] | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0774`. |
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 |
---|---|---|
@@ -1,56 +1,57 @@ | ||
error: `derive` may only be applied to structs, enums and unions | ||
error[E0774]: `derive` may only be applied to structs, enums and unions | ||
--> $DIR/deriving-non-type.rs:5:1 | ||
| | ||
LL | #[derive(PartialEq)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: `derive` may only be applied to structs, enums and unions | ||
error[E0774]: `derive` may only be applied to structs, enums and unions | ||
--> $DIR/deriving-non-type.rs:8:1 | ||
| | ||
LL | #[derive(PartialEq)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: `derive` may only be applied to structs, enums and unions | ||
error[E0774]: `derive` may only be applied to structs, enums and unions | ||
--> $DIR/deriving-non-type.rs:11:1 | ||
| | ||
LL | #[derive(PartialEq)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: `derive` may only be applied to structs, enums and unions | ||
error[E0774]: `derive` may only be applied to structs, enums and unions | ||
--> $DIR/deriving-non-type.rs:14:1 | ||
| | ||
LL | #[derive(PartialEq)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: `derive` may only be applied to structs, enums and unions | ||
error[E0774]: `derive` may only be applied to structs, enums and unions | ||
--> $DIR/deriving-non-type.rs:17:1 | ||
| | ||
LL | #[derive(PartialEq)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: `derive` may only be applied to structs, enums and unions | ||
error[E0774]: `derive` may only be applied to structs, enums and unions | ||
--> $DIR/deriving-non-type.rs:20:1 | ||
| | ||
LL | #[derive(PartialEq)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: `derive` may only be applied to structs, enums and unions | ||
error[E0774]: `derive` may only be applied to structs, enums and unions | ||
--> $DIR/deriving-non-type.rs:23:1 | ||
| | ||
LL | #[derive(PartialEq)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: `derive` may only be applied to structs, enums and unions | ||
error[E0774]: `derive` may only be applied to structs, enums and unions | ||
--> $DIR/deriving-non-type.rs:26:1 | ||
| | ||
LL | #[derive(PartialEq)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: `derive` may only be applied to structs, enums and unions | ||
error[E0774]: `derive` may only be applied to structs, enums and unions | ||
--> $DIR/deriving-non-type.rs:29:1 | ||
| | ||
LL | #[derive(PartialEq)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 9 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0774`. |
11 changes: 6 additions & 5 deletions
11
src/test/ui/feature-gate/issue-43106-gating-of-derive.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 |
---|---|---|
@@ -1,32 +1,33 @@ | ||
error: `derive` may only be applied to structs, enums and unions | ||
error[E0774]: `derive` may only be applied to structs, enums and unions | ||
--> $DIR/issue-43106-gating-of-derive.rs:4:1 | ||
| | ||
LL | #[derive(Debug)] | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: `derive` may only be applied to structs, enums and unions | ||
error[E0774]: `derive` may only be applied to structs, enums and unions | ||
--> $DIR/issue-43106-gating-of-derive.rs:7:17 | ||
| | ||
LL | mod inner { #![derive(Debug)] } | ||
| ^^^^^^^^^^^^^^^^^ help: try an outer attribute: `#[derive(Debug)]` | ||
|
||
error: `derive` may only be applied to structs, enums and unions | ||
error[E0774]: `derive` may only be applied to structs, enums and unions | ||
--> $DIR/issue-43106-gating-of-derive.rs:10:5 | ||
| | ||
LL | #[derive(Debug)] | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: `derive` may only be applied to structs, enums and unions | ||
error[E0774]: `derive` may only be applied to structs, enums and unions | ||
--> $DIR/issue-43106-gating-of-derive.rs:23:5 | ||
| | ||
LL | #[derive(Debug)] | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: `derive` may only be applied to structs, enums and unions | ||
error[E0774]: `derive` may only be applied to structs, enums and unions | ||
--> $DIR/issue-43106-gating-of-derive.rs:27:5 | ||
| | ||
LL | #[derive(Debug)] | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 5 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0774`. |
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
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 |
---|---|---|
@@ -1,20 +1,21 @@ | ||
error: `derive` may only be applied to structs, enums and unions | ||
error[E0774]: `derive` may only be applied to structs, enums and unions | ||
--> $DIR/issue-43023.rs:4:5 | ||
| | ||
LL | #[derive(Debug)] | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: `derive` may only be applied to structs, enums and unions | ||
error[E0774]: `derive` may only be applied to structs, enums and unions | ||
--> $DIR/issue-43023.rs:11:5 | ||
| | ||
LL | #[derive(Debug)] | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: `derive` may only be applied to structs, enums and unions | ||
error[E0774]: `derive` may only be applied to structs, enums and unions | ||
--> $DIR/issue-43023.rs:16:5 | ||
| | ||
LL | #[derive(Debug)] | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0774`. |
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
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
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
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
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
error: `derive` may only be applied to structs, enums and unions | ||
error[E0774]: `derive` may only be applied to structs, enums and unions | ||
--> $DIR/macros-in-extern-derive.rs:2:5 | ||
| | ||
LL | #[derive(Copy)] | ||
| ^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0774`. |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this is generally imported and used without the
rustc_errors
prefix