1//! Built-in attributes and `cfg` flag gating.
23use std::sync::LazyLock;
45use AttributeGate::*;
6use rustc_ast::ast::Safety;
7use rustc_data_structures::fx::FxHashMap;
8use rustc_hir::AttrStyle;
9use rustc_span::{Symbol, sym};
1011use crate::Features;
1213type GateFn = fn(&Features) -> bool;
1415pub type GatedCfg = (Symbol, Symbol, GateFn);
1617/// `cfg(...)`'s that are feature gated.
18const GATED_CFGS: &[GatedCfg] = &[
19// (name in cfg, feature, function to check if the feature is enabled)
20(sym::overflow_checks, sym::cfg_overflow_checks, Features::cfg_overflow_checks),
21 (sym::ub_checks, sym::cfg_ub_checks, Features::cfg_ub_checks),
22 (sym::contract_checks, sym::cfg_contract_checks, Features::cfg_contract_checks),
23 (sym::target_thread_local, sym::cfg_target_thread_local, Features::cfg_target_thread_local),
24 (
25 sym::target_has_atomic_load_store,
26 sym::cfg_target_has_atomic,
27Features::cfg_target_has_atomic,
28 ),
29 (sym::sanitize, sym::cfg_sanitize, Features::cfg_sanitize),
30 (sym::version, sym::cfg_version, Features::cfg_version),
31 (sym::relocation_model, sym::cfg_relocation_model, Features::cfg_relocation_model),
32 (sym::sanitizer_cfi_generalize_pointers, sym::cfg_sanitizer_cfi, Features::cfg_sanitizer_cfi),
33 (sym::sanitizer_cfi_normalize_integers, sym::cfg_sanitizer_cfi, Features::cfg_sanitizer_cfi),
34// this is consistent with naming of the compiler flag it's for
35(sym::fmt_debug, sym::fmt_debug, Features::fmt_debug),
36 (sym::emscripten_wasm_eh, sym::cfg_emscripten_wasm_eh, Features::cfg_emscripten_wasm_eh),
37 (
38 sym::target_has_reliable_f16,
39 sym::cfg_target_has_reliable_f16_f128,
40Features::cfg_target_has_reliable_f16_f128,
41 ),
42 (
43 sym::target_has_reliable_f16_math,
44 sym::cfg_target_has_reliable_f16_f128,
45Features::cfg_target_has_reliable_f16_f128,
46 ),
47 (
48 sym::target_has_reliable_f128,
49 sym::cfg_target_has_reliable_f16_f128,
50Features::cfg_target_has_reliable_f16_f128,
51 ),
52 (
53 sym::target_has_reliable_f128_math,
54 sym::cfg_target_has_reliable_f16_f128,
55Features::cfg_target_has_reliable_f16_f128,
56 ),
57 (sym::target_object_format, sym::cfg_target_object_format, Features::cfg_target_object_format),
58];
5960/// Find a gated cfg determined by the `pred`icate which is given the cfg's name.
61pub fn find_gated_cfg(pred: impl Fn(Symbol) -> bool) -> Option<&'static GatedCfg> {
62GATED_CFGS.iter().find(|(cfg_sym, ..)| pred(*cfg_sym))
63}
6465#[derive(#[automatically_derived]
impl ::core::clone::Clone for AttributeGate {
#[inline]
fn clone(&self) -> AttributeGate {
let _: ::core::clone::AssertParamIsClone<Symbol>;
let _: ::core::clone::AssertParamIsClone<&'static str>;
let _: ::core::clone::AssertParamIsClone<fn(&Features) -> bool>;
let _: ::core::clone::AssertParamIsClone<&'static [&'static str]>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for AttributeGate {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
AttributeGate::Gated {
feature: __self_0,
message: __self_1,
check: __self_2,
notes: __self_3 } =>
::core::fmt::Formatter::debug_struct_field4_finish(f, "Gated",
"feature", __self_0, "message", __self_1, "check", __self_2,
"notes", &__self_3),
AttributeGate::Ungated =>
::core::fmt::Formatter::write_str(f, "Ungated"),
}
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for AttributeGate { }Copy)]
66pub enum AttributeGate {
67/// A gated attribute which requires a feature gate to be enabled.
68Gated {
69/// The feature gate, for example `#![feature(rustc_attrs)]` for rustc_* attributes.
70feature: Symbol,
71/// The error message displayed when an attempt is made to use the attribute without its feature gate.
72message: &'static str,
73/// Check function to be called during the `PostExpansionVisitor` pass.
74check: fn(&Features) -> bool,
75/// Notes to be displayed when an attempt is made to use the attribute without its feature gate.
76notes: &'static [&'static str],
77 },
78/// Ungated attribute, can be used on all release channels
79Ungated,
80}
8182// FIXME(jdonszelmann): move to rustc_hir::attrs
83/// A template that the attribute input must match.
84/// Only top-level shape (`#[attr]` vs `#[attr(...)]` vs `#[attr = ...]`) is considered now.
85#[derive(#[automatically_derived]
impl ::core::clone::Clone for AttributeTemplate {
#[inline]
fn clone(&self) -> AttributeTemplate {
let _: ::core::clone::AssertParamIsClone<bool>;
let _:
::core::clone::AssertParamIsClone<Option<&'static [&'static str]>>;
let _: ::core::clone::AssertParamIsClone<&'static [Symbol]>;
let _:
::core::clone::AssertParamIsClone<Option<&'static [&'static str]>>;
let _: ::core::clone::AssertParamIsClone<Option<&'static str>>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for AttributeTemplate { }Copy, #[automatically_derived]
impl ::core::default::Default for AttributeTemplate {
#[inline]
fn default() -> AttributeTemplate {
AttributeTemplate {
word: ::core::default::Default::default(),
list: ::core::default::Default::default(),
one_of: ::core::default::Default::default(),
name_value_str: ::core::default::Default::default(),
docs: ::core::default::Default::default(),
}
}
}Default)]
86pub struct AttributeTemplate {
87/// If `true`, the attribute is allowed to be a bare word like `#[test]`.
88pub word: bool,
89/// If `Some`, the attribute is allowed to take a list of items like `#[allow(..)]`.
90pub list: Option<&'static [&'static str]>,
91/// If non-empty, the attribute is allowed to take a list containing exactly
92 /// one of the listed words, like `#[coverage(off)]`.
93pub one_of: &'static [Symbol],
94/// If `Some`, the attribute is allowed to be a name/value pair where the
95 /// value is a string, like `#[must_use = "reason"]`.
96pub name_value_str: Option<&'static [&'static str]>,
97/// A link to the document for this attribute.
98pub docs: Option<&'static str>,
99}
100101pub enum AttrSuggestionStyle {
102/// The suggestion is styled for a normal attribute.
103 /// The `AttrStyle` determines whether this is an inner or outer attribute.
104Attribute(AttrStyle),
105/// The suggestion is styled for an attribute embedded into another attribute.
106 /// For example, attributes inside `#[cfg_attr(true, attr(...)]`.
107EmbeddedAttribute,
108/// The suggestion is styled for macros that are parsed with attribute parsers.
109 /// For example, the `cfg!(predicate)` macro.
110Macro,
111}
112113impl AttributeTemplate {
114pub fn suggestions(
115&self,
116 style: AttrSuggestionStyle,
117 safety: Safety,
118 name: impl std::fmt::Display,
119 ) -> Vec<String> {
120let (start, macro_call, end) = match style {
121 AttrSuggestionStyle::Attribute(AttrStyle::Outer) => ("#[", "", "]"),
122 AttrSuggestionStyle::Attribute(AttrStyle::Inner) => ("#![", "", "]"),
123 AttrSuggestionStyle::Macro => ("", "!", ""),
124 AttrSuggestionStyle::EmbeddedAttribute => ("", "", ""),
125 };
126127let mut suggestions = ::alloc::vec::Vec::new()vec![];
128129let (safety_start, safety_end) = match safety {
130 Safety::Unsafe(_) => ("unsafe(", ")"),
131_ => ("", ""),
132 };
133134if self.word {
135if true {
if !macro_call.is_empty() {
{
::core::panicking::panic_fmt(format_args!("Macro suggestions use list style"));
}
};
};debug_assert!(macro_call.is_empty(), "Macro suggestions use list style");
136suggestions.push(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}{1}{2}{3}{4}", start,
safety_start, name, safety_end, end))
})format!("{start}{safety_start}{name}{safety_end}{end}"));
137 }
138if let Some(descr) = self.list {
139for descr in descr {
140 suggestions.push(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}{1}{2}{3}({4}){5}{6}", start,
safety_start, name, macro_call, descr, safety_end, end))
})format!(
141"{start}{safety_start}{name}{macro_call}({descr}){safety_end}{end}"
142));
143 }
144 }
145suggestions.extend(
146self.one_of
147 .iter()
148 .map(|&word| ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}{1}{2}({3}){4}{5}", start,
safety_start, name, word, safety_end, end))
})format!("{start}{safety_start}{name}({word}){safety_end}{end}")),
149 );
150if let Some(descr) = self.name_value_str {
151if true {
if !macro_call.is_empty() {
{
::core::panicking::panic_fmt(format_args!("Macro suggestions use list style"));
}
};
};debug_assert!(macro_call.is_empty(), "Macro suggestions use list style");
152for descr in descr {
153 suggestions
154 .push(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}{1}{2} = \"{3}\"{4}{5}", start,
safety_start, name, descr, safety_end, end))
})format!("{start}{safety_start}{name} = \"{descr}\"{safety_end}{end}"));
155 }
156 }
157suggestions.sort();
158159suggestions160 }
161}
162163/// A convenience macro for constructing attribute templates.
164/// E.g., `template!(Word, List: "description")` means that the attribute
165/// supports forms `#[attr]` and `#[attr(description)]`.
166#[macro_export]
167macro_rules!template {
168 (Word) => { $crate::template!(@ true, None, &[], None, None) };
169 (Word, $link: literal) => { $crate::template!(@ true, None, &[], None, Some($link)) };
170 (List: $descr: expr) => { $crate::template!(@ false, Some($descr), &[], None, None) };
171 (List: $descr: expr, $link: literal) => { $crate::template!(@ false, Some($descr), &[], None, Some($link)) };
172 (OneOf: $one_of: expr) => { $crate::template!(@ false, None, $one_of, None, None) };
173 (NameValueStr: [$($descr: literal),* $(,)?]) => { $crate::template!(@ false, None, &[], Some(&[$($descr,)*]), None) };
174 (NameValueStr: [$($descr: literal),* $(,)?], $link: literal) => { $crate::template!(@ false, None, &[], Some(&[$($descr,)*]), Some($link)) };
175 (NameValueStr: $descr: literal) => { $crate::template!(@ false, None, &[], Some(&[$descr]), None) };
176 (NameValueStr: $descr: literal, $link: literal) => { $crate::template!(@ false, None, &[], Some(&[$descr]), Some($link)) };
177 (Word, List: $descr: expr) => { $crate::template!(@ true, Some($descr), &[], None, None) };
178 (Word, List: $descr: expr, $link: literal) => { $crate::template!(@ true, Some($descr), &[], None, Some($link)) };
179 (Word, NameValueStr: $descr: expr) => { $crate::template!(@ true, None, &[], Some(&[$descr]), None) };
180 (Word, NameValueStr: $descr: expr, $link: literal) => { $crate::template!(@ true, None, &[], Some(&[$descr]), Some($link)) };
181 (List: $descr1: expr, NameValueStr: $descr2: expr) => {
182$crate::template!(@ false, Some($descr1), &[], Some(&[$descr2]), None)
183 };
184 (List: $descr1: expr, NameValueStr: $descr2: expr, $link: literal) => {
185$crate::template!(@ false, Some($descr1), &[], Some(&[$descr2]), Some($link))
186 };
187 (Word, List: $descr1: expr, NameValueStr: $descr2: expr) => {
188$crate::template!(@ true, Some($descr1), &[], Some(&[$descr2]), None)
189 };
190 (Word, List: $descr1: expr, NameValueStr: $descr2: expr, $link: literal) => {
191$crate::template!(@ true, Some($descr1), &[], Some(&[$descr2]), Some($link))
192 };
193 (@ $word: expr, $list: expr, $one_of: expr, $name_value_str: expr, $link: expr) => { $crate::AttributeTemplate {
194 word: $word, list: $list, one_of: $one_of, name_value_str: $name_value_str, docs: $link,
195 } };
196}
197198macro_rules!ungated {
199 ($attr:ident $(,)?) => {
200 BuiltinAttribute { name: sym::$attr, gate: Ungated }
201 };
202}
203204macro_rules!gated {
205 ($attr:ident, $gate:ident, $message:expr $(,)?) => {
206 BuiltinAttribute {
207 name: sym::$attr,
208 gate: Gated {
209 feature: sym::$gate,
210 message: $message,
211 check: Features::$gate,
212 notes: &[],
213 },
214 }
215 };
216 ($attr:ident, $message:expr $(,)?) => {
217 BuiltinAttribute {
218 name: sym::$attr,
219 gate: Gated {
220 feature: sym::$attr,
221 message: $message,
222 check: Features::$attr,
223 notes: &[],
224 },
225 }
226 };
227}
228229macro_rules!rustc_attr {
230 (TEST, $attr:ident $(,)?) => {
231rustc_attr!(
232$attr,
233concat!(
234"the `#[",
235stringify!($attr),
236"]` attribute is used for rustc unit tests"
237),
238 )
239 };
240 ($attr:ident $(, $notes:expr)* $(,)?) => {
241 BuiltinAttribute {
242 name: sym::$attr,
243 gate: Gated {
244 feature: sym::rustc_attrs,
245 message: "use of an internal attribute",
246 check: Features::rustc_attrs,
247 notes: &[
248concat!("the `#[",
249stringify!($attr),
250"]` attribute is an internal implementation detail that will never be stable"),
251 $($notes),*
252 ]
253 },
254 }
255 };
256}
257258macro_rules!experimental {
259 ($attr:ident) => {
260concat!("the `#[", stringify!($attr), "]` attribute is an experimental feature")
261 };
262}
263264pub struct BuiltinAttribute {
265pub name: Symbol,
266pub gate: AttributeGate,
267}
268269/// Attributes that have a special meaning to rustc or rustdoc.
270#[rustfmt::skip]
271pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
272// ==========================================================================
273 // Stable attributes:
274 // ==========================================================================
275276 // Conditional compilation:
277BuiltinAttribute { name: sym::cfg, gate: Ungated }ungated!(cfg),
278BuiltinAttribute { name: sym::cfg_attr, gate: Ungated }ungated!(cfg_attr),
279280// Testing:
281BuiltinAttribute { name: sym::ignore, gate: Ungated }ungated!(ignore),
282BuiltinAttribute { name: sym::should_panic, gate: Ungated }ungated!(should_panic),
283284// Macros:
285BuiltinAttribute { name: sym::automatically_derived, gate: Ungated }ungated!(automatically_derived),
286BuiltinAttribute { name: sym::macro_use, gate: Ungated }ungated!(macro_use),
287BuiltinAttribute { name: sym::macro_escape, gate: Ungated }ungated!(macro_escape), // Deprecated synonym for `macro_use`.
288BuiltinAttribute { name: sym::macro_export, gate: Ungated }ungated!(macro_export),
289BuiltinAttribute { name: sym::proc_macro, gate: Ungated }ungated!(proc_macro),
290BuiltinAttribute { name: sym::proc_macro_derive, gate: Ungated }ungated!(proc_macro_derive),
291BuiltinAttribute { name: sym::proc_macro_attribute, gate: Ungated }ungated!(proc_macro_attribute),
292293// Lints:
294BuiltinAttribute { name: sym::warn, gate: Ungated }ungated!(warn),
295BuiltinAttribute { name: sym::allow, gate: Ungated }ungated!(allow),
296BuiltinAttribute { name: sym::expect, gate: Ungated }ungated!(expect),
297BuiltinAttribute { name: sym::forbid, gate: Ungated }ungated!(forbid),
298BuiltinAttribute { name: sym::deny, gate: Ungated }ungated!(deny),
299BuiltinAttribute { name: sym::must_use, gate: Ungated }ungated!(must_use),
300BuiltinAttribute {
name: sym::must_not_suspend,
gate: Gated {
feature: sym::must_not_suspend,
message: "the `#[must_not_suspend]` attribute is an experimental feature",
check: Features::must_not_suspend,
notes: &[],
},
}gated!(must_not_suspend, experimental!(must_not_suspend)),
301BuiltinAttribute { name: sym::deprecated, gate: Ungated }ungated!(deprecated),
302303// Crate properties:
304BuiltinAttribute { name: sym::crate_name, gate: Ungated }ungated!(crate_name),
305BuiltinAttribute { name: sym::crate_type, gate: Ungated }ungated!(crate_type),
306307// ABI, linking, symbols, and FFI
308BuiltinAttribute { name: sym::link, gate: Ungated }ungated!(link),
309BuiltinAttribute { name: sym::link_name, gate: Ungated }ungated!(link_name),
310BuiltinAttribute { name: sym::no_link, gate: Ungated }ungated!(no_link),
311BuiltinAttribute { name: sym::repr, gate: Ungated }ungated!(repr),
312// FIXME(#82232, #143834): temporarily renamed to mitigate `#[align]` nameres ambiguity
313BuiltinAttribute {
name: sym::rustc_align,
gate: Gated {
feature: sym::fn_align,
message: "the `#[rustc_align]` attribute is an experimental feature",
check: Features::fn_align,
notes: &[],
},
}gated!(rustc_align, fn_align, experimental!(rustc_align)),
314BuiltinAttribute {
name: sym::rustc_align_static,
gate: Gated {
feature: sym::static_align,
message: "the `#[rustc_align_static]` attribute is an experimental feature",
check: Features::static_align,
notes: &[],
},
}gated!(rustc_align_static, static_align, experimental!(rustc_align_static)),
315BuiltinAttribute { name: sym::export_name, gate: Ungated }ungated!(export_name),
316BuiltinAttribute { name: sym::link_section, gate: Ungated }ungated!(link_section),
317BuiltinAttribute { name: sym::no_mangle, gate: Ungated }ungated!(no_mangle),
318BuiltinAttribute { name: sym::used, gate: Ungated }ungated!(used),
319BuiltinAttribute { name: sym::link_ordinal, gate: Ungated }ungated!(link_ordinal),
320BuiltinAttribute { name: sym::naked, gate: Ungated }ungated!(naked),
321// See `TyAndLayout::pass_indirectly_in_non_rustic_abis` for details.
322BuiltinAttribute {
name: sym::rustc_pass_indirectly_in_non_rustic_abis,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_pass_indirectly_in_non_rustic_abis]` attribute is an internal implementation detail that will never be stable",
"types marked with `#[rustc_pass_indirectly_in_non_rustic_abis]` are always passed indirectly by non-Rustic ABIs"],
},
}rustc_attr!(rustc_pass_indirectly_in_non_rustic_abis, "types marked with `#[rustc_pass_indirectly_in_non_rustic_abis]` are always passed indirectly by non-Rustic ABIs"),
323324// Limits:
325BuiltinAttribute { name: sym::recursion_limit, gate: Ungated }ungated!(recursion_limit),
326BuiltinAttribute { name: sym::type_length_limit, gate: Ungated }ungated!(type_length_limit),
327BuiltinAttribute {
name: sym::move_size_limit,
gate: Gated {
feature: sym::large_assignments,
message: "the `#[move_size_limit]` attribute is an experimental feature",
check: Features::large_assignments,
notes: &[],
},
}gated!(move_size_limit, large_assignments, experimental!(move_size_limit)),
328329// Entry point:
330BuiltinAttribute { name: sym::no_main, gate: Ungated }ungated!(no_main),
331332// Modules, prelude, and resolution:
333BuiltinAttribute { name: sym::path, gate: Ungated }ungated!(path),
334BuiltinAttribute { name: sym::no_std, gate: Ungated }ungated!(no_std),
335BuiltinAttribute { name: sym::no_implicit_prelude, gate: Ungated }ungated!(no_implicit_prelude),
336BuiltinAttribute { name: sym::non_exhaustive, gate: Ungated }ungated!(non_exhaustive),
337338// Runtime
339BuiltinAttribute { name: sym::windows_subsystem, gate: Ungated }ungated!(windows_subsystem),
340BuiltinAttribute { name: sym::panic_handler, gate: Ungated }ungated!(panic_handler), // RFC 2070
341342 // Code generation:
343BuiltinAttribute { name: sym::inline, gate: Ungated }ungated!(inline),
344BuiltinAttribute { name: sym::cold, gate: Ungated }ungated!(cold),
345BuiltinAttribute { name: sym::no_builtins, gate: Ungated }ungated!(no_builtins),
346BuiltinAttribute { name: sym::target_feature, gate: Ungated }ungated!(target_feature),
347BuiltinAttribute { name: sym::track_caller, gate: Ungated }ungated!(track_caller),
348BuiltinAttribute { name: sym::instruction_set, gate: Ungated }ungated!(instruction_set),
349BuiltinAttribute {
name: sym::force_target_feature,
gate: Gated {
feature: sym::effective_target_features,
message: "the `#[force_target_feature]` attribute is an experimental feature",
check: Features::effective_target_features,
notes: &[],
},
}gated!(force_target_feature, effective_target_features, experimental!(force_target_feature)),
350BuiltinAttribute {
name: sym::sanitize,
gate: Gated {
feature: sym::sanitize,
message: "the `#[sanitize]` attribute is an experimental feature",
check: Features::sanitize,
notes: &[],
},
}gated!(sanitize, sanitize, experimental!(sanitize)),
351BuiltinAttribute {
name: sym::coverage,
gate: Gated {
feature: sym::coverage_attribute,
message: "the `#[coverage]` attribute is an experimental feature",
check: Features::coverage_attribute,
notes: &[],
},
}gated!(coverage, coverage_attribute, experimental!(coverage)),
352353BuiltinAttribute { name: sym::doc, gate: Ungated }ungated!(doc),
354355// Debugging
356BuiltinAttribute { name: sym::debugger_visualizer, gate: Ungated }ungated!(debugger_visualizer),
357BuiltinAttribute { name: sym::collapse_debuginfo, gate: Ungated }ungated!(collapse_debuginfo),
358359// ==========================================================================
360 // Unstable attributes:
361 // ==========================================================================
362363 // Linking:
364BuiltinAttribute {
name: sym::export_stable,
gate: Gated {
feature: sym::export_stable,
message: "the `#[export_stable]` attribute is an experimental feature",
check: Features::export_stable,
notes: &[],
},
}gated!(export_stable, experimental!(export_stable)),
365366// Testing:
367BuiltinAttribute {
name: sym::test_runner,
gate: Gated {
feature: sym::custom_test_frameworks,
message: "custom test frameworks are an unstable feature",
check: Features::custom_test_frameworks,
notes: &[],
},
}gated!(test_runner, custom_test_frameworks, "custom test frameworks are an unstable feature"),
368369BuiltinAttribute {
name: sym::reexport_test_harness_main,
gate: Gated {
feature: sym::custom_test_frameworks,
message: "custom test frameworks are an unstable feature",
check: Features::custom_test_frameworks,
notes: &[],
},
}gated!(reexport_test_harness_main, custom_test_frameworks, "custom test frameworks are an unstable feature"),
370371// RFC #1268
372BuiltinAttribute {
name: sym::marker,
gate: Gated {
feature: sym::marker_trait_attr,
message: "the `#[marker]` attribute is an experimental feature",
check: Features::marker_trait_attr,
notes: &[],
},
}gated!(marker, marker_trait_attr, experimental!(marker)),
373BuiltinAttribute {
name: sym::thread_local,
gate: Gated {
feature: sym::thread_local,
message: "`#[thread_local]` is an experimental feature, and does not currently handle destructors",
check: Features::thread_local,
notes: &[],
},
}gated!(thread_local, "`#[thread_local]` is an experimental feature, and does not currently handle destructors"),
374BuiltinAttribute {
name: sym::no_core,
gate: Gated {
feature: sym::no_core,
message: "the `#[no_core]` attribute is an experimental feature",
check: Features::no_core,
notes: &[],
},
}gated!(no_core, experimental!(no_core)),
375// RFC 2412
376BuiltinAttribute {
name: sym::optimize,
gate: Gated {
feature: sym::optimize_attribute,
message: "the `#[optimize]` attribute is an experimental feature",
check: Features::optimize_attribute,
notes: &[],
},
}gated!(optimize, optimize_attribute, experimental!(optimize)),
377378BuiltinAttribute {
name: sym::ffi_pure,
gate: Gated {
feature: sym::ffi_pure,
message: "the `#[ffi_pure]` attribute is an experimental feature",
check: Features::ffi_pure,
notes: &[],
},
}gated!(ffi_pure, experimental!(ffi_pure)),
379BuiltinAttribute {
name: sym::ffi_const,
gate: Gated {
feature: sym::ffi_const,
message: "the `#[ffi_const]` attribute is an experimental feature",
check: Features::ffi_const,
notes: &[],
},
}gated!(ffi_const, experimental!(ffi_const)),
380BuiltinAttribute {
name: sym::register_tool,
gate: Gated {
feature: sym::register_tool,
message: "the `#[register_tool]` attribute is an experimental feature",
check: Features::register_tool,
notes: &[],
},
}gated!(register_tool, experimental!(register_tool)),
381// `#[cfi_encoding = ""]`
382BuiltinAttribute {
name: sym::cfi_encoding,
gate: Gated {
feature: sym::cfi_encoding,
message: "the `#[cfi_encoding]` attribute is an experimental feature",
check: Features::cfi_encoding,
notes: &[],
},
}gated!(cfi_encoding, experimental!(cfi_encoding)),
383384// `#[coroutine]` attribute to be applied to closures to make them coroutines instead
385BuiltinAttribute {
name: sym::coroutine,
gate: Gated {
feature: sym::coroutines,
message: "the `#[coroutine]` attribute is an experimental feature",
check: Features::coroutines,
notes: &[],
},
}gated!(coroutine, coroutines, experimental!(coroutine)),
386387// RFC 3543
388 // `#[patchable_function_entry(prefix_nops = m, entry_nops = n)]`
389BuiltinAttribute {
name: sym::patchable_function_entry,
gate: Gated {
feature: sym::patchable_function_entry,
message: "the `#[patchable_function_entry]` attribute is an experimental feature",
check: Features::patchable_function_entry,
notes: &[],
},
}gated!(patchable_function_entry, experimental!(patchable_function_entry)),
390391// The `#[loop_match]` and `#[const_continue]` attributes are part of the
392 // lang experiment for RFC 3720 tracked in:
393 //
394 // - https://github.com/rust-lang/rust/issues/132306
395BuiltinAttribute {
name: sym::const_continue,
gate: Gated {
feature: sym::loop_match,
message: "the `#[const_continue]` attribute is an experimental feature",
check: Features::loop_match,
notes: &[],
},
}gated!(const_continue, loop_match, experimental!(const_continue)),
396BuiltinAttribute {
name: sym::loop_match,
gate: Gated {
feature: sym::loop_match,
message: "the `#[loop_match]` attribute is an experimental feature",
check: Features::loop_match,
notes: &[],
},
}gated!(loop_match, loop_match, experimental!(loop_match)),
397398// The `#[pin_v2]` attribute is part of the `pin_ergonomics` experiment
399 // that allows structurally pinning, tracked in:
400 //
401 // - https://github.com/rust-lang/rust/issues/130494
402BuiltinAttribute {
name: sym::pin_v2,
gate: Gated {
feature: sym::pin_ergonomics,
message: "the `#[pin_v2]` attribute is an experimental feature",
check: Features::pin_ergonomics,
notes: &[],
},
}gated!(pin_v2, pin_ergonomics, experimental!(pin_v2)),
403404// ==========================================================================
405 // Internal attributes: Stability, deprecation, and unsafe:
406 // ==========================================================================
407408BuiltinAttribute { name: sym::feature, gate: Ungated }ungated!(feature),
409// DuplicatesOk since it has its own validation
410BuiltinAttribute { name: sym::stable, gate: Ungated }ungated!(stable),
411BuiltinAttribute { name: sym::unstable, gate: Ungated }ungated!(unstable),
412BuiltinAttribute { name: sym::unstable_feature_bound, gate: Ungated }ungated!(unstable_feature_bound),
413BuiltinAttribute { name: sym::unstable_removed, gate: Ungated }ungated!(unstable_removed),
414BuiltinAttribute { name: sym::rustc_const_unstable, gate: Ungated }ungated!(rustc_const_unstable),
415BuiltinAttribute { name: sym::rustc_const_stable, gate: Ungated }ungated!(rustc_const_stable),
416BuiltinAttribute { name: sym::rustc_default_body_unstable, gate: Ungated }ungated!(rustc_default_body_unstable),
417BuiltinAttribute {
name: sym::allow_internal_unstable,
gate: Gated {
feature: sym::allow_internal_unstable,
message: "allow_internal_unstable side-steps feature gating and stability checks",
check: Features::allow_internal_unstable,
notes: &[],
},
}gated!(
418 allow_internal_unstable,
419"allow_internal_unstable side-steps feature gating and stability checks",
420 ),
421BuiltinAttribute {
name: sym::allow_internal_unsafe,
gate: Gated {
feature: sym::allow_internal_unsafe,
message: "allow_internal_unsafe side-steps the unsafe_code lint",
check: Features::allow_internal_unsafe,
notes: &[],
},
}gated!(
422 allow_internal_unsafe,
423"allow_internal_unsafe side-steps the unsafe_code lint",
424 ),
425BuiltinAttribute {
name: sym::rustc_eii_foreign_item,
gate: Gated {
feature: sym::eii_internals,
message: "used internally to mark types with a `transparent` representation when it is guaranteed by the documentation",
check: Features::eii_internals,
notes: &[],
},
}gated!(
426 rustc_eii_foreign_item,
427 eii_internals,
428"used internally to mark types with a `transparent` representation when it is guaranteed by the documentation",
429 ),
430BuiltinAttribute {
name: sym::rustc_allowed_through_unstable_modules,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_allowed_through_unstable_modules]` attribute is an internal implementation detail that will never be stable",
"rustc_allowed_through_unstable_modules special cases accidental stabilizations of stable items \
through unstable paths"],
},
}rustc_attr!(
431 rustc_allowed_through_unstable_modules,
432"rustc_allowed_through_unstable_modules special cases accidental stabilizations of stable items \
433 through unstable paths"
434),
435BuiltinAttribute {
name: sym::rustc_deprecated_safe_2024,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_deprecated_safe_2024]` attribute is an internal implementation detail that will never be stable",
"`#[rustc_deprecated_safe_2024]` is used to declare functions unsafe across the edition 2024 boundary"],
},
}rustc_attr!(
436 rustc_deprecated_safe_2024,
437"`#[rustc_deprecated_safe_2024]` is used to declare functions unsafe across the edition 2024 boundary",
438 ),
439BuiltinAttribute {
name: sym::rustc_pub_transparent,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_pub_transparent]` attribute is an internal implementation detail that will never be stable",
"used internally to mark types with a `transparent` representation when it is guaranteed by the documentation"],
},
}rustc_attr!(
440 rustc_pub_transparent,
441"used internally to mark types with a `transparent` representation when it is guaranteed by the documentation",
442 ),
443444445// ==========================================================================
446 // Internal attributes: Type system related:
447 // ==========================================================================
448449BuiltinAttribute {
name: sym::fundamental,
gate: Gated {
feature: sym::fundamental,
message: "the `#[fundamental]` attribute is an experimental feature",
check: Features::fundamental,
notes: &[],
},
}gated!(fundamental, experimental!(fundamental)),
450BuiltinAttribute {
name: sym::may_dangle,
gate: Gated {
feature: sym::dropck_eyepatch,
message: "`may_dangle` has unstable semantics and may be removed in the future",
check: Features::dropck_eyepatch,
notes: &[],
},
}gated!(
451 may_dangle,
452 dropck_eyepatch,
453"`may_dangle` has unstable semantics and may be removed in the future",
454 ),
455456BuiltinAttribute {
name: sym::rustc_never_type_options,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_never_type_options]` attribute is an internal implementation detail that will never be stable",
"`rustc_never_type_options` is used to experiment with never type fallback and work on \
never type stabilization"],
},
}rustc_attr!(
457 rustc_never_type_options,
458"`rustc_never_type_options` is used to experiment with never type fallback and work on \
459 never type stabilization"
460),
461462// ==========================================================================
463 // Internal attributes: Runtime related:
464 // ==========================================================================
465466BuiltinAttribute {
name: sym::rustc_allocator,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_allocator]` attribute is an internal implementation detail that will never be stable"],
},
}rustc_attr!(rustc_allocator),
467BuiltinAttribute {
name: sym::rustc_nounwind,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_nounwind]` attribute is an internal implementation detail that will never be stable"],
},
}rustc_attr!(rustc_nounwind),
468BuiltinAttribute {
name: sym::rustc_reallocator,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_reallocator]` attribute is an internal implementation detail that will never be stable"],
},
}rustc_attr!(rustc_reallocator),
469BuiltinAttribute {
name: sym::rustc_deallocator,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_deallocator]` attribute is an internal implementation detail that will never be stable"],
},
}rustc_attr!(rustc_deallocator),
470BuiltinAttribute {
name: sym::rustc_allocator_zeroed,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_allocator_zeroed]` attribute is an internal implementation detail that will never be stable"],
},
}rustc_attr!(rustc_allocator_zeroed),
471BuiltinAttribute {
name: sym::rustc_allocator_zeroed_variant,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_allocator_zeroed_variant]` attribute is an internal implementation detail that will never be stable"],
},
}rustc_attr!(rustc_allocator_zeroed_variant),
472BuiltinAttribute {
name: sym::default_lib_allocator,
gate: Gated {
feature: sym::allocator_internals,
message: "the `#[default_lib_allocator]` attribute is an experimental feature",
check: Features::allocator_internals,
notes: &[],
},
}gated!(
473 default_lib_allocator,
474 allocator_internals, experimental!(default_lib_allocator),
475 ),
476BuiltinAttribute {
name: sym::needs_allocator,
gate: Gated {
feature: sym::allocator_internals,
message: "the `#[needs_allocator]` attribute is an experimental feature",
check: Features::allocator_internals,
notes: &[],
},
}gated!(
477 needs_allocator,
478 allocator_internals, experimental!(needs_allocator),
479 ),
480BuiltinAttribute {
name: sym::panic_runtime,
gate: Gated {
feature: sym::panic_runtime,
message: "the `#[panic_runtime]` attribute is an experimental feature",
check: Features::panic_runtime,
notes: &[],
},
}gated!(
481 panic_runtime,
482experimental!(panic_runtime)
483 ),
484BuiltinAttribute {
name: sym::needs_panic_runtime,
gate: Gated {
feature: sym::needs_panic_runtime,
message: "the `#[needs_panic_runtime]` attribute is an experimental feature",
check: Features::needs_panic_runtime,
notes: &[],
},
}gated!(
485 needs_panic_runtime,
486experimental!(needs_panic_runtime)
487 ),
488BuiltinAttribute {
name: sym::compiler_builtins,
gate: Gated {
feature: sym::compiler_builtins,
message: "the `#[compiler_builtins]` attribute is used to identify the `compiler_builtins` crate \
which contains compiler-rt intrinsics and will never be stable",
check: Features::compiler_builtins,
notes: &[],
},
}gated!(
489 compiler_builtins,
490"the `#[compiler_builtins]` attribute is used to identify the `compiler_builtins` crate \
491 which contains compiler-rt intrinsics and will never be stable",
492 ),
493BuiltinAttribute {
name: sym::profiler_runtime,
gate: Gated {
feature: sym::profiler_runtime,
message: "the `#[profiler_runtime]` attribute is used to identify the `profiler_builtins` crate \
which contains the profiler runtime and will never be stable",
check: Features::profiler_runtime,
notes: &[],
},
}gated!(
494 profiler_runtime,
495"the `#[profiler_runtime]` attribute is used to identify the `profiler_builtins` crate \
496 which contains the profiler runtime and will never be stable",
497 ),
498499// ==========================================================================
500 // Internal attributes, Linkage:
501 // ==========================================================================
502503BuiltinAttribute {
name: sym::linkage,
gate: Gated {
feature: sym::linkage,
message: "the `linkage` attribute is experimental and not portable across platforms",
check: Features::linkage,
notes: &[],
},
}gated!(
504 linkage,
505"the `linkage` attribute is experimental and not portable across platforms",
506 ),
507BuiltinAttribute {
name: sym::rustc_std_internal_symbol,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_std_internal_symbol]` attribute is an internal implementation detail that will never be stable"],
},
}rustc_attr!(rustc_std_internal_symbol),
508BuiltinAttribute {
name: sym::rustc_objc_class,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_objc_class]` attribute is an internal implementation detail that will never be stable"],
},
}rustc_attr!(rustc_objc_class),
509BuiltinAttribute {
name: sym::rustc_objc_selector,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_objc_selector]` attribute is an internal implementation detail that will never be stable"],
},
}rustc_attr!(rustc_objc_selector),
510511// ==========================================================================
512 // Internal attributes, Macro related:
513 // ==========================================================================
514515BuiltinAttribute {
name: sym::rustc_builtin_macro,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_builtin_macro]` attribute is an internal implementation detail that will never be stable"],
},
}rustc_attr!(rustc_builtin_macro),
516BuiltinAttribute {
name: sym::rustc_proc_macro_decls,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_proc_macro_decls]` attribute is an internal implementation detail that will never be stable"],
},
}rustc_attr!(rustc_proc_macro_decls),
517BuiltinAttribute {
name: sym::rustc_macro_transparency,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_macro_transparency]` attribute is an internal implementation detail that will never be stable",
"used internally for testing macro hygiene"],
},
}rustc_attr!(
518 rustc_macro_transparency,
519"used internally for testing macro hygiene",
520 ),
521BuiltinAttribute {
name: sym::rustc_autodiff,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_autodiff]` attribute is an internal implementation detail that will never be stable"],
},
}rustc_attr!(rustc_autodiff),
522BuiltinAttribute {
name: sym::rustc_offload_kernel,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_offload_kernel]` attribute is an internal implementation detail that will never be stable"],
},
}rustc_attr!(rustc_offload_kernel),
523// Traces that are left when `cfg` and `cfg_attr` attributes are expanded.
524 // The attributes are not gated, to avoid stability errors, but they cannot be used in stable
525 // or unstable code directly because `sym::cfg_(attr_)trace` are not valid identifiers, they
526 // can only be generated by the compiler.
527BuiltinAttribute { name: sym::cfg_trace, gate: Ungated }ungated!(cfg_trace),
528BuiltinAttribute { name: sym::cfg_attr_trace, gate: Ungated }ungated!(cfg_attr_trace),
529530// ==========================================================================
531 // Internal attributes, Diagnostics related:
532 // ==========================================================================
533534BuiltinAttribute {
name: sym::rustc_on_unimplemented,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_on_unimplemented]` attribute is an internal implementation detail that will never be stable",
"see `#[diagnostic::on_unimplemented]` for the stable equivalent of this attribute"],
},
}rustc_attr!(
535 rustc_on_unimplemented,
536"see `#[diagnostic::on_unimplemented]` for the stable equivalent of this attribute"
537),
538BuiltinAttribute {
name: sym::rustc_confusables,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_confusables]` attribute is an internal implementation detail that will never be stable"],
},
}rustc_attr!(rustc_confusables),
539// Enumerates "identity-like" conversion methods to suggest on type mismatch.
540BuiltinAttribute {
name: sym::rustc_conversion_suggestion,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_conversion_suggestion]` attribute is an internal implementation detail that will never be stable"],
},
}rustc_attr!(rustc_conversion_suggestion),
541// Prevents field reads in the marked trait or method to be considered
542 // during dead code analysis.
543BuiltinAttribute {
name: sym::rustc_trivial_field_reads,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_trivial_field_reads]` attribute is an internal implementation detail that will never be stable"],
},
}rustc_attr!(rustc_trivial_field_reads),
544// Used by the `rustc::potential_query_instability` lint to warn methods which
545 // might not be stable during incremental compilation.
546BuiltinAttribute {
name: sym::rustc_lint_query_instability,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_lint_query_instability]` attribute is an internal implementation detail that will never be stable"],
},
}rustc_attr!(rustc_lint_query_instability),
547// Used by the `rustc::untracked_query_information` lint to warn methods which
548 // might not be stable during incremental compilation.
549BuiltinAttribute {
name: sym::rustc_lint_untracked_query_information,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_lint_untracked_query_information]` attribute is an internal implementation detail that will never be stable"],
},
}rustc_attr!(rustc_lint_untracked_query_information),
550// Used by the `rustc::bad_opt_access` lint to identify `DebuggingOptions` and `CodegenOptions`
551 // types (as well as any others in future).
552BuiltinAttribute {
name: sym::rustc_lint_opt_ty,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_lint_opt_ty]` attribute is an internal implementation detail that will never be stable"],
},
}rustc_attr!(rustc_lint_opt_ty),
553// Used by the `rustc::bad_opt_access` lint on fields
554 // types (as well as any others in future).
555BuiltinAttribute {
name: sym::rustc_lint_opt_deny_field_access,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_lint_opt_deny_field_access]` attribute is an internal implementation detail that will never be stable"],
},
}rustc_attr!(rustc_lint_opt_deny_field_access),
556557// ==========================================================================
558 // Internal attributes, Const related:
559 // ==========================================================================
560561BuiltinAttribute {
name: sym::rustc_promotable,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_promotable]` attribute is an internal implementation detail that will never be stable"],
},
}rustc_attr!(rustc_promotable),
562BuiltinAttribute {
name: sym::rustc_legacy_const_generics,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_legacy_const_generics]` attribute is an internal implementation detail that will never be stable"],
},
}rustc_attr!(rustc_legacy_const_generics),
563// Do not const-check this function's body. It will always get replaced during CTFE via `hook_special_const_fn`.
564BuiltinAttribute {
name: sym::rustc_do_not_const_check,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_do_not_const_check]` attribute is an internal implementation detail that will never be stable",
"`#[rustc_do_not_const_check]` skips const-check for this function's body"],
},
}rustc_attr!(
565 rustc_do_not_const_check,
566"`#[rustc_do_not_const_check]` skips const-check for this function's body",
567 ),
568BuiltinAttribute {
name: sym::rustc_const_stable_indirect,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_const_stable_indirect]` attribute is an internal implementation detail that will never be stable",
"this is an internal implementation detail"],
},
}rustc_attr!(
569 rustc_const_stable_indirect,
570"this is an internal implementation detail",
571 ),
572BuiltinAttribute {
name: sym::rustc_intrinsic_const_stable_indirect,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_intrinsic_const_stable_indirect]` attribute is an internal implementation detail that will never be stable",
"this is an internal implementation detail"],
},
}rustc_attr!(
573 rustc_intrinsic_const_stable_indirect,
574"this is an internal implementation detail",
575 ),
576BuiltinAttribute {
name: sym::rustc_allow_const_fn_unstable,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_allow_const_fn_unstable]` attribute is an internal implementation detail that will never be stable",
"rustc_allow_const_fn_unstable side-steps feature gating and stability checks"],
},
}rustc_attr!(
577 rustc_allow_const_fn_unstable,
578"rustc_allow_const_fn_unstable side-steps feature gating and stability checks"
579),
580581// ==========================================================================
582 // Internal attributes, Layout related:
583 // ==========================================================================
584585BuiltinAttribute {
name: sym::rustc_simd_monomorphize_lane_limit,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_simd_monomorphize_lane_limit]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_simd_monomorphize_lane_limit]` attribute is just used by std::simd \
for better error messages"],
},
}rustc_attr!(
586 rustc_simd_monomorphize_lane_limit,
587"the `#[rustc_simd_monomorphize_lane_limit]` attribute is just used by std::simd \
588 for better error messages",
589 ),
590BuiltinAttribute {
name: sym::rustc_nonnull_optimization_guaranteed,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_nonnull_optimization_guaranteed]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to document \
guaranteed niche optimizations in the standard library",
"the compiler does not even check whether the type indeed is being non-null-optimized; \
it is your responsibility to ensure that the attribute is only used on types that are optimized"],
},
}rustc_attr!(
591 rustc_nonnull_optimization_guaranteed,
592"the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to document \
593 guaranteed niche optimizations in the standard library",
594"the compiler does not even check whether the type indeed is being non-null-optimized; \
595 it is your responsibility to ensure that the attribute is only used on types that are optimized",
596 ),
597598// ==========================================================================
599 // Internal attributes, Misc:
600 // ==========================================================================
601BuiltinAttribute {
name: sym::lang,
gate: Gated {
feature: sym::lang_items,
message: "lang items are subject to change",
check: Features::lang_items,
notes: &[],
},
}gated!(
602 lang, lang_items,
603"lang items are subject to change",
604 ),
605BuiltinAttribute {
name: sym::rustc_as_ptr,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_as_ptr]` attribute is an internal implementation detail that will never be stable",
"`#[rustc_as_ptr]` is used to mark functions returning pointers to their inner allocations"],
},
}rustc_attr!(
606 rustc_as_ptr,
607"`#[rustc_as_ptr]` is used to mark functions returning pointers to their inner allocations"
608),
609BuiltinAttribute {
name: sym::rustc_should_not_be_called_on_const_items,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_should_not_be_called_on_const_items]` attribute is an internal implementation detail that will never be stable",
"`#[rustc_should_not_be_called_on_const_items]` is used to mark methods that don't make sense to be called on interior mutable consts"],
},
}rustc_attr!(
610 rustc_should_not_be_called_on_const_items,
611"`#[rustc_should_not_be_called_on_const_items]` is used to mark methods that don't make sense to be called on interior mutable consts"
612),
613BuiltinAttribute {
name: sym::rustc_pass_by_value,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_pass_by_value]` attribute is an internal implementation detail that will never be stable",
"`#[rustc_pass_by_value]` is used to mark types that must be passed by value instead of reference"],
},
}rustc_attr!(
614 rustc_pass_by_value,
615"`#[rustc_pass_by_value]` is used to mark types that must be passed by value instead of reference"
616),
617BuiltinAttribute {
name: sym::rustc_never_returns_null_ptr,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_never_returns_null_ptr]` attribute is an internal implementation detail that will never be stable",
"`#[rustc_never_returns_null_ptr]` is used to mark functions returning non-null pointers"],
},
}rustc_attr!(
618 rustc_never_returns_null_ptr,
619"`#[rustc_never_returns_null_ptr]` is used to mark functions returning non-null pointers"
620),
621BuiltinAttribute {
name: sym::rustc_no_implicit_autorefs,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_no_implicit_autorefs]` attribute is an internal implementation detail that will never be stable",
"`#[rustc_no_implicit_autorefs]` is used to mark functions for which an autoref to the dereference of a raw pointer should not be used as an argument"],
},
}rustc_attr!(
622 rustc_no_implicit_autorefs,
623"`#[rustc_no_implicit_autorefs]` is used to mark functions for which an autoref to the dereference of a raw pointer should not be used as an argument"
624),
625BuiltinAttribute {
name: sym::rustc_coherence_is_core,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_coherence_is_core]` attribute is an internal implementation detail that will never be stable",
"`#![rustc_coherence_is_core]` allows inherent methods on builtin types, only intended to be used in `core`"],
},
}rustc_attr!(
626 rustc_coherence_is_core,
627"`#![rustc_coherence_is_core]` allows inherent methods on builtin types, only intended to be used in `core`"
628),
629BuiltinAttribute {
name: sym::rustc_coinductive,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_coinductive]` attribute is an internal implementation detail that will never be stable",
"`#[rustc_coinductive]` changes a trait to be coinductive, allowing cycles in the trait solver"],
},
}rustc_attr!(
630 rustc_coinductive,
631"`#[rustc_coinductive]` changes a trait to be coinductive, allowing cycles in the trait solver"
632),
633BuiltinAttribute {
name: sym::rustc_allow_incoherent_impl,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_allow_incoherent_impl]` attribute is an internal implementation detail that will never be stable",
"`#[rustc_allow_incoherent_impl]` has to be added to all impl items of an incoherent inherent impl"],
},
}rustc_attr!(
634 rustc_allow_incoherent_impl,
635"`#[rustc_allow_incoherent_impl]` has to be added to all impl items of an incoherent inherent impl"
636),
637BuiltinAttribute {
name: sym::rustc_preserve_ub_checks,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_preserve_ub_checks]` attribute is an internal implementation detail that will never be stable",
"`#![rustc_preserve_ub_checks]` prevents the designated crate from evaluating whether UB checks are enabled when optimizing MIR"],
},
}rustc_attr!(
638 rustc_preserve_ub_checks,
639"`#![rustc_preserve_ub_checks]` prevents the designated crate from evaluating whether UB checks are enabled when optimizing MIR",
640 ),
641BuiltinAttribute {
name: sym::rustc_deny_explicit_impl,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_deny_explicit_impl]` attribute is an internal implementation detail that will never be stable",
"`#[rustc_deny_explicit_impl]` enforces that a trait can have no user-provided impls"],
},
}rustc_attr!(
642 rustc_deny_explicit_impl,
643"`#[rustc_deny_explicit_impl]` enforces that a trait can have no user-provided impls"
644),
645BuiltinAttribute {
name: sym::rustc_dyn_incompatible_trait,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_dyn_incompatible_trait]` attribute is an internal implementation detail that will never be stable",
"`#[rustc_dyn_incompatible_trait]` marks a trait as dyn-incompatible, \
even if it otherwise satisfies the requirements to be dyn-compatible."],
},
}rustc_attr!(
646 rustc_dyn_incompatible_trait,
647"`#[rustc_dyn_incompatible_trait]` marks a trait as dyn-incompatible, \
648 even if it otherwise satisfies the requirements to be dyn-compatible."
649),
650BuiltinAttribute {
name: sym::rustc_has_incoherent_inherent_impls,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_has_incoherent_inherent_impls]` attribute is an internal implementation detail that will never be stable",
"`#[rustc_has_incoherent_inherent_impls]` allows the addition of incoherent inherent impls for \
the given type by annotating all impl items with `#[rustc_allow_incoherent_impl]`"],
},
}rustc_attr!(
651 rustc_has_incoherent_inherent_impls,
652"`#[rustc_has_incoherent_inherent_impls]` allows the addition of incoherent inherent impls for \
653 the given type by annotating all impl items with `#[rustc_allow_incoherent_impl]`"
654),
655BuiltinAttribute {
name: sym::rustc_non_const_trait_method,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_non_const_trait_method]` attribute is an internal implementation detail that will never be stable",
"`#[rustc_non_const_trait_method]` should only used by the standard library to mark trait methods \
as non-const to allow large traits an easier transition to const"],
},
}rustc_attr!(
656 rustc_non_const_trait_method,
657"`#[rustc_non_const_trait_method]` should only used by the standard library to mark trait methods \
658 as non-const to allow large traits an easier transition to const"
659),
660661BuiltinAttribute {
662 name: sym::rustc_diagnostic_item,
663 gate: Gated {
664 feature: sym::rustc_attrs,
665 message: "use of an internal attribute",
666 check: Features::rustc_attrs,
667 notes: &["the `#[rustc_diagnostic_item]` attribute allows the compiler to reference types \
668 from the standard library for diagnostic purposes"],
669 },
670 },
671BuiltinAttribute {
name: sym::prelude_import,
gate: Gated {
feature: sym::prelude_import,
message: "`#[prelude_import]` is for use by rustc only",
check: Features::prelude_import,
notes: &[],
},
}gated!(
672// Used in resolve:
673prelude_import,
674"`#[prelude_import]` is for use by rustc only",
675 ),
676BuiltinAttribute {
name: sym::rustc_paren_sugar,
gate: Gated {
feature: sym::unboxed_closures,
message: "unboxed_closures are still evolving",
check: Features::unboxed_closures,
notes: &[],
},
}gated!(
677 rustc_paren_sugar,
678 unboxed_closures, "unboxed_closures are still evolving",
679 ),
680BuiltinAttribute {
name: sym::rustc_inherit_overflow_checks,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_inherit_overflow_checks]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_inherit_overflow_checks]` attribute is just used to control \
overflow checking behavior of several functions in the standard library that are inlined \
across crates"],
},
}rustc_attr!(
681 rustc_inherit_overflow_checks,
682"the `#[rustc_inherit_overflow_checks]` attribute is just used to control \
683 overflow checking behavior of several functions in the standard library that are inlined \
684 across crates",
685 ),
686BuiltinAttribute {
name: sym::rustc_reservation_impl,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_reservation_impl]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_reservation_impl]` attribute is internally used \
for reserving `impl<T> From<!> for T` as part of the effort to stabilize `!`"],
},
}rustc_attr!(
687 rustc_reservation_impl,
688"the `#[rustc_reservation_impl]` attribute is internally used \
689 for reserving `impl<T> From<!> for T` as part of the effort to stabilize `!`"
690),
691BuiltinAttribute {
name: sym::rustc_test_marker,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_test_marker]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_test_marker]` attribute is used internally to track tests"],
},
}rustc_attr!(
692 rustc_test_marker,
693"the `#[rustc_test_marker]` attribute is used internally to track tests",
694 ),
695BuiltinAttribute {
name: sym::rustc_unsafe_specialization_marker,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_unsafe_specialization_marker]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_unsafe_specialization_marker]` attribute is used to check specializations"],
},
}rustc_attr!(
696 rustc_unsafe_specialization_marker,
697"the `#[rustc_unsafe_specialization_marker]` attribute is used to check specializations"
698),
699BuiltinAttribute {
name: sym::rustc_specialization_trait,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_specialization_trait]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_specialization_trait]` attribute is used to check specializations"],
},
}rustc_attr!(
700 rustc_specialization_trait,
701"the `#[rustc_specialization_trait]` attribute is used to check specializations"
702),
703BuiltinAttribute {
name: sym::rustc_main,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_main]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_main]` attribute is used internally to specify test entry point function"],
},
}rustc_attr!(
704 rustc_main,
705"the `#[rustc_main]` attribute is used internally to specify test entry point function",
706 ),
707BuiltinAttribute {
name: sym::rustc_skip_during_method_dispatch,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_skip_during_method_dispatch]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_skip_during_method_dispatch]` attribute is used to exclude a trait \
from method dispatch when the receiver is of the following type, for compatibility in \
editions < 2021 (array) or editions < 2024 (boxed_slice)"],
},
}rustc_attr!(
708 rustc_skip_during_method_dispatch,
709"the `#[rustc_skip_during_method_dispatch]` attribute is used to exclude a trait \
710 from method dispatch when the receiver is of the following type, for compatibility in \
711 editions < 2021 (array) or editions < 2024 (boxed_slice)"
712),
713BuiltinAttribute {
name: sym::rustc_must_implement_one_of,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_must_implement_one_of]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_must_implement_one_of]` attribute is used to change minimal complete \
definition of a trait. Its syntax and semantics are highly experimental and will be \
subject to change before stabilization"],
},
}rustc_attr!(
714 rustc_must_implement_one_of,
715"the `#[rustc_must_implement_one_of]` attribute is used to change minimal complete \
716 definition of a trait. Its syntax and semantics are highly experimental and will be \
717 subject to change before stabilization",
718 ),
719BuiltinAttribute {
name: sym::rustc_doc_primitive,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_doc_primitive]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_doc_primitive]` attribute is used by the standard library \
to provide a way to generate documentation for primitive types"],
},
}rustc_attr!(
720 rustc_doc_primitive,
721"the `#[rustc_doc_primitive]` attribute is used by the standard library \
722 to provide a way to generate documentation for primitive types",
723 ),
724BuiltinAttribute {
name: sym::rustc_intrinsic,
gate: Gated {
feature: sym::intrinsics,
message: "the `#[rustc_intrinsic]` attribute is used to declare intrinsics as function items",
check: Features::intrinsics,
notes: &[],
},
}gated!(
725 rustc_intrinsic, intrinsics,
726"the `#[rustc_intrinsic]` attribute is used to declare intrinsics as function items",
727 ),
728BuiltinAttribute {
name: sym::rustc_no_mir_inline,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_no_mir_inline]` attribute is an internal implementation detail that will never be stable",
"`#[rustc_no_mir_inline]` prevents the MIR inliner from inlining a function while not affecting codegen"],
},
}rustc_attr!(
729 rustc_no_mir_inline,
730"`#[rustc_no_mir_inline]` prevents the MIR inliner from inlining a function while not affecting codegen"
731),
732BuiltinAttribute {
name: sym::rustc_force_inline,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_force_inline]` attribute is an internal implementation detail that will never be stable",
"`#[rustc_force_inline]` forces a free function to be inlined"],
},
}rustc_attr!(
733 rustc_force_inline,
734"`#[rustc_force_inline]` forces a free function to be inlined"
735),
736BuiltinAttribute {
name: sym::rustc_scalable_vector,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_scalable_vector]` attribute is an internal implementation detail that will never be stable",
"`#[rustc_scalable_vector]` defines a scalable vector type"],
},
}rustc_attr!(
737 rustc_scalable_vector,
738"`#[rustc_scalable_vector]` defines a scalable vector type"
739),
740BuiltinAttribute {
name: sym::rustc_must_match_exhaustively,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_must_match_exhaustively]` attribute is an internal implementation detail that will never be stable",
"enums with `#[rustc_must_match_exhaustively]` must be matched on with a match block that mentions all variants explicitly"],
},
}rustc_attr!(
741 rustc_must_match_exhaustively,
742"enums with `#[rustc_must_match_exhaustively]` must be matched on with a match block that mentions all variants explicitly"
743),
744BuiltinAttribute {
name: sym::rustc_no_writable,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_no_writable]` attribute is an internal implementation detail that will never be stable",
"`#[rustc_no_writable]` stops the compiler from considering mutable reference arguments of this function as implicitly writable"],
},
}rustc_attr!(
745 rustc_no_writable,
746"`#[rustc_no_writable]` stops the compiler from considering mutable reference arguments of this function as implicitly writable"
747),
748749// ==========================================================================
750 // Internal attributes, Testing:
751 // ==========================================================================
752753BuiltinAttribute {
name: sym::rustc_effective_visibility,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_effective_visibility]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_effective_visibility]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_effective_visibility),
754BuiltinAttribute {
name: sym::rustc_dump_inferred_outlives,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_dump_inferred_outlives]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_dump_inferred_outlives]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_dump_inferred_outlives),
755BuiltinAttribute {
name: sym::rustc_capture_analysis,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_capture_analysis]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_capture_analysis]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_capture_analysis,),
756BuiltinAttribute {
name: sym::rustc_insignificant_dtor,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_insignificant_dtor]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_insignificant_dtor]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_insignificant_dtor),
757BuiltinAttribute {
name: sym::rustc_no_implicit_bounds,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_no_implicit_bounds]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_no_implicit_bounds]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_no_implicit_bounds),
758BuiltinAttribute {
name: sym::rustc_strict_coherence,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_strict_coherence]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_strict_coherence]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_strict_coherence),
759BuiltinAttribute {
name: sym::rustc_dump_variances,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_dump_variances]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_dump_variances]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_dump_variances),
760BuiltinAttribute {
name: sym::rustc_dump_variances_of_opaques,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_dump_variances_of_opaques]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_dump_variances_of_opaques]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_dump_variances_of_opaques),
761BuiltinAttribute {
name: sym::rustc_dump_hidden_type_of_opaques,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_dump_hidden_type_of_opaques]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_dump_hidden_type_of_opaques]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_dump_hidden_type_of_opaques),
762BuiltinAttribute {
name: sym::rustc_dump_layout,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_dump_layout]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_dump_layout]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_dump_layout),
763BuiltinAttribute {
name: sym::rustc_abi,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_abi]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_abi]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_abi),
764BuiltinAttribute {
name: sym::rustc_regions,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_regions]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_regions]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_regions),
765BuiltinAttribute {
name: sym::rustc_delayed_bug_from_inside_query,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_delayed_bug_from_inside_query]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_delayed_bug_from_inside_query]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_delayed_bug_from_inside_query),
766BuiltinAttribute {
name: sym::rustc_dump_user_args,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_dump_user_args]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_dump_user_args]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_dump_user_args),
767BuiltinAttribute {
name: sym::rustc_evaluate_where_clauses,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_evaluate_where_clauses]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_evaluate_where_clauses]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_evaluate_where_clauses),
768BuiltinAttribute {
name: sym::rustc_if_this_changed,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_if_this_changed]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_if_this_changed]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_if_this_changed),
769BuiltinAttribute {
name: sym::rustc_then_this_would_need,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_then_this_would_need]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_then_this_would_need]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_then_this_would_need),
770BuiltinAttribute {
name: sym::rustc_clean,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_clean]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_clean]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_clean),
771BuiltinAttribute {
name: sym::rustc_partition_reused,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_partition_reused]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_partition_reused]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_partition_reused),
772BuiltinAttribute {
name: sym::rustc_partition_codegened,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_partition_codegened]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_partition_codegened]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_partition_codegened),
773BuiltinAttribute {
name: sym::rustc_expected_cgu_reuse,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_expected_cgu_reuse]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_expected_cgu_reuse]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_expected_cgu_reuse),
774BuiltinAttribute {
name: sym::rustc_dump_symbol_name,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_dump_symbol_name]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_dump_symbol_name]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_dump_symbol_name),
775BuiltinAttribute {
name: sym::rustc_dump_def_path,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_dump_def_path]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_dump_def_path]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_dump_def_path),
776BuiltinAttribute {
name: sym::rustc_mir,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_mir]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_mir]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_mir),
777BuiltinAttribute {
name: sym::custom_mir,
gate: Gated {
feature: sym::custom_mir,
message: "the `#[custom_mir]` attribute is just used for the Rust test suite",
check: Features::custom_mir,
notes: &[],
},
}gated!(
778 custom_mir, "the `#[custom_mir]` attribute is just used for the Rust test suite",
779 ),
780BuiltinAttribute {
name: sym::rustc_dump_item_bounds,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_dump_item_bounds]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_dump_item_bounds]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_dump_item_bounds),
781BuiltinAttribute {
name: sym::rustc_dump_predicates,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_dump_predicates]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_dump_predicates]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_dump_predicates),
782BuiltinAttribute {
name: sym::rustc_dump_def_parents,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_dump_def_parents]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_dump_def_parents]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_dump_def_parents),
783BuiltinAttribute {
name: sym::rustc_dump_object_lifetime_defaults,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_dump_object_lifetime_defaults]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_dump_object_lifetime_defaults]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_dump_object_lifetime_defaults),
784BuiltinAttribute {
name: sym::rustc_dump_vtable,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_dump_vtable]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_dump_vtable]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_dump_vtable),
785BuiltinAttribute {
name: sym::rustc_dummy,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_dummy]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_dummy]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_dummy),
786BuiltinAttribute {
name: sym::pattern_complexity_limit,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[pattern_complexity_limit]` attribute is an internal implementation detail that will never be stable",
"the `#[pattern_complexity_limit]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, pattern_complexity_limit),
787];
788789pub fn is_builtin_attr_name(name: Symbol) -> bool {
790BUILTIN_ATTRIBUTE_MAP.get(&name).is_some()
791}
792793pub static BUILTIN_ATTRIBUTE_MAP: LazyLock<FxHashMap<Symbol, &BuiltinAttribute>> =
794LazyLock::new(|| {
795let mut map = FxHashMap::default();
796for attr in BUILTIN_ATTRIBUTES.iter() {
797if map.insert(attr.name, attr).is_some() {
798{
::core::panicking::panic_fmt(format_args!("duplicate builtin attribute `{0}`",
attr.name));
};panic!("duplicate builtin attribute `{}`", attr.name);
799 }
800 }
801map802 });