-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
// lib.rs in proc-macro crate
#[proc_macro_derive(MyTrait)]
pub fn mytrait(item: TokenStream) -> TokenStream {
"compile_error!()".parse().unwrap()
}
// lib.rs in other crate
#[derive(MyTrait)]
struct MyStruct;
error: macros that expand to items must be delimited with braces or followed by a semicolon
--> examples\mytrait.rs:10:10
|
10 | #[derive(MyTrait)]
| ^^^^^^^
|
= note: this error originates in the derive macro `MyTrait` (in Nightly builds, run with -Z macro-backtrace for more info)
help: change the delimiters to curly braces
|
10 | #[derive({})]
| ~
help: add a semicolon
|
10 | #[derive(MyTrait;)]
| +
Both suggestions have invalid syntax.
Ideally rustc should suggest to add ;
into token stream returned from derive-proc-macro.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.