X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc_passes%2Frvalue_promotion.rs;h=845290467b91e5391a879f59b5e6afa5cc8d0cc0;hb=fff08cb04389497d254fb40948674cbbee402908;hp=85cd602db591f6947449bc460cba813a661b442b;hpb=3b5157917abe5753d994b9de30aa2f1065a3bd45;p=rust.git diff --git a/src/librustc_passes/rvalue_promotion.rs b/src/librustc_passes/rvalue_promotion.rs index 85cd602db59..845290467b9 100644 --- a/src/librustc_passes/rvalue_promotion.rs +++ b/src/librustc_passes/rvalue_promotion.rs @@ -39,10 +39,7 @@ pub fn provide(providers: &mut Providers<'_>) { }; } -fn const_is_rvalue_promotable_to_static<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, - def_id: DefId) - -> bool -{ +fn const_is_rvalue_promotable_to_static<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> bool { assert!(def_id.is_local()); let hir_id = tcx.hir().as_local_hir_id(def_id) @@ -51,10 +48,7 @@ fn const_is_rvalue_promotable_to_static<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx.rvalue_promotable_map(def_id).contains(&body_id.hir_id.local_id) } -fn rvalue_promotable_map<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, - def_id: DefId) - -> &'tcx ItemLocalSet -{ +fn rvalue_promotable_map<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tcx ItemLocalSet { let outer_def_id = tcx.closure_base_def_id(def_id); if outer_def_id != def_id { return tcx.rvalue_promotable_map(outer_def_id); @@ -81,7 +75,7 @@ fn rvalue_promotable_map<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } struct CheckCrateVisitor<'a, 'tcx: 'a> { - tcx: TyCtxt<'a, 'tcx, 'tcx>, + tcx: TyCtxt<'tcx, 'tcx>, in_fn: bool, in_static: bool, mut_rvalue_borrows: HirIdSet, @@ -199,8 +193,15 @@ fn check_nested_body(&mut self, body_id: hir::BodyId) -> Promotability { let param_env = self.param_env; let region_scope_tree = self.tcx.region_scope_tree(item_def_id); let tables = self.tables; - euv::ExprUseVisitor::new(self, tcx, param_env, ®ion_scope_tree, tables, None) - .consume_body(body); + euv::ExprUseVisitor::new( + self, + tcx, + item_def_id, + param_env, + ®ion_scope_tree, + tables, + None, + ).consume_body(body); let body_promotable = self.check_expr(&body.value); self.in_fn = outer_in_fn;