Skip to content

Commit

Permalink
Rollup merge of rust-lang#96212 - marmeladema:nll-revisions-regions, …
Browse files Browse the repository at this point in the history
…r=jackh726

Use revisions instead of nll compare mode for `/regions/` ui tests

Created rust-lang#96211 for the duplicated mismatched types errors

r? `@jackh726`
  • Loading branch information
matthiaskrgr authored Apr 24, 2022
2 parents b7e67a6 + e10aa15 commit 50294f6
Show file tree
Hide file tree
Showing 160 changed files with 743 additions and 470 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
error[E0478]: lifetime bound not satisfied
--> $DIR/issue-28848.rs:10:5
--> $DIR/issue-28848.rs:14:5
|
LL | Foo::<'a, 'b>::xmute(u)
| ^^^^^^^^^^^^^
|
note: lifetime parameter instantiated with the lifetime `'b` as defined here
--> $DIR/issue-28848.rs:9:16
--> $DIR/issue-28848.rs:13:16
|
LL | pub fn foo<'a, 'b>(u: &'b ()) -> &'a () {
| ^^
note: but lifetime parameter must outlive the lifetime `'a` as defined here
--> $DIR/issue-28848.rs:9:12
--> $DIR/issue-28848.rs:13:12
|
LL | pub fn foo<'a, 'b>(u: &'b ()) -> &'a () {
| ^^
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/regions/issue-28848.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/issue-28848.rs:10:5
--> $DIR/issue-28848.rs:14:5
|
LL | pub fn foo<'a, 'b>(u: &'b ()) -> &'a () {
| -- -- lifetime `'b` defined here
Expand Down
8 changes: 7 additions & 1 deletion src/test/ui/regions/issue-28848.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir

struct Foo<'a, 'b: 'a>(&'a &'b ());

impl<'a, 'b> Foo<'a, 'b> {
Expand All @@ -7,7 +11,9 @@ impl<'a, 'b> Foo<'a, 'b> {
}

pub fn foo<'a, 'b>(u: &'b ()) -> &'a () {
Foo::<'a, 'b>::xmute(u) //~ ERROR lifetime bound not satisfied
Foo::<'a, 'b>::xmute(u)
//[base]~^ ERROR lifetime bound not satisfied
//[nll]~^^ ERROR lifetime may not live long enough
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0308]: `if` and `else` have incompatible types
--> $DIR/region-invariant-static-error-reporting.rs:17:9
--> $DIR/region-invariant-static-error-reporting.rs:21:9
|
LL | let bad = if x.is_some() {
| _______________-
Expand All @@ -14,7 +14,7 @@ LL | | };
= note: expected struct `Invariant<'a>`
found struct `Invariant<'static>`
note: the lifetime `'a` as defined here...
--> $DIR/region-invariant-static-error-reporting.rs:13:10
--> $DIR/region-invariant-static-error-reporting.rs:17:10
|
LL | fn unify<'a>(x: Option<Invariant<'a>>, f: fn(Invariant<'a>)) {
| ^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0521]: borrowed data escapes outside of function
--> $DIR/region-invariant-static-error-reporting.rs:15:9
--> $DIR/region-invariant-static-error-reporting.rs:19:9
|
LL | fn unify<'a>(x: Option<Invariant<'a>>, f: fn(Invariant<'a>)) {
| -- - `x` is a reference that is only valid in the function body
Expand Down
12 changes: 8 additions & 4 deletions src/test/ui/regions/region-invariant-static-error-reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@
// over time, but this test used to exhibit some pretty bogus messages
// that were not remotely helpful.

// error-pattern:the lifetime `'a`
// error-pattern:the static lifetime
// revisions: base nll
// ignore-compare-mode-nll
//[base] error-pattern:the lifetime `'a`
//[base] error-pattern:the static lifetime
//[nll] compile-flags: -Z borrowck=mir
//[nll] error-pattern:argument requires that `'a` must outlive `'static`

struct Invariant<'a>(Option<&'a mut &'a mut ()>);

fn mk_static() -> Invariant<'static> { Invariant(None) }

fn unify<'a>(x: Option<Invariant<'a>>, f: fn(Invariant<'a>)) {
let bad = if x.is_some() {
x.unwrap()
x.unwrap() //[nll]~ ERROR borrowed data escapes outside of function [E0521]
} else {
mk_static()
mk_static() //[base]~ ERROR `if` and `else` have incompatible types [E0308]
};
f(bad);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0623]: lifetime mismatch
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:8:10
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:12:10
|
LL | fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) {
| --------- --------- these two types are declared with different lifetimes...
Expand All @@ -8,7 +8,7 @@ LL | *x = *y;
| ^^ ...but data from `y` flows into `x` here

error[E0623]: lifetime mismatch
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:14:7
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:7
|
LL | fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) {
| --------- --------- these two types are declared with different lifetimes...
Expand All @@ -17,7 +17,7 @@ LL | a(x, y);
| ^ ...but data from `y` flows into `x` here

error[E0308]: mismatched types
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:43
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:28:43
|
LL | let _: fn(&mut &isize, &mut &isize) = a;
| ^ one type is more general than the other
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:8:5
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:12:5
|
LL | fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) {
| -- -- lifetime `'b` defined here
Expand All @@ -12,7 +12,7 @@ LL | *x = *y;
= help: consider adding the following bound: `'b: 'a`

error: lifetime may not live long enough
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:14:5
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:5
|
LL | fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) {
| -- -- lifetime `'b` defined here
Expand All @@ -28,7 +28,7 @@ LL | a(x, y);
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance

error[E0308]: mismatched types
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:12
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:28:12
|
LL | let _: fn(&mut &isize, &mut &isize) = a;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
Expand All @@ -37,7 +37,7 @@ LL | let _: fn(&mut &isize, &mut &isize) = a;
found fn pointer `for<'r, 's> fn(&'r mut &isize, &'s mut &isize)`

error[E0308]: mismatched types
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:12
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:28:12
|
LL | let _: fn(&mut &isize, &mut &isize) = a;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
Expand Down
16 changes: 13 additions & 3 deletions src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir

fn a<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) where 'b: 'a {
// Note: this is legal because of the `'b:'a` declaration.
*x = *y;
}

fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) {
// Illegal now because there is no `'b:'a` declaration.
*x = *y; //~ ERROR E0623
*x = *y;
//[base]~^ ERROR E0623
//[nll]~^^ ERROR lifetime may not live long enough
}

fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) {
// Here we try to call `foo` but do not know that `'a` and `'b` are
// related as required.
a(x, y); //~ ERROR lifetime mismatch [E0623]
a(x, y);
//[base]~^ ERROR lifetime mismatch [E0623]
//[nll]~^^ ERROR lifetime may not live long enough
}

fn d() {
// 'a and 'b are early bound in the function `a` because they appear
// inconstraints:
let _: fn(&mut &isize, &mut &isize) = a; //~ ERROR mismatched types
let _: fn(&mut &isize, &mut &isize) = a;
//~^ ERROR mismatched types [E0308]
//[nll]~^^ ERROR mismatched types [E0308]
}

fn e() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0623]: lifetime mismatch
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:9:10
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:13:10
|
LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) {
| --------- --------- these two types are declared with different lifetimes...
Expand All @@ -8,7 +8,7 @@ LL | *x = *y;
| ^^ ...but data from `y` flows into `x` here

error[E0623]: lifetime mismatch
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:10:10
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:16:10
|
LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) {
| --------- ---------
Expand All @@ -19,7 +19,7 @@ LL | *z = *y;
| ^^ ...but data from `y` flows into `z` here

error[E0623]: lifetime mismatch
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:16:7
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:7
|
LL | fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) {
| --------- --------- these two types are declared with different lifetimes...
Expand All @@ -28,7 +28,7 @@ LL | a(x, y, z);
| ^ ...but data from `y` flows into `x` here

error[E0308]: mismatched types
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:56
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:30:56
|
LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a;
| ^ one type is more general than the other
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:9:5
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:13:5
|
LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) {
| -- -- lifetime `'b` defined here
Expand All @@ -12,7 +12,7 @@ LL | *x = *y;
= help: consider adding the following bound: `'b: 'a`

error: lifetime may not live long enough
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:16:5
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:5
|
LL | fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) {
| -- -- lifetime `'b` defined here
Expand All @@ -28,7 +28,7 @@ LL | a(x, y, z);
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance

error[E0308]: mismatched types
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:30:12
|
LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
Expand All @@ -37,7 +37,7 @@ LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a;
found fn pointer `for<'r, 's, 't0> fn(&'r mut &isize, &'s mut &isize, &'t0 mut &isize)`

error[E0308]: mismatched types
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:30:12
|
LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
Expand All @@ -46,7 +46,7 @@ LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a;
found fn pointer `for<'r, 's, 't0> fn(&'r mut &isize, &'s mut &isize, &'t0 mut &isize)`

error[E0308]: mismatched types
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:30:12
|
LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir

fn a<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) where 'b: 'a + 'c {
// Note: this is legal because of the `'b:'a` declaration.
*x = *y;
Expand All @@ -6,20 +10,27 @@ fn a<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) where

fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) {
// Illegal now because there is no `'b:'a` declaration.
*x = *y; //~ ERROR E0623
*z = *y; //~ ERROR E0623
*x = *y;
//[base]~^ ERROR E0623
//[nll]~^^ ERROR lifetime may not live long enough
*z = *y; //[base]~ ERROR E0623
}

fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) {
// Here we try to call `foo` but do not know that `'a` and `'b` are
// related as required.
a(x, y, z); //~ ERROR lifetime mismatch [E0623]
a(x, y, z);
//[base]~^ ERROR lifetime mismatch [E0623]
//[nll]~^^ ERROR lifetime may not live long enough
}

fn d() {
// 'a and 'b are early bound in the function `a` because they appear
// inconstraints:
let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; //~ ERROR E0308
let _: fn(&mut &isize, &mut &isize, &mut &isize) = a;
//~^ ERROR E0308
//[nll]~^^ ERROR mismatched types [E0308]
//[nll]~| ERROR mismatched types [E0308]
}

fn e() {
Expand Down
Loading

0 comments on commit 50294f6

Please sign in to comment.