@@ -149,10 +149,12 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
149
149
}
150
150
Attribute :: Parsed ( AttributeKind :: Repr ( _) ) => { /* handled below this loop and elsewhere */
151
151
}
152
+ Attribute :: Parsed ( AttributeKind :: Cold ( attr_span) ) => {
153
+ self . check_cold ( hir_id, * attr_span, span, target)
154
+ }
152
155
Attribute :: Parsed ( AttributeKind :: Align { align, span : repr_span } ) => {
153
156
self . check_align ( span, target, * align, * repr_span)
154
157
}
155
-
156
158
Attribute :: Parsed (
157
159
AttributeKind :: BodyStability { .. }
158
160
| AttributeKind :: ConstStabilityIndirect
@@ -245,7 +247,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
245
247
[ sym:: ffi_pure, ..] => self . check_ffi_pure ( attr. span ( ) , attrs, target) ,
246
248
[ sym:: ffi_const, ..] => self . check_ffi_const ( attr. span ( ) , target) ,
247
249
[ sym:: link_ordinal, ..] => self . check_link_ordinal ( attr, span, target) ,
248
- [ sym:: cold, ..] => self . check_cold ( hir_id, attr, span, target) ,
249
250
[ sym:: link, ..] => self . check_link ( hir_id, attr, span, target) ,
250
251
[ sym:: link_name, ..] => self . check_link_name ( hir_id, attr, span, target) ,
251
252
[ sym:: link_section, ..] => self . check_link_section ( hir_id, attr, span, target) ,
@@ -651,8 +652,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
651
652
sym:: repr,
652
653
sym:: align,
653
654
sym:: rustc_std_internal_symbol,
654
- // code generation
655
- sym:: cold,
656
655
// documentation
657
656
sym:: doc,
658
657
] ;
@@ -688,7 +687,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
688
687
Attribute :: Parsed (
689
688
AttributeKind :: Deprecation { .. }
690
689
| AttributeKind :: Repr { .. }
691
- | AttributeKind :: Align { .. } ,
690
+ | AttributeKind :: Align { .. }
691
+ | AttributeKind :: Cold ( ..) ,
692
692
) => {
693
693
continue ;
694
694
}
@@ -1640,23 +1640,23 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
1640
1640
}
1641
1641
1642
1642
/// Checks if `#[cold]` is applied to a non-function.
1643
- fn check_cold ( & self , hir_id : HirId , attr : & Attribute , span : Span , target : Target ) {
1643
+ fn check_cold ( & self , hir_id : HirId , attr_span : Span , span : Span , target : Target ) {
1644
1644
match target {
1645
1645
Target :: Fn | Target :: Method ( ..) | Target :: ForeignFn | Target :: Closure => { }
1646
1646
// FIXME(#80564): We permit struct fields, match arms and macro defs to have an
1647
1647
// `#[cold]` attribute with just a lint, because we previously
1648
1648
// erroneously allowed it and some crates used it accidentally, to be compatible
1649
1649
// with crates depending on them, we can't throw an error here.
1650
1650
Target :: Field | Target :: Arm | Target :: MacroDef => {
1651
- self . inline_attr_str_error_with_macro_def ( hir_id, attr . span ( ) , "cold" ) ;
1651
+ self . inline_attr_str_error_with_macro_def ( hir_id, attr_span , "cold" ) ;
1652
1652
}
1653
1653
_ => {
1654
1654
// FIXME: #[cold] was previously allowed on non-functions and some crates used
1655
1655
// this, so only emit a warning.
1656
1656
self . tcx . emit_node_span_lint (
1657
1657
UNUSED_ATTRIBUTES ,
1658
1658
hir_id,
1659
- attr . span ( ) ,
1659
+ attr_span ,
1660
1660
errors:: Cold { span, on_crate : hir_id == CRATE_HIR_ID } ,
1661
1661
) ;
1662
1662
}
0 commit comments