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 ungated!(reexport_test_harness_main, CrateLevel, template!(NameValueStr: "name"), ErrorFollowing),
129
130 ungated!(automatically_derived, Normal, template!(Word), WarnFollowing),
132 ungated!(macro_use, Normal, template!(Word, List: "name1, name2, ..."), WarnFollowingWordOnly),
133 ungated!(macro_escape, Normal, template!(Word), WarnFollowing), ungated!(macro_export, Normal, template!(Word, List: "local_inner_macros"), WarnFollowing),
135 ungated!(proc_macro, Normal, template!(Word), ErrorFollowing),
136 ungated!(
137 proc_macro_derive, Normal,
138 template!(List: "TraitName, /*opt*/ attributes(name1, name2, ...)"), ErrorFollowing,
139 ),
140 ungated!(proc_macro_attribute, Normal, template!(Word), ErrorFollowing),
141
142 ungated!(
144 warn, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#),
145 DuplicatesOk, @only_local: true,
146 ),
147 ungated!(
148 allow, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#),
149 DuplicatesOk, @only_local: true,
150 ),
151 ungated!(
152 expect, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#),
153 DuplicatesOk, @only_local: true,
154 ),
155 ungated!(
156 forbid, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#),
157 DuplicatesOk, @only_local: true,
158 ),
159 ungated!(
160 deny, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#),
161 DuplicatesOk, @only_local: true,
162 ),
163 ungated!(must_use, Normal, template!(Word, NameValueStr: "reason"), FutureWarnFollowing),
164 gated!(
165 must_not_suspend, Normal, template!(Word, NameValueStr: "reason"), WarnFollowing,
166 experimental!(must_not_suspend)
167 ),
168 ungated!(
169 deprecated, Normal,
170 template!(
171 Word,
172 List: r#"/*opt*/ since = "version", /*opt*/ note = "reason""#,
173 NameValueStr: "reason"
174 ),
175 ErrorFollowing
176 ),
177
178 ungated!(crate_name, CrateLevel, template!(NameValueStr: "name"), FutureWarnFollowing),
180 ungated!(crate_type, CrateLevel, template!(NameValueStr: "bin|lib|..."), DuplicatesOk),
181 ungated!(crate_id, CrateLevel, template!(NameValueStr: "ignored"), FutureWarnFollowing),
183
184 ungated!(
186 link, Normal,
187 template!(List: r#"name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ wasm_import_module = "...", /*opt*/ import_name_type = "decorated|noprefix|undecorated""#),
188 DuplicatesOk,
189 ),
190 ungated!(link_name, Normal, template!(NameValueStr: "name"), FutureWarnPreceding),
191 ungated!(no_link, Normal, template!(Word), WarnFollowing),
192 ungated!(repr, Normal, template!(List: "C"), DuplicatesOk, @only_local: true),
193 ungated!(export_name, Normal, template!(NameValueStr: "name"), FutureWarnPreceding),
194 ungated!(link_section, Normal, template!(NameValueStr: "name"), FutureWarnPreceding),
195 ungated!(no_mangle, Normal, template!(Word), WarnFollowing, @only_local: true),
196 ungated!(used, Normal, template!(Word, List: "compiler|linker"), WarnFollowing, @only_local: true),
197 ungated!(link_ordinal, Normal, template!(List: "ordinal"), ErrorPreceding),
198
199 ungated!(recursion_limit, CrateLevel, template!(NameValueStr: "N"), FutureWarnFollowing),
201 ungated!(type_length_limit, CrateLevel, template!(NameValueStr: "N"), FutureWarnFollowing),
202 gated!(
203 move_size_limit, CrateLevel, template!(NameValueStr: "N"), ErrorFollowing,
204 large_assignments, experimental!(move_size_limit)
205 ),
206
207 ungated!(start, Normal, template!(Word), WarnFollowing),
209 ungated!(no_start, CrateLevel, template!(Word), WarnFollowing),
210 ungated!(no_main, CrateLevel, template!(Word), WarnFollowing),
211
212 ungated!(path, Normal, template!(NameValueStr: "file"), FutureWarnFollowing),
214 ungated!(no_std, CrateLevel, template!(Word), WarnFollowing),
215 ungated!(no_implicit_prelude, Normal, template!(Word), WarnFollowing),
216 ungated!(non_exhaustive, Normal, template!(Word), WarnFollowing),
217
218 ungated!(
220 windows_subsystem, CrateLevel,
221 template!(NameValueStr: "windows|console"), FutureWarnFollowing
222 ),
223 ungated!(panic_handler, Normal, template!(Word), WarnFollowing), ungated!(inline, Normal, template!(Word, List: "always|never"), FutureWarnFollowing, @only_local: true),
227 ungated!(cold, Normal, template!(Word), WarnFollowing, @only_local: true),
228 ungated!(no_builtins, CrateLevel, template!(Word), WarnFollowing),
229 ungated!(
230 target_feature, Normal, template!(List: r#"enable = "name""#),
231 DuplicatesOk, @only_local: true,
232 ),
233 ungated!(track_caller, Normal, template!(Word), WarnFollowing),
234 ungated!(instruction_set, Normal, template!(List: "set"), ErrorPreceding),
235 gated!(
236 no_sanitize, Normal,
237 template!(List: "address, kcfi, memory, thread"), DuplicatesOk,
238 experimental!(no_sanitize)
239 ),
240 gated!(coverage, Normal, template!(Word, List: "on|off"), WarnFollowing, coverage_attribute, experimental!(coverage)),
241
242 ungated!(
243 doc, Normal, template!(List: "hidden|inline|...", NameValueStr: "string"), DuplicatesOk
244 ),
245
246 ungated!(
248 debugger_visualizer, Normal,
249 template!(List: r#"natvis_file = "...", gdb_script_file = "...""#), DuplicatesOk
250 ),
251
252 gated!(
258 naked, Normal, template!(Word), WarnFollowing, @only_local: true,
259 naked_functions, experimental!(naked)
260 ),
261
262 gated!(
264 test_runner, CrateLevel, template!(List: "path"), ErrorFollowing, custom_test_frameworks,
265 "custom test frameworks are an unstable feature",
266 ),
267 gated!(
269 marker, Normal, template!(Word), WarnFollowing, @only_local: true,
270 marker_trait_attr, experimental!(marker)
271 ),
272 gated!(
273 thread_local, Normal, template!(Word), WarnFollowing,
274 "`#[thread_local]` is an experimental feature, and does not currently handle destructors",
275 ),
276 gated!(no_core, CrateLevel, template!(Word), WarnFollowing, experimental!(no_core)),
277 gated!(
279 optimize, Normal, template!(List: "size|speed"), ErrorPreceding, optimize_attribute,
280 experimental!(optimize),
281 ),
282
283 gated!(ffi_pure, Normal, template!(Word), WarnFollowing, experimental!(ffi_pure)),
284 gated!(ffi_const, Normal, template!(Word), WarnFollowing, experimental!(ffi_const)),
285 gated!(
286 register_tool, CrateLevel, template!(List: "tool1, tool2, ..."), DuplicatesOk,
287 experimental!(register_tool),
288 ),
289
290 gated!(
291 cmse_nonsecure_entry, Normal, template!(Word), WarnFollowing,
292 experimental!(cmse_nonsecure_entry)
293 ),
294 gated!(
296 const_trait, Normal, template!(Word), WarnFollowing, const_trait_impl,
297 "`const_trait` is a temporary placeholder for marking a trait that is suitable for `const` \
298 `impls` and all default bodies as `const`, which may be removed or renamed in the \
299 future."
300 ),
301 gated!(
303 deprecated_safe, Normal, template!(List: r#"since = "version", note = "...""#), ErrorFollowing,
304 experimental!(deprecated_safe),
305 ),
306
307 gated!(
309 collapse_debuginfo, Normal, template!(Word), WarnFollowing,
310 experimental!(collapse_debuginfo)
311 ),
312
313 gated!(do_not_recommend, Normal, template!(Word), WarnFollowing, experimental!(do_not_recommend)),
315
316 gated!(
318 cfi_encoding, Normal, template!(NameValueStr: "encoding"), ErrorPreceding,
319 experimental!(cfi_encoding)
320 ),
321
322 ungated!(
327 feature, CrateLevel,
328 template!(List: "name1, name2, ..."), DuplicatesOk, @only_local: true,
329 ),
330 ungated!(
332 stable, Normal,
333 template!(List: r#"feature = "name", since = "version""#), DuplicatesOk, @only_local: true,
334 ),
335 ungated!(
336 unstable, Normal,
337 template!(List: r#"feature = "name", reason = "...", issue = "N""#), DuplicatesOk,
338 ),
339 ungated!(rustc_const_unstable, Normal, template!(List: r#"feature = "name""#), DuplicatesOk),
340 ungated!(
341 rustc_const_stable, Normal,
342 template!(List: r#"feature = "name""#), DuplicatesOk, @only_local: true,
343 ),
344 ungated!(
345 rustc_default_body_unstable, Normal,
346 template!(List: r#"feature = "name", reason = "...", issue = "N""#), DuplicatesOk
347 ),
348 gated!(
349 allow_internal_unstable, Normal, template!(Word, List: "feat1, feat2, ..."), DuplicatesOk,
350 "allow_internal_unstable side-steps feature gating and stability checks",
351 ),
352 gated!(
353 rustc_allow_const_fn_unstable, Normal,
354 template!(Word, List: "feat1, feat2, ..."), DuplicatesOk,
355 "rustc_allow_const_fn_unstable side-steps feature gating and stability checks"
356 ),
357 gated!(
358 allow_internal_unsafe, Normal, template!(Word), WarnFollowing,
359 "allow_internal_unsafe side-steps the unsafe_code lint",
360 ),
361 rustc_attr!(rustc_allowed_through_unstable_modules, Normal, template!(Word), WarnFollowing,
362 "rustc_allowed_through_unstable_modules special cases accidental stabilizations of stable items \
363 through unstable paths"),
364
365 gated!(fundamental, Normal, template!(Word), WarnFollowing, experimental!(fundamental)),
370 gated!(
371 may_dangle, Normal, template!(Word), WarnFollowing, dropck_eyepatch,
372 "`may_dangle` has unstable semantics and may be removed in the future",
373 ),
374
375 rustc_attr!(rustc_allocator, Normal, template!(Word), WarnFollowing, IMPL_DETAIL),
380 rustc_attr!(rustc_nounwind, Normal, template!(Word), WarnFollowing, IMPL_DETAIL),
381 rustc_attr!(rustc_reallocator, Normal, template!(Word), WarnFollowing, IMPL_DETAIL),
382 rustc_attr!(rustc_deallocator, Normal, template!(Word), WarnFollowing, IMPL_DETAIL),
383 rustc_attr!(rustc_allocator_zeroed, Normal, template!(Word), WarnFollowing, IMPL_DETAIL),
384 gated!(
385 default_lib_allocator, Normal, template!(Word), WarnFollowing, allocator_internals,
386 experimental!(default_lib_allocator),
387 ),
388 gated!(
389 needs_allocator, Normal, template!(Word), WarnFollowing, allocator_internals,
390 experimental!(needs_allocator),
391 ),
392 gated!(panic_runtime, Normal, template!(Word), WarnFollowing, experimental!(panic_runtime)),
393 gated!(
394 needs_panic_runtime, Normal, template!(Word), WarnFollowing,
395 experimental!(needs_panic_runtime)
396 ),
397 gated!(
398 compiler_builtins, Normal, template!(Word), WarnFollowing,
399 "the `#[compiler_builtins]` attribute is used to identify the `compiler_builtins` crate \
400 which contains compiler-rt intrinsics and will never be stable",
401 ),
402 gated!(
403 profiler_runtime, Normal, template!(Word), WarnFollowing,
404 "the `#[profiler_runtime]` attribute is used to identify the `profiler_builtins` crate \
405 which contains the profiler runtime and will never be stable",
406 ),
407
408 gated!(
413 linkage, Normal, template!(NameValueStr: "external|internal|..."), ErrorPreceding, @only_local: true,
414 "the `linkage` attribute is experimental and not portable across platforms",
415 ),
416 rustc_attr!(
417 rustc_std_internal_symbol, Normal, template!(Word), WarnFollowing, @only_local: true, INTERNAL_UNSTABLE
418 ),
419
420 rustc_attr!(
425 rustc_builtin_macro, Normal,
426 template!(Word, List: "name, /*opt*/ attributes(name1, name2, ...)"), ErrorFollowing,
427 IMPL_DETAIL,
428 ),
429 rustc_attr!(rustc_proc_macro_decls, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE),
430 rustc_attr!(
431 rustc_macro_transparency, Normal,
432 template!(NameValueStr: "transparent|semitransparent|opaque"), ErrorFollowing,
433 "used internally for testing macro hygiene",
434 ),
435
436 rustc_attr!(
441 rustc_on_unimplemented, Normal,
442 template!(
443 List: r#"/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...""#,
444 NameValueStr: "message"
445 ),
446 ErrorFollowing,
447 INTERNAL_UNSTABLE
448 ),
449 rustc_attr!(
450 rustc_confusables, Normal,
451 template!(List: r#""name1", "name2", ..."#),
452 ErrorFollowing,
453 INTERNAL_UNSTABLE,
454 ),
455 rustc_attr!(
457 rustc_conversion_suggestion, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE
458 ),
459 rustc_attr!(
462 rustc_trivial_field_reads, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE
463 ),
464 rustc_attr!(rustc_lint_query_instability, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE),
467 rustc_attr!(rustc_lint_untracked_query_information, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE),
470 rustc_attr!(rustc_lint_diagnostics, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE),
473 rustc_attr!(rustc_lint_opt_ty, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE),
476 rustc_attr!(rustc_lint_opt_deny_field_access, Normal, template!(List: "message"), WarnFollowing, INTERNAL_UNSTABLE),
479
480 rustc_attr!(rustc_promotable, Normal, template!(Word), WarnFollowing, IMPL_DETAIL),
485 rustc_attr!(
486 rustc_legacy_const_generics, Normal, template!(List: "N"), ErrorFollowing,
487 INTERNAL_UNSTABLE
488 ),
489 rustc_attr!(
491 rustc_do_not_const_check, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE
492 ),
493 rustc_attr!(
495 rustc_const_panic_str, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE
496 ),
497
498 rustc_attr!(
503 rustc_layout_scalar_valid_range_start, Normal, template!(List: "value"), ErrorFollowing,
504 "the `#[rustc_layout_scalar_valid_range_start]` attribute is just used to enable \
505 niche optimizations in libcore and libstd and will never be stable",
506 ),
507 rustc_attr!(
508 rustc_layout_scalar_valid_range_end, Normal, template!(List: "value"), ErrorFollowing,
509 "the `#[rustc_layout_scalar_valid_range_end]` attribute is just used to enable \
510 niche optimizations in libcore and libstd and will never be stable",
511 ),
512 rustc_attr!(
513 rustc_nonnull_optimization_guaranteed, Normal, template!(Word), WarnFollowing,
514 "the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to enable \
515 niche optimizations in libcore and libstd and will never be stable",
516 ),
517
518 gated!(
522 lang, Normal, template!(NameValueStr: "name"), DuplicatesOk, @only_local: true, lang_items,
523 "language items are subject to change",
524 ),
525 rustc_attr!(
526 rustc_pass_by_value, Normal, template!(Word), ErrorFollowing,
527 "#[rustc_pass_by_value] is used to mark types that must be passed by value instead of reference."
528 ),
529 rustc_attr!(
530 rustc_never_returns_null_ptr, Normal, template!(Word), ErrorFollowing,
531 "#[rustc_never_returns_null_ptr] is used to mark functions returning non-null pointers."
532 ),
533 rustc_attr!(
534 rustc_coherence_is_core, AttributeType::CrateLevel, template!(Word), ErrorFollowing, @only_local: true,
535 "#![rustc_coherence_is_core] allows inherent methods on builtin types, only intended to be used in `core`."
536 ),
537 rustc_attr!(
538 rustc_coinductive, AttributeType::Normal, template!(Word), WarnFollowing, @only_local: true,
539 "#![rustc_coinductive] changes a trait to be coinductive, allowing cycles in the trait solver."
540 ),
541 rustc_attr!(
542 rustc_allow_incoherent_impl, AttributeType::Normal, template!(Word), ErrorFollowing, @only_local: true,
543 "#[rustc_allow_incoherent_impl] has to be added to all impl items of an incoherent inherent impl."
544 ),
545 rustc_attr!(
546 rustc_deny_explicit_impl,
547 AttributeType::Normal,
548 template!(List: "implement_via_object = (true|false)"),
549 ErrorFollowing,
550 @only_local: true,
551 "#[rustc_deny_explicit_impl] enforces that a trait can have no user-provided impls"
552 ),
553 rustc_attr!(
554 rustc_has_incoherent_inherent_impls, AttributeType::Normal, template!(Word), ErrorFollowing,
555 "#[rustc_has_incoherent_inherent_impls] allows the addition of incoherent inherent impls for \
556 the given type by annotating all impl items with #[rustc_allow_incoherent_impl]."
557 ),
558 rustc_attr!(
559 rustc_box, AttributeType::Normal, template!(Word), ErrorFollowing,
560 "#[rustc_box] allows creating boxes \
561 and it is only intended to be used in `alloc`."
562 ),
563
564 BuiltinAttribute {
565 name: "rustc_diagnostic_item",
567 template: template!(NameValueStr: "name"),
571 },
579 gated!(
580 prelude_import, Normal, template!(Word), WarnFollowing,
582 "`#[prelude_import]` is for use by rustc only",
583 ),
584 gated!(
585 rustc_paren_sugar, Normal, template!(Word), WarnFollowing, unboxed_closures,
586 "unboxed_closures are still evolving",
587 ),
588 rustc_attr!(
589 rustc_inherit_overflow_checks, Normal, template!(Word), WarnFollowing, @only_local: true,
590 "the `#[rustc_inherit_overflow_checks]` attribute is just used to control \
591 overflow checking behavior of several libcore functions that are inlined \
592 across crates and will never be stable",
593 ),
594 rustc_attr!(
595 rustc_reservation_impl, Normal,
596 template!(NameValueStr: "reservation message"), ErrorFollowing,
597 "the `#[rustc_reservation_impl]` attribute is internally used \
598 for reserving for `for<T> From<!> for T` impl"
599 ),
600 rustc_attr!(
601 rustc_test_marker, Normal, template!(NameValueStr: "name"), WarnFollowing,
602 "the `#[rustc_test_marker]` attribute is used internally to track tests",
603 ),
604 rustc_attr!(
605 rustc_unsafe_specialization_marker, Normal, template!(Word), WarnFollowing,
606 "the `#[rustc_unsafe_specialization_marker]` attribute is used to check specializations"
607 ),
608 rustc_attr!(
609 rustc_specialization_trait, Normal, template!(Word), WarnFollowing,
610 "the `#[rustc_specialization_trait]` attribute is used to check specializations"
611 ),
612 rustc_attr!(
613 rustc_main, Normal, template!(Word), WarnFollowing,
614 "the `#[rustc_main]` attribute is used internally to specify test entry point function",
615 ),
616 rustc_attr!(
617 rustc_skip_array_during_method_dispatch, Normal, template!(Word), WarnFollowing,
618 "the `#[rustc_skip_array_during_method_dispatch]` attribute is used to exclude a trait \
619 from method dispatch when the receiver is an array, for compatibility in editions < 2021."
620 ),
621 rustc_attr!(
622 rustc_must_implement_one_of, Normal, template!(List: "function1, function2, ..."), ErrorFollowing,
623 "the `#[rustc_must_implement_one_of]` attribute is used to change minimal complete \
624 definition of a trait, it's currently in experimental form and should be changed before \
625 being exposed outside of the std"
626 ),
627 rustc_attr!(
628 rustc_doc_primitive, Normal, template!(NameValueStr: "primitive name"), ErrorFollowing,
629 r#"`rustc_doc_primitive` is a rustc internal attribute"#,
630 ),
631 rustc_attr!(
632 rustc_safe_intrinsic, Normal, template!(Word), WarnFollowing,
633 "the `#[rustc_safe_intrinsic]` attribute is used internally to mark intrinsics as safe"
634 ),
635 rustc_attr!(
636 rustc_intrinsic, Normal, template!(Word), ErrorFollowing,
637 "the `#[rustc_intrinsic]` attribute is used to declare intrinsics with function bodies",
638 ),
639 rustc_attr!(
640 rustc_no_mir_inline, Normal, template!(Word), WarnFollowing,
641 "#[rustc_no_mir_inline] prevents the MIR inliner from inlining a function while not affecting codegen"
642 ),
643 rustc_attr!(
644 rustc_intrinsic_must_be_overridden, Normal, template!(Word), ErrorFollowing,
645 "the `#[rustc_intrinsic_must_be_overridden]` attribute is used to declare intrinsics without real bodies",
646 ),
647
648 rustc_attr!(
649 rustc_deprecated_safe_2024, Normal, template!(Word), WarnFollowing,
650 "the `#[rustc_safe_intrinsic]` marks functions as unsafe in Rust 2024",
651 ),
652
653 rustc_attr!(TEST, rustc_effective_visibility, Normal, template!(Word), WarnFollowing),
658 rustc_attr!(TEST, rustc_outlives, Normal, template!(Word), WarnFollowing),
659 rustc_attr!(TEST, rustc_capture_analysis, Normal, template!(Word), WarnFollowing),
660 rustc_attr!(TEST, rustc_insignificant_dtor, Normal, template!(Word), WarnFollowing),
661 rustc_attr!(TEST, rustc_strict_coherence, Normal, template!(Word), WarnFollowing),
662 rustc_attr!(TEST, rustc_variance, Normal, template!(Word), WarnFollowing),
663 rustc_attr!(TEST, rustc_variance_of_opaques, Normal, template!(Word), WarnFollowing),
664 rustc_attr!(TEST, rustc_hidden_type_of_opaques, Normal, template!(Word), WarnFollowing),
665 rustc_attr!(TEST, rustc_layout, Normal, template!(List: "field1, field2, ..."), WarnFollowing),
666 rustc_attr!(TEST, rustc_abi, Normal, template!(List: "field1, field2, ..."), WarnFollowing),
667 rustc_attr!(TEST, rustc_regions, Normal, template!(Word), WarnFollowing),
668 rustc_attr!(TEST, rustc_dump_user_args, Normal, template!(Word), WarnFollowing),
669 rustc_attr!(TEST, rustc_evaluate_where_clauses, Normal, template!(Word), WarnFollowing),
670 rustc_attr!(
671 TEST, rustc_if_this_changed, Normal, template!(Word, List: "DepNode"), DuplicatesOk
672 ),
673 rustc_attr!(
674 TEST, rustc_then_this_would_need, Normal, template!(List: "DepNode"), DuplicatesOk
675 ),
676 rustc_attr!(
677 TEST, rustc_clean, Normal,
678 template!(List: r#"cfg = "...", /*opt*/ label = "...", /*opt*/ except = "...""#),
679 DuplicatesOk,
680 ),
681 rustc_attr!(
682 TEST, rustc_partition_reused, Normal,
683 template!(List: r#"cfg = "...", module = "...""#), DuplicatesOk,
684 ),
685 rustc_attr!(
686 TEST, rustc_partition_codegened, Normal,
687 template!(List: r#"cfg = "...", module = "...""#), DuplicatesOk,
688 ),
689 rustc_attr!(
690 TEST, rustc_expected_cgu_reuse, Normal,
691 template!(List: r#"cfg = "...", module = "...", kind = "...""#), DuplicatesOk,
692 ),
693 rustc_attr!(TEST, rustc_symbol_name, Normal, template!(Word), WarnFollowing),
694 rustc_attr!(TEST, rustc_def_path, Normal, template!(Word), WarnFollowing),
695 rustc_attr!(TEST, rustc_mir, Normal, template!(List: "arg1, arg2, ..."), DuplicatesOk),
696 gated!(
697 custom_mir, Normal, template!(List: r#"dialect = "...", phase = "...""#),
698 ErrorFollowing, "the `#[custom_mir]` attribute is just used for the Rust test suite",
699 ),
700 rustc_attr!(TEST, rustc_dump_program_clauses, Normal, template!(Word), WarnFollowing),
701 rustc_attr!(TEST, rustc_dump_env_program_clauses, Normal, template!(Word), WarnFollowing),
702 rustc_attr!(TEST, rustc_object_lifetime_default, Normal, template!(Word), WarnFollowing),
703 rustc_attr!(TEST, rustc_dump_vtable, Normal, template!(Word), WarnFollowing),
704 rustc_attr!(TEST, rustc_dummy, Normal, template!(Word ), DuplicatesOk),
705 gated!(
706 omit_gdb_pretty_printer_section, Normal, template!(Word), WarnFollowing,
707 "the `#[omit_gdb_pretty_printer_section]` attribute is just used for the Rust test suite",
708 ),
709];