about summary refs log tree commit diff
path: root/compiler/rustc_attr_data_structures/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-06-27 16:10:20 +0000
committerbors <bors@rust-lang.org>2025-06-27 16:10:20 +0000
commitfe5f3dedf7b4d6bea2cadb17343f747d70b4c66b (patch)
treea2d21c87c62143398a4550ba96982a29c7d29e9c /compiler/rustc_attr_data_structures/src
parent13c46fd0b089360922a557d8e18a63a2c41dfbeb (diff)
parent0bbeeffe57378b9460ec6df4532b8a569003f7f9 (diff)
Auto merge of #143091 - GuillaumeGomez:rollup-f300qwe, r=GuillaumeGomez
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#142270 (Rustdoc js: even more typechecking improvements)
 - rust-lang/rust#142420 (Report infer ty errors during hir ty lowering)
 - rust-lang/rust#142671 (add #![rustc_no_implicit_bounds])
 - rust-lang/rust#142721 (Add tracing to `InterpCx::layout_of()` )
 - rust-lang/rust#142818 (Port `#[used]` to new attribute parsing infrastructure)
 - rust-lang/rust#143020 (codegen_fn_attrs: make comment more precise)
 - rust-lang/rust#143051 (Add tracing to `validate_operand`)
 - rust-lang/rust#143060 (Only args in main diag are saved and restored without removing the newly added ones)
 - rust-lang/rust#143065 (Improve recovery when users write `where:`)
 - rust-lang/rust#143084 (const-eval: error when initializing a static writes to that static)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_attr_data_structures/src')
-rw-r--r--compiler/rustc_attr_data_structures/src/attributes.rs14
-rw-r--r--compiler/rustc_attr_data_structures/src/encode_cross_crate.rs1
2 files changed, 15 insertions, 0 deletions
diff --git a/compiler/rustc_attr_data_structures/src/attributes.rs b/compiler/rustc_attr_data_structures/src/attributes.rs
index d755afad59f..60a4f289306 100644
--- a/compiler/rustc_attr_data_structures/src/attributes.rs
+++ b/compiler/rustc_attr_data_structures/src/attributes.rs
@@ -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
 }
diff --git a/compiler/rustc_attr_data_structures/src/encode_cross_crate.rs b/compiler/rustc_attr_data_structures/src/encode_cross_crate.rs
index d4402f4e2e6..64bcf1fe6cc 100644
--- a/compiler/rustc_attr_data_structures/src/encode_cross_crate.rs
+++ b/compiler/rustc_attr_data_structures/src/encode_cross_crate.rs
@@ -38,6 +38,7 @@ impl AttributeKind {
             PubTransparent(..) => Yes,
             SkipDuringMethodDispatch { .. } => No,
             TrackCaller(..) => Yes,
+            Used { .. } => No,
         }
     }
 }