Skip to content

Commit

Permalink
Auto merge of #97258 - jackh726:nll-revisions, r=cjgillot
Browse files Browse the repository at this point in the history
Move remaining tests with NLL differences to revisions

Based on #97206

I've already filed issues for any important differences that I've spotted: #97252 #97253 #97256 #97267

There is a lot here, but each commit is self-contained as a separate directory. I can split into separate PRs as wanted or needed.
  • Loading branch information
bors committed May 22, 2022
2 parents b2eed72 + 383fbee commit 07e7b43
Show file tree
Hide file tree
Showing 395 changed files with 2,273 additions and 1,080 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0623]: lifetime mismatch
--> $DIR/implied-region-constraints.rs:17:64
--> $DIR/implied-region-constraints.rs:21:64
|
LL | fn _bad_st<'a, 'b, T>(x: St<'a, 'b, T>)
| ------------- this type is declared with multiple lifetimes...
Expand All @@ -8,7 +8,7 @@ LL | let _failure_proves_not_implied_outlives_region_b: &'b T = &x.f0;
| ^^^^^ ...but data with one lifetime flows into the other here

error[E0623]: lifetime mismatch
--> $DIR/implied-region-constraints.rs:38:72
--> $DIR/implied-region-constraints.rs:43:72
|
LL | fn _bad_en7<'a, 'b, T>(x: En7<'a, 'b, T>)
| -------------- this type is declared with multiple lifetimes...
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/implied-region-constraints.rs:17:56
--> $DIR/implied-region-constraints.rs:21:56
|
LL | fn _bad_st<'a, 'b, T>(x: St<'a, 'b, T>)
| -- -- lifetime `'b` defined here
Expand All @@ -12,7 +12,7 @@ LL | let _failure_proves_not_implied_outlives_region_b: &'b T = &x.f0;
= help: consider adding the following bound: `'a: 'b`

error: lifetime may not live long enough
--> $DIR/implied-region-constraints.rs:38:64
--> $DIR/implied-region-constraints.rs:43:64
|
LL | fn _bad_en7<'a, 'b, T>(x: En7<'a, 'b, T>)
| -- -- lifetime `'b` defined here
Expand Down
10 changes: 8 additions & 2 deletions src/test/ui/associated-type-bounds/implied-region-constraints.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

#![feature(associated_type_bounds)]

trait Tr1 { type As1; }
Expand All @@ -15,7 +19,8 @@ where
{
// This should fail because `T: 'b` is not implied from `WF(St<'a, 'b, T>)`.
let _failure_proves_not_implied_outlives_region_b: &'b T = &x.f0;
//~^ ERROR lifetime mismatch [E0623]
//[base]~^ ERROR lifetime mismatch [E0623]
//[nll]~^^ ERROR lifetime may not live long enough
}

enum En7<'a, 'b, T> // `<T::As1 as Tr2>::As2: 'a` is implied.
Expand All @@ -36,7 +41,8 @@ where
En7::V0(x) => {
// Also fails for the same reason as above:
let _failure_proves_not_implied_outlives_region_b: &'b T = &x;
//~^ ERROR lifetime mismatch [E0623]
//[base]~^ ERROR lifetime mismatch [E0623]
//[nll]~^^ ERROR lifetime may not live long enough
},
En7::V1(_) => {},
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
error[E0271]: type mismatch resolving `for<'x> <UintStruct as TheTrait<&'x isize>>::A == &'x isize`
--> $DIR/associated-types-eq-hr.rs:87:5
--> $DIR/associated-types-eq-hr.rs:91:5
|
LL | foo::<UintStruct>();
| ^^^^^^^^^^^^^^^^^ type mismatch resolving `for<'x> <UintStruct as TheTrait<&'x isize>>::A == &'x isize`
|
note: expected this to be `&isize`
--> $DIR/associated-types-eq-hr.rs:26:14
--> $DIR/associated-types-eq-hr.rs:30:14
|
LL | type A = &'a usize;
| ^^^^^^^^^
= note: expected reference `&isize`
found reference `&usize`
note: required by a bound in `foo`
--> $DIR/associated-types-eq-hr.rs:45:36
--> $DIR/associated-types-eq-hr.rs:49:36
|
LL | fn foo<T>()
| --- required by a bound in this
Expand All @@ -21,20 +21,20 @@ LL | T: for<'x> TheTrait<&'x isize, A = &'x isize>,
| ^^^^^^^^^^^^^ required by this bound in `foo`

error[E0271]: type mismatch resolving `for<'x> <IntStruct as TheTrait<&'x isize>>::A == &'x usize`
--> $DIR/associated-types-eq-hr.rs:91:5
--> $DIR/associated-types-eq-hr.rs:95:5
|
LL | bar::<IntStruct>();
| ^^^^^^^^^^^^^^^^ type mismatch resolving `for<'x> <IntStruct as TheTrait<&'x isize>>::A == &'x usize`
|
note: expected this to be `&usize`
--> $DIR/associated-types-eq-hr.rs:14:14
--> $DIR/associated-types-eq-hr.rs:18:14
|
LL | type A = &'a isize;
| ^^^^^^^^^
= note: expected reference `&usize`
found reference `&isize`
note: required by a bound in `bar`
--> $DIR/associated-types-eq-hr.rs:52:36
--> $DIR/associated-types-eq-hr.rs:56:36
|
LL | fn bar<T>()
| --- required by a bound in this
Expand All @@ -43,7 +43,7 @@ LL | T: for<'x> TheTrait<&'x isize, A = &'x usize>,
| ^^^^^^^^^^^^^ required by this bound in `bar`

error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:96:5
--> $DIR/associated-types-eq-hr.rs:100:5
|
LL | tuple_one::<Tuple>();
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
Expand All @@ -52,7 +52,7 @@ LL | tuple_one::<Tuple>();
= note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`

error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:96:5
--> $DIR/associated-types-eq-hr.rs:100:5
|
LL | tuple_one::<Tuple>();
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
Expand All @@ -61,7 +61,7 @@ LL | tuple_one::<Tuple>();
= note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`

error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:102:5
--> $DIR/associated-types-eq-hr.rs:106:5
|
LL | tuple_two::<Tuple>();
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
Expand All @@ -70,7 +70,7 @@ LL | tuple_two::<Tuple>();
= note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`

error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:102:5
--> $DIR/associated-types-eq-hr.rs:106:5
|
LL | tuple_two::<Tuple>();
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
Expand All @@ -79,7 +79,7 @@ LL | tuple_two::<Tuple>();
= note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`

error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:112:5
--> $DIR/associated-types-eq-hr.rs:116:5
|
LL | tuple_four::<Tuple>();
| ^^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
Expand Down
12 changes: 6 additions & 6 deletions src/test/ui/associated-types/associated-types-eq-hr.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
error[E0271]: type mismatch resolving `for<'x> <UintStruct as TheTrait<&'x isize>>::A == &'x isize`
--> $DIR/associated-types-eq-hr.rs:87:5
--> $DIR/associated-types-eq-hr.rs:91:5
|
LL | foo::<UintStruct>();
| ^^^^^^^^^^^^^^^^^ type mismatch resolving `for<'x> <UintStruct as TheTrait<&'x isize>>::A == &'x isize`
|
note: expected this to be `&isize`
--> $DIR/associated-types-eq-hr.rs:26:14
--> $DIR/associated-types-eq-hr.rs:30:14
|
LL | type A = &'a usize;
| ^^^^^^^^^
= note: expected reference `&isize`
found reference `&usize`
note: required by a bound in `foo`
--> $DIR/associated-types-eq-hr.rs:45:36
--> $DIR/associated-types-eq-hr.rs:49:36
|
LL | fn foo<T>()
| --- required by a bound in this
Expand All @@ -21,20 +21,20 @@ LL | T: for<'x> TheTrait<&'x isize, A = &'x isize>,
| ^^^^^^^^^^^^^ required by this bound in `foo`

error[E0271]: type mismatch resolving `for<'x> <IntStruct as TheTrait<&'x isize>>::A == &'x usize`
--> $DIR/associated-types-eq-hr.rs:91:5
--> $DIR/associated-types-eq-hr.rs:95:5
|
LL | bar::<IntStruct>();
| ^^^^^^^^^^^^^^^^ type mismatch resolving `for<'x> <IntStruct as TheTrait<&'x isize>>::A == &'x usize`
|
note: expected this to be `&usize`
--> $DIR/associated-types-eq-hr.rs:14:14
--> $DIR/associated-types-eq-hr.rs:18:14
|
LL | type A = &'a isize;
| ^^^^^^^^^
= note: expected reference `&usize`
found reference `&isize`
note: required by a bound in `bar`
--> $DIR/associated-types-eq-hr.rs:52:36
--> $DIR/associated-types-eq-hr.rs:56:36
|
LL | fn bar<T>()
| --- required by a bound in this
Expand Down
14 changes: 9 additions & 5 deletions src/test/ui/associated-types/associated-types-eq-hr.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

// Check testing of equality constraints in a higher-ranked context.

pub trait TheTrait<T> {
Expand Down Expand Up @@ -94,14 +98,14 @@ pub fn call_bar() {

pub fn call_tuple_one() {
tuple_one::<Tuple>();
//~^ ERROR implementation of `TheTrait` is not general enough
//~| ERROR implementation of `TheTrait` is not general enough
//[base]~^ ERROR implementation of `TheTrait` is not general enough
//[base]~| ERROR implementation of `TheTrait` is not general enough
}

pub fn call_tuple_two() {
tuple_two::<Tuple>();
//~^ ERROR implementation of `TheTrait` is not general enough
//~| ERROR implementation of `TheTrait` is not general enough
//[base]~^ ERROR implementation of `TheTrait` is not general enough
//[base]~| ERROR implementation of `TheTrait` is not general enough
}

pub fn call_tuple_three() {
Expand All @@ -110,7 +114,7 @@ pub fn call_tuple_three() {

pub fn call_tuple_four() {
tuple_four::<Tuple>();
//~^ ERROR implementation of `TheTrait` is not general enough
//[base]~^ ERROR implementation of `TheTrait` is not general enough
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0623]: lifetime mismatch
--> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:22:40
--> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:26:40
|
LL | x: <I as Foo<&'a isize>>::A,
| --------- these two types are declared with different lifetimes...
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:22:29
--> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:26:29
|
LL | fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>(
| -- -- lifetime `'b` defined here
Expand All @@ -12,7 +12,7 @@ LL | let z: I::A = if cond { x } else { y };
= help: consider adding the following bound: `'a: 'b`

error: lifetime may not live long enough
--> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:22:40
--> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:26:40
|
LL | fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>(
| -- -- lifetime `'b` defined here
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// ignore-compare-mode-nll
// revisions: base nll
// [nll]compile-flags: -Zborrowck=mir

// Check projection of an associated type out of a higher-ranked
// trait-bound in the context of a function body.

Expand All @@ -20,7 +24,9 @@ fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>(
{
// x and y here have two distinct lifetimes:
let z: I::A = if cond { x } else { y };
//~^ ERROR lifetime mismatch
//[base]~^ ERROR lifetime mismatch
//[nll]~^^ ERROR lifetime may not live long enough
//[nll]~| ERROR lifetime may not live long enough
}

pub fn main() {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0623]: lifetime mismatch
--> $DIR/associated-types-subtyping-1.rs:26:38
--> $DIR/associated-types-subtyping-1.rs:31:38
|
LL | fn method2<'a,'b,T>(x: &'a T, y: &'b T)
| ----- ----- these two types are declared with different lifetimes...
Expand All @@ -8,7 +8,7 @@ LL | let _c: <T as Trait<'b>>::Type = a;
| ^ ...but data from `y` flows into `x` here

error[E0623]: lifetime mismatch
--> $DIR/associated-types-subtyping-1.rs:35:38
--> $DIR/associated-types-subtyping-1.rs:41:38
|
LL | fn method3<'a,'b,T>(x: &'a T, y: &'b T)
| ----- ----- these two types are declared with different lifetimes...
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/associated-types-subtyping-1.rs:24:12
--> $DIR/associated-types-subtyping-1.rs:28:12
|
LL | fn method2<'a,'b,T>(x: &'a T, y: &'b T)
| -- -- lifetime `'b` defined here
Expand All @@ -12,7 +12,7 @@ LL | let a: <T as Trait<'a>>::Type = make_any();
= help: consider adding the following bound: `'b: 'a`

error: lifetime may not live long enough
--> $DIR/associated-types-subtyping-1.rs:35:13
--> $DIR/associated-types-subtyping-1.rs:41:13
|
LL | fn method3<'a,'b,T>(x: &'a T, y: &'b T)
| -- -- lifetime `'b` defined here
Expand Down
12 changes: 10 additions & 2 deletions src/test/ui/associated-types/associated-types-subtyping-1.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// ignore-compare-mode-nll
// revisions: base nll
// [nll]compile-flags: -Zborrowck=mir

#![allow(unused_variables)]

fn make_any<T>() -> T { loop {} }
Expand All @@ -22,8 +26,10 @@ fn method2<'a,'b,T>(x: &'a T, y: &'b T)
{
// Note that &'static T <: &'a T.
let a: <T as Trait<'a>>::Type = make_any();
//[nll]~^ ERROR lifetime may not live long enough
let b: <T as Trait<'b>>::Type = make_any();
let _c: <T as Trait<'b>>::Type = a; //~ ERROR E0623
let _c: <T as Trait<'b>>::Type = a;
//[base]~^ ERROR E0623
}

fn method3<'a,'b,T>(x: &'a T, y: &'b T)
Expand All @@ -32,7 +38,9 @@ fn method3<'a,'b,T>(x: &'a T, y: &'b T)
// Note that &'static T <: &'a T.
let a: <T as Trait<'a>>::Type = make_any();
let b: <T as Trait<'b>>::Type = make_any();
let _c: <T as Trait<'a>>::Type = b; //~ ERROR E0623
let _c: <T as Trait<'a>>::Type = b;
//[base]~^ ERROR E0623
//[nll]~^^ ERROR lifetime may not live long enough
}

fn method4<'a,'b,T>(x: &'a T, y: &'b T)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
error[E0623]: lifetime mismatch
--> $DIR/project-fn-ret-contravariant-nll.rs:51:5
|
LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
| ------- ------------------
| |
| this parameter and the return type are declared with different lifetimes...
...
LL | (a, b)
| ^ ...but data from `y` is returned here

error[E0623]: lifetime mismatch
--> $DIR/project-fn-ret-contravariant-nll.rs:51:8
|
LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
| ------- ------------------
| |
| this parameter and the return type are declared with different lifetimes...
...
LL | (a, b)
| ^ ...but data from `x` is returned here

error: aborting due to 2 previous errors

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

0 comments on commit 07e7b43

Please sign in to comment.