Skip to content

Commit

Permalink
Never stop due to errors before borrow checking
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Apr 15, 2019
1 parent f69acab commit 8395dbd
Show file tree
Hide file tree
Showing 22 changed files with 146 additions and 35 deletions.
7 changes: 0 additions & 7 deletions src/librustc_interface/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -936,13 +936,6 @@ fn analysis<'tcx>(
});
});

// Abort so we don't try to construct MIR with liveness errors.
// We also won't want to continue with errors from rvalue promotion
// We only do so if the only error found so far *isn't* a missing `fn main()`
if !(entry_point.is_none() && sess.err_count() == 1) {
tcx.sess.abort_if_errors();
}

time(sess, "borrow checking", || {
if tcx.use_ast_borrowck() {
borrowck::check_crate(tcx);
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/consts/const_let_refutable.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fn main() {}

const fn slice([a, b]: &[i32]) -> i32 { //~ ERROR refutable pattern in function argument
a + b
a + b //~ ERROR can only call other `min_const_fn` within a `min_const_fn`
}
13 changes: 11 additions & 2 deletions src/test/ui/consts/const_let_refutable.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ error[E0005]: refutable pattern in function argument: `&[]` not covered
LL | const fn slice([a, b]: &[i32]) -> i32 {
| ^^^^^^ pattern `&[]` not covered

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

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0005`.
Some errors occurred: E0005, E0723.
For more information about an error, try `rustc --explain E0005`.
1 change: 1 addition & 0 deletions src/test/ui/error-codes/E0007.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ fn main() {
op_string @ Some(s) => {},
//~^ ERROR E0007
//~| ERROR E0303
//~| ERROR E0382
None => {},
}
}
15 changes: 13 additions & 2 deletions src/test/ui/error-codes/E0007.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@ error[E0303]: pattern bindings are not allowed after an `@`
LL | op_string @ Some(s) => {},
| ^ not allowed after `@`

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

error: aborting due to 3 previous errors

Some errors occurred: E0007, E0303.
Some errors occurred: E0007, E0303, E0382.
For more information about an error, try `rustc --explain E0007`.
1 change: 1 addition & 0 deletions src/test/ui/error-codes/E0030-teach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ fn main() {
match 5u32 {
1000 ..= 5 => {}
//~^ ERROR lower range bound must be less than or equal to upper
//~| ERROR lower range bound must be less than or equal to upper
}
}
8 changes: 7 additions & 1 deletion src/test/ui/error-codes/E0030-teach.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ LL | 1000 ..= 5 => {}
|
= 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.

error: aborting due to previous error
error[E0030]: lower range bound must be less than or equal to upper
--> $DIR/E0030-teach.rs:5:9
|
LL | 1000 ..= 5 => {}
| ^^^^ lower bound larger than upper bound

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0030`.
2 changes: 1 addition & 1 deletion src/test/ui/error-codes/E0301.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ fn main() {
match Some(()) {
None => { },
option if option.take().is_none() => {}, //~ ERROR E0301
Some(_) => { }
Some(_) => { } //~^ ERROR E0596
}
}
13 changes: 11 additions & 2 deletions src/test/ui/error-codes/E0301.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ error[E0301]: cannot mutably borrow in a pattern guard
LL | option if option.take().is_none() => {},
| ^^^^^^ borrowed mutably in pattern guard

error: aborting due to previous error
error[E0596]: cannot borrow immutable local variable `option` as mutable
--> $DIR/E0301.rs:4:19
|
LL | option if option.take().is_none() => {},
| ------ ^^^^^^ cannot borrow mutably
| |
| help: make this binding mutable: `mut option`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0301`.
Some errors occurred: E0301, E0596.
For more information about an error, try `rustc --explain E0301`.
2 changes: 1 addition & 1 deletion src/test/ui/error-codes/E0302.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ fn main() {
match Some(()) {
None => { },
option if { option = None; false } => { }, //~ ERROR E0302
Some(_) => { }
Some(_) => { } //~^ ERROR E0384
}
}
13 changes: 11 additions & 2 deletions src/test/ui/error-codes/E0302.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ error[E0302]: cannot assign in a pattern guard
LL | option if { option = None; false } => { },
| ^^^^^^^^^^^^^ assignment in pattern guard

error: aborting due to previous error
error[E0384]: cannot assign twice to immutable variable `option`
--> $DIR/E0302.rs:4:21
|
LL | option if { option = None; false } => { },
| ------ ^^^^^^^^^^^^^ cannot assign twice to immutable variable
| |
| first assignment to `option`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0302`.
Some errors occurred: E0302, E0384.
For more information about an error, try `rustc --explain E0302`.
1 change: 1 addition & 0 deletions src/test/ui/issues/issue-23302-3.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const A: i32 = B; //~ ERROR cycle detected
//~^ ERROR cycle detected

const B: i32 = A;

Expand Down
24 changes: 21 additions & 3 deletions src/test/ui/issues/issue-23302-3.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,36 @@ note: ...which requires checking which parts of `A` are promotable to static...
LL | const A: i32 = B;
| ^
note: ...which requires const checking if rvalue is promotable to static `B`...
--> $DIR/issue-23302-3.rs:3:1
--> $DIR/issue-23302-3.rs:4:1
|
LL | const B: i32 = A;
| ^^^^^^^^^^^^^^^^^
note: ...which requires checking which parts of `B` are promotable to static...
--> $DIR/issue-23302-3.rs:3:16
--> $DIR/issue-23302-3.rs:4:16
|
LL | const B: i32 = A;
| ^
= note: ...which again requires const checking if rvalue is promotable to static `A`, completing the cycle
= note: cycle used when running analysis passes on this crate

error: aborting due to previous error
error[E0391]: cycle detected when processing `A`
--> $DIR/issue-23302-3.rs:1:16
|
LL | const A: i32 = B;
| ^
|
note: ...which requires processing `B`...
--> $DIR/issue-23302-3.rs:4:16
|
LL | const B: i32 = A;
| ^
= note: ...which again requires processing `A`, completing the cycle
note: cycle used when processing `A`
--> $DIR/issue-23302-3.rs:1:1
|
LL | const A: i32 = B;
| ^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0391`.
2 changes: 2 additions & 0 deletions src/test/ui/issues/issue-41255.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ fn main() {
match x {
5.0 => {}, //~ ERROR floating-point types cannot be used in patterns
//~| WARNING hard error
//~| ERROR floating-point types cannot be used in patterns
//~| WARNING this was previously accepted by the compiler but is being
5.0f32 => {}, //~ ERROR floating-point types cannot be used in patterns
//~| WARNING hard error
-5.0 => {}, //~ ERROR floating-point types cannot be used in patterns
Expand Down
27 changes: 18 additions & 9 deletions src/test/ui/issues/issue-41255.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ LL | #![forbid(illegal_floating_point_literal_pattern)]
= note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>

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

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

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

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

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

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

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

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

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

error: aborting due to 10 previous errors

2 changes: 2 additions & 0 deletions src/test/ui/issues/issue-6804.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ fn main() {
match x {
NAN => {}, //~ ERROR floating-point types cannot be used
//~^ WARN this was previously accepted by the compiler but is being phased out
//~| ERROR floating-point types cannot be used in patterns
//~| WARN this was previously accepted by the compiler but is being phased out
_ => {},
};

Expand Down
13 changes: 11 additions & 2 deletions src/test/ui/issues/issue-6804.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,22 @@ LL | #![deny(illegal_floating_point_literal_pattern)]
= note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>

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

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

error: aborting due to 3 previous errors

9 changes: 9 additions & 0 deletions src/test/ui/match/match-range-fail-dominate.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,14 @@ error: unreachable pattern
LL | 0.02f64 => {}
| ^^^^^^^

warning: floating-point types cannot be used in patterns
--> $DIR/match-range-fail-dominate.rs:35:7
|
LL | 0.01f64 ... 6.5f64 => {}
| ^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>

error: aborting due to 5 previous errors

1 change: 1 addition & 0 deletions src/test/ui/rfc-2005-default-binding-mode/for.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ pub fn main() {
// The below desugars to &(ref n, mut m).
for (n, mut m) in &tups {
//~^ ERROR cannot bind by-move and by-ref in the same pattern
//~| ERROR cannot move out of borrowed content
}
}
14 changes: 12 additions & 2 deletions src/test/ui/rfc-2005-default-binding-mode/for.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ LL | for (n, mut m) in &tups {
| |
| both by-ref and by-move used

error: aborting due to previous error
error[E0507]: cannot move out of borrowed content
--> $DIR/for.rs:6:9
|
LL | for (n, mut m) in &tups {
| ^^^^-----^
| | |
| | hint: to prevent move, use `ref m` or `ref mut m`
| cannot move out of borrowed content

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0009`.
Some errors occurred: E0009, E0507.
For more information about an error, try `rustc --explain E0009`.
2 changes: 2 additions & 0 deletions src/test/ui/rfc1445/match-forbidden-without-eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ fn main() {
f32::INFINITY => { }
//~^ WARNING floating-point types cannot be used in patterns
//~| WARNING will become a hard error in a future release
//~| WARNING floating-point types cannot be used in patterns
//~| WARNING this was previously accepted by the compiler but is being phased out
_ => { }
}
}
9 changes: 9 additions & 0 deletions src/test/ui/rfc1445/match-forbidden-without-eq.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,14 @@ LL | f32::INFINITY => { }
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>

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

error: aborting due to previous error

0 comments on commit 8395dbd

Please sign in to comment.