@@ -2,9 +2,9 @@ use clippy_utils::diagnostics::span_lint_and_then;
22use clippy_utils:: { match_def_path, paths} ;
33use rustc_data_structures:: fx:: FxHashMap ;
44use rustc_hir:: def_id:: DefId ;
5- use rustc_hir:: { AsyncGeneratorKind , Body , GeneratorKind } ;
5+ use rustc_hir:: { AsyncCoroutineKind , Body , CoroutineKind } ;
66use rustc_lint:: { LateContext , LateLintPass } ;
7- use rustc_middle:: mir:: GeneratorLayout ;
7+ use rustc_middle:: mir:: CoroutineLayout ;
88use rustc_session:: { declare_tool_lint, impl_lint_pass} ;
99use rustc_span:: { sym, Span } ;
1010
@@ -195,26 +195,26 @@ impl LateLintPass<'_> for AwaitHolding {
195195 }
196196
197197 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 {
200200 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 ) ;
203203 }
204204 }
205205 }
206206}
207207
208208impl 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 ( ) {
211211 if let rustc_middle:: ty:: Adt ( adt, _) = ty_cause. ty . kind ( ) {
212212 let await_points = || {
213- generator
213+ coroutine
214214 . variant_source_info
215215 . iter_enumerated ( )
216216 . filter_map ( |( variant, source_info) | {
217- generator . variant_fields [ variant]
217+ coroutine . variant_fields [ variant]
218218 . raw
219219 . contains ( & ty_index)
220220 . then_some ( source_info. span )
@@ -287,5 +287,8 @@ fn is_mutex_guard(cx: &LateContext<'_>, def_id: DefId) -> bool {
287287}
288288
289289fn 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+ )
291294}
0 commit comments