-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #76406 - GuillaumeGomez:create-e0774, r=pickfire,jyn514
Create E0774
- Loading branch information
Showing
14 changed files
with
69 additions
and
31 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
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