@@ -296,20 +296,24 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
296
296
297
297
// Lints:
298
298
ungated ! (
299
- warn, Normal , template!( List : r#"lint1, lint2, ..., /*opt*/ reason = "...""# ) , DuplicatesOk
299
+ warn, Normal , template!( List : r#"lint1, lint2, ..., /*opt*/ reason = "...""# ) ,
300
+ DuplicatesOk , @only_local: true ,
300
301
) ,
301
302
ungated ! (
302
- allow, Normal , template!( List : r#"lint1, lint2, ..., /*opt*/ reason = "...""# ) , DuplicatesOk
303
+ allow, Normal , template!( List : r#"lint1, lint2, ..., /*opt*/ reason = "...""# ) ,
304
+ DuplicatesOk , @only_local: true ,
303
305
) ,
304
306
gated ! (
305
307
expect, Normal , template!( List : r#"lint1, lint2, ..., /*opt*/ reason = "...""# ) , DuplicatesOk ,
306
308
lint_reasons, experimental!( expect)
307
309
) ,
308
310
ungated ! (
309
- forbid, Normal , template!( List : r#"lint1, lint2, ..., /*opt*/ reason = "...""# ) , DuplicatesOk
311
+ forbid, Normal , template!( List : r#"lint1, lint2, ..., /*opt*/ reason = "...""# ) ,
312
+ DuplicatesOk , @only_local: true ,
310
313
) ,
311
314
ungated ! (
312
- deny, Normal , template!( List : r#"lint1, lint2, ..., /*opt*/ reason = "...""# ) , DuplicatesOk
315
+ deny, Normal , template!( List : r#"lint1, lint2, ..., /*opt*/ reason = "...""# ) ,
316
+ DuplicatesOk , @only_local: true ,
313
317
) ,
314
318
ungated ! ( must_use, Normal , template!( Word , NameValueStr : "reason" ) , FutureWarnFollowing ) ,
315
319
gated ! (
@@ -340,7 +344,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
340
344
) ,
341
345
ungated ! ( link_name, Normal , template!( NameValueStr : "name" ) , FutureWarnPreceding ) ,
342
346
ungated ! ( no_link, Normal , template!( Word ) , WarnFollowing ) ,
343
- ungated ! ( repr, Normal , template!( List : "C" ) , DuplicatesOk ) ,
347
+ ungated ! ( repr, Normal , template!( List : "C" ) , DuplicatesOk , @only_local : true ) ,
344
348
ungated ! ( export_name, Normal , template!( NameValueStr : "name" ) , FutureWarnPreceding ) ,
345
349
ungated ! ( link_section, Normal , template!( NameValueStr : "name" ) , FutureWarnPreceding ) ,
346
350
ungated ! ( no_mangle, Normal , template!( Word ) , WarnFollowing , @only_local: true ) ,
@@ -382,7 +386,10 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
382
386
ungated ! ( inline, Normal , template!( Word , List : "always|never" ) , FutureWarnFollowing , @only_local: true ) ,
383
387
ungated ! ( cold, Normal , template!( Word ) , WarnFollowing , @only_local: true ) ,
384
388
ungated ! ( no_builtins, CrateLevel , template!( Word ) , WarnFollowing ) ,
385
- ungated ! ( target_feature, Normal , template!( List : r#"enable = "name""# ) , DuplicatesOk ) ,
389
+ ungated ! (
390
+ target_feature, Normal , template!( List : r#"enable = "name""# ) ,
391
+ DuplicatesOk , @only_local: true ,
392
+ ) ,
386
393
ungated ! ( track_caller, Normal , template!( Word ) , WarnFollowing ) ,
387
394
gated ! (
388
395
no_sanitize, Normal ,
@@ -488,18 +495,24 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
488
495
// Internal attributes: Stability, deprecation, and unsafe:
489
496
// ==========================================================================
490
497
491
- ungated ! ( feature, CrateLevel , template!( List : "name1, name2, ..." ) , DuplicatesOk ) ,
498
+ ungated ! (
499
+ feature, CrateLevel ,
500
+ template!( List : "name1, name2, ..." ) , DuplicatesOk , @only_local: true ,
501
+ ) ,
492
502
// DuplicatesOk since it has its own validation
493
503
ungated ! (
494
- stable, Normal , template!( List : r#"feature = "name", since = "version""# ) , DuplicatesOk ,
504
+ stable, Normal ,
505
+ template!( List : r#"feature = "name", since = "version""# ) , DuplicatesOk , @only_local: true ,
495
506
) ,
496
507
ungated ! (
497
508
unstable, Normal ,
498
509
template!( List : r#"feature = "name", reason = "...", issue = "N""# ) , DuplicatesOk ,
499
510
) ,
500
511
ungated ! ( rustc_const_unstable, Normal , template!( List : r#"feature = "name""# ) , DuplicatesOk ) ,
501
- ungated ! ( rustc_const_stable, Normal , template!( List : r#"feature = "name""# ) , DuplicatesOk ) ,
502
- ungated ! ( rustc_safe_intrinsic, Normal , template!( Word ) , DuplicatesOk ) ,
512
+ ungated ! (
513
+ rustc_const_stable, Normal ,
514
+ template!( List : r#"feature = "name""# ) , DuplicatesOk , @only_local: true ,
515
+ ) ,
503
516
ungated ! (
504
517
rustc_default_body_unstable, Normal ,
505
518
template!( List : r#"feature = "name", reason = "...", issue = "N""# ) , DuplicatesOk
@@ -517,6 +530,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
517
530
allow_internal_unsafe, Normal , template!( Word ) , WarnFollowing ,
518
531
"allow_internal_unsafe side-steps the unsafe_code lint" ,
519
532
) ,
533
+ ungated ! ( rustc_safe_intrinsic, Normal , template!( Word ) , DuplicatesOk ) ,
520
534
rustc_attr ! ( rustc_allowed_through_unstable_modules, Normal , template!( Word ) , WarnFollowing ,
521
535
"rustc_allowed_through_unstable_modules special cases accidental stabilizations of stable items \
522
536
through unstable paths") ,
@@ -823,6 +837,8 @@ pub fn is_builtin_attr_name(name: Symbol) -> bool {
823
837
BUILTIN_ATTRIBUTE_MAP . get ( & name) . is_some ( )
824
838
}
825
839
840
+ /// Whether this builtin attribute is only used in the local crate.
841
+ /// If so, it is not encoded in the crate metadata.
826
842
pub fn is_builtin_only_local ( name : Symbol ) -> bool {
827
843
BUILTIN_ATTRIBUTE_MAP . get ( & name) . map_or ( false , |attr| attr. only_local )
828
844
}
0 commit comments