1//! Built-in attributes and `cfg` flag gating.
23use std::sync::LazyLock;
45use AttributeGate::*;
6use rustc_data_structures::fx::FxHashMap;
7use rustc_hir::AttrStyle;
8use rustc_span::edition::Edition;
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_equal_alignment,
26 sym::cfg_target_has_atomic_equal_alignment,
27Features::cfg_target_has_atomic_equal_alignment,
28 ),
29 (
30 sym::target_has_atomic_load_store,
31 sym::cfg_target_has_atomic,
32Features::cfg_target_has_atomic,
33 ),
34 (sym::sanitize, sym::cfg_sanitize, Features::cfg_sanitize),
35 (sym::version, sym::cfg_version, Features::cfg_version),
36 (sym::relocation_model, sym::cfg_relocation_model, Features::cfg_relocation_model),
37 (sym::sanitizer_cfi_generalize_pointers, sym::cfg_sanitizer_cfi, Features::cfg_sanitizer_cfi),
38 (sym::sanitizer_cfi_normalize_integers, sym::cfg_sanitizer_cfi, Features::cfg_sanitizer_cfi),
39// this is consistent with naming of the compiler flag it's for
40(sym::fmt_debug, sym::fmt_debug, Features::fmt_debug),
41 (sym::emscripten_wasm_eh, sym::cfg_emscripten_wasm_eh, Features::cfg_emscripten_wasm_eh),
42 (
43 sym::target_has_reliable_f16,
44 sym::cfg_target_has_reliable_f16_f128,
45Features::cfg_target_has_reliable_f16_f128,
46 ),
47 (
48 sym::target_has_reliable_f16_math,
49 sym::cfg_target_has_reliable_f16_f128,
50Features::cfg_target_has_reliable_f16_f128,
51 ),
52 (
53 sym::target_has_reliable_f128,
54 sym::cfg_target_has_reliable_f16_f128,
55Features::cfg_target_has_reliable_f16_f128,
56 ),
57 (
58 sym::target_has_reliable_f128_math,
59 sym::cfg_target_has_reliable_f16_f128,
60Features::cfg_target_has_reliable_f16_f128,
61 ),
62];
6364/// Find a gated cfg determined by the `pred`icate which is given the cfg's name.
65pub fn find_gated_cfg(pred: impl Fn(Symbol) -> bool) -> Option<&'static GatedCfg> {
66GATED_CFGS.iter().find(|(cfg_sym, ..)| pred(*cfg_sym))
67}
6869// If you change this, please modify `src/doc/unstable-book` as well. You must
70// move that documentation into the relevant place in the other docs, and
71// remove the chapter on the flag.
7273#[derive(#[automatically_derived]
impl ::core::marker::Copy for AttributeSafety { }Copy, #[automatically_derived]
impl ::core::clone::Clone for AttributeSafety {
#[inline]
fn clone(&self) -> AttributeSafety {
let _: ::core::clone::AssertParamIsClone<Option<Edition>>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for AttributeSafety {
#[inline]
fn eq(&self, other: &AttributeSafety) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(AttributeSafety::Unsafe { unsafe_since: __self_0 },
AttributeSafety::Unsafe { unsafe_since: __arg1_0 }) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for AttributeSafety {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
AttributeSafety::Normal =>
::core::fmt::Formatter::write_str(f, "Normal"),
AttributeSafety::Unsafe { unsafe_since: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Unsafe", "unsafe_since", &__self_0),
}
}
}Debug)]
74pub enum AttributeSafety {
75/// Normal attribute that does not need `#[unsafe(...)]`
76Normal,
77/// Unsafe attribute that requires safety obligations to be discharged.
78 ///
79 /// An error is emitted when `#[unsafe(...)]` is omitted, except when the attribute's edition
80 /// is less than the one stored in `unsafe_since`. This handles attributes that were safe in
81 /// earlier editions, but become unsafe in later ones.
82Unsafe { unsafe_since: Option<Edition> },
83}
8485#[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)]
86pub enum AttributeGate {
87/// A gated attribute which requires a feature gate to be enabled.
88Gated {
89/// The feature gate, for example `#![feature(rustc_attrs)]` for rustc_* attributes.
90feature: Symbol,
91/// The error message displayed when an attempt is made to use the attribute without its feature gate.
92message: &'static str,
93/// Check function to be called during the `PostExpansionVisitor` pass.
94check: fn(&Features) -> bool,
95/// Notes to be displayed when an attempt is made to use the attribute without its feature gate.
96notes: &'static [&'static str],
97 },
98/// Ungated attribute, can be used on all release channels
99Ungated,
100}
101102// FIXME(jdonszelmann): move to rustc_hir::attrs
103/// A template that the attribute input must match.
104/// Only top-level shape (`#[attr]` vs `#[attr(...)]` vs `#[attr = ...]`) is considered now.
105#[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)]
106pub struct AttributeTemplate {
107/// If `true`, the attribute is allowed to be a bare word like `#[test]`.
108pub word: bool,
109/// If `Some`, the attribute is allowed to take a list of items like `#[allow(..)]`.
110pub list: Option<&'static [&'static str]>,
111/// If non-empty, the attribute is allowed to take a list containing exactly
112 /// one of the listed words, like `#[coverage(off)]`.
113pub one_of: &'static [Symbol],
114/// If `Some`, the attribute is allowed to be a name/value pair where the
115 /// value is a string, like `#[must_use = "reason"]`.
116pub name_value_str: Option<&'static [&'static str]>,
117/// A link to the document for this attribute.
118pub docs: Option<&'static str>,
119}
120121pub enum AttrSuggestionStyle {
122/// The suggestion is styled for a normal attribute.
123 /// The `AttrStyle` determines whether this is an inner or outer attribute.
124Attribute(AttrStyle),
125/// The suggestion is styled for an attribute embedded into another attribute.
126 /// For example, attributes inside `#[cfg_attr(true, attr(...)]`.
127EmbeddedAttribute,
128/// The suggestion is styled for macros that are parsed with attribute parsers.
129 /// For example, the `cfg!(predicate)` macro.
130Macro,
131}
132133impl AttributeTemplate {
134pub fn suggestions(
135&self,
136 style: AttrSuggestionStyle,
137 name: impl std::fmt::Display,
138 ) -> Vec<String> {
139let (start, macro_call, end) = match style {
140 AttrSuggestionStyle::Attribute(AttrStyle::Outer) => ("#[", "", "]"),
141 AttrSuggestionStyle::Attribute(AttrStyle::Inner) => ("#![", "", "]"),
142 AttrSuggestionStyle::Macro => ("", "!", ""),
143 AttrSuggestionStyle::EmbeddedAttribute => ("", "", ""),
144 };
145146let mut suggestions = ::alloc::vec::Vec::new()vec![];
147148if self.word {
149if 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");
150suggestions.push(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}{1}{2}", start, name, end))
})format!("{start}{name}{end}"));
151 }
152if let Some(descr) = self.list {
153for descr in descr {
154 suggestions.push(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}{1}{2}({3}){4}", start, name,
macro_call, descr, end))
})format!("{start}{name}{macro_call}({descr}){end}"));
155 }
156 }
157suggestions.extend(self.one_of.iter().map(|&word| ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}{1}({2}){3}", start, name, word,
end))
})format!("{start}{name}({word}){end}")));
158if let Some(descr) = self.name_value_str {
159if 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");
160for descr in descr {
161 suggestions.push(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}{1} = \"{2}\"{3}", start, name,
descr, end))
})format!("{start}{name} = \"{descr}\"{end}"));
162 }
163 }
164suggestions.sort();
165166suggestions167 }
168}
169170/// A convenience macro for constructing attribute templates.
171/// E.g., `template!(Word, List: "description")` means that the attribute
172/// supports forms `#[attr]` and `#[attr(description)]`.
173#[macro_export]
174macro_rules!template {
175 (Word) => { $crate::template!(@ true, None, &[], None, None) };
176 (Word, $link: literal) => { $crate::template!(@ true, None, &[], None, Some($link)) };
177 (List: $descr: expr) => { $crate::template!(@ false, Some($descr), &[], None, None) };
178 (List: $descr: expr, $link: literal) => { $crate::template!(@ false, Some($descr), &[], None, Some($link)) };
179 (OneOf: $one_of: expr) => { $crate::template!(@ false, None, $one_of, None, None) };
180 (NameValueStr: [$($descr: literal),* $(,)?]) => { $crate::template!(@ false, None, &[], Some(&[$($descr,)*]), None) };
181 (NameValueStr: [$($descr: literal),* $(,)?], $link: literal) => { $crate::template!(@ false, None, &[], Some(&[$($descr,)*]), Some($link)) };
182 (NameValueStr: $descr: literal) => { $crate::template!(@ false, None, &[], Some(&[$descr]), None) };
183 (NameValueStr: $descr: literal, $link: literal) => { $crate::template!(@ false, None, &[], Some(&[$descr]), Some($link)) };
184 (Word, List: $descr: expr) => { $crate::template!(@ true, Some($descr), &[], None, None) };
185 (Word, List: $descr: expr, $link: literal) => { $crate::template!(@ true, Some($descr), &[], None, Some($link)) };
186 (Word, NameValueStr: $descr: expr) => { $crate::template!(@ true, None, &[], Some(&[$descr]), None) };
187 (Word, NameValueStr: $descr: expr, $link: literal) => { $crate::template!(@ true, None, &[], Some(&[$descr]), Some($link)) };
188 (List: $descr1: expr, NameValueStr: $descr2: expr) => {
189$crate::template!(@ false, Some($descr1), &[], Some(&[$descr2]), None)
190 };
191 (List: $descr1: expr, NameValueStr: $descr2: expr, $link: literal) => {
192$crate::template!(@ false, Some($descr1), &[], Some(&[$descr2]), Some($link))
193 };
194 (Word, List: $descr1: expr, NameValueStr: $descr2: expr) => {
195$crate::template!(@ true, Some($descr1), &[], Some(&[$descr2]), None)
196 };
197 (Word, List: $descr1: expr, NameValueStr: $descr2: expr, $link: literal) => {
198$crate::template!(@ true, Some($descr1), &[], Some(&[$descr2]), Some($link))
199 };
200 (@ $word: expr, $list: expr, $one_of: expr, $name_value_str: expr, $link: expr) => { $crate::AttributeTemplate {
201 word: $word, list: $list, one_of: $one_of, name_value_str: $name_value_str, docs: $link,
202 } };
203}
204205macro_rules!ungated {
206 (unsafe($edition:ident) $attr:ident $(,)?) => {
207 BuiltinAttribute {
208 name: sym::$attr,
209 safety: AttributeSafety::Unsafe { unsafe_since: Some(Edition::$edition) },
210 gate: Ungated,
211 }
212 };
213 (unsafe $attr:ident $(,)?) => {
214 BuiltinAttribute {
215 name: sym::$attr,
216 safety: AttributeSafety::Unsafe { unsafe_since: None },
217 gate: Ungated,
218 }
219 };
220 ($attr:ident $(,)?) => {
221 BuiltinAttribute { name: sym::$attr, safety: AttributeSafety::Normal, gate: Ungated }
222 };
223}
224225macro_rules!gated {
226 (unsafe $attr:ident, $gate:ident, $message:expr $(,)?) => {
227 BuiltinAttribute {
228 name: sym::$attr,
229 safety: AttributeSafety::Unsafe { unsafe_since: None },
230231 gate: Gated {
232 feature: sym::$gate,
233 message: $message,
234 check: Features::$gate,
235 notes: &[],
236 },
237 }
238 };
239 (unsafe $attr:ident, $message:expr $(,)?) => {
240 BuiltinAttribute {
241 name: sym::$attr,
242 safety: AttributeSafety::Unsafe { unsafe_since: None },
243244 gate: Gated {
245 feature: sym::$attr,
246 message: $message,
247 check: Features::$attr,
248 notes: &[],
249 },
250 }
251 };
252 ($attr:ident, $gate:ident, $message:expr $(,)?) => {
253 BuiltinAttribute {
254 name: sym::$attr,
255 safety: AttributeSafety::Normal,
256257 gate: Gated {
258 feature: sym::$gate,
259 message: $message,
260 check: Features::$gate,
261 notes: &[],
262 },
263 }
264 };
265 ($attr:ident, $message:expr $(,)?) => {
266 BuiltinAttribute {
267 name: sym::$attr,
268 safety: AttributeSafety::Normal,
269270 gate: Gated {
271 feature: sym::$attr,
272 message: $message,
273 check: Features::$attr,
274 notes: &[],
275 },
276 }
277 };
278}
279280macro_rules!rustc_attr {
281 (TEST, $attr:ident $(,)?) => {
282rustc_attr!( $attr,
283concat!(
284"the `#[",
285stringify!($attr),
286"]` attribute is used for rustc unit tests"
287),
288 )
289 };
290 ($attr:ident $(, $notes:expr)* $(,)?) => {
291 BuiltinAttribute {
292 name: sym::$attr,
293 safety: AttributeSafety::Normal,
294 gate: Gated {
295 feature: sym::rustc_attrs,
296 message: "use of an internal attribute",
297 check: Features::rustc_attrs,
298 notes: &[
299concat!("the `#[",
300stringify!($attr),
301"]` attribute is an internal implementation detail that will never be stable"),
302 $($notes),*
303 ]
304 },
305 }
306 };
307}
308309macro_rules!experimental {
310 ($attr:ident) => {
311concat!("the `#[", stringify!($attr), "]` attribute is an experimental feature")
312 };
313}
314315pub struct BuiltinAttribute {
316pub name: Symbol,
317pub safety: AttributeSafety,
318pub gate: AttributeGate,
319}
320321/// Attributes that have a special meaning to rustc or rustdoc.
322#[rustfmt::skip]
323pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
324// ==========================================================================
325 // Stable attributes:
326 // ==========================================================================
327328 // Conditional compilation:
329BuiltinAttribute {
name: sym::cfg,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(cfg),
330BuiltinAttribute {
name: sym::cfg_attr,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(cfg_attr),
331332// Testing:
333BuiltinAttribute {
name: sym::ignore,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(ignore),
334BuiltinAttribute {
name: sym::should_panic,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(should_panic),
335336// Macros:
337BuiltinAttribute {
name: sym::automatically_derived,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(automatically_derived),
338BuiltinAttribute {
name: sym::macro_use,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(macro_use),
339BuiltinAttribute {
name: sym::macro_escape,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(macro_escape), // Deprecated synonym for `macro_use`.
340BuiltinAttribute {
name: sym::macro_export,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(macro_export),
341BuiltinAttribute {
name: sym::proc_macro,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(proc_macro),
342BuiltinAttribute {
name: sym::proc_macro_derive,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(proc_macro_derive),
343BuiltinAttribute {
name: sym::proc_macro_attribute,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(proc_macro_attribute),
344345// Lints:
346BuiltinAttribute {
name: sym::warn,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(warn),
347BuiltinAttribute {
name: sym::allow,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(allow),
348BuiltinAttribute {
name: sym::expect,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(expect),
349BuiltinAttribute {
name: sym::forbid,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(forbid),
350BuiltinAttribute {
name: sym::deny,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(deny),
351BuiltinAttribute {
name: sym::must_use,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(must_use),
352BuiltinAttribute {
name: sym::must_not_suspend,
safety: AttributeSafety::Normal,
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)),
353BuiltinAttribute {
name: sym::deprecated,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(deprecated),
354355// Crate properties:
356BuiltinAttribute {
name: sym::crate_name,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(crate_name),
357BuiltinAttribute {
name: sym::crate_type,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(crate_type),
358359// ABI, linking, symbols, and FFI
360BuiltinAttribute {
name: sym::link,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(link),
361BuiltinAttribute {
name: sym::link_name,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(link_name),
362BuiltinAttribute {
name: sym::no_link,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(no_link),
363BuiltinAttribute {
name: sym::repr,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(repr),
364// FIXME(#82232, #143834): temporarily renamed to mitigate `#[align]` nameres ambiguity
365BuiltinAttribute {
name: sym::rustc_align,
safety: AttributeSafety::Normal,
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)),
366BuiltinAttribute {
name: sym::rustc_align_static,
safety: AttributeSafety::Normal,
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)),
367BuiltinAttribute {
name: sym::export_name,
safety: AttributeSafety::Unsafe {
unsafe_since: Some(Edition::Edition2024),
},
gate: Ungated,
}ungated!(unsafe(Edition2024) export_name),
368BuiltinAttribute {
name: sym::link_section,
safety: AttributeSafety::Unsafe {
unsafe_since: Some(Edition::Edition2024),
},
gate: Ungated,
}ungated!(unsafe(Edition2024) link_section),
369BuiltinAttribute {
name: sym::no_mangle,
safety: AttributeSafety::Unsafe {
unsafe_since: Some(Edition::Edition2024),
},
gate: Ungated,
}ungated!(unsafe(Edition2024) no_mangle),
370BuiltinAttribute {
name: sym::used,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(used),
371BuiltinAttribute {
name: sym::link_ordinal,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(link_ordinal),
372BuiltinAttribute {
name: sym::naked,
safety: AttributeSafety::Unsafe { unsafe_since: None },
gate: Ungated,
}ungated!(unsafe naked),
373// See `TyAndLayout::pass_indirectly_in_non_rustic_abis` for details.
374BuiltinAttribute {
name: sym::rustc_pass_indirectly_in_non_rustic_abis,
safety: AttributeSafety::Normal,
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"),
375376// Limits:
377BuiltinAttribute {
name: sym::recursion_limit,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(recursion_limit),
378BuiltinAttribute {
name: sym::type_length_limit,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(type_length_limit),
379BuiltinAttribute {
name: sym::move_size_limit,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::large_assignments,
message: "the `#[move_size_limit]` attribute is an experimental feature",
check: Features::large_assignments,
notes: &[],
},
}gated!(
380 move_size_limit, large_assignments, experimental!(move_size_limit)
381 ),
382383// Entry point:
384BuiltinAttribute {
name: sym::no_main,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(no_main),
385386// Modules, prelude, and resolution:
387BuiltinAttribute {
name: sym::path,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(path),
388BuiltinAttribute {
name: sym::no_std,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(no_std),
389BuiltinAttribute {
name: sym::no_implicit_prelude,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(no_implicit_prelude),
390BuiltinAttribute {
name: sym::non_exhaustive,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(non_exhaustive),
391392// Runtime
393BuiltinAttribute {
name: sym::windows_subsystem,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(windows_subsystem),
394BuiltinAttribute {
name: sym::panic_handler,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(// RFC 2070
395panic_handler
396 ),
397398// Code generation:
399BuiltinAttribute {
name: sym::inline,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(inline),
400BuiltinAttribute {
name: sym::cold,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(cold),
401BuiltinAttribute {
name: sym::no_builtins,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(no_builtins),
402BuiltinAttribute {
name: sym::target_feature,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(target_feature),
403BuiltinAttribute {
name: sym::track_caller,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(track_caller),
404BuiltinAttribute {
name: sym::instruction_set,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(instruction_set),
405BuiltinAttribute {
name: sym::force_target_feature,
safety: AttributeSafety::Unsafe { unsafe_since: None },
gate: Gated {
feature: sym::effective_target_features,
message: "the `#[force_target_feature]` attribute is an experimental feature",
check: Features::effective_target_features,
notes: &[],
},
}gated!(
406unsafe force_target_feature,
407 effective_target_features, experimental!(force_target_feature)
408 ),
409BuiltinAttribute {
name: sym::sanitize,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::sanitize,
message: "the `#[sanitize]` attribute is an experimental feature",
check: Features::sanitize,
notes: &[],
},
}gated!(
410 sanitize,
411 sanitize, experimental!(sanitize)
412 ),
413BuiltinAttribute {
name: sym::coverage,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::coverage_attribute,
message: "the `#[coverage]` attribute is an experimental feature",
check: Features::coverage_attribute,
notes: &[],
},
}gated!(
414 coverage,
415 coverage_attribute, experimental!(coverage)
416 ),
417418BuiltinAttribute {
name: sym::doc,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(doc),
419420// Debugging
421BuiltinAttribute {
name: sym::debugger_visualizer,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(debugger_visualizer),
422BuiltinAttribute {
name: sym::collapse_debuginfo,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(collapse_debuginfo),
423424// ==========================================================================
425 // Unstable attributes:
426 // ==========================================================================
427428 // Linking:
429BuiltinAttribute {
name: sym::export_stable,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::export_stable,
message: "the `#[export_stable]` attribute is an experimental feature",
check: Features::export_stable,
notes: &[],
},
}gated!(
430 export_stable, experimental!(export_stable)
431 ),
432433// Testing:
434BuiltinAttribute {
name: sym::test_runner,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::custom_test_frameworks,
message: "custom test frameworks are an unstable feature",
check: Features::custom_test_frameworks,
notes: &[],
},
}gated!(
435 test_runner, custom_test_frameworks,
436"custom test frameworks are an unstable feature"
437),
438439BuiltinAttribute {
name: sym::reexport_test_harness_main,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::custom_test_frameworks,
message: "custom test frameworks are an unstable feature",
check: Features::custom_test_frameworks,
notes: &[],
},
}gated!(
440 reexport_test_harness_main, custom_test_frameworks,
441"custom test frameworks are an unstable feature"
442),
443444// RFC #1268
445BuiltinAttribute {
name: sym::marker,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::marker_trait_attr,
message: "the `#[marker]` attribute is an experimental feature",
check: Features::marker_trait_attr,
notes: &[],
},
}gated!(
446 marker,marker_trait_attr, experimental!(marker)
447 ),
448BuiltinAttribute {
name: sym::thread_local,
safety: AttributeSafety::Normal,
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!(
449 thread_local,"`#[thread_local]` is an experimental feature, and does not currently handle destructors"
450),
451BuiltinAttribute {
name: sym::no_core,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::no_core,
message: "the `#[no_core]` attribute is an experimental feature",
check: Features::no_core,
notes: &[],
},
}gated!(
452 no_core, experimental!(no_core)
453 ),
454// RFC 2412
455BuiltinAttribute {
name: sym::optimize,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::optimize_attribute,
message: "the `#[optimize]` attribute is an experimental feature",
check: Features::optimize_attribute,
notes: &[],
},
}gated!(
456 optimize,
457 optimize_attribute, experimental!(optimize)
458 ),
459460BuiltinAttribute {
name: sym::ffi_pure,
safety: AttributeSafety::Unsafe { unsafe_since: None },
gate: Gated {
feature: sym::ffi_pure,
message: "the `#[ffi_pure]` attribute is an experimental feature",
check: Features::ffi_pure,
notes: &[],
},
}gated!(
461unsafe ffi_pure, experimental!(ffi_pure)
462 ),
463BuiltinAttribute {
name: sym::ffi_const,
safety: AttributeSafety::Unsafe { unsafe_since: None },
gate: Gated {
feature: sym::ffi_const,
message: "the `#[ffi_const]` attribute is an experimental feature",
check: Features::ffi_const,
notes: &[],
},
}gated!(
464unsafe ffi_const, experimental!(ffi_const)
465 ),
466BuiltinAttribute {
name: sym::register_tool,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::register_tool,
message: "the `#[register_tool]` attribute is an experimental feature",
check: Features::register_tool,
notes: &[],
},
}gated!(
467 register_tool, experimental!(register_tool)
468 ),
469// `#[cfi_encoding = ""]`
470BuiltinAttribute {
name: sym::cfi_encoding,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::cfi_encoding,
message: "the `#[cfi_encoding]` attribute is an experimental feature",
check: Features::cfi_encoding,
notes: &[],
},
}gated!(
471 cfi_encoding,
472experimental!(cfi_encoding)
473 ),
474475// `#[coroutine]` attribute to be applied to closures to make them coroutines instead
476BuiltinAttribute {
name: sym::coroutine,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::coroutines,
message: "the `#[coroutine]` attribute is an experimental feature",
check: Features::coroutines,
notes: &[],
},
}gated!(
477 coroutine,coroutines, experimental!(coroutine)
478 ),
479480// RFC 3543
481 // `#[patchable_function_entry(prefix_nops = m, entry_nops = n)]`
482BuiltinAttribute {
name: sym::patchable_function_entry,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::patchable_function_entry,
message: "the `#[patchable_function_entry]` attribute is an experimental feature",
check: Features::patchable_function_entry,
notes: &[],
},
}gated!(
483 patchable_function_entry,
484experimental!(patchable_function_entry)
485 ),
486487// The `#[loop_match]` and `#[const_continue]` attributes are part of the
488 // lang experiment for RFC 3720 tracked in:
489 //
490 // - https://github.com/rust-lang/rust/issues/132306
491BuiltinAttribute {
name: sym::const_continue,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::loop_match,
message: "the `#[const_continue]` attribute is an experimental feature",
check: Features::loop_match,
notes: &[],
},
}gated!(
492 const_continue,loop_match, experimental!(const_continue)
493 ),
494BuiltinAttribute {
name: sym::loop_match,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::loop_match,
message: "the `#[loop_match]` attribute is an experimental feature",
check: Features::loop_match,
notes: &[],
},
}gated!(
495 loop_match,loop_match, experimental!(loop_match)
496 ),
497498// The `#[pin_v2]` attribute is part of the `pin_ergonomics` experiment
499 // that allows structurally pinning, tracked in:
500 //
501 // - https://github.com/rust-lang/rust/issues/130494
502BuiltinAttribute {
name: sym::pin_v2,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::pin_ergonomics,
message: "the `#[pin_v2]` attribute is an experimental feature",
check: Features::pin_ergonomics,
notes: &[],
},
}gated!(
503 pin_v2,pin_ergonomics, experimental!(pin_v2),
504 ),
505506// ==========================================================================
507 // Internal attributes: Stability, deprecation, and unsafe:
508 // ==========================================================================
509510BuiltinAttribute {
name: sym::feature,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(feature),
511// DuplicatesOk since it has its own validation
512BuiltinAttribute {
name: sym::stable,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(stable),
513BuiltinAttribute {
name: sym::unstable,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(unstable),
514BuiltinAttribute {
name: sym::unstable_feature_bound,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(unstable_feature_bound),
515BuiltinAttribute {
name: sym::rustc_const_unstable,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(rustc_const_unstable),
516BuiltinAttribute {
name: sym::rustc_const_stable,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(rustc_const_stable),
517BuiltinAttribute {
name: sym::rustc_default_body_unstable,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(rustc_default_body_unstable),
518BuiltinAttribute {
name: sym::allow_internal_unstable,
safety: AttributeSafety::Normal,
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!(
519 allow_internal_unstable,
520"allow_internal_unstable side-steps feature gating and stability checks",
521 ),
522BuiltinAttribute {
name: sym::allow_internal_unsafe,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::allow_internal_unsafe,
message: "allow_internal_unsafe side-steps the unsafe_code lint",
check: Features::allow_internal_unsafe,
notes: &[],
},
}gated!(
523 allow_internal_unsafe, "allow_internal_unsafe side-steps the unsafe_code lint",
524 ),
525BuiltinAttribute {
name: sym::rustc_eii_foreign_item,
safety: AttributeSafety::Normal,
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!(
526 rustc_eii_foreign_item,
527 eii_internals,
528"used internally to mark types with a `transparent` representation when it is guaranteed by the documentation",
529 ),
530BuiltinAttribute {
name: sym::rustc_allowed_through_unstable_modules,
safety: AttributeSafety::Normal,
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!(rustc_allowed_through_unstable_modules,
531"rustc_allowed_through_unstable_modules special cases accidental stabilizations of stable items \
532 through unstable paths"
533),
534BuiltinAttribute {
name: sym::rustc_deprecated_safe_2024,
safety: AttributeSafety::Normal,
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!(rustc_deprecated_safe_2024,"`#[rustc_deprecated_safe_2024]` is used to declare functions unsafe across the edition 2024 boundary",
535 ),
536BuiltinAttribute {
name: sym::rustc_pub_transparent,
safety: AttributeSafety::Normal,
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!(rustc_pub_transparent,"used internally to mark types with a `transparent` representation when it is guaranteed by the documentation",
537 ),
538539540// ==========================================================================
541 // Internal attributes: Type system related:
542 // ==========================================================================
543544BuiltinAttribute {
name: sym::fundamental,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::fundamental,
message: "the `#[fundamental]` attribute is an experimental feature",
check: Features::fundamental,
notes: &[],
},
}gated!(fundamental, experimental!(fundamental)),
545BuiltinAttribute {
name: sym::may_dangle,
safety: AttributeSafety::Normal,
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!(
546 may_dangle, dropck_eyepatch,
547"`may_dangle` has unstable semantics and may be removed in the future"
548),
549550BuiltinAttribute {
name: sym::rustc_never_type_options,
safety: AttributeSafety::Normal,
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!(rustc_never_type_options,
551"`rustc_never_type_options` is used to experiment with never type fallback and work on \
552 never type stabilization"
553),
554555// ==========================================================================
556 // Internal attributes: Runtime related:
557 // ==========================================================================
558559BuiltinAttribute {
name: sym::rustc_allocator,
safety: AttributeSafety::Normal,
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),
560BuiltinAttribute {
name: sym::rustc_nounwind,
safety: AttributeSafety::Normal,
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),
561BuiltinAttribute {
name: sym::rustc_reallocator,
safety: AttributeSafety::Normal,
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),
562BuiltinAttribute {
name: sym::rustc_deallocator,
safety: AttributeSafety::Normal,
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),
563BuiltinAttribute {
name: sym::rustc_allocator_zeroed,
safety: AttributeSafety::Normal,
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),
564BuiltinAttribute {
name: sym::rustc_allocator_zeroed_variant,
safety: AttributeSafety::Normal,
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),
565BuiltinAttribute {
name: sym::default_lib_allocator,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::allocator_internals,
message: "the `#[default_lib_allocator]` attribute is an experimental feature",
check: Features::allocator_internals,
notes: &[],
},
}gated!(
566 default_lib_allocator, allocator_internals, experimental!(default_lib_allocator),
567 ),
568BuiltinAttribute {
name: sym::needs_allocator,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::allocator_internals,
message: "the `#[needs_allocator]` attribute is an experimental feature",
check: Features::allocator_internals,
notes: &[],
},
}gated!(
569 needs_allocator, allocator_internals, experimental!(needs_allocator),
570 ),
571BuiltinAttribute {
name: sym::panic_runtime,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::panic_runtime,
message: "the `#[panic_runtime]` attribute is an experimental feature",
check: Features::panic_runtime,
notes: &[],
},
}gated!(
572 panic_runtime, experimental!(panic_runtime)
573 ),
574BuiltinAttribute {
name: sym::needs_panic_runtime,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::needs_panic_runtime,
message: "the `#[needs_panic_runtime]` attribute is an experimental feature",
check: Features::needs_panic_runtime,
notes: &[],
},
}gated!(
575 needs_panic_runtime, experimental!(needs_panic_runtime)
576 ),
577BuiltinAttribute {
name: sym::compiler_builtins,
safety: AttributeSafety::Normal,
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!(
578 compiler_builtins,
579"the `#[compiler_builtins]` attribute is used to identify the `compiler_builtins` crate \
580 which contains compiler-rt intrinsics and will never be stable"
581),
582BuiltinAttribute {
name: sym::profiler_runtime,
safety: AttributeSafety::Normal,
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!(
583 profiler_runtime,
584"the `#[profiler_runtime]` attribute is used to identify the `profiler_builtins` crate \
585 which contains the profiler runtime and will never be stable"
586),
587588// ==========================================================================
589 // Internal attributes, Linkage:
590 // ==========================================================================
591592BuiltinAttribute {
name: sym::linkage,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::linkage,
message: "the `linkage` attribute is experimental and not portable across platforms",
check: Features::linkage,
notes: &[],
},
}gated!(
593 linkage,
594"the `linkage` attribute is experimental and not portable across platforms"
595),
596BuiltinAttribute {
name: sym::rustc_std_internal_symbol,
safety: AttributeSafety::Normal,
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),
597BuiltinAttribute {
name: sym::rustc_objc_class,
safety: AttributeSafety::Normal,
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),
598BuiltinAttribute {
name: sym::rustc_objc_selector,
safety: AttributeSafety::Normal,
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),
599600// ==========================================================================
601 // Internal attributes, Macro related:
602 // ==========================================================================
603604BuiltinAttribute {
name: sym::rustc_builtin_macro,
safety: AttributeSafety::Normal,
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),
605BuiltinAttribute {
name: sym::rustc_proc_macro_decls,
safety: AttributeSafety::Normal,
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),
606BuiltinAttribute {
name: sym::rustc_macro_transparency,
safety: AttributeSafety::Normal,
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!(rustc_macro_transparency,
607"used internally for testing macro hygiene"
608),
609BuiltinAttribute {
name: sym::rustc_autodiff,
safety: AttributeSafety::Normal,
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),
610BuiltinAttribute {
name: sym::rustc_offload_kernel,
safety: AttributeSafety::Normal,
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),
611// Traces that are left when `cfg` and `cfg_attr` attributes are expanded.
612 // The attributes are not gated, to avoid stability errors, but they cannot be used in stable
613 // or unstable code directly because `sym::cfg_(attr_)trace` are not valid identifiers, they
614 // can only be generated by the compiler.
615BuiltinAttribute {
name: sym::cfg_trace,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(cfg_trace
616 ),
617BuiltinAttribute {
name: sym::cfg_attr_trace,
safety: AttributeSafety::Normal,
gate: Ungated,
}ungated!(cfg_attr_trace
618 ),
619620// ==========================================================================
621 // Internal attributes, Diagnostics related:
622 // ==========================================================================
623624BuiltinAttribute {
name: sym::rustc_on_unimplemented,
safety: AttributeSafety::Normal,
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!(rustc_on_unimplemented,"see `#[diagnostic::on_unimplemented]` for the stable equivalent of this attribute"
625),
626BuiltinAttribute {
name: sym::rustc_confusables,
safety: AttributeSafety::Normal,
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),
627// Enumerates "identity-like" conversion methods to suggest on type mismatch.
628BuiltinAttribute {
name: sym::rustc_conversion_suggestion,
safety: AttributeSafety::Normal,
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),
629// Prevents field reads in the marked trait or method to be considered
630 // during dead code analysis.
631BuiltinAttribute {
name: sym::rustc_trivial_field_reads,
safety: AttributeSafety::Normal,
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),
632// Used by the `rustc::potential_query_instability` lint to warn methods which
633 // might not be stable during incremental compilation.
634BuiltinAttribute {
name: sym::rustc_lint_query_instability,
safety: AttributeSafety::Normal,
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),
635// Used by the `rustc::untracked_query_information` lint to warn methods which
636 // might not be stable during incremental compilation.
637BuiltinAttribute {
name: sym::rustc_lint_untracked_query_information,
safety: AttributeSafety::Normal,
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),
638// Used by the `rustc::bad_opt_access` lint to identify `DebuggingOptions` and `CodegenOptions`
639 // types (as well as any others in future).
640BuiltinAttribute {
name: sym::rustc_lint_opt_ty,
safety: AttributeSafety::Normal,
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),
641// Used by the `rustc::bad_opt_access` lint on fields
642 // types (as well as any others in future).
643BuiltinAttribute {
name: sym::rustc_lint_opt_deny_field_access,
safety: AttributeSafety::Normal,
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),
644645// ==========================================================================
646 // Internal attributes, Const related:
647 // ==========================================================================
648649BuiltinAttribute {
name: sym::rustc_promotable,
safety: AttributeSafety::Normal,
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),
650BuiltinAttribute {
name: sym::rustc_legacy_const_generics,
safety: AttributeSafety::Normal,
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),
651// Do not const-check this function's body. It will always get replaced during CTFE via `hook_special_const_fn`.
652BuiltinAttribute {
name: sym::rustc_do_not_const_check,
safety: AttributeSafety::Normal,
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!(rustc_do_not_const_check, "`#[rustc_do_not_const_check]` skips const-check for this function's body"),
653BuiltinAttribute {
name: sym::rustc_const_stable_indirect,
safety: AttributeSafety::Normal,
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!(rustc_const_stable_indirect,
654"this is an internal implementation detail"),
655BuiltinAttribute {
name: sym::rustc_intrinsic_const_stable_indirect,
safety: AttributeSafety::Normal,
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!(rustc_intrinsic_const_stable_indirect,
656"this is an internal implementation detail"),
657BuiltinAttribute {
name: sym::rustc_allow_const_fn_unstable,
safety: AttributeSafety::Normal,
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!(rustc_allow_const_fn_unstable,
658"rustc_allow_const_fn_unstable side-steps feature gating and stability checks"
659),
660661// ==========================================================================
662 // Internal attributes, Layout related:
663 // ==========================================================================
664665BuiltinAttribute {
name: sym::rustc_layout_scalar_valid_range_start,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_layout_scalar_valid_range_start]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_layout_scalar_valid_range_start]` attribute is just used to enable \
niche optimizations in the standard library"],
},
}rustc_attr!(rustc_layout_scalar_valid_range_start, "the `#[rustc_layout_scalar_valid_range_start]` attribute is just used to enable \
666 niche optimizations in the standard library"),
667BuiltinAttribute {
name: sym::rustc_layout_scalar_valid_range_end,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_layout_scalar_valid_range_end]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_layout_scalar_valid_range_end]` attribute is just used to enable \
niche optimizations in the standard library"],
},
}rustc_attr!(rustc_layout_scalar_valid_range_end, "the `#[rustc_layout_scalar_valid_range_end]` attribute is just used to enable \
668 niche optimizations in the standard library"),
669BuiltinAttribute {
name: sym::rustc_simd_monomorphize_lane_limit,
safety: AttributeSafety::Normal,
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!(rustc_simd_monomorphize_lane_limit, "the `#[rustc_simd_monomorphize_lane_limit]` attribute is just used by std::simd \
670 for better error messages"),
671BuiltinAttribute {
name: sym::rustc_nonnull_optimization_guaranteed,
safety: AttributeSafety::Normal,
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!(rustc_nonnull_optimization_guaranteed,
672"the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to document \
673 guaranteed niche optimizations in the standard library",
674"the compiler does not even check whether the type indeed is being non-null-optimized; \
675 it is your responsibility to ensure that the attribute is only used on types that are optimized"),
676677// ==========================================================================
678 // Internal attributes, Misc:
679 // ==========================================================================
680BuiltinAttribute {
name: sym::lang,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::lang_items,
message: "lang items are subject to change",
check: Features::lang_items,
notes: &[],
},
}gated!(
681 lang,lang_items,
682"lang items are subject to change"
683),
684BuiltinAttribute {
name: sym::rustc_as_ptr,
safety: AttributeSafety::Normal,
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!(rustc_as_ptr, "`#[rustc_as_ptr]` is used to mark functions returning pointers to their inner allocations"),
685BuiltinAttribute {
name: sym::rustc_should_not_be_called_on_const_items,
safety: AttributeSafety::Normal,
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!(rustc_should_not_be_called_on_const_items, "`#[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"),
686BuiltinAttribute {
name: sym::rustc_pass_by_value,
safety: AttributeSafety::Normal,
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!(rustc_pass_by_value, "`#[rustc_pass_by_value]` is used to mark types that must be passed by value instead of reference"),
687BuiltinAttribute {
name: sym::rustc_never_returns_null_ptr,
safety: AttributeSafety::Normal,
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!(rustc_never_returns_null_ptr, "`#[rustc_never_returns_null_ptr]` is used to mark functions returning non-null pointers"),
688BuiltinAttribute {
name: sym::rustc_no_implicit_autorefs,
safety: AttributeSafety::Normal,
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!(rustc_no_implicit_autorefs, "`#[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"),
689BuiltinAttribute {
name: sym::rustc_coherence_is_core,
safety: AttributeSafety::Normal,
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!(rustc_coherence_is_core, "`#![rustc_coherence_is_core]` allows inherent methods on builtin types, only intended to be used in `core`"),
690BuiltinAttribute {
name: sym::rustc_coinductive,
safety: AttributeSafety::Normal,
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!(rustc_coinductive, "`#[rustc_coinductive]` changes a trait to be coinductive, allowing cycles in the trait solver"),
691BuiltinAttribute {
name: sym::rustc_allow_incoherent_impl,
safety: AttributeSafety::Normal,
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!(rustc_allow_incoherent_impl, "`#[rustc_allow_incoherent_impl]` has to be added to all impl items of an incoherent inherent impl"),
692BuiltinAttribute {
name: sym::rustc_preserve_ub_checks,
safety: AttributeSafety::Normal,
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!(rustc_preserve_ub_checks, "`#![rustc_preserve_ub_checks]` prevents the designated crate from evaluating whether UB checks are enabled when optimizing MIR"),
693BuiltinAttribute {
name: sym::rustc_deny_explicit_impl,
safety: AttributeSafety::Normal,
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!(rustc_deny_explicit_impl,
694"`#[rustc_deny_explicit_impl]` enforces that a trait can have no user-provided impls"
695),
696BuiltinAttribute {
name: sym::rustc_dyn_incompatible_trait,
safety: AttributeSafety::Normal,
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!(rustc_dyn_incompatible_trait,
697"`#[rustc_dyn_incompatible_trait]` marks a trait as dyn-incompatible, \
698 even if it otherwise satisfies the requirements to be dyn-compatible."
699),
700BuiltinAttribute {
name: sym::rustc_has_incoherent_inherent_impls,
safety: AttributeSafety::Normal,
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!(rustc_has_incoherent_inherent_impls, "`#[rustc_has_incoherent_inherent_impls]` allows the addition of incoherent inherent impls for \
701 the given type by annotating all impl items with `#[rustc_allow_incoherent_impl]`"
702),
703BuiltinAttribute {
name: sym::rustc_non_const_trait_method,
safety: AttributeSafety::Normal,
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!(rustc_non_const_trait_method, "`#[rustc_non_const_trait_method]` should only used by the standard library to mark trait methods \
704 as non-const to allow large traits an easier transition to const"
705),
706707BuiltinAttribute {
708 name: sym::rustc_diagnostic_item,
709 safety: AttributeSafety::Normal,
710 gate: Gated {
711 feature: sym::rustc_attrs,
712 message: "use of an internal attribute",
713 check: Features::rustc_attrs,
714 notes: &["the `#[rustc_diagnostic_item]` attribute allows the compiler to reference types \
715 from the standard library for diagnostic purposes"],
716 },
717 },
718BuiltinAttribute {
name: sym::prelude_import,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::prelude_import,
message: "`#[prelude_import]` is for use by rustc only",
check: Features::prelude_import,
notes: &[],
},
}gated!(
719// Used in resolve:
720prelude_import, "`#[prelude_import]` is for use by rustc only",
721 ),
722BuiltinAttribute {
name: sym::rustc_paren_sugar,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::unboxed_closures,
message: "unboxed_closures are still evolving",
check: Features::unboxed_closures,
notes: &[],
},
}gated!(
723 rustc_paren_sugar,unboxed_closures, "unboxed_closures are still evolving",
724 ),
725BuiltinAttribute {
name: sym::rustc_inherit_overflow_checks,
safety: AttributeSafety::Normal,
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!(rustc_inherit_overflow_checks,"the `#[rustc_inherit_overflow_checks]` attribute is just used to control \
726 overflow checking behavior of several functions in the standard library that are inlined \
727 across crates"
728),
729BuiltinAttribute {
name: sym::rustc_reservation_impl,
safety: AttributeSafety::Normal,
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!(rustc_reservation_impl,"the `#[rustc_reservation_impl]` attribute is internally used \
730 for reserving `impl<T> From<!> for T` as part of the effort to stabilize `!`"
731),
732BuiltinAttribute {
name: sym::rustc_test_marker,
safety: AttributeSafety::Normal,
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!(rustc_test_marker, "the `#[rustc_test_marker]` attribute is used internally to track tests"),
733BuiltinAttribute {
name: sym::rustc_unsafe_specialization_marker,
safety: AttributeSafety::Normal,
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!(rustc_unsafe_specialization_marker,
734"the `#[rustc_unsafe_specialization_marker]` attribute is used to check specializations"
735),
736BuiltinAttribute {
name: sym::rustc_specialization_trait,
safety: AttributeSafety::Normal,
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!(rustc_specialization_trait,
737"the `#[rustc_specialization_trait]` attribute is used to check specializations"
738),
739BuiltinAttribute {
name: sym::rustc_main,
safety: AttributeSafety::Normal,
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!(rustc_main,"the `#[rustc_main]` attribute is used internally to specify test entry point function"),
740BuiltinAttribute {
name: sym::rustc_skip_during_method_dispatch,
safety: AttributeSafety::Normal,
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!(rustc_skip_during_method_dispatch, "the `#[rustc_skip_during_method_dispatch]` attribute is used to exclude a trait \
741 from method dispatch when the receiver is of the following type, for compatibility in \
742 editions < 2021 (array) or editions < 2024 (boxed_slice)"
743),
744BuiltinAttribute {
name: sym::rustc_must_implement_one_of,
safety: AttributeSafety::Normal,
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!(rustc_must_implement_one_of,"the `#[rustc_must_implement_one_of]` attribute is used to change minimal complete \
745 definition of a trait. Its syntax and semantics are highly experimental and will be \
746 subject to change before stabilization",
747 ),
748BuiltinAttribute {
name: sym::rustc_doc_primitive,
safety: AttributeSafety::Normal,
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!(rustc_doc_primitive,"the `#[rustc_doc_primitive]` attribute is used by the standard library \
749 to provide a way to generate documentation for primitive types",
750 ),
751BuiltinAttribute {
name: sym::rustc_intrinsic,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::intrinsics,
message: "the `#[rustc_intrinsic]` attribute is used to declare intrinsics as function items",
check: Features::intrinsics,
notes: &[],
},
}gated!(
752 rustc_intrinsic,intrinsics,
753"the `#[rustc_intrinsic]` attribute is used to declare intrinsics as function items"),
754BuiltinAttribute {
name: sym::rustc_no_mir_inline,
safety: AttributeSafety::Normal,
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!(rustc_no_mir_inline,"`#[rustc_no_mir_inline]` prevents the MIR inliner from inlining a function while not affecting codegen"
755),
756BuiltinAttribute {
name: sym::rustc_force_inline,
safety: AttributeSafety::Normal,
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!(rustc_force_inline,"`#[rustc_force_inline]` forces a free function to be inlined"),
757BuiltinAttribute {
name: sym::rustc_scalable_vector,
safety: AttributeSafety::Normal,
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!(rustc_scalable_vector,"`#[rustc_scalable_vector]` defines a scalable vector type"),
758759// ==========================================================================
760 // Internal attributes, Testing:
761 // ==========================================================================
762763BuiltinAttribute {
name: sym::rustc_effective_visibility,
safety: AttributeSafety::Normal,
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),
764BuiltinAttribute {
name: sym::rustc_dump_inferred_outlives,
safety: AttributeSafety::Normal,
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),
765BuiltinAttribute {
name: sym::rustc_capture_analysis,
safety: AttributeSafety::Normal,
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),
766BuiltinAttribute {
name: sym::rustc_insignificant_dtor,
safety: AttributeSafety::Normal,
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),
767BuiltinAttribute {
name: sym::rustc_no_implicit_bounds,
safety: AttributeSafety::Normal,
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),
768BuiltinAttribute {
name: sym::rustc_strict_coherence,
safety: AttributeSafety::Normal,
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),
769BuiltinAttribute {
name: sym::rustc_dump_variances,
safety: AttributeSafety::Normal,
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),
770BuiltinAttribute {
name: sym::rustc_dump_variances_of_opaques,
safety: AttributeSafety::Normal,
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),
771BuiltinAttribute {
name: sym::rustc_hidden_type_of_opaques,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_hidden_type_of_opaques]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_hidden_type_of_opaques]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_hidden_type_of_opaques),
772BuiltinAttribute {
name: sym::rustc_layout,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_layout]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_layout]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_layout),
773BuiltinAttribute {
name: sym::rustc_abi,
safety: AttributeSafety::Normal,
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),
774BuiltinAttribute {
name: sym::rustc_regions,
safety: AttributeSafety::Normal,
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),
775BuiltinAttribute {
name: sym::rustc_delayed_bug_from_inside_query,
safety: AttributeSafety::Normal,
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),
776BuiltinAttribute {
name: sym::rustc_dump_user_args,
safety: AttributeSafety::Normal,
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),
777BuiltinAttribute {
name: sym::rustc_evaluate_where_clauses,
safety: AttributeSafety::Normal,
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),
778BuiltinAttribute {
name: sym::rustc_if_this_changed,
safety: AttributeSafety::Normal,
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),
779BuiltinAttribute {
name: sym::rustc_then_this_would_need,
safety: AttributeSafety::Normal,
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),
780BuiltinAttribute {
name: sym::rustc_clean,
safety: AttributeSafety::Normal,
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),
781BuiltinAttribute {
name: sym::rustc_partition_reused,
safety: AttributeSafety::Normal,
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),
782BuiltinAttribute {
name: sym::rustc_partition_codegened,
safety: AttributeSafety::Normal,
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),
783BuiltinAttribute {
name: sym::rustc_expected_cgu_reuse,
safety: AttributeSafety::Normal,
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),
784BuiltinAttribute {
name: sym::rustc_symbol_name,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_symbol_name]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_symbol_name]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_symbol_name),
785BuiltinAttribute {
name: sym::rustc_def_path,
safety: AttributeSafety::Normal,
gate: Gated {
feature: sym::rustc_attrs,
message: "use of an internal attribute",
check: Features::rustc_attrs,
notes: &["the `#[rustc_def_path]` attribute is an internal implementation detail that will never be stable",
"the `#[rustc_def_path]` attribute is used for rustc unit tests"],
},
}rustc_attr!(TEST, rustc_def_path),
786BuiltinAttribute {
name: sym::rustc_mir,
safety: AttributeSafety::Normal,
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),
787BuiltinAttribute {
name: sym::custom_mir,
safety: AttributeSafety::Normal,
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!(custom_mir,"the `#[custom_mir]` attribute is just used for the Rust test suite"),
788BuiltinAttribute {
name: sym::rustc_dump_item_bounds,
safety: AttributeSafety::Normal,
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),
789BuiltinAttribute {
name: sym::rustc_dump_predicates,
safety: AttributeSafety::Normal,
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),
790BuiltinAttribute {
name: sym::rustc_dump_def_parents,
safety: AttributeSafety::Normal,
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),
791BuiltinAttribute {
name: sym::rustc_dump_object_lifetime_defaults,
safety: AttributeSafety::Normal,
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),
792BuiltinAttribute {
name: sym::rustc_dump_vtable,
safety: AttributeSafety::Normal,
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),
793BuiltinAttribute {
name: sym::rustc_dummy,
safety: AttributeSafety::Normal,
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),
794BuiltinAttribute {
name: sym::pattern_complexity_limit,
safety: AttributeSafety::Normal,
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),
795];
796797pub fn is_builtin_attr_name(name: Symbol) -> bool {
798BUILTIN_ATTRIBUTE_MAP.get(&name).is_some()
799}
800801pub static BUILTIN_ATTRIBUTE_MAP: LazyLock<FxHashMap<Symbol, &BuiltinAttribute>> =
802LazyLock::new(|| {
803let mut map = FxHashMap::default();
804for attr in BUILTIN_ATTRIBUTES.iter() {
805if map.insert(attr.name, attr).is_some() {
806{
::core::panicking::panic_fmt(format_args!("duplicate builtin attribute `{0}`",
attr.name));
};panic!("duplicate builtin attribute `{}`", attr.name);
807 }
808 }
809map810 });
811812pub fn is_stable_diagnostic_attribute(sym: Symbol, features: &Features) -> bool {
813match sym {
814 sym::on_unimplemented | sym::do_not_recommend => true,
815 sym::on_const => features.diagnostic_on_const(),
816 sym::on_move => features.diagnostic_on_move(),
817_ => false,
818 }
819}