@@ -296,20 +296,24 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
296296
297297 // Lints:
298298 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 ,
300301 ) ,
301302 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 ,
303305 ) ,
304306 gated ! (
305307 expect, Normal , template!( List : r#"lint1, lint2, ..., /*opt*/ reason = "...""# ) , DuplicatesOk ,
306308 lint_reasons, experimental!( expect)
307309 ) ,
308310 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 ,
310313 ) ,
311314 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 ,
313317 ) ,
314318 ungated ! ( must_use, Normal , template!( Word , NameValueStr : "reason" ) , FutureWarnFollowing ) ,
315319 gated ! (
@@ -340,7 +344,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
340344 ) ,
341345 ungated ! ( link_name, Normal , template!( NameValueStr : "name" ) , FutureWarnPreceding ) ,
342346 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 ) ,
344348 ungated ! ( export_name, Normal , template!( NameValueStr : "name" ) , FutureWarnPreceding ) ,
345349 ungated ! ( link_section, Normal , template!( NameValueStr : "name" ) , FutureWarnPreceding ) ,
346350 ungated ! ( no_mangle, Normal , template!( Word ) , WarnFollowing , @only_local: true ) ,
@@ -382,7 +386,10 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
382386 ungated ! ( inline, Normal , template!( Word , List : "always|never" ) , FutureWarnFollowing , @only_local: true ) ,
383387 ungated ! ( cold, Normal , template!( Word ) , WarnFollowing , @only_local: true ) ,
384388 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+ ) ,
386393 ungated ! ( track_caller, Normal , template!( Word ) , WarnFollowing ) ,
387394 gated ! (
388395 no_sanitize, Normal ,
@@ -488,18 +495,24 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
488495 // Internal attributes: Stability, deprecation, and unsafe:
489496 // ==========================================================================
490497
491- ungated ! ( feature, CrateLevel , template!( List : "name1, name2, ..." ) , DuplicatesOk ) ,
498+ ungated ! (
499+ feature, CrateLevel ,
500+ template!( List : "name1, name2, ..." ) , DuplicatesOk , @only_local: true ,
501+ ) ,
492502 // DuplicatesOk since it has its own validation
493503 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 ,
495506 ) ,
496507 ungated ! (
497508 unstable, Normal ,
498509 template!( List : r#"feature = "name", reason = "...", issue = "N""# ) , DuplicatesOk ,
499510 ) ,
500511 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+ ) ,
503516 ungated ! (
504517 rustc_default_body_unstable, Normal ,
505518 template!( List : r#"feature = "name", reason = "...", issue = "N""# ) , DuplicatesOk
@@ -517,6 +530,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
517530 allow_internal_unsafe, Normal , template!( Word ) , WarnFollowing ,
518531 "allow_internal_unsafe side-steps the unsafe_code lint" ,
519532 ) ,
533+ ungated ! ( rustc_safe_intrinsic, Normal , template!( Word ) , DuplicatesOk ) ,
520534 rustc_attr ! ( rustc_allowed_through_unstable_modules, Normal , template!( Word ) , WarnFollowing ,
521535 "rustc_allowed_through_unstable_modules special cases accidental stabilizations of stable items \
522536 through unstable paths") ,
@@ -823,6 +837,8 @@ pub fn is_builtin_attr_name(name: Symbol) -> bool {
823837 BUILTIN_ATTRIBUTE_MAP . get ( & name) . is_some ( )
824838}
825839
840+ /// Whether this builtin attribute is only used in the local crate.
841+ /// If so, it is not encoded in the crate metadata.
826842pub fn is_builtin_only_local ( name : Symbol ) -> bool {
827843 BUILTIN_ATTRIBUTE_MAP . get ( & name) . map_or ( false , |attr| attr. only_local )
828844}
0 commit comments