-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Look at proc-macro attributes when encountering unknown attribute
``` error: cannot find attribute `sede` in this scope --> src/main.rs:18:7 | 18 | #[sede(untagged)] | ^^^^ | help: the derive macros `Serialize` and `Deserialize` accept the similarly named `serde` attribute | 18 | #[serde(untagged)] | ~~~~~ error: cannot find attribute `serde` in this scope --> src/main.rs:12:7 | 12 | #[serde(untagged)] | ^^^^^ | = note: `serde` is in scope, but it is a crate, not an attribute help: `serde` is an attribute that can be used by the derive macros `Serialize` and `Deserialize`, you might be missing a `derive` attribute | 10 | #[derive(Serialize, Deserialize)] | ``` Mitigate #47608.
- Loading branch information
Showing
12 changed files
with
273 additions
and
2 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
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//@ force-host | ||
//@ no-prefer-dynamic | ||
|
||
#![crate_type = "proc-macro"] | ||
#![feature(proc_macro_quote)] | ||
|
||
extern crate proc_macro; | ||
|
||
use proc_macro::*; | ||
|
||
#[proc_macro_derive(Serialize, attributes(serde))] | ||
pub fn serialize(ts: TokenStream) -> TokenStream { | ||
quote!{} | ||
} | ||
|
||
#[proc_macro_derive(Deserialize, attributes(serde))] | ||
pub fn deserialize(ts: TokenStream) -> TokenStream { | ||
quote!{} | ||
} |
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,33 @@ | ||
//@aux-build:serde.rs | ||
|
||
// derive macros imported and used | ||
|
||
extern crate serde; | ||
use serde::{Serialize, Deserialize}; | ||
|
||
#[serde(untagged)] //~ ERROR cannot find attribute `serde` | ||
enum A { //~ HELP `serde` is an attribute that can be used by the derive macros `Serialize` and `Deserialize` | ||
A, | ||
B, | ||
} | ||
|
||
enum B { //~ HELP `serde` is an attribute that can be used by the derive macros `Serialize` and `Deserialize` | ||
A, | ||
#[serde(untagged)] //~ ERROR cannot find attribute `serde` | ||
B, | ||
} | ||
|
||
enum C { | ||
A, | ||
#[sede(untagged)] //~ ERROR cannot find attribute `sede` | ||
B, //~^ HELP the derive macros `Serialize` and `Deserialize` accept the similarly named `serde` attribute | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
#[serde(untagged)] | ||
enum D { | ||
A, | ||
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,47 @@ | ||
error: cannot find attribute `serde` in this scope | ||
--> $DIR/missing-derive-1.rs:8:3 | ||
| | ||
LL | #[serde(untagged)] | ||
| ^^^^^ | ||
| | ||
note: `serde` is imported here, but it is a crate, not an attribute | ||
--> $DIR/missing-derive-1.rs:5:1 | ||
| | ||
LL | extern crate 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)] | ||
LL | enum A { | ||
| | ||
|
||
error: cannot find attribute `serde` in this scope | ||
--> $DIR/missing-derive-1.rs:16:7 | ||
| | ||
LL | #[serde(untagged)] | ||
| ^^^^^ | ||
| | ||
note: `serde` is imported here, but it is a crate, not an attribute | ||
--> $DIR/missing-derive-1.rs:5:1 | ||
| | ||
LL | extern crate 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)] | ||
LL | enum B { | ||
| | ||
|
||
error: cannot find attribute `sede` in this scope | ||
--> $DIR/missing-derive-1.rs:22:7 | ||
| | ||
LL | #[sede(untagged)] | ||
| ^^^^ | ||
| | ||
help: the derive macros `Serialize` and `Deserialize` accept the similarly named `serde` attribute | ||
| | ||
LL | #[serde(untagged)] | ||
| ~~~~~ | ||
|
||
error: aborting due to 3 previous errors | ||
|
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,26 @@ | ||
//@aux-build:serde.rs | ||
|
||
// derive macros imported but unused | ||
|
||
extern crate serde; | ||
use serde::{Serialize, Deserialize}; | ||
|
||
#[serde(untagged)] //~ ERROR cannot find attribute `serde` | ||
enum A { //~ HELP `serde` is an attribute that can be used by the derive macros `Serialize` and `Deserialize` | ||
A, | ||
B, | ||
} | ||
|
||
enum B { //~ HELP `serde` is an attribute that can be used by the derive macros `Serialize` and `Deserialize` | ||
A, | ||
#[serde(untagged)] //~ ERROR cannot find attribute `serde` | ||
B, | ||
} | ||
|
||
enum C { | ||
A, | ||
#[sede(untagged)] //~ ERROR cannot find attribute `sede` | ||
B, //~^ HELP the derive macros `Serialize` and `Deserialize` accept the similarly named `serde` attribute | ||
} | ||
|
||
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,47 @@ | ||
error: cannot find attribute `sede` in this scope | ||
--> $DIR/missing-derive-2.rs:22: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-2.rs:16:7 | ||
| | ||
LL | #[serde(untagged)] | ||
| ^^^^^ | ||
| | ||
note: `serde` is imported here, but it is a crate, not an attribute | ||
--> $DIR/missing-derive-2.rs:5:1 | ||
| | ||
LL | extern crate 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)] | ||
LL | enum B { | ||
| | ||
|
||
error: cannot find attribute `serde` in this scope | ||
--> $DIR/missing-derive-2.rs:8:3 | ||
| | ||
LL | #[serde(untagged)] | ||
| ^^^^^ | ||
| | ||
note: `serde` is imported here, but it is a crate, not an attribute | ||
--> $DIR/missing-derive-2.rs:5:1 | ||
| | ||
LL | extern crate 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)] | ||
LL | enum A { | ||
| | ||
|
||
error: aborting due to 3 previous errors | ||
|
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 @@ | ||
//@aux-build:serde.rs | ||
|
||
// derive macros not imported, but namespace imported. Not yet handled. | ||
extern crate 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,32 @@ | ||
error: cannot find attribute `sede` in this scope | ||
--> $DIR/missing-derive-3.rs:20:7 | ||
| | ||
LL | #[sede(untagged)] | ||
| ^^^^ | ||
|
||
error: cannot find attribute `serde` in this scope | ||
--> $DIR/missing-derive-3.rs:14:7 | ||
| | ||
LL | #[serde(untagged)] | ||
| ^^^^^ | ||
| | ||
note: `serde` is imported here, but it is a crate, not an attribute | ||
--> $DIR/missing-derive-3.rs:4:1 | ||
| | ||
LL | extern crate serde; | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: cannot find attribute `serde` in this scope | ||
--> $DIR/missing-derive-3.rs:6:3 | ||
| | ||
LL | #[serde(untagged)] | ||
| ^^^^^ | ||
| | ||
note: `serde` is imported here, but it is a crate, not an attribute | ||
--> $DIR/missing-derive-3.rs:4:1 | ||
| | ||
LL | extern crate serde; | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|