@@ -6,10 +6,10 @@ use rustc_ast::{AttrItemKind, AttrStyle, NodeId, Safety};
66use rustc_errors:: DiagCtxtHandle ;
77use rustc_feature:: { AttributeTemplate , Features } ;
88use rustc_hir:: attrs:: AttributeKind ;
9- use rustc_hir:: lints:: AttributeLint ;
9+ use rustc_hir:: lints:: AttributeLintKind ;
1010use rustc_hir:: { AttrArgs , AttrItem , AttrPath , Attribute , HashIgnoredAttrId , Target } ;
1111use rustc_session:: Session ;
12- use rustc_session:: lint:: BuiltinLintDiag ;
12+ use rustc_session:: lint:: { BuiltinLintDiag , LintId } ;
1313use rustc_span:: { DUMMY_SP , Span , Symbol , sym} ;
1414
1515use crate :: context:: { AcceptContext , FinalizeContext , SharedContext , Stage } ;
@@ -113,16 +113,15 @@ impl<'sess> AttributeParser<'sess, Early> {
113113 p. parse_attribute_list (
114114 attrs,
115115 target_span,
116- target_node_id,
117116 target,
118117 OmitDoc :: Skip ,
119118 std:: convert:: identity,
120- |lint | {
119+ |lint_id , span , kind | {
121120 sess. psess . buffer_lint (
122- lint . lint_id . lint ,
123- lint . span ,
124- lint . id ,
125- BuiltinLintDiag :: AttributeLint ( lint . kind ) ,
121+ lint_id. lint ,
122+ span,
123+ target_node_id ,
124+ BuiltinLintDiag :: AttributeLint ( kind) ,
126125 )
127126 } ,
128127 )
@@ -135,6 +134,7 @@ impl<'sess> AttributeParser<'sess, Early> {
135134 attr : & ast:: Attribute ,
136135 target_span : Span ,
137136 target_node_id : NodeId ,
137+ target : Target ,
138138 features : Option < & ' sess Features > ,
139139 emit_errors : ShouldEmit ,
140140 parse_fn : fn ( cx : & mut AcceptContext < ' _ , ' _ , Early > , item : & ArgParser ) -> Option < T > ,
@@ -163,6 +163,7 @@ impl<'sess> AttributeParser<'sess, Early> {
163163 ParsedDescription :: Attribute ,
164164 target_span,
165165 target_node_id,
166+ target,
166167 features,
167168 emit_errors,
168169 & args,
@@ -183,6 +184,7 @@ impl<'sess> AttributeParser<'sess, Early> {
183184 parsed_description : ParsedDescription ,
184185 target_span : Span ,
185186 target_node_id : NodeId ,
187+ target : Target ,
186188 features : Option < & ' sess Features > ,
187189 emit_errors : ShouldEmit ,
188190 args : & I ,
@@ -196,29 +198,22 @@ impl<'sess> AttributeParser<'sess, Early> {
196198 sess,
197199 stage : Early { emit_errors } ,
198200 } ;
199- let mut emit_lint = |lint : AttributeLint < NodeId > | {
201+ let mut emit_lint = |lint_id : LintId , span : Span , kind : AttributeLintKind | {
200202 sess. psess . buffer_lint (
201- lint . lint_id . lint ,
202- lint . span ,
203- lint . id ,
204- BuiltinLintDiag :: AttributeLint ( lint . kind ) ,
203+ lint_id. lint ,
204+ span,
205+ target_node_id ,
206+ BuiltinLintDiag :: AttributeLint ( kind) ,
205207 )
206208 } ;
207209 if let Some ( safety) = attr_safety {
208- parser. check_attribute_safety (
209- & attr_path,
210- inner_span,
211- safety,
212- & mut emit_lint,
213- target_node_id,
214- )
210+ parser. check_attribute_safety ( & attr_path, inner_span, safety, & mut emit_lint)
215211 }
216212 let mut cx: AcceptContext < ' _ , ' sess , Early > = AcceptContext {
217213 shared : SharedContext {
218214 cx : & mut parser,
219215 target_span,
220- target_id : target_node_id,
221- target : None ,
216+ target,
222217 emit_lint : & mut emit_lint,
223218 } ,
224219 attr_span,
@@ -266,11 +261,10 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
266261 & mut self ,
267262 attrs : & [ ast:: Attribute ] ,
268263 target_span : Span ,
269- target_id : S :: Id ,
270264 target : Target ,
271265 omit_doc : OmitDoc ,
272266 lower_span : impl Copy + Fn ( Span ) -> Span ,
273- mut emit_lint : impl FnMut ( AttributeLint < S :: Id > ) ,
267+ mut emit_lint : impl FnMut ( LintId , Span , AttributeLintKind ) ,
274268 ) -> Vec < Attribute > {
275269 let mut attributes = Vec :: new ( ) ;
276270 let mut attr_paths: Vec < RefPathParser < ' _ > > = Vec :: new ( ) ;
@@ -326,7 +320,6 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
326320 lower_span ( n. item . span ( ) ) ,
327321 n. item . unsafety ,
328322 & mut emit_lint,
329- target_id,
330323 ) ;
331324
332325 let parts =
@@ -378,8 +371,7 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
378371 shared : SharedContext {
379372 cx : self ,
380373 target_span,
381- target_id,
382- target : Some ( target) ,
374+ target,
383375 emit_lint : & mut emit_lint,
384376 } ,
385377 attr_span,
@@ -427,13 +419,7 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
427419 early_parsed_state. finalize_early_parsed_attributes ( & mut attributes) ;
428420 for f in & S :: parsers ( ) . finalizers {
429421 if let Some ( attr) = f ( & mut FinalizeContext {
430- shared : SharedContext {
431- cx : self ,
432- target_span,
433- target_id,
434- target : Some ( target) ,
435- emit_lint : & mut emit_lint,
436- } ,
422+ shared : SharedContext { cx : self , target_span, target, emit_lint : & mut emit_lint } ,
437423 all_attrs : & attr_paths,
438424 } ) {
439425 attributes. push ( Attribute :: Parsed ( attr) ) ;
0 commit comments