@@ -59,7 +59,7 @@ pub use self::Note::*;
59
59
use self :: Aliasability :: * ;
60
60
61
61
use crate :: middle:: region;
62
- use crate :: hir:: def_id:: DefId ;
62
+ use crate :: hir:: def_id:: { DefId , LocalDefId } ;
63
63
use crate :: hir:: Node ;
64
64
use crate :: infer:: InferCtxt ;
65
65
use crate :: hir:: def:: { CtorOf , Res , DefKind , CtorKind } ;
@@ -214,7 +214,7 @@ impl HirNode for hir::Pat {
214
214
pub struct MemCategorizationContext < ' a , ' tcx > {
215
215
pub tcx : TyCtxt < ' tcx > ,
216
216
param_env : ty:: ParamEnv < ' tcx > ,
217
- pub body_owner : DefId ,
217
+ pub body_owner : LocalDefId ,
218
218
pub upvars : Option < & ' tcx FxIndexMap < hir:: HirId , hir:: Upvar > > ,
219
219
pub region_scope_tree : & ' a region:: ScopeTree ,
220
220
pub tables : & ' a ty:: TypeckTables < ' tcx > ,
@@ -330,14 +330,14 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
330
330
pub fn new (
331
331
tcx : TyCtxt < ' tcx > ,
332
332
param_env : ty:: ParamEnv < ' tcx > ,
333
- body_owner : DefId ,
333
+ body_owner : LocalDefId ,
334
334
region_scope_tree : & ' a region:: ScopeTree ,
335
335
tables : & ' a ty:: TypeckTables < ' tcx > ,
336
336
) -> MemCategorizationContext < ' a , ' tcx > {
337
337
MemCategorizationContext {
338
338
tcx,
339
339
body_owner,
340
- upvars : tcx. upvars ( body_owner) ,
340
+ upvars : tcx. upvars ( body_owner. to_def_id ( ) ) ,
341
341
region_scope_tree,
342
342
tables,
343
343
infcx : None ,
@@ -359,7 +359,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
359
359
pub fn with_infer (
360
360
infcx : & ' a InferCtxt < ' a , ' tcx > ,
361
361
param_env : ty:: ParamEnv < ' tcx > ,
362
- body_owner : DefId ,
362
+ body_owner : LocalDefId ,
363
363
region_scope_tree : & ' a region:: ScopeTree ,
364
364
tables : & ' a ty:: TypeckTables < ' tcx > ,
365
365
) -> MemCategorizationContext < ' a , ' tcx > {
@@ -368,7 +368,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
368
368
MemCategorizationContext {
369
369
tcx,
370
370
body_owner,
371
- upvars : tcx. upvars ( body_owner) ,
371
+ upvars : tcx. upvars ( body_owner. to_def_id ( ) ) ,
372
372
region_scope_tree,
373
373
tables,
374
374
infcx : Some ( infcx) ,
@@ -722,9 +722,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
722
722
// FnOnce | copied | upvar -> &'up bk
723
723
724
724
let closure_expr_def_id = self . body_owner ;
725
- let fn_hir_id = self . tcx . hir ( ) . local_def_id_to_hir_id (
726
- closure_expr_def_id. assert_local ( ) ,
727
- ) ;
725
+ let fn_hir_id = self . tcx . hir ( ) . local_def_id_to_hir_id ( closure_expr_def_id) ;
728
726
let ty = self . node_ty ( fn_hir_id) ?;
729
727
let kind = match ty. kind {
730
728
ty:: Generator ( ..) => ty:: ClosureKind :: FnOnce ,
@@ -747,7 +745,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
747
745
748
746
let upvar_id = ty:: UpvarId {
749
747
var_path : ty:: UpvarPath { hir_id : var_id } ,
750
- closure_expr_id : closure_expr_def_id. assert_local ( ) ,
748
+ closure_expr_id : closure_expr_def_id,
751
749
} ;
752
750
753
751
let var_ty = self . node_ty ( var_id) ?;
0 commit comments