Skip to content

Invalid derive proc macro output silently ignored #87314

Open
@m-ou-se

Description

@m-ou-se

A derive proc macro expanding to something starting with a { is ignored:

use proc_macro::TokenStream;

#[proc_macro_derive(Test)]
pub fn test(_: TokenStream) -> TokenStream {
    quote::quote!(
        {}
        fn main() {}
    ).into()
}
use scratchpad::Test;

#[derive(Test)]
struct A;
error[E0601]: `main` function not found in crate `scratchpad`
 --> src/main.rs:1:1
  |
1 | / use scratchpad::Test;
2 | |
3 | | #[derive(Test)]
4 | | struct A;
  | |_________^ consider adding a `main` function to `src/main.rs`

Metadata

Metadata

Assignees

Labels

A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-proc-macrosArea: Procedural macrosC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions