Skip to content

Commit

Permalink
Auto merge of #108692 - nnethercote:dont-call-temporary_scope-twice, …
Browse files Browse the repository at this point in the history
…r=cjgillot

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.

r? `@cjgillot`
  • Loading branch information
bors committed Mar 4, 2023
2 parents 276b75a + 6b9c412 commit b171953
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions compiler/rustc_mir_build/src/thir/cx/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ impl<'tcx> Cx<'tcx> {

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

Expand Down Expand Up @@ -68,7 +66,7 @@ impl<'tcx> Cx<'tcx> {

// Next, wrap this up in the expr's scope.
expr = Expr {
temp_lifetime,
temp_lifetime: expr.temp_lifetime,
ty: expr.ty,
span: hir_expr.span,
kind: ExprKind::Scope {
Expand All @@ -83,7 +81,7 @@ impl<'tcx> Cx<'tcx> {
self.region_scope_tree.opt_destruction_scope(hir_expr.hir_id.local_id)
{
expr = Expr {
temp_lifetime,
temp_lifetime: expr.temp_lifetime,
ty: expr.ty,
span: hir_expr.span,
kind: ExprKind::Scope {
Expand Down

0 comments on commit b171953

Please sign in to comment.