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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions