@@ -1292,6 +1292,18 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
1292
1292
attribute is just used for rustc unit \
1293
1293
tests and will never be stable",
1294
1294
cfg_fn ! ( rustc_attrs) ) ) ,
1295
+ ( sym:: rustc_dump_env_program_clauses, Whitelisted , template ! ( Word ) , Gated ( Stability :: Unstable ,
1296
+ sym:: rustc_attrs,
1297
+ "the `#[rustc_dump_env_program_clauses]` \
1298
+ attribute is just used for rustc unit \
1299
+ tests and will never be stable",
1300
+ cfg_fn ! ( rustc_attrs) ) ) ,
1301
+ ( sym:: rustc_object_lifetime_default, Whitelisted , template ! ( Word ) , Gated ( Stability :: Unstable ,
1302
+ sym:: rustc_attrs,
1303
+ "the `#[rustc_object_lifetime_default]` \
1304
+ attribute is just used for rustc unit \
1305
+ tests and will never be stable",
1306
+ cfg_fn ! ( rustc_attrs) ) ) ,
1295
1307
( sym:: rustc_test_marker, Normal , template ! ( Word ) , Gated ( Stability :: Unstable ,
1296
1308
sym:: rustc_attrs,
1297
1309
"the `#[rustc_test_marker]` attribute \
@@ -1353,6 +1365,26 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
1353
1365
"internal implementation detail" ,
1354
1366
cfg_fn ! ( rustc_attrs) ) ) ,
1355
1367
1368
+ ( sym:: rustc_allocator_nounwind, Whitelisted , template ! ( Word ) , Gated ( Stability :: Unstable ,
1369
+ sym:: rustc_attrs,
1370
+ "internal implementation detail" ,
1371
+ cfg_fn ! ( rustc_attrs) ) ) ,
1372
+
1373
+ ( sym:: rustc_doc_only_macro, Whitelisted , template ! ( Word ) , Gated ( Stability :: Unstable ,
1374
+ sym:: rustc_attrs,
1375
+ "internal implementation detail" ,
1376
+ cfg_fn ! ( rustc_attrs) ) ) ,
1377
+
1378
+ ( sym:: rustc_promotable, Whitelisted , template ! ( Word ) , Gated ( Stability :: Unstable ,
1379
+ sym:: rustc_attrs,
1380
+ "internal implementation detail" ,
1381
+ cfg_fn ! ( rustc_attrs) ) ) ,
1382
+
1383
+ ( sym:: rustc_allow_const_fn_ptr, Whitelisted , template ! ( Word ) , Gated ( Stability :: Unstable ,
1384
+ sym:: rustc_attrs,
1385
+ "internal implementation detail" ,
1386
+ cfg_fn ! ( rustc_attrs) ) ) ,
1387
+
1356
1388
( sym:: rustc_dummy, Normal , template ! ( Word /* doesn't matter*/ ) , Gated ( Stability :: Unstable ,
1357
1389
sym:: rustc_attrs,
1358
1390
"used by the test suite" ,
@@ -1639,6 +1671,14 @@ impl<'a> Context<'a> {
1639
1671
}
1640
1672
debug ! ( "check_attribute: {:?} is builtin, {:?}, {:?}" , attr. path, ty, gateage) ;
1641
1673
return ;
1674
+ } else {
1675
+ for segment in & attr. path . segments {
1676
+ if segment. ident . as_str ( ) . starts_with ( "rustc" ) {
1677
+ let msg = "attributes starting with `rustc` are \
1678
+ reserved for use by the `rustc` compiler";
1679
+ gate_feature ! ( self , rustc_attrs, segment. ident. span, msg) ;
1680
+ }
1681
+ }
1642
1682
}
1643
1683
for & ( n, ty) in self . plugin_attributes {
1644
1684
if attr. path == n {
@@ -1649,19 +1689,13 @@ impl<'a> Context<'a> {
1649
1689
return ;
1650
1690
}
1651
1691
}
1652
- if !attr:: is_known ( attr) {
1653
- if attr. name_or_empty ( ) . as_str ( ) . starts_with ( "rustc_" ) {
1654
- let msg = "unless otherwise specified, attributes with the prefix `rustc_` \
1655
- are reserved for internal compiler diagnostics";
1656
- gate_feature ! ( self , rustc_attrs, attr. span, msg) ;
1657
- } else if !is_macro {
1658
- // Only run the custom attribute lint during regular feature gate
1659
- // checking. Macro gating runs before the plugin attributes are
1660
- // registered, so we skip this in that case.
1661
- let msg = format ! ( "The attribute `{}` is currently unknown to the compiler and \
1662
- may have meaning added to it in the future", attr. path) ;
1663
- gate_feature ! ( self , custom_attribute, attr. span, & msg) ;
1664
- }
1692
+ if !is_macro && !attr:: is_known ( attr) {
1693
+ // Only run the custom attribute lint during regular feature gate
1694
+ // checking. Macro gating runs before the plugin attributes are
1695
+ // registered, so we skip this in that case.
1696
+ let msg = format ! ( "The attribute `{}` is currently unknown to the compiler and \
1697
+ may have meaning added to it in the future", attr. path) ;
1698
+ gate_feature ! ( self , custom_attribute, attr. span, & msg) ;
1665
1699
}
1666
1700
}
1667
1701
}
0 commit comments