@@ -171,6 +171,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
171
171
Attribute :: Parsed ( AttributeKind :: MayDangle ( attr_span) ) => {
172
172
self . check_may_dangle ( hir_id, * attr_span)
173
173
}
174
+ Attribute :: Parsed ( AttributeKind :: NoMangle ( attr_span) ) => {
175
+ self . check_no_mangle ( hir_id, * attr_span, span, target)
176
+ }
174
177
Attribute :: Unparsed ( attr_item) => {
175
178
style = Some ( attr_item. style ) ;
176
179
match attr. path ( ) . as_slice ( ) {
@@ -259,7 +262,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
259
262
[ sym:: link, ..] => self . check_link ( hir_id, attr, span, target) ,
260
263
[ sym:: link_name, ..] => self . check_link_name ( hir_id, attr, span, target) ,
261
264
[ 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) ,
263
265
[ sym:: macro_use, ..] | [ sym:: macro_escape, ..] => {
264
266
self . check_macro_use ( hir_id, attr, target)
265
267
}
@@ -696,6 +698,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
696
698
AttributeKind :: Deprecation { .. }
697
699
| AttributeKind :: Repr { .. }
698
700
| AttributeKind :: Align { .. }
701
+ | AttributeKind :: NoMangle ( ..)
699
702
| AttributeKind :: Cold ( ..) ,
700
703
) => {
701
704
continue ;
@@ -1949,7 +1952,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
1949
1952
}
1950
1953
1951
1954
/// 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 ) {
1953
1956
match target {
1954
1957
Target :: Static | Target :: Fn => { }
1955
1958
Target :: Method ( ..) if self . is_impl_item ( hir_id) => { }
@@ -1958,7 +1961,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
1958
1961
// erroneously allowed it and some crates used it accidentally, to be compatible
1959
1962
// with crates depending on them, we can't throw an error here.
1960
1963
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" ) ;
1962
1965
}
1963
1966
// FIXME: #[no_mangle] was previously allowed on non-functions/statics, this should be an error
1964
1967
// The error should specify that the item that is wrong is specifically a *foreign* fn/static
@@ -1972,8 +1975,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
1972
1975
self . tcx . emit_node_span_lint (
1973
1976
UNUSED_ATTRIBUTES ,
1974
1977
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 } ,
1977
1980
) ;
1978
1981
}
1979
1982
_ => {
@@ -1982,7 +1985,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
1982
1985
self . tcx . emit_node_span_lint (
1983
1986
UNUSED_ATTRIBUTES ,
1984
1987
hir_id,
1985
- attr . span ( ) ,
1988
+ attr_span ,
1986
1989
errors:: NoMangle { span } ,
1987
1990
) ;
1988
1991
}
0 commit comments