@@ -174,6 +174,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
174
174
Attribute :: Parsed ( AttributeKind :: MustUse { span, .. } ) => {
175
175
self . check_must_use ( hir_id, * span, target)
176
176
}
177
+ Attribute :: Parsed ( AttributeKind :: NoMangle ( attr_span) ) => {
178
+ self . check_no_mangle ( hir_id, * attr_span, span, target)
179
+ }
177
180
Attribute :: Unparsed ( attr_item) => {
178
181
style = Some ( attr_item. style ) ;
179
182
match attr. path ( ) . as_slice ( ) {
@@ -261,7 +264,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
261
264
[ sym:: link, ..] => self . check_link ( hir_id, attr, span, target) ,
262
265
[ sym:: link_name, ..] => self . check_link_name ( hir_id, attr, span, target) ,
263
266
[ sym:: link_section, ..] => self . check_link_section ( hir_id, attr, span, target) ,
264
- [ sym:: no_mangle, ..] => self . check_no_mangle ( hir_id, attr, span, target) ,
265
267
[ sym:: macro_use, ..] | [ sym:: macro_escape, ..] => {
266
268
self . check_macro_use ( hir_id, attr, target)
267
269
}
@@ -698,6 +700,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
698
700
AttributeKind :: Deprecation { .. }
699
701
| AttributeKind :: Repr { .. }
700
702
| AttributeKind :: Align { .. }
703
+ | AttributeKind :: NoMangle ( ..)
701
704
| AttributeKind :: Cold ( ..)
702
705
| AttributeKind :: MustUse { .. } ,
703
706
) => {
@@ -1952,7 +1955,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
1952
1955
}
1953
1956
1954
1957
/// Checks if `#[no_mangle]` is applied to a function or static.
1955
- fn check_no_mangle ( & self , hir_id : HirId , attr : & Attribute , span : Span , target : Target ) {
1958
+ fn check_no_mangle ( & self , hir_id : HirId , attr_span : Span , span : Span , target : Target ) {
1956
1959
match target {
1957
1960
Target :: Static | Target :: Fn => { }
1958
1961
Target :: Method ( ..) if self . is_impl_item ( hir_id) => { }
@@ -1961,7 +1964,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
1961
1964
// erroneously allowed it and some crates used it accidentally, to be compatible
1962
1965
// with crates depending on them, we can't throw an error here.
1963
1966
Target :: Field | Target :: Arm | Target :: MacroDef => {
1964
- self . inline_attr_str_error_with_macro_def ( hir_id, attr . span ( ) , "no_mangle" ) ;
1967
+ self . inline_attr_str_error_with_macro_def ( hir_id, attr_span , "no_mangle" ) ;
1965
1968
}
1966
1969
// FIXME: #[no_mangle] was previously allowed on non-functions/statics, this should be an error
1967
1970
// The error should specify that the item that is wrong is specifically a *foreign* fn/static
@@ -1975,8 +1978,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
1975
1978
self . tcx . emit_node_span_lint (
1976
1979
UNUSED_ATTRIBUTES ,
1977
1980
hir_id,
1978
- attr . span ( ) ,
1979
- errors:: NoMangleForeign { span, attr_span : attr . span ( ) , foreign_item_kind } ,
1981
+ attr_span ,
1982
+ errors:: NoMangleForeign { span, attr_span, foreign_item_kind } ,
1980
1983
) ;
1981
1984
}
1982
1985
_ => {
@@ -1985,7 +1988,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
1985
1988
self . tcx . emit_node_span_lint (
1986
1989
UNUSED_ATTRIBUTES ,
1987
1990
hir_id,
1988
- attr . span ( ) ,
1991
+ attr_span ,
1989
1992
errors:: NoMangle { span } ,
1990
1993
) ;
1991
1994
}
0 commit comments