Skip to content

Commit 8395dbd

Browse files
committed
Never stop due to errors before borrow checking
1 parent f69acab commit 8395dbd

22 files changed

+146
-35
lines changed

src/librustc_interface/passes.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -936,13 +936,6 @@ fn analysis<'tcx>(
936936
});
937937
});
938938

939-
// Abort so we don't try to construct MIR with liveness errors.
940-
// We also won't want to continue with errors from rvalue promotion
941-
// We only do so if the only error found so far *isn't* a missing `fn main()`
942-
if !(entry_point.is_none() && sess.err_count() == 1) {
943-
tcx.sess.abort_if_errors();
944-
}
945-
946939
time(sess, "borrow checking", || {
947940
if tcx.use_ast_borrowck() {
948941
borrowck::check_crate(tcx);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
fn main() {}
22

33
const fn slice([a, b]: &[i32]) -> i32 { //~ ERROR refutable pattern in function argument
4-
a + b
4+
a + b //~ ERROR can only call other `min_const_fn` within a `min_const_fn`
55
}

src/test/ui/consts/const_let_refutable.stderr

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ error[E0005]: refutable pattern in function argument: `&[]` not covered
44
LL | const fn slice([a, b]: &[i32]) -> i32 {
55
| ^^^^^^ pattern `&[]` not covered
66

7-
error: aborting due to previous error
7+
error[E0723]: can only call other `min_const_fn` within a `min_const_fn` (see issue #57563)
8+
--> $DIR/const_let_refutable.rs:4:5
9+
|
10+
LL | a + b
11+
| ^^^^^
12+
|
13+
= help: add #![feature(const_fn)] to the crate attributes to enable
14+
15+
error: aborting due to 2 previous errors
816

9-
For more information about this error, try `rustc --explain E0005`.
17+
Some errors occurred: E0005, E0723.
18+
For more information about an error, try `rustc --explain E0005`.

src/test/ui/error-codes/E0007.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ fn main() {
44
op_string @ Some(s) => {},
55
//~^ ERROR E0007
66
//~| ERROR E0303
7+
//~| ERROR E0382
78
None => {},
89
}
910
}

src/test/ui/error-codes/E0007.stderr

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,18 @@ error[E0303]: pattern bindings are not allowed after an `@`
1010
LL | op_string @ Some(s) => {},
1111
| ^ not allowed after `@`
1212

13-
error: aborting due to 2 previous errors
13+
error[E0382]: use of partially moved value: `x`
14+
--> $DIR/E0007.rs:4:9
15+
|
16+
LL | op_string @ Some(s) => {},
17+
| ^^^^^^^^^^^^^^^^^-^
18+
| | |
19+
| | value moved here
20+
| value used here after move
21+
|
22+
= note: move occurs because the value has type `std::string::String`, which does not implement the `Copy` trait
23+
24+
error: aborting due to 3 previous errors
1425

15-
Some errors occurred: E0007, E0303.
26+
Some errors occurred: E0007, E0303, E0382.
1627
For more information about an error, try `rustc --explain E0007`.

src/test/ui/error-codes/E0030-teach.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ fn main() {
44
match 5u32 {
55
1000 ..= 5 => {}
66
//~^ ERROR lower range bound must be less than or equal to upper
7+
//~| ERROR lower range bound must be less than or equal to upper
78
}
89
}

src/test/ui/error-codes/E0030-teach.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ LL | 1000 ..= 5 => {}
66
|
77
= note: When matching against a range, the compiler verifies that the range is non-empty. Range patterns include both end-points, so this is equivalent to requiring the start of the range to be less than or equal to the end of the range.
88

9-
error: aborting due to previous error
9+
error[E0030]: lower range bound must be less than or equal to upper
10+
--> $DIR/E0030-teach.rs:5:9
11+
|
12+
LL | 1000 ..= 5 => {}
13+
| ^^^^ lower bound larger than upper bound
14+
15+
error: aborting due to 2 previous errors
1016

1117
For more information about this error, try `rustc --explain E0030`.

src/test/ui/error-codes/E0301.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ fn main() {
22
match Some(()) {
33
None => { },
44
option if option.take().is_none() => {}, //~ ERROR E0301
5-
Some(_) => { }
5+
Some(_) => { } //~^ ERROR E0596
66
}
77
}

src/test/ui/error-codes/E0301.stderr

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ error[E0301]: cannot mutably borrow in a pattern guard
44
LL | option if option.take().is_none() => {},
55
| ^^^^^^ borrowed mutably in pattern guard
66

7-
error: aborting due to previous error
7+
error[E0596]: cannot borrow immutable local variable `option` as mutable
8+
--> $DIR/E0301.rs:4:19
9+
|
10+
LL | option if option.take().is_none() => {},
11+
| ------ ^^^^^^ cannot borrow mutably
12+
| |
13+
| help: make this binding mutable: `mut option`
14+
15+
error: aborting due to 2 previous errors
816

9-
For more information about this error, try `rustc --explain E0301`.
17+
Some errors occurred: E0301, E0596.
18+
For more information about an error, try `rustc --explain E0301`.

src/test/ui/error-codes/E0302.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ fn main() {
22
match Some(()) {
33
None => { },
44
option if { option = None; false } => { }, //~ ERROR E0302
5-
Some(_) => { }
5+
Some(_) => { } //~^ ERROR E0384
66
}
77
}

src/test/ui/error-codes/E0302.stderr

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ error[E0302]: cannot assign in a pattern guard
44
LL | option if { option = None; false } => { },
55
| ^^^^^^^^^^^^^ assignment in pattern guard
66

7-
error: aborting due to previous error
7+
error[E0384]: cannot assign twice to immutable variable `option`
8+
--> $DIR/E0302.rs:4:21
9+
|
10+
LL | option if { option = None; false } => { },
11+
| ------ ^^^^^^^^^^^^^ cannot assign twice to immutable variable
12+
| |
13+
| first assignment to `option`
14+
15+
error: aborting due to 2 previous errors
816

9-
For more information about this error, try `rustc --explain E0302`.
17+
Some errors occurred: E0302, E0384.
18+
For more information about an error, try `rustc --explain E0302`.

src/test/ui/issues/issue-23302-3.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const A: i32 = B; //~ ERROR cycle detected
2+
//~^ ERROR cycle detected
23

34
const B: i32 = A;
45

src/test/ui/issues/issue-23302-3.stderr

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,36 @@ note: ...which requires checking which parts of `A` are promotable to static...
1010
LL | const A: i32 = B;
1111
| ^
1212
note: ...which requires const checking if rvalue is promotable to static `B`...
13-
--> $DIR/issue-23302-3.rs:3:1
13+
--> $DIR/issue-23302-3.rs:4:1
1414
|
1515
LL | const B: i32 = A;
1616
| ^^^^^^^^^^^^^^^^^
1717
note: ...which requires checking which parts of `B` are promotable to static...
18-
--> $DIR/issue-23302-3.rs:3:16
18+
--> $DIR/issue-23302-3.rs:4:16
1919
|
2020
LL | const B: i32 = A;
2121
| ^
2222
= note: ...which again requires const checking if rvalue is promotable to static `A`, completing the cycle
2323
= note: cycle used when running analysis passes on this crate
2424

25-
error: aborting due to previous error
25+
error[E0391]: cycle detected when processing `A`
26+
--> $DIR/issue-23302-3.rs:1:16
27+
|
28+
LL | const A: i32 = B;
29+
| ^
30+
|
31+
note: ...which requires processing `B`...
32+
--> $DIR/issue-23302-3.rs:4:16
33+
|
34+
LL | const B: i32 = A;
35+
| ^
36+
= note: ...which again requires processing `A`, completing the cycle
37+
note: cycle used when processing `A`
38+
--> $DIR/issue-23302-3.rs:1:1
39+
|
40+
LL | const A: i32 = B;
41+
| ^^^^^^^^^^^^^^^^^
42+
43+
error: aborting due to 2 previous errors
2644

2745
For more information about this error, try `rustc --explain E0391`.

src/test/ui/issues/issue-41255.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ fn main() {
99
match x {
1010
5.0 => {}, //~ ERROR floating-point types cannot be used in patterns
1111
//~| WARNING hard error
12+
//~| ERROR floating-point types cannot be used in patterns
13+
//~| WARNING this was previously accepted by the compiler but is being
1214
5.0f32 => {}, //~ ERROR floating-point types cannot be used in patterns
1315
//~| WARNING hard error
1416
-5.0 => {}, //~ ERROR floating-point types cannot be used in patterns

src/test/ui/issues/issue-41255.stderr

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ LL | #![forbid(illegal_floating_point_literal_pattern)]
1313
= note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
1414

1515
error: floating-point types cannot be used in patterns
16-
--> $DIR/issue-41255.rs:12:9
16+
--> $DIR/issue-41255.rs:14:9
1717
|
1818
LL | 5.0f32 => {},
1919
| ^^^^^^
@@ -22,7 +22,7 @@ LL | 5.0f32 => {},
2222
= note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
2323

2424
error: floating-point types cannot be used in patterns
25-
--> $DIR/issue-41255.rs:14:10
25+
--> $DIR/issue-41255.rs:16:10
2626
|
2727
LL | -5.0 => {},
2828
| ^^^
@@ -31,7 +31,7 @@ LL | -5.0 => {},
3131
= note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
3232

3333
error: floating-point types cannot be used in patterns
34-
--> $DIR/issue-41255.rs:16:9
34+
--> $DIR/issue-41255.rs:18:9
3535
|
3636
LL | 1.0 .. 33.0 => {},
3737
| ^^^
@@ -40,7 +40,7 @@ LL | 1.0 .. 33.0 => {},
4040
= note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
4141

4242
error: floating-point types cannot be used in patterns
43-
--> $DIR/issue-41255.rs:16:16
43+
--> $DIR/issue-41255.rs:18:16
4444
|
4545
LL | 1.0 .. 33.0 => {},
4646
| ^^^^
@@ -49,7 +49,7 @@ LL | 1.0 .. 33.0 => {},
4949
= note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
5050

5151
error: floating-point types cannot be used in patterns
52-
--> $DIR/issue-41255.rs:20:9
52+
--> $DIR/issue-41255.rs:22:9
5353
|
5454
LL | 39.0 ..= 70.0 => {},
5555
| ^^^^
@@ -58,7 +58,7 @@ LL | 39.0 ..= 70.0 => {},
5858
= note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
5959

6060
error: floating-point types cannot be used in patterns
61-
--> $DIR/issue-41255.rs:20:18
61+
--> $DIR/issue-41255.rs:22:18
6262
|
6363
LL | 39.0 ..= 70.0 => {},
6464
| ^^^^
@@ -67,7 +67,7 @@ LL | 39.0 ..= 70.0 => {},
6767
= note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
6868

6969
error: floating-point types cannot be used in patterns
70-
--> $DIR/issue-41255.rs:29:10
70+
--> $DIR/issue-41255.rs:31:10
7171
|
7272
LL | (3.14, 1) => {},
7373
| ^^^^
@@ -76,13 +76,22 @@ LL | (3.14, 1) => {},
7676
= note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
7777

7878
error: floating-point types cannot be used in patterns
79-
--> $DIR/issue-41255.rs:36:18
79+
--> $DIR/issue-41255.rs:38:18
8080
|
8181
LL | Foo { x: 2.0 } => {},
8282
| ^^^
8383
|
8484
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
8585
= note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
8686

87-
error: aborting due to 9 previous errors
87+
error: floating-point types cannot be used in patterns
88+
--> $DIR/issue-41255.rs:10:9
89+
|
90+
LL | 5.0 => {},
91+
| ^^^
92+
|
93+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
94+
= note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
95+
96+
error: aborting due to 10 previous errors
8897

src/test/ui/issues/issue-6804.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ fn main() {
1010
match x {
1111
NAN => {}, //~ ERROR floating-point types cannot be used
1212
//~^ WARN this was previously accepted by the compiler but is being phased out
13+
//~| ERROR floating-point types cannot be used in patterns
14+
//~| WARN this was previously accepted by the compiler but is being phased out
1315
_ => {},
1416
};
1517

src/test/ui/issues/issue-6804.stderr

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,22 @@ LL | #![deny(illegal_floating_point_literal_pattern)]
1313
= note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
1414

1515
error: floating-point types cannot be used in patterns
16-
--> $DIR/issue-6804.rs:17:10
16+
--> $DIR/issue-6804.rs:19:10
1717
|
1818
LL | [NAN, _] => {},
1919
| ^^^
2020
|
2121
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2222
= note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
2323

24-
error: aborting due to 2 previous errors
24+
error: floating-point types cannot be used in patterns
25+
--> $DIR/issue-6804.rs:11:9
26+
|
27+
LL | NAN => {},
28+
| ^^^
29+
|
30+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
31+
= note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
32+
33+
error: aborting due to 3 previous errors
2534

src/test/ui/match/match-range-fail-dominate.stderr

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,14 @@ error: unreachable pattern
6262
LL | 0.02f64 => {}
6363
| ^^^^^^^
6464

65+
warning: floating-point types cannot be used in patterns
66+
--> $DIR/match-range-fail-dominate.rs:35:7
67+
|
68+
LL | 0.01f64 ... 6.5f64 => {}
69+
| ^^^^^^^
70+
|
71+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
72+
= note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
73+
6574
error: aborting due to 5 previous errors
6675

src/test/ui/rfc-2005-default-binding-mode/for.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ pub fn main() {
55
// The below desugars to &(ref n, mut m).
66
for (n, mut m) in &tups {
77
//~^ ERROR cannot bind by-move and by-ref in the same pattern
8+
//~| ERROR cannot move out of borrowed content
89
}
910
}

src/test/ui/rfc-2005-default-binding-mode/for.stderr

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ LL | for (n, mut m) in &tups {
66
| |
77
| both by-ref and by-move used
88

9-
error: aborting due to previous error
9+
error[E0507]: cannot move out of borrowed content
10+
--> $DIR/for.rs:6:9
11+
|
12+
LL | for (n, mut m) in &tups {
13+
| ^^^^-----^
14+
| | |
15+
| | hint: to prevent move, use `ref m` or `ref mut m`
16+
| cannot move out of borrowed content
17+
18+
error: aborting due to 2 previous errors
1019

11-
For more information about this error, try `rustc --explain E0009`.
20+
Some errors occurred: E0009, E0507.
21+
For more information about an error, try `rustc --explain E0009`.

src/test/ui/rfc1445/match-forbidden-without-eq.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ fn main() {
2020
f32::INFINITY => { }
2121
//~^ WARNING floating-point types cannot be used in patterns
2222
//~| WARNING will become a hard error in a future release
23+
//~| WARNING floating-point types cannot be used in patterns
24+
//~| WARNING this was previously accepted by the compiler but is being phased out
2325
_ => { }
2426
}
2527
}

src/test/ui/rfc1445/match-forbidden-without-eq.stderr

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,14 @@ LL | f32::INFINITY => { }
1414
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1515
= note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
1616

17+
warning: floating-point types cannot be used in patterns
18+
--> $DIR/match-forbidden-without-eq.rs:20:9
19+
|
20+
LL | f32::INFINITY => { }
21+
| ^^^^^^^^^^^^^
22+
|
23+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
24+
= note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
25+
1726
error: aborting due to previous error
1827

0 commit comments

Comments
 (0)