@@ -166,6 +166,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
166
166
& Attribute :: Parsed ( AttributeKind :: MayDangle ( attr_span) ) => {
167
167
self . check_may_dangle ( hir_id, attr_span)
168
168
}
169
+ Attribute :: Parsed ( AttributeKind :: NoMangle ( attr_span) ) => {
170
+ self . check_no_mangle ( hir_id, * attr_span, span, target)
171
+ }
169
172
Attribute :: Unparsed ( _) => {
170
173
match attr. path ( ) . as_slice ( ) {
171
174
[ sym:: diagnostic, sym:: do_not_recommend, ..] => {
@@ -252,7 +255,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
252
255
[ sym:: link, ..] => self . check_link ( hir_id, attr, span, target) ,
253
256
[ sym:: link_name, ..] => self . check_link_name ( hir_id, attr, span, target) ,
254
257
[ sym:: link_section, ..] => self . check_link_section ( hir_id, attr, span, target) ,
255
- [ sym:: no_mangle, ..] => self . check_no_mangle ( hir_id, attr, span, target) ,
256
258
[ sym:: macro_use, ..] | [ sym:: macro_escape, ..] => {
257
259
self . check_macro_use ( hir_id, attr, target)
258
260
}
@@ -690,6 +692,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
690
692
AttributeKind :: Deprecation { .. }
691
693
| AttributeKind :: Repr { .. }
692
694
| AttributeKind :: Align { .. }
695
+ | AttributeKind :: NoMangle ( ..)
693
696
| AttributeKind :: Cold ( ..) ,
694
697
) => {
695
698
continue ;
@@ -1938,7 +1941,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
1938
1941
}
1939
1942
1940
1943
/// Checks if `#[no_mangle]` is applied to a function or static.
1941
- fn check_no_mangle ( & self , hir_id : HirId , attr : & Attribute , span : Span , target : Target ) {
1944
+ fn check_no_mangle ( & self , hir_id : HirId , attr_span : Span , span : Span , target : Target ) {
1942
1945
match target {
1943
1946
Target :: Static | Target :: Fn => { }
1944
1947
Target :: Method ( ..) if self . is_impl_item ( hir_id) => { }
@@ -1947,7 +1950,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
1947
1950
// erroneously allowed it and some crates used it accidentally, to be compatible
1948
1951
// with crates depending on them, we can't throw an error here.
1949
1952
Target :: Field | Target :: Arm | Target :: MacroDef => {
1950
- self . inline_attr_str_error_with_macro_def ( hir_id, attr . span ( ) , "no_mangle" ) ;
1953
+ self . inline_attr_str_error_with_macro_def ( hir_id, attr_span , "no_mangle" ) ;
1951
1954
}
1952
1955
// FIXME: #[no_mangle] was previously allowed on non-functions/statics, this should be an error
1953
1956
// The error should specify that the item that is wrong is specifically a *foreign* fn/static
@@ -1961,8 +1964,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
1961
1964
self . tcx . emit_node_span_lint (
1962
1965
UNUSED_ATTRIBUTES ,
1963
1966
hir_id,
1964
- attr . span ( ) ,
1965
- errors:: NoMangleForeign { span, attr_span : attr . span ( ) , foreign_item_kind } ,
1967
+ attr_span ,
1968
+ errors:: NoMangleForeign { span, attr_span, foreign_item_kind } ,
1966
1969
) ;
1967
1970
}
1968
1971
_ => {
@@ -1971,7 +1974,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
1971
1974
self . tcx . emit_node_span_lint (
1972
1975
UNUSED_ATTRIBUTES ,
1973
1976
hir_id,
1974
- attr . span ( ) ,
1977
+ attr_span ,
1975
1978
errors:: NoMangle { span } ,
1976
1979
) ;
1977
1980
}
0 commit comments