@@ -177,6 +177,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
177
177
Attribute :: Parsed ( AttributeKind :: Align { align, span : repr_span } ) => {
178
178
self . check_align ( span, target, * align, * repr_span)
179
179
}
180
+ Attribute :: Parsed ( AttributeKind :: LinkSection { span : attr_span, .. } ) => {
181
+ self . check_link_section ( hir_id, * attr_span, span, target)
182
+ }
180
183
Attribute :: Parsed ( AttributeKind :: Naked ( attr_span) ) => {
181
184
self . check_naked ( hir_id, * attr_span, span, target)
182
185
}
@@ -286,7 +289,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
286
289
[ sym:: ffi_const, ..] => self . check_ffi_const ( attr. span ( ) , target) ,
287
290
[ sym:: link_ordinal, ..] => self . check_link_ordinal ( attr, span, target) ,
288
291
[ sym:: link, ..] => self . check_link ( hir_id, attr, span, target) ,
289
- [ sym:: link_section, ..] => self . check_link_section ( hir_id, attr, span, target) ,
290
292
[ sym:: macro_use, ..] | [ sym:: macro_escape, ..] => {
291
293
self . check_macro_use ( hir_id, attr, target)
292
294
}
@@ -1831,23 +1833,23 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
1831
1833
}
1832
1834
1833
1835
/// 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 ) {
1835
1837
match target {
1836
1838
Target :: Static | Target :: Fn | Target :: Method ( ..) => { }
1837
1839
// FIXME(#80564): We permit struct fields, match arms and macro defs to have an
1838
1840
// `#[link_section]` attribute with just a lint, because we previously
1839
1841
// erroneously allowed it and some crates used it accidentally, to be compatible
1840
1842
// with crates depending on them, we can't throw an error here.
1841
1843
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" ) ;
1843
1845
}
1844
1846
_ => {
1845
1847
// FIXME: #[link_section] was previously allowed on non-functions/statics and some
1846
1848
// crates used this, so only emit a warning.
1847
1849
self . tcx . emit_node_span_lint (
1848
1850
UNUSED_ATTRIBUTES ,
1849
1851
hir_id,
1850
- attr . span ( ) ,
1852
+ attr_span ,
1851
1853
errors:: LinkSection { span } ,
1852
1854
) ;
1853
1855
}
0 commit comments