3
3
use rustc_ast:: token:: Delimiter ;
4
4
use rustc_ast:: tokenstream:: DelimSpan ;
5
5
use rustc_ast:: {
6
- self as ast, AttrArgs , Attribute , DelimArgs , MetaItem , MetaItemInner , MetaItemKind , Safety ,
6
+ self as ast, AttrArgs , Attribute , DelimArgs , MetaItem , MetaItemInner , MetaItemKind , NodeId ,
7
+ Safety ,
7
8
} ;
8
9
use rustc_errors:: { Applicability , FatalError , PResult } ;
9
10
use rustc_feature:: { AttributeSafety , AttributeTemplate , BUILTIN_ATTRIBUTE_MAP , BuiltinAttribute } ;
@@ -15,7 +16,7 @@ use rustc_span::{Span, Symbol, sym};
15
16
16
17
use crate :: { errors, parse_in} ;
17
18
18
- pub fn check_attr ( psess : & ParseSess , attr : & Attribute ) {
19
+ pub fn check_attr ( psess : & ParseSess , attr : & Attribute , id : NodeId ) {
19
20
if attr. is_doc_comment ( ) || attr. has_name ( sym:: cfg_trace) || attr. has_name ( sym:: cfg_attr_trace)
20
21
{
21
22
return ;
@@ -26,7 +27,7 @@ pub fn check_attr(psess: &ParseSess, attr: &Attribute) {
26
27
27
28
// All non-builtin attributes are considered safe
28
29
let safety = attr_info. map ( |x| x. safety ) . unwrap_or ( AttributeSafety :: Normal ) ;
29
- check_attribute_safety ( psess, safety, attr) ;
30
+ check_attribute_safety ( psess, safety, attr, id ) ;
30
31
31
32
// Check input tokens for built-in and key-value attributes.
32
33
match attr_info {
@@ -154,7 +155,12 @@ fn is_attr_template_compatible(template: &AttributeTemplate, meta: &ast::MetaIte
154
155
}
155
156
}
156
157
157
- pub fn check_attribute_safety ( psess : & ParseSess , safety : AttributeSafety , attr : & Attribute ) {
158
+ pub fn check_attribute_safety (
159
+ psess : & ParseSess ,
160
+ safety : AttributeSafety ,
161
+ attr : & Attribute ,
162
+ id : NodeId ,
163
+ ) {
158
164
let attr_item = attr. get_normal_item ( ) ;
159
165
160
166
if let AttributeSafety :: Unsafe { unsafe_since } = safety {
@@ -185,7 +191,7 @@ pub fn check_attribute_safety(psess: &ParseSess, safety: AttributeSafety, attr:
185
191
psess. buffer_lint (
186
192
UNSAFE_ATTR_OUTSIDE_UNSAFE ,
187
193
path_span,
188
- ast :: CRATE_NODE_ID ,
194
+ id ,
189
195
BuiltinLintDiag :: UnsafeAttrOutsideUnsafe {
190
196
attribute_name_span : path_span,
191
197
sugg_spans : ( diag_span. shrink_to_lo ( ) , diag_span. shrink_to_hi ( ) ) ,
0 commit comments