Files
rust/compiler
bors 80729d7ce0 Auto merge of #155662 - mejrs:this_the_thing, r=petrochenkov
Permit `{This}` in diagnostic attribute format literals

My motivation was that yesterday I wanted to write something like this and reference `$name` in the string literal.

```rust
pub mod sym {
   // stuff here
}

macro_rules! my_macro {
    ($name:ident $(,)?) => {{
        #[diagnostic::on_unknown(
            message = "this is not present in symbol table",
            note = "you must add it to rustc_span::symbol::symbol!"
        )]
        use sym::$name as name;
        // ...
    }}
}
```

That is (as far as I can tell) impossible or at least very unergonomic. This adds the ability to just reference the name of the item the attribute is on. I imagine that's useful for use inside macros generally, so it's also added for some other attributes.

The affected attributes are all unstable, it is not implemented for diagnostic::on_unimplemented (will do in its own PR).

Note that `{This}` is already usable in `#[rustc_on_unimplemented]`, so this does not implement it but just enables some more.

This PR also migrates one lint away from AttributeLintKind, and improves the messages for that lint.
2026-04-24 20:46:55 +00:00
..
2026-04-19 15:58:02 +09:00
2026-04-20 00:18:28 +08:00
2026-04-15 13:50:43 +02:00
2026-04-22 19:28:44 +08:00
2026-04-22 19:28:44 +08:00
2026-04-20 00:18:28 +08:00
2026-04-20 00:18:28 +08:00
2026-04-20 00:18:28 +08:00
2026-04-08 21:09:07 +02:00
2026-04-22 19:28:44 +08:00
2026-04-20 00:18:28 +08:00