Skip to content

Commit 53deccf

Browse files
committed
More minimal changes
1 parent b48f3d8 commit 53deccf

12 files changed

+82
-103
lines changed

compiler/rustc_mir_build/src/build/expr/into.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
7070
&this.thir[cond],
7171
Some(condition_scope),
7272
condition_scope,
73-
then_expr.span
73+
then_expr.span,
7474
));
75-
7675
this.expr_into_dest(destination, then_blk, then_expr)
7776
});
7877
then_block.and(else_block)
@@ -98,7 +97,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
9897
ExprKind::Let { expr, ref pat } => {
9998
let scope = this.local_scope();
10099
let (true_block, false_block) = this.in_if_then_scope(scope, |this| {
101-
this.lower_let_expr(block, &this.thir[expr], pat, scope, None, expr_span)
100+
this.lower_let_expr(block, &this.thir[expr], pat, scope, expr_span)
102101
});
103102

104103
this.cfg.push_assign_constant(

compiler/rustc_mir_build/src/build/matches/mod.rs

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
4141
expr: &Expr<'tcx>,
4242
temp_scope_override: Option<region::Scope>,
4343
break_scope: region::Scope,
44-
variable_span: Span,
44+
variable_scope_span: Span,
4545
) -> BlockAnd<()> {
4646
let this = self;
4747
let expr_span = expr.span;
@@ -53,15 +53,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
5353
&this.thir[lhs],
5454
temp_scope_override,
5555
break_scope,
56-
variable_span,
56+
variable_scope_span,
5757
));
5858

5959
let rhs_then_block = unpack!(this.then_else_break(
6060
lhs_then_block,
6161
&this.thir[rhs],
6262
temp_scope_override,
6363
break_scope,
64-
variable_span,
64+
variable_scope_span,
6565
));
6666

6767
rhs_then_block.unit()
@@ -74,22 +74,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
7474
&this.thir[value],
7575
temp_scope_override,
7676
break_scope,
77-
variable_span,
77+
variable_scope_span,
7878
)
7979
})
8080
}
8181
ExprKind::Let { expr, ref pat } => {
82-
let variable_scope =
83-
this.new_source_scope(variable_span, LintLevel::Inherited, None);
84-
this.source_scope = variable_scope;
85-
this.lower_let_expr(
86-
block,
87-
&this.thir[expr],
88-
pat,
89-
break_scope,
90-
Some(variable_scope),
91-
variable_span,
92-
)
82+
this.lower_let_expr(block, &this.thir[expr], pat, break_scope, variable_scope_span)
9383
}
9484
_ => {
9585
let temp_scope = temp_scope_override.unwrap_or_else(|| this.local_scope());
@@ -1783,7 +1773,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
17831773
expr: &Expr<'tcx>,
17841774
pat: &Pat<'tcx>,
17851775
else_target: region::Scope,
1786-
source_scope: Option<SourceScope>,
17871776
span: Span,
17881777
) -> BlockAnd<()> {
17891778
let expr_span = expr.span;
@@ -1809,13 +1798,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
18091798
let otherwise_post_guard_block = otherwise_candidate.pre_binding_block.unwrap();
18101799
self.break_for_else(otherwise_post_guard_block, else_target, self.source_info(expr_span));
18111800

1812-
self.declare_bindings(
1813-
source_scope,
1814-
pat.span.to(span),
1815-
pat,
1816-
ArmHasGuard(false),
1817-
opt_expr_place,
1818-
);
1801+
let scope =
1802+
self.declare_bindings(None, pat.span.to(span), pat, ArmHasGuard(false), opt_expr_place);
1803+
1804+
if let Some(scope) = scope {
1805+
self.source_scope = scope;
1806+
}
18191807

18201808
let post_guard_block = self.bind_pattern(
18211809
self.source_info(pat.span),
@@ -1993,7 +1981,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
19931981
Guard::IfLet(ref pat, scrutinee) => {
19941982
let s = &this.thir[scrutinee];
19951983
guard_span = s.span;
1996-
this.lower_let_expr(block, s, pat, match_scope, None, arm_span)
1984+
this.lower_let_expr(block, s, pat, match_scope, arm_span)
19971985
}
19981986
});
19991987

src/test/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,22 @@
1010
scope 1 {
1111
debug x => _1; // in scope 1 at $DIR/discriminant.rs:11:9: 11:10
1212
}
13-
scope 2 {
14-
}
1513

1614
bb0: {
1715
StorageLive(_1); // scope 0 at $DIR/discriminant.rs:11:9: 11:10
1816
StorageLive(_2); // scope 0 at $DIR/discriminant.rs:11:13: 11:64
19-
StorageLive(_3); // scope 2 at $DIR/discriminant.rs:11:34: 11:44
20-
Deinit(_3); // scope 2 at $DIR/discriminant.rs:11:34: 11:44
21-
((_3 as Some).0: bool) = const true; // scope 2 at $DIR/discriminant.rs:11:34: 11:44
22-
discriminant(_3) = 1; // scope 2 at $DIR/discriminant.rs:11:34: 11:44
23-
- _4 = discriminant(_3); // scope 2 at $DIR/discriminant.rs:11:21: 11:31
24-
- switchInt(move _4) -> [1_isize: bb1, otherwise: bb3]; // scope 2 at $DIR/discriminant.rs:11:21: 11:31
25-
+ _4 = const 1_isize; // scope 2 at $DIR/discriminant.rs:11:21: 11:31
26-
+ switchInt(const 1_isize) -> [1_isize: bb1, otherwise: bb3]; // scope 2 at $DIR/discriminant.rs:11:21: 11:31
17+
StorageLive(_3); // scope 0 at $DIR/discriminant.rs:11:34: 11:44
18+
Deinit(_3); // scope 0 at $DIR/discriminant.rs:11:34: 11:44
19+
((_3 as Some).0: bool) = const true; // scope 0 at $DIR/discriminant.rs:11:34: 11:44
20+
discriminant(_3) = 1; // scope 0 at $DIR/discriminant.rs:11:34: 11:44
21+
- _4 = discriminant(_3); // scope 0 at $DIR/discriminant.rs:11:21: 11:31
22+
- switchInt(move _4) -> [1_isize: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:11:21: 11:31
23+
+ _4 = const 1_isize; // scope 0 at $DIR/discriminant.rs:11:21: 11:31
24+
+ switchInt(const 1_isize) -> [1_isize: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:11:21: 11:31
2725
}
2826

2927
bb1: {
30-
switchInt(((_3 as Some).0: bool)) -> [false: bb3, otherwise: bb2]; // scope 2 at $DIR/discriminant.rs:11:21: 11:31
28+
switchInt(((_3 as Some).0: bool)) -> [false: bb3, otherwise: bb2]; // scope 0 at $DIR/discriminant.rs:11:21: 11:31
3129
}
3230

3331
bb2: {

src/test/mir-opt/early_otherwise_branch_soundness.no_downcast.EarlyOtherwiseBranch.diff

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,18 @@
77
let mut _2: isize; // in scope 0 at $DIR/early_otherwise_branch_soundness.rs:13:20: 13:30
88
let mut _3: isize; // in scope 0 at $DIR/early_otherwise_branch_soundness.rs:13:12: 13:31
99
let mut _4: &E; // in scope 0 at $DIR/early_otherwise_branch_soundness.rs:12:16: 12:17
10-
scope 1 {
11-
}
1210

1311
bb0: {
14-
_3 = discriminant((*_1)); // scope 1 at $DIR/early_otherwise_branch_soundness.rs:13:12: 13:31
15-
switchInt(move _3) -> [1_isize: bb1, otherwise: bb3]; // scope 1 at $DIR/early_otherwise_branch_soundness.rs:13:12: 13:31
12+
_3 = discriminant((*_1)); // scope 0 at $DIR/early_otherwise_branch_soundness.rs:13:12: 13:31
13+
switchInt(move _3) -> [1_isize: bb1, otherwise: bb3]; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:13:12: 13:31
1614
}
1715

1816
bb1: {
19-
StorageLive(_4); // scope 1 at $DIR/early_otherwise_branch_soundness.rs:13:12: 13:31
20-
_4 = move (((*_1) as Some).0: &E); // scope 1 at $DIR/early_otherwise_branch_soundness.rs:13:12: 13:31
21-
_2 = discriminant((*_4)); // scope 1 at $DIR/early_otherwise_branch_soundness.rs:13:12: 13:31
22-
StorageDead(_4); // scope 1 at $DIR/early_otherwise_branch_soundness.rs:13:12: 13:31
23-
switchInt(move _2) -> [1_isize: bb2, otherwise: bb3]; // scope 1 at $DIR/early_otherwise_branch_soundness.rs:13:12: 13:31
17+
StorageLive(_4); // scope 0 at $DIR/early_otherwise_branch_soundness.rs:13:12: 13:31
18+
_4 = move (((*_1) as Some).0: &E); // scope 0 at $DIR/early_otherwise_branch_soundness.rs:13:12: 13:31
19+
_2 = discriminant((*_4)); // scope 0 at $DIR/early_otherwise_branch_soundness.rs:13:12: 13:31
20+
StorageDead(_4); // scope 0 at $DIR/early_otherwise_branch_soundness.rs:13:12: 13:31
21+
switchInt(move _2) -> [1_isize: bb2, otherwise: bb3]; // scope 0 at $DIR/early_otherwise_branch_soundness.rs:13:12: 13:31
2422
}
2523

2624
bb2: {

src/test/mir-opt/funky_arms.float_to_exponential_common.ConstProp.diff

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
let _6: core::num::flt2dec::Sign; // in scope 1 at $DIR/funky_arms.rs:19:9: 19:13
2828
scope 2 {
2929
debug sign => _6; // in scope 2 at $DIR/funky_arms.rs:19:9: 19:13
30+
let _10: usize; // in scope 2 at $DIR/funky_arms.rs:24:17: 24:26
3031
scope 3 {
3132
debug precision => _10; // in scope 3 at $DIR/funky_arms.rs:24:17: 24:26
32-
let _10: usize; // in scope 3 at $DIR/funky_arms.rs:24:17: 24:26
3333
}
3434
}
3535
}
@@ -63,19 +63,19 @@
6363
}
6464

6565
bb4: {
66-
StorageLive(_7); // scope 3 at $DIR/funky_arms.rs:24:30: 24:45
67-
StorageLive(_8); // scope 3 at $DIR/funky_arms.rs:24:30: 24:45
68-
_8 = &(*_1); // scope 3 at $DIR/funky_arms.rs:24:30: 24:45
69-
_7 = Formatter::precision(move _8) -> bb5; // scope 3 at $DIR/funky_arms.rs:24:30: 24:45
66+
StorageLive(_7); // scope 2 at $DIR/funky_arms.rs:24:30: 24:45
67+
StorageLive(_8); // scope 2 at $DIR/funky_arms.rs:24:30: 24:45
68+
_8 = &(*_1); // scope 2 at $DIR/funky_arms.rs:24:30: 24:45
69+
_7 = Formatter::precision(move _8) -> bb5; // scope 2 at $DIR/funky_arms.rs:24:30: 24:45
7070
// mir::Constant
7171
// + span: $DIR/funky_arms.rs:24:34: 24:43
7272
// + literal: Const { ty: for<'r> fn(&'r Formatter) -> Option<usize> {Formatter::precision}, val: Value(Scalar(<ZST>)) }
7373
}
7474

7575
bb5: {
76-
StorageDead(_8); // scope 3 at $DIR/funky_arms.rs:24:44: 24:45
77-
_9 = discriminant(_7); // scope 3 at $DIR/funky_arms.rs:24:12: 24:27
78-
switchInt(move _9) -> [1_isize: bb6, otherwise: bb8]; // scope 3 at $DIR/funky_arms.rs:24:12: 24:27
76+
StorageDead(_8); // scope 2 at $DIR/funky_arms.rs:24:44: 24:45
77+
_9 = discriminant(_7); // scope 2 at $DIR/funky_arms.rs:24:12: 24:27
78+
switchInt(move _9) -> [1_isize: bb6, otherwise: bb8]; // scope 2 at $DIR/funky_arms.rs:24:12: 24:27
7979
}
8080

8181
bb6: {

src/test/mir-opt/issue_41888.main.ElaborateDrops.after.mir

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ fn main() -> () {
1414
let mut _11: isize; // in scope 0 at $DIR/issue-41888.rs:15:1: 15:2
1515
scope 1 {
1616
debug e => _1; // in scope 1 at $DIR/issue-41888.rs:7:9: 7:10
17+
let _6: K; // in scope 1 at $DIR/issue-41888.rs:10:21: 10:23
1718
scope 2 {
1819
debug _k => _6; // in scope 2 at $DIR/issue-41888.rs:10:21: 10:23
19-
let _6: K; // in scope 2 at $DIR/issue-41888.rs:10:21: 10:23
2020
}
2121
}
2222

@@ -51,8 +51,8 @@ fn main() -> () {
5151

5252
bb4: {
5353
StorageDead(_3); // scope 1 at $DIR/issue-41888.rs:9:19: 9:20
54-
_5 = discriminant(_1); // scope 2 at $DIR/issue-41888.rs:10:16: 10:24
55-
switchInt(move _5) -> [0_isize: bb5, otherwise: bb6]; // scope 2 at $DIR/issue-41888.rs:10:16: 10:24
54+
_5 = discriminant(_1); // scope 1 at $DIR/issue-41888.rs:10:16: 10:24
55+
switchInt(move _5) -> [0_isize: bb5, otherwise: bb6]; // scope 1 at $DIR/issue-41888.rs:10:16: 10:24
5656
}
5757

5858
bb5: {

src/test/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
let mut _6: u32; // in scope 0 at $DIR/issue-75439.rs:10:33: 10:35
1111
scope 1 {
1212
debug dwords => _2; // in scope 1 at $DIR/issue-75439.rs:7:9: 7:15
13+
let _4: u32; // in scope 1 at $DIR/issue-75439.rs:9:27: 9:29
1314
scope 3 {
1415
debug ip => _4; // in scope 3 at $DIR/issue-75439.rs:9:27: 9:29
15-
let _4: u32; // in scope 3 at $DIR/issue-75439.rs:9:27: 9:29
1616
}
1717
scope 4 {
1818
}
@@ -32,15 +32,15 @@
3232

3333
bb1: {
3434
StorageDead(_3); // scope 2 at $DIR/issue-75439.rs:7:52: 7:53
35-
switchInt(_2[0 of 4]) -> [0_u32: bb2, otherwise: bb8]; // scope 3 at $DIR/issue-75439.rs:9:12: 9:30
35+
switchInt(_2[0 of 4]) -> [0_u32: bb2, otherwise: bb8]; // scope 1 at $DIR/issue-75439.rs:9:12: 9:30
3636
}
3737

3838
bb2: {
39-
switchInt(_2[1 of 4]) -> [0_u32: bb3, otherwise: bb8]; // scope 3 at $DIR/issue-75439.rs:9:12: 9:30
39+
switchInt(_2[1 of 4]) -> [0_u32: bb3, otherwise: bb8]; // scope 1 at $DIR/issue-75439.rs:9:12: 9:30
4040
}
4141

4242
bb3: {
43-
switchInt(_2[2 of 4]) -> [0_u32: bb5, 4294901760_u32: bb6, otherwise: bb8]; // scope 3 at $DIR/issue-75439.rs:9:12: 9:30
43+
switchInt(_2[2 of 4]) -> [0_u32: bb5, 4294901760_u32: bb6, otherwise: bb8]; // scope 1 at $DIR/issue-75439.rs:9:12: 9:30
4444
}
4545

4646
bb4: {

src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,33 @@
88
let mut _3: std::option::Option<T>; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:51: 4:68
99
let mut _4: isize; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:22: 4:26
1010
let mut _5: isize; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:13: 4:20
11+
let _6: u8; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:18: 4:19
1112
- let mut _7: bool; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20
1213
- let mut _8: u8; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13
1314
scope 1 {
1415
debug a => _6; // in scope 1 at $DIR/simplify-locals-fixedpoint.rs:4:18: 4:19
15-
let _6: u8; // in scope 1 at $DIR/simplify-locals-fixedpoint.rs:4:18: 4:19
1616
}
1717

1818
bb0: {
19-
StorageLive(_1); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:4:30: 4:69
20-
StorageLive(_2); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:4:31: 4:49
21-
Deinit(_2); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:4:31: 4:49
22-
discriminant(_2) = 0; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:4:31: 4:49
23-
StorageLive(_3); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:4:51: 4:68
24-
Deinit(_3); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:4:51: 4:68
25-
discriminant(_3) = 0; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:4:51: 4:68
26-
Deinit(_1); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:4:30: 4:69
27-
(_1.0: std::option::Option<u8>) = move _2; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:4:30: 4:69
28-
(_1.1: std::option::Option<T>) = move _3; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:4:30: 4:69
29-
StorageDead(_3); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:4:68: 4:69
30-
StorageDead(_2); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:4:68: 4:69
31-
_5 = discriminant((_1.0: std::option::Option<u8>)); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:4:12: 4:27
32-
switchInt(move _5) -> [1_isize: bb1, otherwise: bb3]; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:4:12: 4:27
19+
StorageLive(_1); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:30: 4:69
20+
StorageLive(_2); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:31: 4:49
21+
Deinit(_2); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:31: 4:49
22+
discriminant(_2) = 0; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:31: 4:49
23+
StorageLive(_3); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:51: 4:68
24+
Deinit(_3); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:51: 4:68
25+
discriminant(_3) = 0; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:51: 4:68
26+
Deinit(_1); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:30: 4:69
27+
(_1.0: std::option::Option<u8>) = move _2; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:30: 4:69
28+
(_1.1: std::option::Option<T>) = move _3; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:30: 4:69
29+
StorageDead(_3); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:68: 4:69
30+
StorageDead(_2); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:68: 4:69
31+
_5 = discriminant((_1.0: std::option::Option<u8>)); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:12: 4:27
32+
switchInt(move _5) -> [1_isize: bb1, otherwise: bb3]; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:12: 4:27
3333
}
3434

3535
bb1: {
36-
_4 = discriminant((_1.1: std::option::Option<T>)); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:4:12: 4:27
37-
switchInt(move _4) -> [0_isize: bb2, otherwise: bb3]; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:4:12: 4:27
36+
_4 = discriminant((_1.1: std::option::Option<T>)); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:12: 4:27
37+
switchInt(move _4) -> [0_isize: bb2, otherwise: bb3]; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:12: 4:27
3838
}
3939

4040
bb2: {

0 commit comments

Comments
 (0)