@@ -163,6 +163,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
163163 Attribute :: Parsed ( AttributeKind :: AsPtr ( attr_span) ) => {
164164 self . check_applied_to_fn_or_method ( hir_id, * attr_span, span, target)
165165 }
166+ Attribute :: Parsed ( AttributeKind :: NoMangle ( attr_span) ) => {
167+ self . check_no_mangle ( hir_id, * attr_span, span, target)
168+ }
166169 Attribute :: Unparsed ( _) => {
167170 match attr. path ( ) . as_slice ( ) {
168171 [ sym:: diagnostic, sym:: do_not_recommend, ..] => {
@@ -250,7 +253,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
250253 [ sym:: link, ..] => self . check_link ( hir_id, attr, span, target) ,
251254 [ sym:: link_name, ..] => self . check_link_name ( hir_id, attr, span, target) ,
252255 [ sym:: link_section, ..] => self . check_link_section ( hir_id, attr, span, target) ,
253- [ sym:: no_mangle, ..] => self . check_no_mangle ( hir_id, attr, span, target) ,
254256 [ sym:: macro_use, ..] | [ sym:: macro_escape, ..] => {
255257 self . check_macro_use ( hir_id, attr, target)
256258 }
@@ -688,6 +690,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
688690 AttributeKind :: Deprecation { .. }
689691 | AttributeKind :: Repr { .. }
690692 | AttributeKind :: Align { .. }
693+ | AttributeKind :: NoMangle ( ..)
691694 | AttributeKind :: Cold ( ..) ,
692695 ) => {
693696 continue ;
@@ -1936,7 +1939,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
19361939 }
19371940
19381941 /// Checks if `#[no_mangle]` is applied to a function or static.
1939- fn check_no_mangle ( & self , hir_id : HirId , attr : & Attribute , span : Span , target : Target ) {
1942+ fn check_no_mangle ( & self , hir_id : HirId , attr_span : Span , span : Span , target : Target ) {
19401943 match target {
19411944 Target :: Static | Target :: Fn => { }
19421945 Target :: Method ( ..) if self . is_impl_item ( hir_id) => { }
@@ -1945,7 +1948,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
19451948 // erroneously allowed it and some crates used it accidentally, to be compatible
19461949 // with crates depending on them, we can't throw an error here.
19471950 Target :: Field | Target :: Arm | Target :: MacroDef => {
1948- self . inline_attr_str_error_with_macro_def ( hir_id, attr . span ( ) , "no_mangle" ) ;
1951+ self . inline_attr_str_error_with_macro_def ( hir_id, attr_span , "no_mangle" ) ;
19491952 }
19501953 // FIXME: #[no_mangle] was previously allowed on non-functions/statics, this should be an error
19511954 // The error should specify that the item that is wrong is specifically a *foreign* fn/static
@@ -1959,8 +1962,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
19591962 self . tcx . emit_node_span_lint (
19601963 UNUSED_ATTRIBUTES ,
19611964 hir_id,
1962- attr . span ( ) ,
1963- errors:: NoMangleForeign { span, attr_span : attr . span ( ) , foreign_item_kind } ,
1965+ attr_span ,
1966+ errors:: NoMangleForeign { span, attr_span, foreign_item_kind } ,
19641967 ) ;
19651968 }
19661969 _ => {
@@ -1969,7 +1972,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
19691972 self . tcx . emit_node_span_lint (
19701973 UNUSED_ATTRIBUTES ,
19711974 hir_id,
1972- attr . span ( ) ,
1975+ attr_span ,
19731976 errors:: NoMangle { span } ,
19741977 ) ;
19751978 }
0 commit comments