Port #[used] to new attribute parsing infrastructure

Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
This commit is contained in:
Jonathan Brouwer
2025-06-25 09:36:26 +02:00
parent e61dd437f3
commit 9e35684072
15 changed files with 188 additions and 127 deletions

View File

@@ -131,6 +131,17 @@ impl Deprecation {
}
}
/// There are three valid forms of the attribute:
/// `#[used]`, which is semantically equivalent to `#[used(linker)]` except that the latter is currently unstable.
/// `#[used(compiler)]`
/// `#[used(linker)]`
#[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[derive(HashStable_Generic, PrintAttribute)]
pub enum UsedBy {
Compiler,
Linker,
}
/// Represents parsed *built-in* inert attributes.
///
/// ## Overview
@@ -285,5 +296,8 @@ pub enum AttributeKind {
/// Represents `#[track_caller]`
TrackCaller(Span),
/// Represents `#[used]`
Used { used_by: UsedBy, span: Span },
// tidy-alphabetical-end
}

View File

@@ -38,6 +38,7 @@ impl AttributeKind {
PubTransparent(..) => Yes,
SkipDuringMethodDispatch { .. } => No,
TrackCaller(..) => Yes,
Used { .. } => No,
}
}
}