@@ -23,7 +23,6 @@ use rustc_data_structures::graph::dominators::Dominators;
23
23
use rustc_errors:: { Applicability , Diagnostic , DiagnosticBuilder , ErrorGuaranteed } ;
24
24
use rustc_hir as hir;
25
25
use rustc_hir:: def_id:: LocalDefId ;
26
- use rustc_hir:: Node ;
27
26
use rustc_index:: bit_set:: ChunkedBitSet ;
28
27
use rustc_index:: vec:: IndexVec ;
29
28
use rustc_infer:: infer:: { InferCtxt , TyCtxtInferExt } ;
@@ -288,14 +287,16 @@ fn do_mir_borrowck<'a, 'tcx>(
288
287
. pass_name ( "borrowck" )
289
288
. iterate_to_fixpoint ( ) ;
290
289
291
- let def_hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( def. did ) ;
292
- let movable_generator = !matches ! (
293
- tcx. hir( ) . get( def_hir_id) ,
294
- Node :: Expr ( & hir:: Expr {
295
- kind: hir:: ExprKind :: Closure ( .., Some ( hir:: Movability :: Static ) ) ,
296
- ..
297
- } )
298
- ) ;
290
+ let movable_generator =
291
+ // The first argument is the generator type passed by value
292
+ if let Some ( local) = body. local_decls . raw . get ( 1 )
293
+ // Get the interior types and substs which typeck computed
294
+ && let ty:: Generator ( _, _, hir:: Movability :: Static ) = local. ty . kind ( )
295
+ {
296
+ false
297
+ } else {
298
+ true
299
+ } ;
299
300
300
301
for ( idx, move_data_results) in promoted_errors {
301
302
let promoted_body = & promoted[ idx] ;
@@ -385,7 +386,7 @@ fn do_mir_borrowck<'a, 'tcx>(
385
386
let scope = mbcx. body . source_info ( location) . scope ;
386
387
let lint_root = match & mbcx. body . source_scopes [ scope] . local_data {
387
388
ClearCrossCrate :: Set ( data) => data. lint_root ,
388
- _ => def_hir_id ,
389
+ _ => tcx . hir ( ) . local_def_id_to_hir_id ( def . did ) ,
389
390
} ;
390
391
391
392
// Span and message don't matter; we overwrite them below anyway
0 commit comments