@@ -3,9 +3,8 @@ use std::borrow::Cow;
3
3
use rustc_ast:: AttrStyle ;
4
4
use rustc_errors:: DiagArgValue ;
5
5
use rustc_feature:: { AttributeType , Features } ;
6
- use rustc_hir:: lints:: { AttributeLint , AttributeLintKind } ;
7
- use rustc_hir:: { AttrPath , MethodKind , Target } ;
8
- use rustc_span:: Span ;
6
+ use rustc_hir:: lints:: AttributeLintKind ;
7
+ use rustc_hir:: { MethodKind , Target } ;
9
8
10
9
use crate :: AttributeParser ;
11
10
use crate :: context:: { AcceptContext , Stage } ;
@@ -71,38 +70,34 @@ pub(crate) enum Policy {
71
70
72
71
impl < ' sess , S : Stage > AttributeParser < ' sess , S > {
73
72
pub ( crate ) fn check_target (
74
- & self ,
75
- attr_name : AttrPath ,
76
- attr_span : Span ,
77
73
allowed_targets : & AllowedTargets ,
78
74
target : Target ,
79
- target_id : S :: Id ,
80
- mut emit_lint : impl FnMut ( AttributeLint < S :: Id > ) ,
75
+ cx : & mut AcceptContext < ' _ , ' sess , S > ,
81
76
) {
82
77
match allowed_targets. is_allowed ( target) {
83
78
AllowedResult :: Allowed => { }
84
79
AllowedResult :: Warn => {
85
80
let allowed_targets = allowed_targets. allowed_targets ( ) ;
86
- let ( applied, only) =
87
- allowed_targets_applied ( allowed_targets, target, self . features ) ;
88
- emit_lint ( AttributeLint {
89
- id : target_id,
90
- span : attr_span,
91
- kind : AttributeLintKind :: InvalidTarget {
92
- name : attr_name,
81
+ let ( applied, only) = allowed_targets_applied ( allowed_targets, target, cx. features ) ;
82
+ let name = cx. attr_path . clone ( ) ;
83
+ let attr_span = cx. attr_span ;
84
+ cx. emit_lint (
85
+ AttributeLintKind :: InvalidTarget {
86
+ name,
93
87
target,
94
88
only : if only { "only " } else { "" } ,
95
89
applied,
96
90
} ,
97
- } ) ;
91
+ attr_span,
92
+ ) ;
98
93
}
99
94
AllowedResult :: Error => {
100
95
let allowed_targets = allowed_targets. allowed_targets ( ) ;
101
- let ( applied, only) =
102
- allowed_targets_applied ( allowed_targets , target , self . features ) ;
103
- self . dcx ( ) . emit_err ( InvalidTarget {
104
- span : attr_span,
105
- name : attr_name ,
96
+ let ( applied, only) = allowed_targets_applied ( allowed_targets , target , cx . features ) ;
97
+ let name = cx . attr_path . clone ( ) ;
98
+ cx . dcx ( ) . emit_err ( InvalidTarget {
99
+ span : cx . attr_span . clone ( ) ,
100
+ name,
106
101
target : target. plural_name ( ) ,
107
102
only : if only { "only " } else { "" } ,
108
103
applied : DiagArgValue :: StrListSepByAnd (
0 commit comments