2
2
//!
3
3
//! The actual definitions were copied from rustc's `compiler/rustc_feature/src/builtin_attrs.rs`.
4
4
//!
5
- //! It was last synchronized with upstream commit c1a2db3372a4d6896744919284f3287650a38ab7 .
5
+ //! It was last synchronized with upstream commit e29821ff85a2a3000d226f99f62f89464028d5d6 .
6
6
//!
7
7
//! The macros were adjusted to only expand to the attribute name, since that is all we need to do
8
8
//! name resolution, and `BUILTIN_ATTRIBUTES` is almost entirely unchanged from the original, to
@@ -108,7 +108,7 @@ macro_rules! experimental {
108
108
} ;
109
109
}
110
110
111
- /// "Inert" built-in attributes that have a special meaning to rustc or rustdoc.
111
+ /// Attributes that have a special meaning to rustc or rustdoc.
112
112
#[ rustfmt:: skip]
113
113
pub const INERT_ATTRIBUTES : & [ BuiltinAttribute ] = & [
114
114
// ==========================================================================
@@ -123,7 +123,7 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
123
123
ungated ! ( ignore, Normal , template!( Word , NameValueStr : "reason" ) , WarnFollowing ) ,
124
124
ungated ! (
125
125
should_panic, Normal ,
126
- template!( Word , List : r#"expected = "reason"# , NameValueStr : "reason" ) , FutureWarnFollowing ,
126
+ template!( Word , List : r#"expected = "reason"" # , NameValueStr : "reason" ) , FutureWarnFollowing ,
127
127
) ,
128
128
// FIXME(Centril): This can be used on stable but shouldn't.
129
129
ungated ! ( reexport_test_harness_main, CrateLevel , template!( NameValueStr : "name" ) , ErrorFollowing ) ,
@@ -142,20 +142,24 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
142
142
143
143
// Lints:
144
144
ungated ! (
145
- warn, Normal , template!( List : r#"lint1, lint2, ..., /*opt*/ reason = "...""# ) , DuplicatesOk
145
+ warn, Normal , template!( List : r#"lint1, lint2, ..., /*opt*/ reason = "...""# ) ,
146
+ DuplicatesOk , @only_local: true ,
146
147
) ,
147
148
ungated ! (
148
- allow, Normal , template!( List : r#"lint1, lint2, ..., /*opt*/ reason = "...""# ) , DuplicatesOk
149
+ allow, Normal , template!( List : r#"lint1, lint2, ..., /*opt*/ reason = "...""# ) ,
150
+ DuplicatesOk , @only_local: true ,
149
151
) ,
150
152
gated ! (
151
153
expect, Normal , template!( List : r#"lint1, lint2, ..., /*opt*/ reason = "...""# ) , DuplicatesOk ,
152
154
lint_reasons, experimental!( expect)
153
155
) ,
154
156
ungated ! (
155
- forbid, Normal , template!( List : r#"lint1, lint2, ..., /*opt*/ reason = "...""# ) , DuplicatesOk
157
+ forbid, Normal , template!( List : r#"lint1, lint2, ..., /*opt*/ reason = "...""# ) ,
158
+ DuplicatesOk , @only_local: true ,
156
159
) ,
157
160
ungated ! (
158
- deny, Normal , template!( List : r#"lint1, lint2, ..., /*opt*/ reason = "...""# ) , DuplicatesOk
161
+ deny, Normal , template!( List : r#"lint1, lint2, ..., /*opt*/ reason = "...""# ) ,
162
+ DuplicatesOk , @only_local: true ,
159
163
) ,
160
164
ungated ! ( must_use, Normal , template!( Word , NameValueStr : "reason" ) , FutureWarnFollowing ) ,
161
165
gated ! (
@@ -181,16 +185,17 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
181
185
// ABI, linking, symbols, and FFI
182
186
ungated ! (
183
187
link, Normal ,
184
- template!( List : r#"name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ wasm_import_module = "...""# ) ,
188
+ template!( List : r#"name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ wasm_import_module = "...", /*opt*/ import_name_type = "decorated|noprefix|undecorated" "# ) ,
185
189
DuplicatesOk ,
186
190
) ,
187
191
ungated ! ( link_name, Normal , template!( NameValueStr : "name" ) , FutureWarnPreceding ) ,
188
192
ungated ! ( no_link, Normal , template!( Word ) , WarnFollowing ) ,
189
- ungated ! ( repr, Normal , template!( List : "C" ) , DuplicatesOk ) ,
193
+ ungated ! ( repr, Normal , template!( List : "C" ) , DuplicatesOk , @only_local : true ) ,
190
194
ungated ! ( export_name, Normal , template!( NameValueStr : "name" ) , FutureWarnPreceding ) ,
191
195
ungated ! ( link_section, Normal , template!( NameValueStr : "name" ) , FutureWarnPreceding ) ,
192
196
ungated ! ( no_mangle, Normal , template!( Word ) , WarnFollowing , @only_local: true ) ,
193
197
ungated ! ( used, Normal , template!( Word , List : "compiler|linker" ) , WarnFollowing , @only_local: true ) ,
198
+ ungated ! ( link_ordinal, Normal , template!( List : "ordinal" ) , ErrorPreceding ) ,
194
199
195
200
// Limits:
196
201
ungated ! ( recursion_limit, CrateLevel , template!( NameValueStr : "N" ) , FutureWarnFollowing ) ,
@@ -205,6 +210,7 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
205
210
) ,
206
211
207
212
// Entry point:
213
+ gated ! ( unix_sigpipe, Normal , template!( Word , NameValueStr : "inherit|sig_ign|sig_dfl" ) , ErrorFollowing , experimental!( unix_sigpipe) ) ,
208
214
ungated ! ( start, Normal , template!( Word ) , WarnFollowing ) ,
209
215
ungated ! ( no_start, CrateLevel , template!( Word ) , WarnFollowing ) ,
210
216
ungated ! ( no_main, CrateLevel , template!( Word ) , WarnFollowing ) ,
@@ -226,11 +232,15 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
226
232
ungated ! ( inline, Normal , template!( Word , List : "always|never" ) , FutureWarnFollowing , @only_local: true ) ,
227
233
ungated ! ( cold, Normal , template!( Word ) , WarnFollowing , @only_local: true ) ,
228
234
ungated ! ( no_builtins, CrateLevel , template!( Word ) , WarnFollowing ) ,
229
- ungated ! ( target_feature, Normal , template!( List : r#"enable = "name""# ) , DuplicatesOk ) ,
235
+ ungated ! (
236
+ target_feature, Normal , template!( List : r#"enable = "name""# ) ,
237
+ DuplicatesOk , @only_local: true ,
238
+ ) ,
230
239
ungated ! ( track_caller, Normal , template!( Word ) , WarnFollowing ) ,
240
+ ungated ! ( instruction_set, Normal , template!( List : "set" ) , ErrorPreceding ) ,
231
241
gated ! (
232
242
no_sanitize, Normal ,
233
- template!( List : "address, memory, thread" ) , DuplicatesOk ,
243
+ template!( List : "address, kcfi, memory, thread" ) , DuplicatesOk ,
234
244
experimental!( no_sanitize)
235
245
) ,
236
246
gated ! ( no_coverage, Normal , template!( Word ) , WarnFollowing , experimental!( no_coverage) ) ,
@@ -239,25 +249,23 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
239
249
doc, Normal , template!( List : "hidden|inline|..." , NameValueStr : "string" ) , DuplicatesOk
240
250
) ,
241
251
252
+ // Debugging
253
+ ungated ! (
254
+ debugger_visualizer, Normal ,
255
+ template!( List : r#"natvis_file = "...", gdb_script_file = "...""# ) , DuplicatesOk
256
+ ) ,
257
+
242
258
// ==========================================================================
243
259
// Unstable attributes:
244
260
// ==========================================================================
245
261
246
- // RFC #3191: #[debugger_visualizer] support
247
- gated ! (
248
- debugger_visualizer, Normal , template!( List : r#"natvis_file = "...", gdb_script_file = "...""# ) ,
249
- DuplicatesOk , experimental!( debugger_visualizer)
250
- ) ,
251
-
252
262
// Linking:
253
- gated ! ( naked, Normal , template!( Word ) , WarnFollowing , @only_local: true , naked_functions, experimental!( naked) ) ,
254
263
gated ! (
255
- link_ordinal , Normal , template!( List : "ordinal" ) , ErrorPreceding , raw_dylib ,
256
- experimental!( link_ordinal )
264
+ naked , Normal , template!( Word ) , WarnFollowing , @only_local : true ,
265
+ naked_functions , experimental!( naked )
257
266
) ,
258
267
259
268
// Plugins:
260
- // XXX Modified for use in rust-analyzer
261
269
// BuiltinAttribute {
262
270
// name: sym::plugin,
263
271
// only_local: false,
@@ -274,10 +282,6 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
274
282
// cfg_fn!(plugin)
275
283
// ),
276
284
// },
277
- BuiltinAttribute {
278
- name : "plugin" ,
279
- template : template ! ( List : "name" ) ,
280
- } ,
281
285
282
286
// Testing:
283
287
gated ! (
@@ -286,7 +290,8 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
286
290
) ,
287
291
// RFC #1268
288
292
gated ! (
289
- marker, Normal , template!( Word ) , WarnFollowing , marker_trait_attr, experimental!( marker)
293
+ marker, Normal , template!( Word ) , WarnFollowing , @only_local: true ,
294
+ marker_trait_attr, experimental!( marker)
290
295
) ,
291
296
gated ! (
292
297
thread_local, Normal , template!( Word ) , WarnFollowing ,
@@ -298,21 +303,12 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
298
303
optimize, Normal , template!( List : "size|speed" ) , ErrorPreceding , optimize_attribute,
299
304
experimental!( optimize) ,
300
305
) ,
301
- // RFC 2867
302
- gated ! (
303
- instruction_set, Normal , template!( List : "set" ) , ErrorPreceding ,
304
- isa_attribute, experimental!( instruction_set)
305
- ) ,
306
306
307
307
gated ! (
308
308
ffi_returns_twice, Normal , template!( Word ) , WarnFollowing , experimental!( ffi_returns_twice)
309
309
) ,
310
310
gated ! ( ffi_pure, Normal , template!( Word ) , WarnFollowing , experimental!( ffi_pure) ) ,
311
311
gated ! ( ffi_const, Normal , template!( Word ) , WarnFollowing , experimental!( ffi_const) ) ,
312
- gated ! (
313
- register_attr, CrateLevel , template!( List : "attr1, attr2, ..." ) , DuplicatesOk ,
314
- experimental!( register_attr) ,
315
- ) ,
316
312
gated ! (
317
313
register_tool, CrateLevel , template!( List : "tool1, tool2, ..." ) , DuplicatesOk ,
318
314
experimental!( register_tool) ,
@@ -325,7 +321,7 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
325
321
// RFC 2632
326
322
gated ! (
327
323
const_trait, Normal , template!( Word ) , WarnFollowing , const_trait_impl,
328
- "`const ` is a temporary placeholder for marking a trait that is suitable for `const` \
324
+ "`const_trait ` is a temporary placeholder for marking a trait that is suitable for `const` \
329
325
`impls` and all default bodies as `const`, which may be removed or renamed in the \
330
326
future."
331
327
) ,
@@ -335,22 +331,47 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
335
331
experimental!( deprecated_safe) ,
336
332
) ,
337
333
334
+ // `#[collapse_debuginfo]`
335
+ gated ! (
336
+ collapse_debuginfo, Normal , template!( Word ) , WarnFollowing ,
337
+ experimental!( collapse_debuginfo)
338
+ ) ,
339
+
340
+ // RFC 2397
341
+ gated ! ( do_not_recommend, Normal , template!( Word ) , WarnFollowing , experimental!( do_not_recommend) ) ,
342
+
343
+ // `#[cfi_encoding = ""]`
344
+ gated ! (
345
+ cfi_encoding, Normal , template!( NameValueStr : "encoding" ) , ErrorPreceding ,
346
+ experimental!( cfi_encoding)
347
+ ) ,
348
+
338
349
// ==========================================================================
339
350
// Internal attributes: Stability, deprecation, and unsafe:
340
351
// ==========================================================================
341
352
342
- ungated ! ( feature, CrateLevel , template!( List : "name1, name2, ..." ) , DuplicatesOk ) ,
353
+ ungated ! (
354
+ feature, CrateLevel ,
355
+ template!( List : "name1, name2, ..." ) , DuplicatesOk , @only_local: true ,
356
+ ) ,
343
357
// DuplicatesOk since it has its own validation
344
358
ungated ! (
345
- stable, Normal , template!( List : r#"feature = "name", since = "version""# ) , DuplicatesOk ,
359
+ stable, Normal ,
360
+ template!( List : r#"feature = "name", since = "version""# ) , DuplicatesOk , @only_local: true ,
346
361
) ,
347
362
ungated ! (
348
363
unstable, Normal ,
349
364
template!( List : r#"feature = "name", reason = "...", issue = "N""# ) , DuplicatesOk ,
350
365
) ,
351
366
ungated ! ( rustc_const_unstable, Normal , template!( List : r#"feature = "name""# ) , DuplicatesOk ) ,
352
- ungated ! ( rustc_const_stable, Normal , template!( List : r#"feature = "name""# ) , DuplicatesOk ) ,
353
- ungated ! ( rustc_safe_intrinsic, Normal , template!( List : r#"feature = "name""# ) , DuplicatesOk ) ,
367
+ ungated ! (
368
+ rustc_const_stable, Normal ,
369
+ template!( List : r#"feature = "name""# ) , DuplicatesOk , @only_local: true ,
370
+ ) ,
371
+ ungated ! (
372
+ rustc_default_body_unstable, Normal ,
373
+ template!( List : r#"feature = "name", reason = "...", issue = "N""# ) , DuplicatesOk
374
+ ) ,
354
375
gated ! (
355
376
allow_internal_unstable, Normal , template!( Word , List : "feat1, feat2, ..." ) , DuplicatesOk ,
356
377
"allow_internal_unstable side-steps feature gating and stability checks" ,
@@ -364,6 +385,10 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
364
385
allow_internal_unsafe, Normal , template!( Word ) , WarnFollowing ,
365
386
"allow_internal_unsafe side-steps the unsafe_code lint" ,
366
387
) ,
388
+ ungated ! ( rustc_safe_intrinsic, Normal , template!( Word ) , DuplicatesOk ) ,
389
+ rustc_attr ! ( rustc_allowed_through_unstable_modules, Normal , template!( Word ) , WarnFollowing ,
390
+ "rustc_allowed_through_unstable_modules special cases accidental stabilizations of stable items \
391
+ through unstable paths") ,
367
392
368
393
// ==========================================================================
369
394
// Internal attributes: Type system related:
@@ -381,10 +406,9 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
381
406
382
407
rustc_attr ! ( rustc_allocator, Normal , template!( Word ) , WarnFollowing , IMPL_DETAIL ) ,
383
408
rustc_attr ! ( rustc_nounwind, Normal , template!( Word ) , WarnFollowing , IMPL_DETAIL ) ,
384
- gated ! (
385
- alloc_error_handler, Normal , template!( Word ) , WarnFollowing ,
386
- experimental!( alloc_error_handler)
387
- ) ,
409
+ rustc_attr ! ( rustc_reallocator, Normal , template!( Word ) , WarnFollowing , IMPL_DETAIL ) ,
410
+ rustc_attr ! ( rustc_deallocator, Normal , template!( Word ) , WarnFollowing , IMPL_DETAIL ) ,
411
+ rustc_attr ! ( rustc_allocator_zeroed, Normal , template!( Word ) , WarnFollowing , IMPL_DETAIL ) ,
388
412
gated ! (
389
413
default_lib_allocator, Normal , template!( Word ) , WarnFollowing , allocator_internals,
390
414
experimental!( default_lib_allocator) ,
@@ -465,6 +489,12 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
465
489
// Used by the `rustc::untranslatable_diagnostic` and `rustc::diagnostic_outside_of_impl` lints
466
490
// to assist in changes to diagnostic APIs.
467
491
rustc_attr ! ( rustc_lint_diagnostics, Normal , template!( Word ) , WarnFollowing , INTERNAL_UNSTABLE ) ,
492
+ // Used by the `rustc::bad_opt_access` lint to identify `DebuggingOptions` and `CodegenOptions`
493
+ // types (as well as any others in future).
494
+ rustc_attr ! ( rustc_lint_opt_ty, Normal , template!( Word ) , WarnFollowing , INTERNAL_UNSTABLE ) ,
495
+ // Used by the `rustc::bad_opt_access` lint on fields
496
+ // types (as well as any others in future).
497
+ rustc_attr ! ( rustc_lint_opt_deny_field_access, Normal , template!( List : "message" ) , WarnFollowing , INTERNAL_UNSTABLE ) ,
468
498
469
499
// ==========================================================================
470
500
// Internal attributes, Const related:
@@ -508,18 +538,25 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
508
538
"language items are subject to change" ,
509
539
) ,
510
540
rustc_attr ! (
511
- rustc_pass_by_value, Normal ,
512
- template!( Word ) , ErrorFollowing ,
541
+ rustc_pass_by_value, Normal , template!( Word ) , ErrorFollowing ,
513
542
"#[rustc_pass_by_value] is used to mark types that must be passed by value instead of reference."
514
543
) ,
515
544
rustc_attr ! (
516
545
rustc_coherence_is_core, AttributeType :: CrateLevel , template!( Word ) , ErrorFollowing , @only_local: true ,
517
546
"#![rustc_coherence_is_core] allows inherent methods on builtin types, only intended to be used in `core`."
518
547
) ,
548
+ rustc_attr ! (
549
+ rustc_coinductive, AttributeType :: Normal , template!( Word ) , WarnFollowing , @only_local: true ,
550
+ "#![rustc_coinductive] changes a trait to be coinductive, allowing cycles in the trait solver."
551
+ ) ,
519
552
rustc_attr ! (
520
553
rustc_allow_incoherent_impl, AttributeType :: Normal , template!( Word ) , ErrorFollowing , @only_local: true ,
521
554
"#[rustc_allow_incoherent_impl] has to be added to all impl items of an incoherent inherent impl."
522
555
) ,
556
+ rustc_attr ! (
557
+ rustc_deny_explicit_impl, AttributeType :: Normal , template!( Word ) , ErrorFollowing , @only_local: false ,
558
+ "#[rustc_deny_explicit_impl] enforces that a trait can have no user-provided impls"
559
+ ) ,
523
560
rustc_attr ! (
524
561
rustc_has_incoherent_inherent_impls, AttributeType :: Normal , template!( Word ) , ErrorFollowing ,
525
562
"#[rustc_has_incoherent_inherent_impls] allows the addition of incoherent inherent impls for \
@@ -531,24 +568,20 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
531
568
and it is only intended to be used in `alloc`."
532
569
) ,
533
570
534
- // modified for r-a
535
- // BuiltinAttribute {
536
- // name: sym::rustc_diagnostic_item,
537
- // // FIXME: This can be `true` once we always use `tcx.is_diagnostic_item`.
538
- // only_local: false,
539
- // type_: Normal,
540
- // template: template!(NameValueStr: "name"),
541
- // duplicates: ErrorFollowing,
542
- // gate: Gated(
543
- // Stability::Unstable,
544
- // sym::rustc_attrs,
545
- // "diagnostic items compiler internal support for linting",
546
- // cfg_fn!(rustc_attrs),
547
- // ),
548
- // },
549
571
BuiltinAttribute {
572
+ // name: sym::rustc_diagnostic_item,
550
573
name : "rustc_diagnostic_item" ,
574
+ // FIXME: This can be `true` once we always use `tcx.is_diagnostic_item`.
575
+ // only_local: false,
576
+ // type_: Normal,
551
577
template : template ! ( NameValueStr : "name" ) ,
578
+ // duplicates: ErrorFollowing,
579
+ // gate: Gated(
580
+ // Stability::Unstable,
581
+ // sym::rustc_attrs,
582
+ // "diagnostic items compiler internal support for linting",
583
+ // cfg_fn!(rustc_attrs),
584
+ // ),
552
585
} ,
553
586
gated ! (
554
587
// Used in resolve:
@@ -572,7 +605,7 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
572
605
for reserving for `for<T> From<!> for T` impl"
573
606
) ,
574
607
rustc_attr ! (
575
- rustc_test_marker, Normal , template!( Word ) , WarnFollowing ,
608
+ rustc_test_marker, Normal , template!( NameValueStr : "name" ) , WarnFollowing ,
576
609
"the `#[rustc_test_marker]` attribute is used internally to track tests" ,
577
610
) ,
578
611
rustc_attr ! (
@@ -598,11 +631,16 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
598
631
definition of a trait, it's currently in experimental form and should be changed before \
599
632
being exposed outside of the std"
600
633
) ,
634
+ rustc_attr ! (
635
+ rustc_doc_primitive, Normal , template!( NameValueStr : "primitive name" ) , ErrorFollowing ,
636
+ r#"`rustc_doc_primitive` is a rustc internal attribute"# ,
637
+ ) ,
601
638
602
639
// ==========================================================================
603
640
// Internal attributes, Testing:
604
641
// ==========================================================================
605
642
643
+ rustc_attr ! ( TEST , rustc_effective_visibility, Normal , template!( Word ) , WarnFollowing ) ,
606
644
rustc_attr ! ( TEST , rustc_outlives, Normal , template!( Word ) , WarnFollowing ) ,
607
645
rustc_attr ! ( TEST , rustc_capture_analysis, Normal , template!( Word ) , WarnFollowing ) ,
608
646
rustc_attr ! ( TEST , rustc_insignificant_dtor, Normal , template!( Word ) , WarnFollowing ) ,
@@ -643,6 +681,10 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
643
681
rustc_attr ! ( TEST , rustc_polymorphize_error, Normal , template!( Word ) , WarnFollowing ) ,
644
682
rustc_attr ! ( TEST , rustc_def_path, Normal , template!( Word ) , WarnFollowing ) ,
645
683
rustc_attr ! ( TEST , rustc_mir, Normal , template!( List : "arg1, arg2, ..." ) , DuplicatesOk ) ,
684
+ gated ! (
685
+ custom_mir, Normal , template!( List : r#"dialect = "...", phase = "...""# ) ,
686
+ ErrorFollowing , "the `#[custom_mir]` attribute is just used for the Rust test suite" ,
687
+ ) ,
646
688
rustc_attr ! ( TEST , rustc_dump_program_clauses, Normal , template!( Word ) , WarnFollowing ) ,
647
689
rustc_attr ! ( TEST , rustc_dump_env_program_clauses, Normal , template!( Word ) , WarnFollowing ) ,
648
690
rustc_attr ! ( TEST , rustc_object_lifetime_default, Normal , template!( Word ) , WarnFollowing ) ,
0 commit comments