Skip to content

Commit 37859fe

Browse files
committed
Auto merge of #116170 - matthewjasper:remove-thir-destruction-scopes, r=<try>
Don't include destruction scopes in THIR They are not used by anyone, and add memory/performance overhead.
2 parents d23062b + a792217 commit 37859fe

File tree

5 files changed

+167
-321
lines changed

5 files changed

+167
-321
lines changed

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

+1-17
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<'tcx> Cx<'tcx> {
5454

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

57-
// Next, wrap this up in the expr's scope.
57+
// Finally, wrap this up in the expr's scope.
5858
expr = Expr {
5959
temp_lifetime: expr.temp_lifetime,
6060
ty: expr.ty,
@@ -66,22 +66,6 @@ impl<'tcx> Cx<'tcx> {
6666
},
6767
};
6868

69-
// Finally, create a destruction scope, if any.
70-
if let Some(region_scope) =
71-
self.region_scope_tree.opt_destruction_scope(hir_expr.hir_id.local_id)
72-
{
73-
expr = Expr {
74-
temp_lifetime: expr.temp_lifetime,
75-
ty: expr.ty,
76-
span: hir_expr.span,
77-
kind: ExprKind::Scope {
78-
region_scope,
79-
value: self.thir.exprs.push(expr),
80-
lint_level: LintLevel::Inherited,
81-
},
82-
};
83-
}
84-
8569
// OK, all done!
8670
self.thir.exprs.push(expr)
8771
}

tests/ui/thir-print/thir-flat-const-variant.stdout

-60
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,6 @@ Thir {
6666
),
6767
span: $DIR/thir-flat-const-variant.rs:12:23: 12:35 (#0),
6868
},
69-
Expr {
70-
kind: Scope {
71-
region_scope: Destruction(3),
72-
lint_level: Inherited,
73-
value: e3,
74-
},
75-
ty: Foo,
76-
temp_lifetime: Some(
77-
Node(3),
78-
),
79-
span: $DIR/thir-flat-const-variant.rs:12:23: 12:35 (#0),
80-
},
8169
],
8270
stmts: [],
8371
params: [],
@@ -151,18 +139,6 @@ Thir {
151139
),
152140
span: $DIR/thir-flat-const-variant.rs:13:23: 13:36 (#0),
153141
},
154-
Expr {
155-
kind: Scope {
156-
region_scope: Destruction(3),
157-
lint_level: Inherited,
158-
value: e3,
159-
},
160-
ty: Foo,
161-
temp_lifetime: Some(
162-
Node(3),
163-
),
164-
span: $DIR/thir-flat-const-variant.rs:13:23: 13:36 (#0),
165-
},
166142
],
167143
stmts: [],
168144
params: [],
@@ -236,18 +212,6 @@ Thir {
236212
),
237213
span: $DIR/thir-flat-const-variant.rs:14:24: 14:36 (#0),
238214
},
239-
Expr {
240-
kind: Scope {
241-
region_scope: Destruction(3),
242-
lint_level: Inherited,
243-
value: e3,
244-
},
245-
ty: Foo,
246-
temp_lifetime: Some(
247-
Node(3),
248-
),
249-
span: $DIR/thir-flat-const-variant.rs:14:24: 14:36 (#0),
250-
},
251215
],
252216
stmts: [],
253217
params: [],
@@ -321,18 +285,6 @@ Thir {
321285
),
322286
span: $DIR/thir-flat-const-variant.rs:15:24: 15:37 (#0),
323287
},
324-
Expr {
325-
kind: Scope {
326-
region_scope: Destruction(3),
327-
lint_level: Inherited,
328-
value: e3,
329-
},
330-
ty: Foo,
331-
temp_lifetime: Some(
332-
Node(3),
333-
),
334-
span: $DIR/thir-flat-const-variant.rs:15:24: 15:37 (#0),
335-
},
336288
],
337289
stmts: [],
338290
params: [],
@@ -380,18 +332,6 @@ Thir {
380332
),
381333
span: $DIR/thir-flat-const-variant.rs:18:11: 18:13 (#0),
382334
},
383-
Expr {
384-
kind: Scope {
385-
region_scope: Destruction(2),
386-
lint_level: Inherited,
387-
value: e1,
388-
},
389-
ty: (),
390-
temp_lifetime: Some(
391-
Node(2),
392-
),
393-
span: $DIR/thir-flat-const-variant.rs:18:11: 18:13 (#0),
394-
},
395335
],
396336
stmts: [],
397337
params: [],

tests/ui/thir-print/thir-flat.stdout

-12
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,6 @@ Thir {
4040
),
4141
span: $DIR/thir-flat.rs:4:15: 4:17 (#0),
4242
},
43-
Expr {
44-
kind: Scope {
45-
region_scope: Destruction(2),
46-
lint_level: Inherited,
47-
value: e1,
48-
},
49-
ty: (),
50-
temp_lifetime: Some(
51-
Node(2),
52-
),
53-
span: $DIR/thir-flat.rs:4:15: 4:17 (#0),
54-
},
5543
],
5644
stmts: [],
5745
params: [],

0 commit comments

Comments
 (0)