Skip to content

Commit

Permalink
Auto merge of rust-lang#116170 - matthewjasper:remove-thir-destructio…
Browse files Browse the repository at this point in the history
…n-scopes, r=<try>

Don't include destruction scopes in THIR

They are not used by anyone, and add memory/performance overhead.
  • Loading branch information
bors committed Sep 26, 2023
2 parents d23062b + a792217 commit 37859fe
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 321 deletions.
18 changes: 1 addition & 17 deletions compiler/rustc_mir_build/src/thir/cx/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<'tcx> Cx<'tcx> {

trace!(?expr.ty, "after adjustments");

// Next, wrap this up in the expr's scope.
// Finally, wrap this up in the expr's scope.
expr = Expr {
temp_lifetime: expr.temp_lifetime,
ty: expr.ty,
Expand All @@ -66,22 +66,6 @@ impl<'tcx> Cx<'tcx> {
},
};

// Finally, create a destruction scope, if any.
if let Some(region_scope) =
self.region_scope_tree.opt_destruction_scope(hir_expr.hir_id.local_id)
{
expr = Expr {
temp_lifetime: expr.temp_lifetime,
ty: expr.ty,
span: hir_expr.span,
kind: ExprKind::Scope {
region_scope,
value: self.thir.exprs.push(expr),
lint_level: LintLevel::Inherited,
},
};
}

// OK, all done!
self.thir.exprs.push(expr)
}
Expand Down
60 changes: 0 additions & 60 deletions tests/ui/thir-print/thir-flat-const-variant.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,6 @@ Thir {
),
span: $DIR/thir-flat-const-variant.rs:12:23: 12:35 (#0),
},
Expr {
kind: Scope {
region_scope: Destruction(3),
lint_level: Inherited,
value: e3,
},
ty: Foo,
temp_lifetime: Some(
Node(3),
),
span: $DIR/thir-flat-const-variant.rs:12:23: 12:35 (#0),
},
],
stmts: [],
params: [],
Expand Down Expand Up @@ -151,18 +139,6 @@ Thir {
),
span: $DIR/thir-flat-const-variant.rs:13:23: 13:36 (#0),
},
Expr {
kind: Scope {
region_scope: Destruction(3),
lint_level: Inherited,
value: e3,
},
ty: Foo,
temp_lifetime: Some(
Node(3),
),
span: $DIR/thir-flat-const-variant.rs:13:23: 13:36 (#0),
},
],
stmts: [],
params: [],
Expand Down Expand Up @@ -236,18 +212,6 @@ Thir {
),
span: $DIR/thir-flat-const-variant.rs:14:24: 14:36 (#0),
},
Expr {
kind: Scope {
region_scope: Destruction(3),
lint_level: Inherited,
value: e3,
},
ty: Foo,
temp_lifetime: Some(
Node(3),
),
span: $DIR/thir-flat-const-variant.rs:14:24: 14:36 (#0),
},
],
stmts: [],
params: [],
Expand Down Expand Up @@ -321,18 +285,6 @@ Thir {
),
span: $DIR/thir-flat-const-variant.rs:15:24: 15:37 (#0),
},
Expr {
kind: Scope {
region_scope: Destruction(3),
lint_level: Inherited,
value: e3,
},
ty: Foo,
temp_lifetime: Some(
Node(3),
),
span: $DIR/thir-flat-const-variant.rs:15:24: 15:37 (#0),
},
],
stmts: [],
params: [],
Expand Down Expand Up @@ -380,18 +332,6 @@ Thir {
),
span: $DIR/thir-flat-const-variant.rs:18:11: 18:13 (#0),
},
Expr {
kind: Scope {
region_scope: Destruction(2),
lint_level: Inherited,
value: e1,
},
ty: (),
temp_lifetime: Some(
Node(2),
),
span: $DIR/thir-flat-const-variant.rs:18:11: 18:13 (#0),
},
],
stmts: [],
params: [],
Expand Down
12 changes: 0 additions & 12 deletions tests/ui/thir-print/thir-flat.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,6 @@ Thir {
),
span: $DIR/thir-flat.rs:4:15: 4:17 (#0),
},
Expr {
kind: Scope {
region_scope: Destruction(2),
lint_level: Inherited,
value: e1,
},
ty: (),
temp_lifetime: Some(
Node(2),
),
span: $DIR/thir-flat.rs:4:15: 4:17 (#0),
},
],
stmts: [],
params: [],
Expand Down
Loading

0 comments on commit 37859fe

Please sign in to comment.