Skip to content

Macro expansion bypasses #[derive_*] stability checks. #32655

Closed
@eddyb

Description

@eddyb

One can use macro expansion to bypass all early attribute checks, directly:

macro_rules! evil {
    () => {
        #[derive_Debug]
        struct Foo;
    }
}
evil!();
fn main() {}

Or by using the built-in include! macro.

// foo.rs
#[derive_Debug]
struct Foo; 
include!("foo.rs");
fn main() {}

Found while investigating libpnet breakage.

This affects any use of #[derive(...)] in syntex, as virtually everyone uses include!.
Even though I don't like stabilizing this, there may be too many cases in the wild.

Metadata

Metadata

Assignees

Labels

I-needs-decisionIssue: In need of a decision.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language 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