@@ -214,6 +214,7 @@ impl HirNode for hir::Pat {
214214#[ derive( Clone ) ]
215215pub struct MemCategorizationContext < ' a , ' tcx > {
216216 pub tcx : TyCtxt < ' tcx > ,
217+ param_env : ty:: ParamEnv < ' tcx > ,
217218 pub body_owner : DefId ,
218219 pub upvars : Option < & ' tcx FxIndexMap < hir:: HirId , hir:: Upvar > > ,
219220 pub region_scope_tree : & ' a region:: ScopeTree ,
@@ -330,6 +331,7 @@ impl MutabilityCategory {
330331impl < ' a , ' tcx > MemCategorizationContext < ' a , ' tcx > {
331332 pub fn new (
332333 tcx : TyCtxt < ' tcx > ,
334+ param_env : ty:: ParamEnv < ' tcx > ,
333335 body_owner : DefId ,
334336 region_scope_tree : & ' a region:: ScopeTree ,
335337 tables : & ' a ty:: TypeckTables < ' tcx > ,
@@ -342,7 +344,8 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
342344 region_scope_tree,
343345 tables,
344346 rvalue_promotable_map,
345- infcx : None
347+ infcx : None ,
348+ param_env,
346349 }
347350 }
348351}
@@ -359,6 +362,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
359362 /// known, the results around upvar accesses may be incorrect.
360363 pub fn with_infer (
361364 infcx : & ' a InferCtxt < ' a , ' tcx > ,
365+ param_env : ty:: ParamEnv < ' tcx > ,
362366 body_owner : DefId ,
363367 region_scope_tree : & ' a region:: ScopeTree ,
364368 tables : & ' a ty:: TypeckTables < ' tcx > ,
@@ -379,6 +383,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
379383 tables,
380384 rvalue_promotable_map,
381385 infcx : Some ( infcx) ,
386+ param_env,
382387 }
383388 }
384389
@@ -896,7 +901,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
896901
897902 // Always promote `[T; 0]` (even when e.g., borrowed mutably).
898903 let promotable = match expr_ty. sty {
899- ty:: Array ( _, len) if len. try_eval_usize ( self . tcx ) == Some ( 0 ) => true ,
904+ ty:: Array ( _, len) if len. try_eval_usize ( self . tcx , self . param_env ) == Some ( 0 ) => true ,
900905 _ => promotable,
901906 } ;
902907
0 commit comments