Skip to content

Commit 37ba9ca

Browse files
committed
Disable some nice region errors in NLL mode.
1 parent 4b8089d commit 37ba9ca

File tree

39 files changed

+205
-187
lines changed

39 files changed

+205
-187
lines changed

src/librustc/infer/error_reporting/nice_region_error/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ impl<'cx, 'gcx, 'tcx> NiceRegionError<'cx, 'gcx, 'tcx> {
6464
Self { tcx, error: None, regions: Some((span, sub, sup)), tables }
6565
}
6666

67+
pub fn try_report_from_nll(&self) -> Option<ErrorReported> {
68+
// Due to the improved diagnostics returned by the MIR borrow checker, only a subset of
69+
// the nice region errors are required when running under the MIR borrow checker.
70+
self.try_report_named_anon_conflict()
71+
}
72+
6773
pub fn try_report(&self) -> Option<ErrorReported> {
6874
self.try_report_named_anon_conflict()
6975
.or_else(|| self.try_report_anon_anon_conflict())

src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
310310
if let (Some(f), Some(o)) = (self.to_error_region(fr), self.to_error_region(outlived_fr)) {
311311
let tables = infcx.tcx.typeck_tables_of(mir_def_id);
312312
let nice = NiceRegionError::new_from_span(infcx.tcx, span, o, f, Some(tables));
313-
if let Some(_error_reported) = nice.try_report() {
313+
if let Some(_error_reported) = nice.try_report_from_nll() {
314314
return;
315315
}
316316
}

src/test/compile-fail/nll/where_clauses_in_functions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ where
2121

2222
fn bar<'a, 'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
2323
foo(x, y)
24-
//~^ ERROR lifetime mismatch [E0623]
24+
//~^ ERROR unsatisfied lifetime constraints
2525
//~| WARNING not reporting region error due to nll
2626
}
2727

src/test/compile-fail/nll/where_clauses_in_structs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct Foo<'a: 'b, 'b> {
2121

2222
fn bar<'a, 'b>(x: Cell<&'a u32>, y: Cell<&'b u32>) {
2323
Foo { x, y };
24-
//~^ ERROR lifetime mismatch [E0623]
24+
//~^ ERROR unsatisfied lifetime constraints
2525
//~| WARNING not reporting region error due to nll
2626
}
2727

src/test/ui/in-band-lifetimes/mismatched.nll.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ LL | fn foo(x: &'a u32, y: &u32) -> &'a u32 { y } //~ ERROR explicit lifetime re
1818
| |
1919
| consider changing the type of `y` to `&'a u32`
2020

21-
error[E0623]: lifetime mismatch
21+
error: unsatisfied lifetime constraints
2222
--> $DIR/mismatched.rs:16:46
2323
|
2424
LL | fn foo2(x: &'a u32, y: &'b u32) -> &'a u32 { y } //~ ERROR lifetime mismatch
25-
| ------- ------- ^ ...but data from `y` is returned here
26-
| |
27-
| this parameter and the return type are declared with different lifetimes...
25+
| -- -- ^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
26+
| | |
27+
| | lifetime `'b` defined here
28+
| lifetime `'a` defined here
2829

2930
error: aborting due to 2 previous errors
3031

31-
Some errors occurred: E0621, E0623.
32-
For more information about an error, try `rustc --explain E0621`.
32+
For more information about this error, try `rustc --explain E0621`.

src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.nll.stderr

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@ warning: not reporting region error due to nll
44
LL | if x > y { x } else { y } //~ ERROR lifetime mismatch
55
| ^
66

7-
error[E0623]: lifetime mismatch
7+
error: unsatisfied lifetime constraints
88
--> $DIR/ex1-return-one-existing-name-if-else-using-impl.rs:21:12
99
|
1010
LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
11-
| ---- -------
12-
| |
13-
| this parameter and the return type are declared with different lifetimes...
11+
| -- - let's call the lifetime of this reference `'1`
12+
| |
13+
| lifetime `'a` defined here
1414
LL |
1515
LL | if x > y { x } else { y } //~ ERROR lifetime mismatch
16-
| ^^^^^ ...but data from `x` is returned here
16+
| ^^^^^ requires that `'1` must outlive `'a`
1717

1818
error: aborting due to previous error
1919

20-
For more information about this error, try `rustc --explain E0623`.

src/test/ui/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.nll.stderr

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@ warning: not reporting region error due to nll
44
LL | x //~ ERROR lifetime mismatch
55
| ^
66

7-
error[E0623]: lifetime mismatch
7+
error: unsatisfied lifetime constraints
88
--> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:18:5
99
|
1010
LL | fn foo<'a>(&self, x: &'a i32) -> &i32 {
11-
| ------- ----
12-
| |
13-
| this parameter and the return type are declared with different lifetimes...
11+
| -- - let's call the lifetime of this reference `'1`
12+
| |
13+
| lifetime `'a` defined here
1414
LL |
1515
LL | x //~ ERROR lifetime mismatch
16-
| ^ ...but data from `x` is returned here
16+
| ^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1`
1717

1818
error: aborting due to previous error
1919

20-
For more information about this error, try `rustc --explain E0623`.

src/test/ui/lifetime-errors/ex1-return-one-existing-name-self-is-anon.nll.stderr

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@ warning: not reporting region error due to nll
44
LL | if true { x } else { self } //~ ERROR lifetime mismatch
55
| ^^^^
66

7-
error[E0623]: lifetime mismatch
7+
error: unsatisfied lifetime constraints
88
--> $DIR/ex1-return-one-existing-name-self-is-anon.rs:18:9
99
|
1010
LL | fn foo<'a>(&self, x: &'a Foo) -> &'a Foo {
11-
| ----- -------
12-
| |
13-
| this parameter and the return type are declared with different lifetimes...
11+
| -- - let's call the lifetime of this reference `'1`
12+
| |
13+
| lifetime `'a` defined here
1414
LL |
1515
LL | if true { x } else { self } //~ ERROR lifetime mismatch
16-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...but data from `self` is returned here
16+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'1` must outlive `'a`
1717

1818
error: aborting due to previous error
1919

20-
For more information about this error, try `rustc --explain E0623`.

src/test/ui/lifetime-errors/ex2b-push-no-existing-names.nll.stderr

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ warning: not reporting region error due to nll
44
LL | x.push(y); //~ ERROR lifetime mismatch
55
| ^
66

7-
error[E0623]: lifetime mismatch
7+
error: unsatisfied lifetime constraints
88
--> $DIR/ex2b-push-no-existing-names.rs:16:5
99
|
1010
LL | fn foo(x: &mut Vec<Ref<i32>>, y: Ref<i32>) {
11-
| -------- -------- these two types are declared with different lifetimes...
11+
| -------- -------- lifetime `'1` appears in this type
12+
| |
13+
| lifetime `'2` appears in this type
1214
LL | x.push(y); //~ ERROR lifetime mismatch
13-
| ^^^^^^^^^ ...but data from `y` flows into `x` here
15+
| ^^^^^^^^^ argument requires that `'1` must outlive `'2`
1416

1517
error: aborting due to previous error
1618

17-
For more information about this error, try `rustc --explain E0623`.

src/test/ui/lifetime-errors/ex2c-push-inference-variable.nll.stderr

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ warning: not reporting region error due to nll
44
LL | let z = Ref { data: y.data };
55
| ^^^
66

7-
error[E0623]: lifetime mismatch
7+
error: unsatisfied lifetime constraints
88
--> $DIR/ex2c-push-inference-variable.rs:17:5
99
|
1010
LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
11-
| ------------ ------------ these two types are declared with different lifetimes...
11+
| -- -- lifetime `'c` defined here
12+
| |
13+
| lifetime `'b` defined here
1214
LL | let z = Ref { data: y.data };
1315
LL | x.push(z); //~ ERROR lifetime mismatch
14-
| ^^^^^^^^^ ...but data from `y` flows into `x` here
16+
| ^^^^^^^^^ argument requires that `'c` must outlive `'b`
1517

1618
error: aborting due to previous error
1719

18-
For more information about this error, try `rustc --explain E0623`.

src/test/ui/lifetime-errors/ex2d-push-inference-variable-2.nll.stderr

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ warning: not reporting region error due to nll
44
LL | let b = Ref { data: y.data };
55
| ^^^
66

7-
error[E0623]: lifetime mismatch
7+
error: unsatisfied lifetime constraints
88
--> $DIR/ex2d-push-inference-variable-2.rs:18:5
99
|
1010
LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
11-
| ------------ ------------ these two types are declared with different lifetimes...
11+
| -- -- lifetime `'c` defined here
12+
| |
13+
| lifetime `'b` defined here
1214
...
1315
LL | a.push(b);
14-
| ^^^^^^^^^ ...but data from `y` flows into `x` here
16+
| ^^^^^^^^^ argument requires that `'c` must outlive `'b`
1517

1618
error: aborting due to previous error
1719

18-
For more information about this error, try `rustc --explain E0623`.

src/test/ui/lifetime-errors/ex2e-push-inference-variable-3.nll.stderr

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ warning: not reporting region error due to nll
44
LL | let b = Ref { data: y.data };
55
| ^^^
66

7-
error[E0623]: lifetime mismatch
7+
error: unsatisfied lifetime constraints
88
--> $DIR/ex2e-push-inference-variable-3.rs:18:5
99
|
1010
LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
11-
| ------------ ------------ these two types are declared with different lifetimes...
11+
| -- -- lifetime `'c` defined here
12+
| |
13+
| lifetime `'b` defined here
1214
...
1315
LL | Vec::push(a, b);
14-
| ^^^^^^^^^^^^^^^ ...but data from `y` flows into `x` here
16+
| ^^^^^^^^^^^^^^^ argument requires that `'c` must outlive `'b`
1517

1618
error: aborting due to previous error
1719

18-
For more information about this error, try `rustc --explain E0623`.

src/test/ui/lifetime-errors/ex3-both-anon-regions-2.nll.stderr

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ warning: not reporting region error due to nll
44
LL | *v = x; //~ ERROR lifetime mismatch
55
| ^
66

7-
error[E0623]: lifetime mismatch
7+
error: unsatisfied lifetime constraints
88
--> $DIR/ex3-both-anon-regions-2.rs:12:5
99
|
1010
LL | fn foo(&mut (ref mut v, w): &mut (&u8, &u8), x: &u8) {
11-
| --- --- these two types are declared with different lifetimes...
11+
| - - let's call the lifetime of this reference `'1`
12+
| |
13+
| let's call the lifetime of this reference `'2`
1214
LL | *v = x; //~ ERROR lifetime mismatch
13-
| ^^^^^^ ...but data from `x` flows here
15+
| ^^^^^^ requires that `'1` must outlive `'2`
1416

1517
error: aborting due to previous error
1618

17-
For more information about this error, try `rustc --explain E0623`.

src/test/ui/lifetime-errors/ex3-both-anon-regions-3.nll.stderr

+10-7
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,25 @@ warning: not reporting region error due to nll
1010
LL | z.push((x,y)); //~ ERROR lifetime mismatch
1111
| ^
1212

13-
error[E0623]: lifetime mismatch
13+
error: unsatisfied lifetime constraints
1414
--> $DIR/ex3-both-anon-regions-3.rs:12:5
1515
|
1616
LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) {
17-
| --- --- these two types are declared with different lifetimes...
17+
| - - let's call the lifetime of this reference `'1`
18+
| |
19+
| let's call the lifetime of this reference `'2`
1820
LL | z.push((x,y)); //~ ERROR lifetime mismatch
19-
| ^^^^^^^^^^^^^ ...but data flows into `z` here
21+
| ^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2`
2022

21-
error[E0623]: lifetime mismatch
23+
error: unsatisfied lifetime constraints
2224
--> $DIR/ex3-both-anon-regions-3.rs:12:5
2325
|
2426
LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) {
25-
| --- --- these two types are declared with different lifetimes...
27+
| - - let's call the lifetime of this reference `'1`
28+
| |
29+
| let's call the lifetime of this reference `'2`
2630
LL | z.push((x,y)); //~ ERROR lifetime mismatch
27-
| ^^^^^^^^^^^^^ ...but data flows into `z` here
31+
| ^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2`
2832

2933
error: aborting due to 2 previous errors
3034

31-
For more information about this error, try `rustc --explain E0623`.

src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.nll.stderr

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ warning: not reporting region error due to nll
44
LL | x.b = y.b; //~ ERROR lifetime mismatch
55
| ^^^
66

7-
error[E0623]: lifetime mismatch
7+
error: unsatisfied lifetime constraints
88
--> $DIR/ex3-both-anon-regions-both-are-structs-2.rs:16:5
99
|
1010
LL | fn foo(mut x: Ref, y: Ref) {
11-
| --- --- these two types are declared with different lifetimes...
11+
| --- --- lifetime `'1` appears in this type
12+
| |
13+
| lifetime `'2` appears in this type
1214
LL | x.b = y.b; //~ ERROR lifetime mismatch
13-
| ^^^^^^^^^ ...but data from `y` flows into `x` here
15+
| ^^^^^^^^^ requires that `'1` must outlive `'2`
1416

1517
error: aborting due to previous error
1618

17-
For more information about this error, try `rustc --explain E0623`.

src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.nll.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ warning: not reporting region error due to nll
44
LL | x.a = x.b; //~ ERROR lifetime mismatch
55
| ^^^
66

7-
error[E0623]: lifetime mismatch
7+
error: unsatisfied lifetime constraints
88
--> $DIR/ex3-both-anon-regions-both-are-structs-3.rs:16:5
99
|
1010
LL | fn foo(mut x: Ref) {
1111
| ---
1212
| |
13-
| this type is declared with multiple lifetimes...
13+
| lifetime `'1` appears in this type
14+
| lifetime `'2` appears in this type
1415
LL | x.a = x.b; //~ ERROR lifetime mismatch
15-
| ^^^^^^^^^ ...but data with one lifetime flows into the other here
16+
| ^^^^^^^^^ requires that `'1` must outlive `'2`
1617

1718
error: aborting due to previous error
1819

19-
For more information about this error, try `rustc --explain E0623`.

src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.nll.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ warning: not reporting region error due to nll
44
LL | x.a = x.b; //~ ERROR lifetime mismatch
55
| ^^^
66

7-
error[E0623]: lifetime mismatch
7+
error: unsatisfied lifetime constraints
88
--> $DIR/ex3-both-anon-regions-both-are-structs-4.rs:16:5
99
|
1010
LL | fn foo(mut x: Ref) {
1111
| ---
1212
| |
13-
| this type is declared with multiple lifetimes...
13+
| lifetime `'1` appears in this type
14+
| lifetime `'2` appears in this type
1415
LL | x.a = x.b; //~ ERROR lifetime mismatch
15-
| ^^^^^^^^^ ...but data with one lifetime flows into the other here
16+
| ^^^^^^^^^ requires that `'1` must outlive `'2`
1617

1718
error: aborting due to previous error
1819

19-
For more information about this error, try `rustc --explain E0623`.

src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.nll.stderr

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ warning: not reporting region error due to nll
44
LL | x.push(y); //~ ERROR lifetime mismatch
55
| ^
66

7-
error[E0623]: lifetime mismatch
7+
error: unsatisfied lifetime constraints
88
--> $DIR/ex3-both-anon-regions-both-are-structs-earlybound-regions.rs:18:5
99
|
1010
LL | fn foo<'a, 'b>(mut x: Vec<Ref<'a>>, y: Ref<'b>)
11-
| ------- ------- these two types are declared with different lifetimes...
11+
| -- -- lifetime `'b` defined here
12+
| |
13+
| lifetime `'a` defined here
1214
...
1315
LL | x.push(y); //~ ERROR lifetime mismatch
14-
| ^^^^^^^^^ ...but data from `y` flows into `x` here
16+
| ^^^^^^^^^ argument requires that `'b` must outlive `'a`
1517

1618
error: aborting due to previous error
1719

18-
For more information about this error, try `rustc --explain E0623`.

src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.nll.stderr

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ warning: not reporting region error due to nll
44
LL | x.push(y); //~ ERROR lifetime mismatch
55
| ^
66

7-
error[E0623]: lifetime mismatch
7+
error: unsatisfied lifetime constraints
88
--> $DIR/ex3-both-anon-regions-both-are-structs-latebound-regions.rs:15:5
99
|
1010
LL | fn foo<'a, 'b>(mut x: Vec<Ref<'a>>, y: Ref<'b>) {
11-
| ------- ------- these two types are declared with different lifetimes...
11+
| -- -- lifetime `'b` defined here
12+
| |
13+
| lifetime `'a` defined here
1214
LL | x.push(y); //~ ERROR lifetime mismatch
13-
| ^^^^^^^^^ ...but data from `y` flows into `x` here
15+
| ^^^^^^^^^ argument requires that `'b` must outlive `'a`
1416

1517
error: aborting due to previous error
1618

17-
For more information about this error, try `rustc --explain E0623`.

src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs.nll.stderr

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ warning: not reporting region error due to nll
44
LL | x.push(y); //~ ERROR lifetime mismatch
55
| ^
66

7-
error[E0623]: lifetime mismatch
7+
error: unsatisfied lifetime constraints
88
--> $DIR/ex3-both-anon-regions-both-are-structs.rs:15:5
99
|
1010
LL | fn foo(mut x: Vec<Ref>, y: Ref) {
11-
| --- --- these two types are declared with different lifetimes...
11+
| --- --- lifetime `'1` appears in this type
12+
| |
13+
| lifetime `'2` appears in this type
1214
LL | x.push(y); //~ ERROR lifetime mismatch
13-
| ^^^^^^^^^ ...but data from `y` flows into `x` here
15+
| ^^^^^^^^^ argument requires that `'1` must outlive `'2`
1416

1517
error: aborting due to previous error
1618

17-
For more information about this error, try `rustc --explain E0623`.

0 commit comments

Comments
 (0)