Skip to content

Commit b171953

Browse files
committed
Auto merge of #108692 - nnethercote:dont-call-temporary_scope-twice, 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`
2 parents 276b75a + 6b9c412 commit b171953

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
@@ -34,8 +34,6 @@ impl<'tcx> Cx<'tcx> {
3434

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

@@ -68,7 +66,7 @@ impl<'tcx> Cx<'tcx> {
6866

6967
// Next, wrap this up in the expr's scope.
7068
expr = Expr {
71-
temp_lifetime,
69+
temp_lifetime: expr.temp_lifetime,
7270
ty: expr.ty,
7371
span: hir_expr.span,
7472
kind: ExprKind::Scope {
@@ -83,7 +81,7 @@ impl<'tcx> Cx<'tcx> {
8381
self.region_scope_tree.opt_destruction_scope(hir_expr.hir_id.local_id)
8482
{
8583
expr = Expr {
86-
temp_lifetime,
84+
temp_lifetime: expr.temp_lifetime,
8785
ty: expr.ty,
8886
span: hir_expr.span,
8987
kind: ExprKind::Scope {

0 commit comments

Comments
 (0)