@@ -163,6 +163,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
163
163
Attribute :: Parsed ( AttributeKind :: AsPtr ( attr_span) ) => {
164
164
self . check_applied_to_fn_or_method ( hir_id, * attr_span, span, target)
165
165
}
166
+ Attribute :: Parsed ( AttributeKind :: NoMangle ( attr_span) ) => {
167
+ self . check_no_mangle ( hir_id, * attr_span, span, target)
168
+ }
166
169
Attribute :: Unparsed ( _) => {
167
170
match attr. path ( ) . as_slice ( ) {
168
171
[ sym:: diagnostic, sym:: do_not_recommend, ..] => {
@@ -250,7 +253,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
250
253
[ sym:: link, ..] => self . check_link ( hir_id, attr, span, target) ,
251
254
[ sym:: link_name, ..] => self . check_link_name ( hir_id, attr, span, target) ,
252
255
[ 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) ,
254
256
[ sym:: macro_use, ..] | [ sym:: macro_escape, ..] => {
255
257
self . check_macro_use ( hir_id, attr, target)
256
258
}
@@ -688,6 +690,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
688
690
AttributeKind :: Deprecation { .. }
689
691
| AttributeKind :: Repr { .. }
690
692
| AttributeKind :: Align { .. }
693
+ | AttributeKind :: NoMangle ( ..)
691
694
| AttributeKind :: Cold ( ..) ,
692
695
) => {
693
696
continue ;
@@ -1936,7 +1939,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
1936
1939
}
1937
1940
1938
1941
/// 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 ) {
1940
1943
match target {
1941
1944
Target :: Static | Target :: Fn => { }
1942
1945
Target :: Method ( ..) if self . is_impl_item ( hir_id) => { }
@@ -1945,7 +1948,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
1945
1948
// erroneously allowed it and some crates used it accidentally, to be compatible
1946
1949
// with crates depending on them, we can't throw an error here.
1947
1950
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" ) ;
1949
1952
}
1950
1953
// FIXME: #[no_mangle] was previously allowed on non-functions/statics, this should be an error
1951
1954
// The error should specify that the item that is wrong is specifically a *foreign* fn/static
@@ -1959,8 +1962,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
1959
1962
self . tcx . emit_node_span_lint (
1960
1963
UNUSED_ATTRIBUTES ,
1961
1964
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 } ,
1964
1967
) ;
1965
1968
}
1966
1969
_ => {
@@ -1969,7 +1972,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
1969
1972
self . tcx . emit_node_span_lint (
1970
1973
UNUSED_ATTRIBUTES ,
1971
1974
hir_id,
1972
- attr . span ( ) ,
1975
+ attr_span ,
1973
1976
errors:: NoMangle { span } ,
1974
1977
) ;
1975
1978
}
0 commit comments