Skip to content

Commit 6b9c412

Browse files
committed
Don't call temporary_scope twice.
`mirror_expr_inner` calls `temporary_scope`. It then calls `make_mirror_unadjusted` which makes an identical call to `temporary_scope`. This commit changes the `mirror_expr_inner` to get the `temp_lifetime` out of the expression produced by `make_mirror_unadjusted`, similar to how it currently gets the type.
1 parent ca1bc7f commit 6b9c412

File tree

1 file changed

+2
-4
lines changed
  • compiler/rustc_mir_build/src/thir/cx

1 file changed

+2
-4
lines changed

compiler/rustc_mir_build/src/thir/cx/expr.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ impl<'tcx> Cx<'tcx> {
3333

3434
#[instrument(level = "trace", skip(self, hir_expr))]
3535
pub(super) fn mirror_expr_inner(&mut self, hir_expr: &'tcx hir::Expr<'tcx>) -> ExprId {
36-
let temp_lifetime =
37-
self.rvalue_scopes.temporary_scope(self.region_scope_tree, hir_expr.hir_id.local_id);
3836
let expr_scope =
3937
region::Scope { id: hir_expr.hir_id.local_id, data: region::ScopeData::Node };
4038

@@ -67,7 +65,7 @@ impl<'tcx> Cx<'tcx> {
6765

6866
// Next, wrap this up in the expr's scope.
6967
expr = Expr {
70-
temp_lifetime,
68+
temp_lifetime: expr.temp_lifetime,
7169
ty: expr.ty,
7270
span: hir_expr.span,
7371
kind: ExprKind::Scope {
@@ -82,7 +80,7 @@ impl<'tcx> Cx<'tcx> {
8280
self.region_scope_tree.opt_destruction_scope(hir_expr.hir_id.local_id)
8381
{
8482
expr = Expr {
85-
temp_lifetime,
83+
temp_lifetime: expr.temp_lifetime,
8684
ty: expr.ty,
8785
span: hir_expr.span,
8886
kind: ExprKind::Scope {

0 commit comments

Comments
 (0)