-
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.
Find derive macro attributes even if the macro isn't imported directly
- Loading branch information
Showing
3 changed files
with
152 additions
and
5 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,25 @@ | ||
// aux-build:serde.rs | ||
// compile-flags:--extern serde --crate-type bin --edition 2021 | ||
|
||
// derive macros not imported, but namespace imported | ||
use serde; | ||
|
||
#[serde(untagged)] //~ ERROR cannot find attribute `serde` | ||
enum A { | ||
A, | ||
B, | ||
} | ||
|
||
enum B { | ||
A, | ||
#[serde(untagged)] //~ ERROR cannot find attribute `serde` | ||
B, | ||
} | ||
|
||
enum C { | ||
A, | ||
#[sede(untagged)] //~ ERROR cannot find attribute `sede` | ||
B, | ||
} | ||
|
||
fn main() {} |
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,45 @@ | ||
error: cannot find attribute `sede` in this scope | ||
--> $DIR/missing-derive-4.rs:21:7 | ||
| | ||
LL | #[sede(untagged)] | ||
| ^^^^ | ||
| | ||
help: the derive macros `Serialize` and `Deserialize` accept the similarly named `serde` attribute | ||
| | ||
LL | #[serde(untagged)] | ||
| ~~~~~ | ||
|
||
error: cannot find attribute `serde` in this scope | ||
--> $DIR/missing-derive-4.rs:15:7 | ||
| | ||
LL | #[serde(untagged)] | ||
| ^^^^^ | ||
| | ||
note: `serde` is imported here, but it is a crate, not an attribute | ||
--> $DIR/missing-derive-4.rs:5:5 | ||
| | ||
LL | use serde; | ||
| ^^^^^ | ||
help: `serde` is an attribute that can be used by the derive macros `Serialize` and `Deserialize`, you might be missing a `derive` attribute | ||
| | ||
LL | #[derive(Serialize, Deserialize)] | ||
| | ||
|
||
error: cannot find attribute `serde` in this scope | ||
--> $DIR/missing-derive-4.rs:7:3 | ||
| | ||
LL | #[serde(untagged)] | ||
| ^^^^^ | ||
| | ||
note: `serde` is imported here, but it is a crate, not an attribute | ||
--> $DIR/missing-derive-4.rs:5:5 | ||
| | ||
LL | use serde; | ||
| ^^^^^ | ||
help: `serde` is an attribute that can be used by the derive macros `Serialize` and `Deserialize`, you might be missing a `derive` attribute | ||
| | ||
LL | #[derive(Serialize, Deserialize)] | ||
| | ||
|
||
error: aborting due to 3 previous errors | ||
|