Rollup merge of #142498 - GrigorenkoPV:as-ptr-refactor, r=jdonszelmann

Port `#[rustc_as_ptr]` to the new attribute system

It might make sense to introduce some new parser analogous to `Single`, but even more simple: for parsing attributes that take no arguments and may appear only once (such as `#[rustc_as_ptr]` or `#[rustc_const_stable_indirect]`). Not sure if this should be a single `impl` parsing all such attributes, or one impl per attribute. Or how it will play along with the upcoming rework of attribute validation. Or how these argumentless attributes should be called (I've loosely referred to them as `markers` in the name of the new module in this PR, but not sure how good it is).

This is a part of rust-lang/rust#131229, so
r? `@jdonszelmann`

---

For reference, the `#[rustc_as_ptr]` attribute was created back in rust-lang/rust#132732 as a followup to rust-lang/rust#128985.
This commit is contained in:
Jakub Beránek
2025-06-16 19:54:34 +02:00
committed by GitHub
6 changed files with 41 additions and 13 deletions

View File

@@ -188,6 +188,9 @@ pub enum AttributeKind {
/// Represents `#[allow_internal_unstable]`.
AllowInternalUnstable(ThinVec<(Symbol, Span)>),
/// Represents `#[rustc_as_ptr]` (used by the `dangling_pointers_from_temporaries` lint).
AsPtr(Span),
/// Represents `#[rustc_default_body_unstable]`.
BodyStability {
stability: DefaultBodyStability,