@@ -81,8 +81,8 @@ impl LintPass for AttrPass {
81
81
}
82
82
}
83
83
84
- impl LateLintPass for AttrPass {
85
- fn check_attribute ( & mut self , cx : & LateContext , attr : & Attribute ) {
84
+ impl < ' a , ' tcx > LateLintPass < ' a , ' tcx > for AttrPass {
85
+ fn check_attribute ( & mut self , cx : & LateContext < ' a , ' tcx > , attr : & ' tcx Attribute ) {
86
86
if let MetaItemKind :: List ( ref items) = attr. value . node {
87
87
if items. is_empty ( ) || attr. name ( ) != "deprecated" {
88
88
return ;
@@ -99,21 +99,21 @@ impl LateLintPass for AttrPass {
99
99
}
100
100
}
101
101
102
- fn check_item ( & mut self , cx : & LateContext , item : & Item ) {
102
+ fn check_item ( & mut self , cx : & LateContext < ' a , ' tcx > , item : & ' tcx Item ) {
103
103
if is_relevant_item ( cx, item) {
104
104
check_attrs ( cx, item. span , & item. name , & item. attrs )
105
105
}
106
106
match item. node {
107
107
ItemExternCrate ( _) |
108
- ItemUse ( _) => {
108
+ ItemUse ( _, _ ) => {
109
109
for attr in & item. attrs {
110
110
if let MetaItemKind :: List ( ref lint_list) = attr. value . node {
111
111
match & * attr. name ( ) . as_str ( ) {
112
112
"allow" | "warn" | "deny" | "forbid" => {
113
113
// whitelist `unused_imports`
114
114
for lint in lint_list {
115
115
if is_word ( lint, "unused_imports" ) {
116
- if let ItemUse ( _) = item. node {
116
+ if let ItemUse ( _, _ ) = item. node {
117
117
return ;
118
118
}
119
119
}
@@ -138,38 +138,38 @@ impl LateLintPass for AttrPass {
138
138
}
139
139
}
140
140
141
- fn check_impl_item ( & mut self , cx : & LateContext , item : & ImplItem ) {
141
+ fn check_impl_item ( & mut self , cx : & LateContext < ' a , ' tcx > , item : & ' tcx ImplItem ) {
142
142
if is_relevant_impl ( cx, item) {
143
143
check_attrs ( cx, item. span , & item. name , & item. attrs )
144
144
}
145
145
}
146
146
147
- fn check_trait_item ( & mut self , cx : & LateContext , item : & TraitItem ) {
147
+ fn check_trait_item ( & mut self , cx : & LateContext < ' a , ' tcx > , item : & ' tcx TraitItem ) {
148
148
if is_relevant_trait ( cx, item) {
149
149
check_attrs ( cx, item. span , & item. name , & item. attrs )
150
150
}
151
151
}
152
152
}
153
153
154
154
fn is_relevant_item ( cx : & LateContext , item : & Item ) -> bool {
155
- if let ItemFn ( _, _, _, _, _, ref expr ) = item. node {
156
- is_relevant_expr ( cx, expr)
155
+ if let ItemFn ( _, _, _, _, _, eid ) = item. node {
156
+ is_relevant_expr ( cx, cx . tcx . map . expr ( eid ) )
157
157
} else {
158
158
false
159
159
}
160
160
}
161
161
162
162
fn is_relevant_impl ( cx : & LateContext , item : & ImplItem ) -> bool {
163
163
match item. node {
164
- ImplItemKind :: Method ( _, ref expr ) => is_relevant_expr ( cx, expr) ,
164
+ ImplItemKind :: Method ( _, eid ) => is_relevant_expr ( cx, cx . tcx . map . expr ( eid ) ) ,
165
165
_ => false ,
166
166
}
167
167
}
168
168
169
169
fn is_relevant_trait ( cx : & LateContext , item : & TraitItem ) -> bool {
170
170
match item. node {
171
171
MethodTraitItem ( _, None ) => true ,
172
- MethodTraitItem ( _, Some ( ref expr ) ) => is_relevant_expr ( cx, expr) ,
172
+ MethodTraitItem ( _, Some ( eid ) ) => is_relevant_expr ( cx, cx . tcx . map . expr ( eid ) ) ,
173
173
_ => false ,
174
174
}
175
175
}
@@ -193,8 +193,8 @@ fn is_relevant_expr(cx: &LateContext, expr: &Expr) -> bool {
193
193
ExprRet ( Some ( ref e) ) => is_relevant_expr ( cx, e) ,
194
194
ExprRet ( None ) | ExprBreak ( _, None ) => false ,
195
195
ExprCall ( ref path_expr, _) => {
196
- if let ExprPath ( .. ) = path_expr. node {
197
- let fun_id = resolve_node ( cx, path_expr. id ) . expect ( "function should be resolved" ) . def_id ( ) ;
196
+ if let ExprPath ( ref qpath ) = path_expr. node {
197
+ let fun_id = resolve_node ( cx, qpath , path_expr. id ) . def_id ( ) ;
198
198
!match_def_path ( cx, fun_id, & paths:: BEGIN_PANIC )
199
199
} else {
200
200
true
0 commit comments