1use std::sync::OnceLock;
12
13use intern::Symbol;
14use rustc_hash::FxHashMap;
15
16pub struct BuiltinAttribute {
17 pub name: &'static str,
18 pub template: AttributeTemplate,
19}
20
21#[derive(Clone, Copy)]
24pub struct AttributeTemplate {
25 pub word: bool,
26 pub list: Option<&'static str>,
27 pub name_value_str: Option<&'static str>,
28}
29
30pub fn find_builtin_attr_idx(name: &Symbol) -> Option<usize> {
31 static BUILTIN_LOOKUP_TABLE: OnceLock<FxHashMap<Symbol, usize>> = OnceLock::new();
32 BUILTIN_LOOKUP_TABLE
33 .get_or_init(|| {
34 INERT_ATTRIBUTES
35 .iter()
36 .map(|attr| attr.name)
37 .enumerate()
38 .map(|(a, b)| (Symbol::intern(b), a))
39 .collect()
40 })
41 .get(name)
42 .copied()
43}
44
45macro_rules! template {
49 (Word) => { template!(@ true, None, None) };
50 (List: $descr: expr) => { template!(@ false, Some($descr), None) };
51 (NameValueStr: $descr: expr) => { template!(@ false, None, Some($descr)) };
52 (Word, List: $descr: expr) => { template!(@ true, Some($descr), None) };
53 (Word, NameValueStr: $descr: expr) => { template!(@ true, None, Some($descr)) };
54 (List: $descr1: expr, NameValueStr: $descr2: expr) => {
55 template!(@ false, Some($descr1), Some($descr2))
56 };
57 (Word, List: $descr1: expr, NameValueStr: $descr2: expr) => {
58 template!(@ true, Some($descr1), Some($descr2))
59 };
60 (@ $word: expr, $list: expr, $name_value_str: expr) => {
61 AttributeTemplate {
62 word: $word, list: $list, name_value_str: $name_value_str
63 }
64 };
65}
66
67macro_rules! ungated {
68 ($attr:ident, $typ:expr, $tpl:expr, $duplicates:expr $(, @only_local: $only_local:expr)? $(,)?) => {
69 BuiltinAttribute { name: stringify!($attr), template: $tpl }
70 };
71}
72
73macro_rules! gated {
74 ($attr:ident, $typ:expr, $tpl:expr, $duplicates:expr $(, @only_local: $only_local:expr)?, $gate:ident, $msg:expr $(,)?) => {
75 BuiltinAttribute { name: stringify!($attr), template: $tpl }
76 };
77 ($attr:ident, $typ:expr, $tpl:expr, $duplicates:expr $(, @only_local: $only_local:expr)?, $msg:expr $(,)?) => {
78 BuiltinAttribute { name: stringify!($attr), template: $tpl }
79 };
80}
81
82macro_rules! rustc_attr {
83 (TEST, $attr:ident, $typ:expr, $tpl:expr, $duplicate:expr $(, @only_local: $only_local:expr)? $(,)?) => {
84 rustc_attr!(
85 $attr,
86 $typ,
87 $tpl,
88 $duplicate,
89 $(@only_local: $only_local,)?
90 concat!(
91 "the `#[",
92 stringify!($attr),
93 "]` attribute is just used for rustc unit tests \
94 and will never be stable",
95 ),
96 )
97 };
98 ($attr:ident, $typ:expr, $tpl:expr, $duplicates:expr $(, @only_local: $only_local:expr)?, $msg:expr $(,)?) => {
99 BuiltinAttribute { name: stringify!($attr), template: $tpl }
100 };
101}
102
103#[allow(unused_macros)]
104macro_rules! experimental {
105 ($attr:ident) => {
106 concat!("the `#[", stringify!($attr), "]` attribute is an experimental feature")
107 };
108}
109
110#[rustfmt::skip]
112pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
113 ungated!(cfg, Normal, template!(List: "predicate"), DuplicatesOk),
119 ungated!(cfg_attr, Normal, template!(List: "predicate, attr1, attr2, ..."), DuplicatesOk),
120
121 ungated!(ignore, Normal, template!(Word, NameValueStr: "reason"), WarnFollowing),
123 ungated!(
124 should_panic, Normal,
125 template!(Word, List: r#"expected = "reason""#, NameValueStr: "reason"), FutureWarnFollowing,
126 ),
127
128 ungated!(automatically_derived, Normal, template!(Word), WarnFollowing),
130 ungated!(macro_use, Normal, template!(Word, List: "name1, name2, ..."), WarnFollowingWordOnly),
131 ungated!(macro_escape, Normal, template!(Word), WarnFollowing), ungated!(macro_export, Normal, template!(Word, List: "local_inner_macros"), WarnFollowing),
133 ungated!(proc_macro, Normal, template!(Word), ErrorFollowing),
134 ungated!(
135 proc_macro_derive, Normal,
136 template!(List: "TraitName, /*opt*/ attributes(name1, name2, ...)"), ErrorFollowing,
137 ),
138 ungated!(proc_macro_attribute, Normal, template!(Word), ErrorFollowing),
139
140 ungated!(
142 warn, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#),
143 DuplicatesOk, @only_local: true,
144 ),
145 ungated!(
146 allow, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#),
147 DuplicatesOk, @only_local: true,
148 ),
149 ungated!(
150 expect, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#),
151 DuplicatesOk, @only_local: true,
152 ),
153 ungated!(
154 forbid, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#),
155 DuplicatesOk, @only_local: true,
156 ),
157 ungated!(
158 deny, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#),
159 DuplicatesOk, @only_local: true,
160 ),
161 ungated!(must_use, Normal, template!(Word, NameValueStr: "reason"), FutureWarnFollowing),
162 gated!(
163 must_not_suspend, Normal, template!(Word, NameValueStr: "reason"), WarnFollowing,
164 experimental!(must_not_suspend)
165 ),
166 ungated!(
167 deprecated, Normal,
168 template!(
169 Word,
170 List: r#"/*opt*/ since = "version", /*opt*/ note = "reason""#,
171 NameValueStr: "reason"
172 ),
173 ErrorFollowing
174 ),
175
176 ungated!(crate_name, CrateLevel, template!(NameValueStr: "name"), FutureWarnFollowing),
178 ungated!(crate_type, CrateLevel, template!(NameValueStr: "bin|lib|..."), DuplicatesOk),
179 ungated!(crate_id, CrateLevel, template!(NameValueStr: "ignored"), FutureWarnFollowing),
181
182 ungated!(
184 link, Normal,
185 template!(List: r#"name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ wasm_import_module = "...", /*opt*/ import_name_type = "decorated|noprefix|undecorated""#),
186 DuplicatesOk,
187 ),
188 ungated!(link_name, Normal, template!(NameValueStr: "name"), FutureWarnPreceding),
189 ungated!(no_link, Normal, template!(Word), WarnFollowing),
190 ungated!(repr, Normal, template!(List: "C"), DuplicatesOk, @only_local: true),
191 ungated!(export_name, Normal, template!(NameValueStr: "name"), FutureWarnPreceding),
192 ungated!(link_section, Normal, template!(NameValueStr: "name"), FutureWarnPreceding),
193 ungated!(no_mangle, Normal, template!(Word), WarnFollowing, @only_local: true),
194 ungated!(used, Normal, template!(Word, List: "compiler|linker"), WarnFollowing, @only_local: true),
195 ungated!(link_ordinal, Normal, template!(List: "ordinal"), ErrorPreceding),
196
197 ungated!(recursion_limit, CrateLevel, template!(NameValueStr: "N"), FutureWarnFollowing),
199 ungated!(type_length_limit, CrateLevel, template!(NameValueStr: "N"), FutureWarnFollowing),
200 gated!(
201 move_size_limit, CrateLevel, template!(NameValueStr: "N"), ErrorFollowing,
202 large_assignments, experimental!(move_size_limit)
203 ),
204
205 ungated!(start, Normal, template!(Word), WarnFollowing),
207 ungated!(no_start, CrateLevel, template!(Word), WarnFollowing),
208 ungated!(no_main, CrateLevel, template!(Word), WarnFollowing),
209
210 ungated!(path, Normal, template!(NameValueStr: "file"), FutureWarnFollowing),
212 ungated!(no_std, CrateLevel, template!(Word), WarnFollowing),
213 ungated!(no_implicit_prelude, Normal, template!(Word), WarnFollowing),
214 ungated!(non_exhaustive, Normal, template!(Word), WarnFollowing),
215
216 ungated!(
218 windows_subsystem, CrateLevel,
219 template!(NameValueStr: "windows|console"), FutureWarnFollowing
220 ),
221 ungated!(panic_handler, Normal, template!(Word), WarnFollowing), ungated!(inline, Normal, template!(Word, List: "always|never"), FutureWarnFollowing, @only_local: true),
225 ungated!(cold, Normal, template!(Word), WarnFollowing, @only_local: true),
226 ungated!(no_builtins, CrateLevel, template!(Word), WarnFollowing),
227 ungated!(
228 target_feature, Normal, template!(List: r#"enable = "name""#),
229 DuplicatesOk, @only_local: true,
230 ),
231 ungated!(track_caller, Normal, template!(Word), WarnFollowing),
232 ungated!(instruction_set, Normal, template!(List: "set"), ErrorPreceding),
233 gated!(
234 no_sanitize, Normal,
235 template!(List: "address, kcfi, memory, thread"), DuplicatesOk,
236 experimental!(no_sanitize)
237 ),
238 gated!(coverage, Normal, template!(Word, List: "on|off"), WarnFollowing, coverage_attribute, experimental!(coverage)),
239
240 ungated!(
241 doc, Normal, template!(List: "hidden|inline|...", NameValueStr: "string"), DuplicatesOk
242 ),
243
244 ungated!(
246 debugger_visualizer, Normal,
247 template!(List: r#"natvis_file = "...", gdb_script_file = "...""#), DuplicatesOk
248 ),
249
250 gated!(
256 naked, Normal, template!(Word), WarnFollowing, @only_local: true,
257 naked_functions, experimental!(naked)
258 ),
259
260 gated!(
262 test_runner, CrateLevel, template!(List: "path"), ErrorFollowing, custom_test_frameworks,
263 "custom test frameworks are an unstable feature",
264 ),
265
266 gated!(
267 reexport_test_harness_main, CrateLevel, template!(NameValueStr: "name"),
268 ErrorFollowing, custom_test_frameworks,
269 "custom test frameworks are an unstable feature",
270 ),
271
272 gated!(
274 marker, Normal, template!(Word), WarnFollowing, @only_local: true,
275 marker_trait_attr, experimental!(marker)
276 ),
277 gated!(
278 thread_local, Normal, template!(Word), WarnFollowing,
279 "`#[thread_local]` is an experimental feature, and does not currently handle destructors",
280 ),
281 gated!(no_core, CrateLevel, template!(Word), WarnFollowing, experimental!(no_core)),
282 ungated!(
284 optimize, Normal, template!(List: "size|speed|none"), ErrorPreceding
285 ),
286
287 gated!(ffi_pure, Normal, template!(Word), WarnFollowing, experimental!(ffi_pure)),
288 gated!(ffi_const, Normal, template!(Word), WarnFollowing, experimental!(ffi_const)),
289 gated!(
290 register_tool, CrateLevel, template!(List: "tool1, tool2, ..."), DuplicatesOk,
291 experimental!(register_tool),
292 ),
293
294 gated!(
295 cmse_nonsecure_entry, Normal, template!(Word), WarnFollowing,
296 experimental!(cmse_nonsecure_entry)
297 ),
298 gated!(
300 const_trait, Normal, template!(Word), WarnFollowing, const_trait_impl,
301 "`const_trait` is a temporary placeholder for marking a trait that is suitable for `const` \
302 `impls` and all default bodies as `const`, which may be removed or renamed in the \
303 future."
304 ),
305 gated!(
307 deprecated_safe, Normal, template!(List: r#"since = "version", note = "...""#), ErrorFollowing,
308 experimental!(deprecated_safe),
309 ),
310
311 gated!(
313 collapse_debuginfo, Normal, template!(Word), WarnFollowing,
314 experimental!(collapse_debuginfo)
315 ),
316
317 gated!(do_not_recommend, Normal, template!(Word), WarnFollowing, experimental!(do_not_recommend)),
319
320 gated!(
322 cfi_encoding, Normal, template!(NameValueStr: "encoding"), ErrorPreceding,
323 experimental!(cfi_encoding)
324 ),
325
326 ungated!(
331 feature, CrateLevel,
332 template!(List: "name1, name2, ..."), DuplicatesOk, @only_local: true,
333 ),
334 ungated!(
336 stable, Normal,
337 template!(List: r#"feature = "name", since = "version""#), DuplicatesOk, @only_local: true,
338 ),
339 ungated!(
340 unstable, Normal,
341 template!(List: r#"feature = "name", reason = "...", issue = "N""#), DuplicatesOk,
342 ),
343 ungated!(rustc_const_unstable, Normal, template!(List: r#"feature = "name""#), DuplicatesOk),
344 ungated!(
345 rustc_const_stable, Normal,
346 template!(List: r#"feature = "name""#), DuplicatesOk, @only_local: true,
347 ),
348 ungated!(
349 rustc_default_body_unstable, Normal,
350 template!(List: r#"feature = "name", reason = "...", issue = "N""#), DuplicatesOk
351 ),
352 gated!(
353 allow_internal_unstable, Normal, template!(Word, List: "feat1, feat2, ..."), DuplicatesOk,
354 "allow_internal_unstable side-steps feature gating and stability checks",
355 ),
356 gated!(
357 rustc_allow_const_fn_unstable, Normal,
358 template!(Word, List: "feat1, feat2, ..."), DuplicatesOk,
359 "rustc_allow_const_fn_unstable side-steps feature gating and stability checks"
360 ),
361 gated!(
362 allow_internal_unsafe, Normal, template!(Word), WarnFollowing,
363 "allow_internal_unsafe side-steps the unsafe_code lint",
364 ),
365 rustc_attr!(rustc_allowed_through_unstable_modules, Normal, template!(Word), WarnFollowing,
366 "rustc_allowed_through_unstable_modules special cases accidental stabilizations of stable items \
367 through unstable paths"),
368
369 gated!(fundamental, Normal, template!(Word), WarnFollowing, experimental!(fundamental)),
374 gated!(
375 may_dangle, Normal, template!(Word), WarnFollowing, dropck_eyepatch,
376 "`may_dangle` has unstable semantics and may be removed in the future",
377 ),
378
379 rustc_attr!(rustc_allocator, Normal, template!(Word), WarnFollowing, IMPL_DETAIL),
384 rustc_attr!(rustc_nounwind, Normal, template!(Word), WarnFollowing, IMPL_DETAIL),
385 rustc_attr!(rustc_reallocator, Normal, template!(Word), WarnFollowing, IMPL_DETAIL),
386 rustc_attr!(rustc_deallocator, Normal, template!(Word), WarnFollowing, IMPL_DETAIL),
387 rustc_attr!(rustc_allocator_zeroed, Normal, template!(Word), WarnFollowing, IMPL_DETAIL),
388 gated!(
389 default_lib_allocator, Normal, template!(Word), WarnFollowing, allocator_internals,
390 experimental!(default_lib_allocator),
391 ),
392 gated!(
393 needs_allocator, Normal, template!(Word), WarnFollowing, allocator_internals,
394 experimental!(needs_allocator),
395 ),
396 gated!(panic_runtime, Normal, template!(Word), WarnFollowing, experimental!(panic_runtime)),
397 gated!(
398 needs_panic_runtime, Normal, template!(Word), WarnFollowing,
399 experimental!(needs_panic_runtime)
400 ),
401 gated!(
402 compiler_builtins, Normal, template!(Word), WarnFollowing,
403 "the `#[compiler_builtins]` attribute is used to identify the `compiler_builtins` crate \
404 which contains compiler-rt intrinsics and will never be stable",
405 ),
406 gated!(
407 profiler_runtime, Normal, template!(Word), WarnFollowing,
408 "the `#[profiler_runtime]` attribute is used to identify the `profiler_builtins` crate \
409 which contains the profiler runtime and will never be stable",
410 ),
411
412 gated!(
417 linkage, Normal, template!(NameValueStr: "external|internal|..."), ErrorPreceding, @only_local: true,
418 "the `linkage` attribute is experimental and not portable across platforms",
419 ),
420 rustc_attr!(
421 rustc_std_internal_symbol, Normal, template!(Word), WarnFollowing, @only_local: true, INTERNAL_UNSTABLE
422 ),
423
424 rustc_attr!(
429 rustc_builtin_macro, Normal,
430 template!(Word, List: "name, /*opt*/ attributes(name1, name2, ...)"), ErrorFollowing,
431 IMPL_DETAIL,
432 ),
433 rustc_attr!(rustc_proc_macro_decls, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE),
434 rustc_attr!(
435 rustc_macro_transparency, Normal,
436 template!(NameValueStr: "transparent|semiopaque|opaque"), ErrorFollowing,
437 "used internally for testing macro hygiene",
438 ),
439
440 rustc_attr!(
445 rustc_on_unimplemented, Normal,
446 template!(
447 List: r#"/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...""#,
448 NameValueStr: "message"
449 ),
450 ErrorFollowing,
451 INTERNAL_UNSTABLE
452 ),
453 rustc_attr!(
454 rustc_confusables, Normal,
455 template!(List: r#""name1", "name2", ..."#),
456 ErrorFollowing,
457 INTERNAL_UNSTABLE,
458 ),
459 rustc_attr!(
461 rustc_conversion_suggestion, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE
462 ),
463 rustc_attr!(
466 rustc_trivial_field_reads, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE
467 ),
468 rustc_attr!(rustc_lint_query_instability, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE),
471 rustc_attr!(rustc_lint_untracked_query_information, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE),
474 rustc_attr!(rustc_lint_opt_ty, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE),
477 rustc_attr!(rustc_lint_opt_deny_field_access, Normal, template!(List: "message"), WarnFollowing, INTERNAL_UNSTABLE),
480
481 rustc_attr!(rustc_promotable, Normal, template!(Word), WarnFollowing, IMPL_DETAIL),
486 rustc_attr!(
487 rustc_legacy_const_generics, Normal, template!(List: "N"), ErrorFollowing,
488 INTERNAL_UNSTABLE
489 ),
490 rustc_attr!(
492 rustc_do_not_const_check, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE
493 ),
494 rustc_attr!(
496 rustc_const_panic_str, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE
497 ),
498
499 rustc_attr!(
504 rustc_layout_scalar_valid_range_start, Normal, template!(List: "value"), ErrorFollowing,
505 "the `#[rustc_layout_scalar_valid_range_start]` attribute is just used to enable \
506 niche optimizations in libcore and libstd and will never be stable",
507 ),
508 rustc_attr!(
509 rustc_layout_scalar_valid_range_end, Normal, template!(List: "value"), ErrorFollowing,
510 "the `#[rustc_layout_scalar_valid_range_end]` attribute is just used to enable \
511 niche optimizations in libcore and libstd and will never be stable",
512 ),
513 rustc_attr!(
514 rustc_nonnull_optimization_guaranteed, Normal, template!(Word), WarnFollowing,
515 "the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to enable \
516 niche optimizations in libcore and libstd and will never be stable",
517 ),
518
519 gated!(
523 lang, Normal, template!(NameValueStr: "name"), DuplicatesOk, @only_local: true, lang_items,
524 "language items are subject to change",
525 ),
526 rustc_attr!(
527 rustc_pass_by_value, Normal, template!(Word), ErrorFollowing,
528 "#[rustc_pass_by_value] is used to mark types that must be passed by value instead of reference."
529 ),
530 rustc_attr!(
531 rustc_never_returns_null_ptr, Normal, template!(Word), ErrorFollowing,
532 "#[rustc_never_returns_null_ptr] is used to mark functions returning non-null pointers."
533 ),
534 rustc_attr!(
535 rustc_coherence_is_core, AttributeType::CrateLevel, template!(Word), ErrorFollowing, @only_local: true,
536 "#![rustc_coherence_is_core] allows inherent methods on builtin types, only intended to be used in `core`."
537 ),
538 rustc_attr!(
539 rustc_coinductive, AttributeType::Normal, template!(Word), WarnFollowing, @only_local: true,
540 "#![rustc_coinductive] changes a trait to be coinductive, allowing cycles in the trait solver."
541 ),
542 rustc_attr!(
543 rustc_allow_incoherent_impl, AttributeType::Normal, template!(Word), ErrorFollowing, @only_local: true,
544 "#[rustc_allow_incoherent_impl] has to be added to all impl items of an incoherent inherent impl."
545 ),
546 rustc_attr!(
547 rustc_deny_explicit_impl,
548 AttributeType::Normal,
549 template!(List: "implement_via_object = (true|false)"),
550 ErrorFollowing,
551 @only_local: true,
552 "#[rustc_deny_explicit_impl] enforces that a trait can have no user-provided impls"
553 ),
554 rustc_attr!(
555 rustc_has_incoherent_inherent_impls, AttributeType::Normal, template!(Word), ErrorFollowing,
556 "#[rustc_has_incoherent_inherent_impls] allows the addition of incoherent inherent impls for \
557 the given type by annotating all impl items with #[rustc_allow_incoherent_impl]."
558 ),
559 rustc_attr!(
560 rustc_box, AttributeType::Normal, template!(Word), ErrorFollowing,
561 "#[rustc_box] allows creating boxes \
562 and it is only intended to be used in `alloc`."
563 ),
564
565 BuiltinAttribute {
566 name: "rustc_diagnostic_item",
568 template: template!(NameValueStr: "name"),
572 },
580 gated!(
581 prelude_import, Normal, template!(Word), WarnFollowing,
583 "`#[prelude_import]` is for use by rustc only",
584 ),
585 gated!(
586 rustc_paren_sugar, Normal, template!(Word), WarnFollowing, unboxed_closures,
587 "unboxed_closures are still evolving",
588 ),
589 rustc_attr!(
590 rustc_inherit_overflow_checks, Normal, template!(Word), WarnFollowing, @only_local: true,
591 "the `#[rustc_inherit_overflow_checks]` attribute is just used to control \
592 overflow checking behavior of several libcore functions that are inlined \
593 across crates and will never be stable",
594 ),
595 rustc_attr!(
596 rustc_reservation_impl, Normal,
597 template!(NameValueStr: "reservation message"), ErrorFollowing,
598 "the `#[rustc_reservation_impl]` attribute is internally used \
599 for reserving for `for<T> From<!> for T` impl"
600 ),
601 rustc_attr!(
602 rustc_test_marker, Normal, template!(NameValueStr: "name"), WarnFollowing,
603 "the `#[rustc_test_marker]` attribute is used internally to track tests",
604 ),
605 rustc_attr!(
606 rustc_unsafe_specialization_marker, Normal, template!(Word), WarnFollowing,
607 "the `#[rustc_unsafe_specialization_marker]` attribute is used to check specializations"
608 ),
609 rustc_attr!(
610 rustc_specialization_trait, Normal, template!(Word), WarnFollowing,
611 "the `#[rustc_specialization_trait]` attribute is used to check specializations"
612 ),
613 rustc_attr!(
614 rustc_main, Normal, template!(Word), WarnFollowing,
615 "the `#[rustc_main]` attribute is used internally to specify test entry point function",
616 ),
617 rustc_attr!(
618 rustc_skip_array_during_method_dispatch, Normal, template!(Word), WarnFollowing,
619 "the `#[rustc_skip_array_during_method_dispatch]` attribute is used to exclude a trait \
620 from method dispatch when the receiver is an array, for compatibility in editions < 2021."
621 ),
622 rustc_attr!(
623 rustc_must_implement_one_of, Normal, template!(List: "function1, function2, ..."), ErrorFollowing,
624 "the `#[rustc_must_implement_one_of]` attribute is used to change minimal complete \
625 definition of a trait, it's currently in experimental form and should be changed before \
626 being exposed outside of the std"
627 ),
628 rustc_attr!(
629 rustc_doc_primitive, Normal, template!(NameValueStr: "primitive name"), ErrorFollowing,
630 r#"`rustc_doc_primitive` is a rustc internal attribute"#,
631 ),
632 rustc_attr!(
633 rustc_safe_intrinsic, Normal, template!(Word), WarnFollowing,
634 "the `#[rustc_safe_intrinsic]` attribute is used internally to mark intrinsics as safe"
635 ),
636 rustc_attr!(
637 rustc_intrinsic, Normal, template!(Word), ErrorFollowing,
638 "the `#[rustc_intrinsic]` attribute is used to declare intrinsics with function bodies",
639 ),
640 rustc_attr!(
641 rustc_no_mir_inline, Normal, template!(Word), WarnFollowing,
642 "#[rustc_no_mir_inline] prevents the MIR inliner from inlining a function while not affecting codegen"
643 ),
644 rustc_attr!(
645 rustc_intrinsic_must_be_overridden, Normal, template!(Word), ErrorFollowing,
646 "the `#[rustc_intrinsic_must_be_overridden]` attribute is used to declare intrinsics without real bodies",
647 ),
648
649 rustc_attr!(
650 rustc_deprecated_safe_2024, Normal, template!(Word), WarnFollowing,
651 "the `#[rustc_safe_intrinsic]` marks functions as unsafe in Rust 2024",
652 ),
653
654 rustc_attr!(TEST, rustc_effective_visibility, Normal, template!(Word), WarnFollowing),
659 rustc_attr!(TEST, rustc_outlives, Normal, template!(Word), WarnFollowing),
660 rustc_attr!(TEST, rustc_capture_analysis, Normal, template!(Word), WarnFollowing),
661 rustc_attr!(TEST, rustc_insignificant_dtor, Normal, template!(Word), WarnFollowing),
662 rustc_attr!(TEST, rustc_strict_coherence, Normal, template!(Word), WarnFollowing),
663 rustc_attr!(TEST, rustc_variance, Normal, template!(Word), WarnFollowing),
664 rustc_attr!(TEST, rustc_variance_of_opaques, Normal, template!(Word), WarnFollowing),
665 rustc_attr!(TEST, rustc_hidden_type_of_opaques, Normal, template!(Word), WarnFollowing),
666 rustc_attr!(TEST, rustc_layout, Normal, template!(List: "field1, field2, ..."), WarnFollowing),
667 rustc_attr!(TEST, rustc_abi, Normal, template!(List: "field1, field2, ..."), WarnFollowing),
668 rustc_attr!(TEST, rustc_regions, Normal, template!(Word), WarnFollowing),
669 rustc_attr!(TEST, rustc_dump_user_args, Normal, template!(Word), WarnFollowing),
670 rustc_attr!(TEST, rustc_evaluate_where_clauses, Normal, template!(Word), WarnFollowing),
671 rustc_attr!(
672 TEST, rustc_if_this_changed, Normal, template!(Word, List: "DepNode"), DuplicatesOk
673 ),
674 rustc_attr!(
675 TEST, rustc_then_this_would_need, Normal, template!(List: "DepNode"), DuplicatesOk
676 ),
677 rustc_attr!(
678 TEST, rustc_clean, Normal,
679 template!(List: r#"cfg = "...", /*opt*/ label = "...", /*opt*/ except = "...""#),
680 DuplicatesOk,
681 ),
682 rustc_attr!(
683 TEST, rustc_partition_reused, Normal,
684 template!(List: r#"cfg = "...", module = "...""#), DuplicatesOk,
685 ),
686 rustc_attr!(
687 TEST, rustc_partition_codegened, Normal,
688 template!(List: r#"cfg = "...", module = "...""#), DuplicatesOk,
689 ),
690 rustc_attr!(
691 TEST, rustc_expected_cgu_reuse, Normal,
692 template!(List: r#"cfg = "...", module = "...", kind = "...""#), DuplicatesOk,
693 ),
694 rustc_attr!(TEST, rustc_symbol_name, Normal, template!(Word), WarnFollowing),
695 rustc_attr!(TEST, rustc_def_path, Normal, template!(Word), WarnFollowing),
696 rustc_attr!(TEST, rustc_mir, Normal, template!(List: "arg1, arg2, ..."), DuplicatesOk),
697 gated!(
698 custom_mir, Normal, template!(List: r#"dialect = "...", phase = "...""#),
699 ErrorFollowing, "the `#[custom_mir]` attribute is just used for the Rust test suite",
700 ),
701 rustc_attr!(TEST, rustc_dump_program_clauses, Normal, template!(Word), WarnFollowing),
702 rustc_attr!(TEST, rustc_dump_env_program_clauses, Normal, template!(Word), WarnFollowing),
703 rustc_attr!(TEST, rustc_object_lifetime_default, Normal, template!(Word), WarnFollowing),
704 rustc_attr!(TEST, rustc_dyn_incompatible_trait, Normal, template!(Word), WarnFollowing),
705 rustc_attr!(TEST, rustc_dump_vtable, Normal, template!(Word), WarnFollowing),
706 rustc_attr!(TEST, rustc_dummy, Normal, template!(Word ), DuplicatesOk),
707 gated!(
708 omit_gdb_pretty_printer_section, Normal, template!(Word), WarnFollowing,
709 "the `#[omit_gdb_pretty_printer_section]` attribute is just used for the Rust test suite",
710 ),
711];