@@ -171,6 +171,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
171171 Attribute :: Parsed ( AttributeKind :: MayDangle ( attr_span) ) => {
172172 self . check_may_dangle ( hir_id, * attr_span)
173173 }
174+ Attribute :: Parsed ( AttributeKind :: NoMangle ( attr_span) ) => {
175+ self . check_no_mangle ( hir_id, * attr_span, span, target)
176+ }
174177 Attribute :: Unparsed ( attr_item) => {
175178 style = Some ( attr_item. style ) ;
176179 match attr. path ( ) . as_slice ( ) {
@@ -259,7 +262,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
259262 [ sym:: link, ..] => self . check_link ( hir_id, attr, span, target) ,
260263 [ sym:: link_name, ..] => self . check_link_name ( hir_id, attr, span, target) ,
261264 [ sym:: link_section, ..] => self . check_link_section ( hir_id, attr, span, target) ,
262- [ sym:: no_mangle, ..] => self . check_no_mangle ( hir_id, attr, span, target) ,
263265 [ sym:: macro_use, ..] | [ sym:: macro_escape, ..] => {
264266 self . check_macro_use ( hir_id, attr, target)
265267 }
@@ -696,6 +698,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
696698 AttributeKind :: Deprecation { .. }
697699 | AttributeKind :: Repr { .. }
698700 | AttributeKind :: Align { .. }
701+ | AttributeKind :: NoMangle ( ..)
699702 | AttributeKind :: Cold ( ..) ,
700703 ) => {
701704 continue ;
@@ -1949,7 +1952,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
19491952 }
19501953
19511954 /// Checks if `#[no_mangle]` is applied to a function or static.
1952- fn check_no_mangle ( & self , hir_id : HirId , attr : & Attribute , span : Span , target : Target ) {
1955+ fn check_no_mangle ( & self , hir_id : HirId , attr_span : Span , span : Span , target : Target ) {
19531956 match target {
19541957 Target :: Static | Target :: Fn => { }
19551958 Target :: Method ( ..) if self . is_impl_item ( hir_id) => { }
@@ -1958,7 +1961,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
19581961 // erroneously allowed it and some crates used it accidentally, to be compatible
19591962 // with crates depending on them, we can't throw an error here.
19601963 Target :: Field | Target :: Arm | Target :: MacroDef => {
1961- self . inline_attr_str_error_with_macro_def ( hir_id, attr . span ( ) , "no_mangle" ) ;
1964+ self . inline_attr_str_error_with_macro_def ( hir_id, attr_span , "no_mangle" ) ;
19621965 }
19631966 // FIXME: #[no_mangle] was previously allowed on non-functions/statics, this should be an error
19641967 // The error should specify that the item that is wrong is specifically a *foreign* fn/static
@@ -1972,8 +1975,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
19721975 self . tcx . emit_node_span_lint (
19731976 UNUSED_ATTRIBUTES ,
19741977 hir_id,
1975- attr . span ( ) ,
1976- errors:: NoMangleForeign { span, attr_span : attr . span ( ) , foreign_item_kind } ,
1978+ attr_span ,
1979+ errors:: NoMangleForeign { span, attr_span, foreign_item_kind } ,
19771980 ) ;
19781981 }
19791982 _ => {
@@ -1982,7 +1985,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
19821985 self . tcx . emit_node_span_lint (
19831986 UNUSED_ATTRIBUTES ,
19841987 hir_id,
1985- attr . span ( ) ,
1988+ attr_span ,
19861989 errors:: NoMangle { span } ,
19871990 ) ;
19881991 }
0 commit comments