@@ -174,6 +174,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
174174 Attribute :: Parsed ( AttributeKind :: MustUse { span, .. } ) => {
175175 self . check_must_use ( hir_id, * span, target)
176176 }
177+ Attribute :: Parsed ( AttributeKind :: NoMangle ( attr_span) ) => {
178+ self . check_no_mangle ( hir_id, * attr_span, span, target)
179+ }
177180 Attribute :: Unparsed ( attr_item) => {
178181 style = Some ( attr_item. style ) ;
179182 match attr. path ( ) . as_slice ( ) {
@@ -261,7 +264,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
261264 [ sym:: link, ..] => self . check_link ( hir_id, attr, span, target) ,
262265 [ sym:: link_name, ..] => self . check_link_name ( hir_id, attr, span, target) ,
263266 [ sym:: link_section, ..] => self . check_link_section ( hir_id, attr, span, target) ,
264- [ sym:: no_mangle, ..] => self . check_no_mangle ( hir_id, attr, span, target) ,
265267 [ sym:: macro_use, ..] | [ sym:: macro_escape, ..] => {
266268 self . check_macro_use ( hir_id, attr, target)
267269 }
@@ -698,6 +700,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
698700 AttributeKind :: Deprecation { .. }
699701 | AttributeKind :: Repr { .. }
700702 | AttributeKind :: Align { .. }
703+ | AttributeKind :: NoMangle ( ..)
701704 | AttributeKind :: Cold ( ..)
702705 | AttributeKind :: MustUse { .. } ,
703706 ) => {
@@ -1952,7 +1955,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
19521955 }
19531956
19541957 /// Checks if `#[no_mangle]` is applied to a function or static.
1955- fn check_no_mangle ( & self , hir_id : HirId , attr : & Attribute , span : Span , target : Target ) {
1958+ fn check_no_mangle ( & self , hir_id : HirId , attr_span : Span , span : Span , target : Target ) {
19561959 match target {
19571960 Target :: Static | Target :: Fn => { }
19581961 Target :: Method ( ..) if self . is_impl_item ( hir_id) => { }
@@ -1961,7 +1964,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
19611964 // erroneously allowed it and some crates used it accidentally, to be compatible
19621965 // with crates depending on them, we can't throw an error here.
19631966 Target :: Field | Target :: Arm | Target :: MacroDef => {
1964- self . inline_attr_str_error_with_macro_def ( hir_id, attr . span ( ) , "no_mangle" ) ;
1967+ self . inline_attr_str_error_with_macro_def ( hir_id, attr_span , "no_mangle" ) ;
19651968 }
19661969 // FIXME: #[no_mangle] was previously allowed on non-functions/statics, this should be an error
19671970 // The error should specify that the item that is wrong is specifically a *foreign* fn/static
@@ -1975,8 +1978,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
19751978 self . tcx . emit_node_span_lint (
19761979 UNUSED_ATTRIBUTES ,
19771980 hir_id,
1978- attr . span ( ) ,
1979- errors:: NoMangleForeign { span, attr_span : attr . span ( ) , foreign_item_kind } ,
1981+ attr_span ,
1982+ errors:: NoMangleForeign { span, attr_span, foreign_item_kind } ,
19801983 ) ;
19811984 }
19821985 _ => {
@@ -1985,7 +1988,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
19851988 self . tcx . emit_node_span_lint (
19861989 UNUSED_ATTRIBUTES ,
19871990 hir_id,
1988- attr . span ( ) ,
1991+ attr_span ,
19891992 errors:: NoMangle { span } ,
19901993 ) ;
19911994 }
0 commit comments