@@ -177,6 +177,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
177177 Attribute :: Parsed ( AttributeKind :: Align { align, span : repr_span } ) => {
178178 self . check_align ( span, target, * align, * repr_span)
179179 }
180+ Attribute :: Parsed ( AttributeKind :: LinkSection { span : attr_span, .. } ) => {
181+ self . check_link_section ( hir_id, * attr_span, span, target)
182+ }
180183 Attribute :: Parsed ( AttributeKind :: Naked ( attr_span) ) => {
181184 self . check_naked ( hir_id, * attr_span, span, target)
182185 }
@@ -286,7 +289,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
286289 [ sym:: ffi_const, ..] => self . check_ffi_const ( attr. span ( ) , target) ,
287290 [ sym:: link_ordinal, ..] => self . check_link_ordinal ( attr, span, target) ,
288291 [ sym:: link, ..] => self . check_link ( hir_id, attr, span, target) ,
289- [ sym:: link_section, ..] => self . check_link_section ( hir_id, attr, span, target) ,
290292 [ sym:: macro_use, ..] | [ sym:: macro_escape, ..] => {
291293 self . check_macro_use ( hir_id, attr, target)
292294 }
@@ -1831,23 +1833,23 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
18311833 }
18321834
18331835 /// Checks if `#[link_section]` is applied to a function or static.
1834- fn check_link_section ( & self , hir_id : HirId , attr : & Attribute , span : Span , target : Target ) {
1836+ fn check_link_section ( & self , hir_id : HirId , attr_span : Span , span : Span , target : Target ) {
18351837 match target {
18361838 Target :: Static | Target :: Fn | Target :: Method ( ..) => { }
18371839 // FIXME(#80564): We permit struct fields, match arms and macro defs to have an
18381840 // `#[link_section]` attribute with just a lint, because we previously
18391841 // erroneously allowed it and some crates used it accidentally, to be compatible
18401842 // with crates depending on them, we can't throw an error here.
18411843 Target :: Field | Target :: Arm | Target :: MacroDef => {
1842- self . inline_attr_str_error_with_macro_def ( hir_id, attr . span ( ) , "link_section" ) ;
1844+ self . inline_attr_str_error_with_macro_def ( hir_id, attr_span , "link_section" ) ;
18431845 }
18441846 _ => {
18451847 // FIXME: #[link_section] was previously allowed on non-functions/statics and some
18461848 // crates used this, so only emit a warning.
18471849 self . tcx . emit_node_span_lint (
18481850 UNUSED_ATTRIBUTES ,
18491851 hir_id,
1850- attr . span ( ) ,
1852+ attr_span ,
18511853 errors:: LinkSection { span } ,
18521854 ) ;
18531855 }
0 commit comments