@@ -2,9 +2,9 @@ use clippy_utils::diagnostics::span_lint_and_then;
2
2
use clippy_utils:: { match_def_path, paths} ;
3
3
use rustc_data_structures:: fx:: FxHashMap ;
4
4
use rustc_hir:: def_id:: DefId ;
5
- use rustc_hir:: { AsyncGeneratorKind , Body , GeneratorKind } ;
5
+ use rustc_hir:: { AsyncCoroutineKind , Body , CoroutineKind } ;
6
6
use rustc_lint:: { LateContext , LateLintPass } ;
7
- use rustc_middle:: mir:: GeneratorLayout ;
7
+ use rustc_middle:: mir:: CoroutineLayout ;
8
8
use rustc_session:: { declare_tool_lint, impl_lint_pass} ;
9
9
use rustc_span:: { sym, Span } ;
10
10
@@ -195,26 +195,26 @@ impl LateLintPass<'_> for AwaitHolding {
195
195
}
196
196
197
197
fn check_body ( & mut self , cx : & LateContext < ' _ > , body : & ' _ Body < ' _ > ) {
198
- use AsyncGeneratorKind :: { Block , Closure , Fn } ;
199
- if let Some ( GeneratorKind :: Async ( Block | Closure | Fn ) ) = body. generator_kind {
198
+ use AsyncCoroutineKind :: { Block , Closure , Fn } ;
199
+ if let Some ( CoroutineKind :: Async ( Block | Closure | Fn ) ) = body. coroutine_kind {
200
200
let def_id = cx. tcx . hir ( ) . body_owner_def_id ( body. id ( ) ) ;
201
- if let Some ( generator_layout ) = cx. tcx . mir_generator_witnesses ( def_id) {
202
- self . check_interior_types ( cx, generator_layout ) ;
201
+ if let Some ( coroutine_layout ) = cx. tcx . mir_coroutine_witnesses ( def_id) {
202
+ self . check_interior_types ( cx, coroutine_layout ) ;
203
203
}
204
204
}
205
205
}
206
206
}
207
207
208
208
impl AwaitHolding {
209
- fn check_interior_types ( & self , cx : & LateContext < ' _ > , generator : & GeneratorLayout < ' _ > ) {
210
- for ( ty_index, ty_cause) in generator . field_tys . iter_enumerated ( ) {
209
+ fn check_interior_types ( & self , cx : & LateContext < ' _ > , coroutine : & CoroutineLayout < ' _ > ) {
210
+ for ( ty_index, ty_cause) in coroutine . field_tys . iter_enumerated ( ) {
211
211
if let rustc_middle:: ty:: Adt ( adt, _) = ty_cause. ty . kind ( ) {
212
212
let await_points = || {
213
- generator
213
+ coroutine
214
214
. variant_source_info
215
215
. iter_enumerated ( )
216
216
. filter_map ( |( variant, source_info) | {
217
- generator . variant_fields [ variant]
217
+ coroutine . variant_fields [ variant]
218
218
. raw
219
219
. contains ( & ty_index)
220
220
. then_some ( source_info. span )
@@ -287,5 +287,8 @@ fn is_mutex_guard(cx: &LateContext<'_>, def_id: DefId) -> bool {
287
287
}
288
288
289
289
fn is_refcell_ref ( cx : & LateContext < ' _ > , def_id : DefId ) -> bool {
290
- match_def_path ( cx, def_id, & paths:: REFCELL_REF ) || match_def_path ( cx, def_id, & paths:: REFCELL_REFMUT )
290
+ matches ! (
291
+ cx. tcx. get_diagnostic_name( def_id) ,
292
+ Some ( sym:: RefCellRef | sym:: RefCellRefMut )
293
+ )
291
294
}
0 commit comments