Skip to content

doc attributes on macro invocations can contain arbitrary expressions #160880

Description

@mejrs

I tried this code:

fn main() {
    #[doc = {
        let a = 1;
        let b = 1;
        let sum = a + b;
        assert_eq!(sum, 2);
    }]
    println!();
}

I expected to see this happen: compiler error

Instead, this happened: program compiles, no diagnostic issued

This works on rust 1.94 and newer.

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions