Skip to content

Commit

Permalink
tests: cases where we now do the right thing but did not before
Browse files Browse the repository at this point in the history
Fixes #33684
  • Loading branch information
nikomatsakis committed Jan 2, 2019
1 parent d3c96ff commit c8e0a90
Show file tree
Hide file tree
Showing 19 changed files with 137 additions and 137 deletions.
@@ -1,16 +1,19 @@
error[E0308]: mismatched types
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter 'a in generic type due to conflicting requirements
--> $DIR/hr-subtype.rs:39:26
|
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a
| ^^^^^^^^^^^
...
LL | / check! { bound_a_b_ret_a_vs_bound_a_ret_a: (for<'a,'b> fn(&'a u32, &'b u32) -> &'a u32,
LL | | for<'a> fn(&'a u32, &'a u32) -> &'a u32) }
| |_________________________________________________________________________________________- in this macro invocation
|
= note: expected type `std::option::Option<for<'a, 'b> fn(&'a u32, &'b u32) -> &'a u32>`
found type `std::option::Option<for<'a> fn(&'a u32, &'a u32) -> &'a u32>`
= note: first, the lifetime cannot outlive lifetime RePlaceholder(Placeholder { universe: U1, name: BrNamed(crate0:DefIndex(1:26), 'b) })...
= note: ...but the lifetime must also be valid for lifetime RePlaceholder(Placeholder { universe: U1, name: BrNamed(crate0:DefIndex(1:25), 'a) })...
= note: ...so that the expression is assignable:
expected std::option::Option<for<'a, 'b> fn(&'a u32, &'b u32) -> &'a u32>
found std::option::Option<for<'a> fn(&'a u32, &'a u32) -> &'a u32>

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
For more information about this error, try `rustc --explain E0495`.
22 changes: 10 additions & 12 deletions src/test/ui/hr-subtype/hr-subtype.bound_a_b_vs_bound_a.stderr
@@ -1,16 +1,14 @@
error[E0308]: mismatched types
--> $DIR/hr-subtype.rs:39:26
error: compilation successful
--> $DIR/hr-subtype.rs:96:1
|
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a
...
LL | / check! { bound_a_b_vs_bound_a: (for<'a,'b> fn(&'a u32, &'b u32),
LL | | for<'a> fn(&'a u32, &'a u32)) }
| |__________________________________________________________________- in this macro invocation
|
= note: expected type `std::option::Option<for<'a, 'b> fn(&'a u32, &'b u32)>`
found type `std::option::Option<for<'a> fn(&'a u32, &'a u32)>`
LL | / fn main() {
LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful
LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful
LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful
... |
LL | | //[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^^ ERROR compilation successful
LL | | }
| |_^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
6 changes: 3 additions & 3 deletions src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_a.stderr
@@ -1,12 +1,12 @@
error: compilation successful
--> $DIR/hr-subtype.rs:100:1
--> $DIR/hr-subtype.rs:96:1
|
LL | / fn main() {
LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful
LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful
LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful
LL | | //[bound_co_a_vs_bound_co_b]~^^^^ ERROR compilation successful
LL | | //[free_x_vs_free_x]~^^^^^ ERROR compilation successful
... |
LL | | //[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^^ ERROR compilation successful
LL | | }
| |_^

Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_b.stderr
@@ -1,12 +1,12 @@
error: compilation successful
--> $DIR/hr-subtype.rs:100:1
--> $DIR/hr-subtype.rs:96:1
|
LL | / fn main() {
LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful
LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful
LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful
LL | | //[bound_co_a_vs_bound_co_b]~^^^^ ERROR compilation successful
LL | | //[free_x_vs_free_x]~^^^^^ ERROR compilation successful
... |
LL | | //[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^^ ERROR compilation successful
LL | | }
| |_^

Expand Down
12 changes: 11 additions & 1 deletion src/test/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.stderr
Expand Up @@ -2,14 +2,24 @@ error[E0308]: mismatched types
--> $DIR/hr-subtype.rs:39:26
|
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a
| ^^^^^^^^^^^ lifetime mismatch
...
LL | / check! { bound_a_vs_free_x: (for<'a> fn(&'a u32),
LL | | fn(&'x u32)) }
| |___________________________________________- in this macro invocation
|
= note: expected type `std::option::Option<for<'a> fn(&'a u32)>`
found type `std::option::Option<fn(&'x u32)>`
= note: lifetime RePlaceholder(Placeholder { universe: U1, name: BrNamed(crate0:DefIndex(1:23), 'a) })...
note: ...does not necessarily outlive the lifetime 'x as defined on the function body at 48:22
--> $DIR/hr-subtype.rs:48:22
|
LL | fn supertype<'x,'y:'x,'z:'y>() {
| ^^
...
LL | / check! { bound_a_vs_free_x: (for<'a> fn(&'a u32),
LL | | fn(&'x u32)) }
| |___________________________________________- in this macro invocation

error: aborting due to previous error

Expand Down
22 changes: 10 additions & 12 deletions src/test/ui/hr-subtype/hr-subtype.bound_co_a_b_vs_bound_co_a.stderr
@@ -1,16 +1,14 @@
error[E0308]: mismatched types
--> $DIR/hr-subtype.rs:39:26
error: compilation successful
--> $DIR/hr-subtype.rs:96:1
|
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a
...
LL | / check! { bound_co_a_b_vs_bound_co_a: (for<'a,'b> fn(Co<'a>, Co<'b>),
LL | | for<'a> fn(Co<'a>, Co<'a>)) }
| |______________________________________________________________________- in this macro invocation
|
= note: expected type `std::option::Option<for<'a, 'b> fn(Co<'a>, Co<'b>)>`
found type `std::option::Option<for<'a> fn(Co<'a>, Co<'a>)>`
LL | / fn main() {
LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful
LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful
LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful
... |
LL | | //[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^^ ERROR compilation successful
LL | | }
| |_^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
@@ -1,16 +1,14 @@
error[E0308]: mismatched types
--> $DIR/hr-subtype.rs:39:26
error: compilation successful
--> $DIR/hr-subtype.rs:96:1
|
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a
...
LL | / check! { bound_co_a_co_b_ret_contra_a: (for<'a,'b> fn(Co<'a>, Co<'b>) -> Contra<'a>,
LL | | for<'a> fn(Co<'a>, Co<'a>) -> Contra<'a>) }
| |______________________________________________________________________________________- in this macro invocation
|
= note: expected type `std::option::Option<for<'a, 'b> fn(Co<'a>, Co<'b>) -> Contra<'a>>`
found type `std::option::Option<for<'a> fn(Co<'a>, Co<'a>) -> Contra<'a>>`
LL | / fn main() {
LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful
LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful
LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful
... |
LL | | //[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^^ ERROR compilation successful
LL | | }
| |_^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
@@ -1,12 +1,12 @@
error: compilation successful
--> $DIR/hr-subtype.rs:100:1
--> $DIR/hr-subtype.rs:96:1
|
LL | / fn main() {
LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful
LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful
LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful
LL | | //[bound_co_a_vs_bound_co_b]~^^^^ ERROR compilation successful
LL | | //[free_x_vs_free_x]~^^^^^ ERROR compilation successful
... |
LL | | //[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^^ ERROR compilation successful
LL | | }
| |_^

Expand Down
@@ -1,16 +1,14 @@
error[E0308]: mismatched types
--> $DIR/hr-subtype.rs:39:26
error: compilation successful
--> $DIR/hr-subtype.rs:96:1
|
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a
...
LL | / check! { bound_contra_a_contra_b_ret_co_a: (for<'a,'b> fn(Contra<'a>, Contra<'b>) -> Co<'a>,
LL | | for<'a> fn(Contra<'a>, Contra<'a>) -> Co<'a>) }
| |______________________________________________________________________________________________- in this macro invocation
|
= note: expected type `std::option::Option<for<'a, 'b> fn(Contra<'a>, Contra<'b>) -> Co<'a>>`
found type `std::option::Option<for<'a> fn(Contra<'a>, Contra<'a>) -> Co<'a>>`
LL | / fn main() {
LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful
LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful
LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful
... |
LL | | //[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^^ ERROR compilation successful
LL | | }
| |_^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
@@ -1,16 +1,19 @@
error[E0308]: mismatched types
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter 'a in generic type due to conflicting requirements
--> $DIR/hr-subtype.rs:39:26
|
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a
| ^^^^^^^^^^^
...
LL | / check! { bound_inv_a_b_vs_bound_inv_a: (for<'a,'b> fn(Inv<'a>, Inv<'b>),
LL | | for<'a> fn(Inv<'a>, Inv<'a>)) }
| |__________________________________________________________________________- in this macro invocation
|
= note: expected type `std::option::Option<for<'a, 'b> fn(Inv<'a>, Inv<'b>)>`
found type `std::option::Option<for<'a> fn(Inv<'a>, Inv<'a>)>`
= note: first, the lifetime cannot outlive lifetime RePlaceholder(Placeholder { universe: U1, name: BrNamed(crate0:DefIndex(1:25), 'a) })...
= note: ...but the lifetime must also be valid for lifetime RePlaceholder(Placeholder { universe: U1, name: BrNamed(crate0:DefIndex(1:26), 'b) })...
= note: ...so that the expression is assignable:
expected std::option::Option<for<'a, 'b> fn(Inv<'a>, Inv<'b>)>
found std::option::Option<for<'a> fn(Inv<'a>, Inv<'a>)>

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
For more information about this error, try `rustc --explain E0495`.
@@ -1,12 +1,12 @@
error: compilation successful
--> $DIR/hr-subtype.rs:100:1
--> $DIR/hr-subtype.rs:96:1
|
LL | / fn main() {
LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful
LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful
LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful
LL | | //[bound_co_a_vs_bound_co_b]~^^^^ ERROR compilation successful
LL | | //[free_x_vs_free_x]~^^^^^ ERROR compilation successful
... |
LL | | //[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^^ ERROR compilation successful
LL | | }
| |_^

Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_x.stderr
@@ -1,12 +1,12 @@
error: compilation successful
--> $DIR/hr-subtype.rs:100:1
--> $DIR/hr-subtype.rs:96:1
|
LL | / fn main() {
LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful
LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful
LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful
LL | | //[bound_co_a_vs_bound_co_b]~^^^^ ERROR compilation successful
LL | | //[free_x_vs_free_x]~^^^^^ ERROR compilation successful
... |
LL | | //[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^^ ERROR compilation successful
LL | | }
| |_^

Expand Down
20 changes: 10 additions & 10 deletions src/test/ui/hr-subtype/hr-subtype.rs
Expand Up @@ -31,21 +31,17 @@ macro_rules! check {
#[cfg($rev)]
fn subtype<'x,'y:'x,'z:'y>() {
gimme::<$t2>(None::<$t1>);
//[free_inv_x_vs_free_inv_y]~^ ERROR mismatched types
//[free_inv_x_vs_free_inv_y]~^ ERROR
}

#[cfg($rev)]
fn supertype<'x,'y:'x,'z:'y>() {
gimme::<$t1>(None::<$t2>);
//[bound_a_vs_free_x]~^ ERROR mismatched types
//[free_x_vs_free_y]~^^ ERROR mismatched types
//[bound_inv_a_b_vs_bound_inv_a]~^^^ ERROR mismatched types
//[bound_a_b_ret_a_vs_bound_a_ret_a]~^^^^ ERROR mismatched types
//[free_inv_x_vs_free_inv_y]~^^^^^ ERROR mismatched types
//[bound_a_b_vs_bound_a]~^^^^^^ ERROR mismatched types
//[bound_co_a_b_vs_bound_co_a]~^^^^^^^ ERROR mismatched types
//[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^ ERROR mismatched types
//[bound_co_a_co_b_ret_contra_a]~^^^^^^^^^ ERROR mismatched types
//[bound_a_vs_free_x]~^ ERROR
//[free_x_vs_free_y]~^^ ERROR
//[bound_inv_a_b_vs_bound_inv_a]~^^^ ERROR
//[bound_a_b_ret_a_vs_bound_a_ret_a]~^^^^ ERROR
//[free_inv_x_vs_free_inv_y]~^^^^^ ERROR
}
}
}
Expand Down Expand Up @@ -103,4 +99,8 @@ fn main() {
//[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful
//[bound_co_a_vs_bound_co_b]~^^^^ ERROR compilation successful
//[free_x_vs_free_x]~^^^^^ ERROR compilation successful
//[bound_a_b_vs_bound_a]~^^^^^^ ERROR compilation successful
//[bound_co_a_co_b_ret_contra_a]~^^^^^^^ ERROR compilation successful
//[bound_co_a_b_vs_bound_co_a]~^^^^^^^^ ERROR compilation successful
//[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^^ ERROR compilation successful
}
9 changes: 7 additions & 2 deletions src/test/ui/lub-glb/old-lub-glb-hr.rs
@@ -1,11 +1,16 @@
// Test that we give a note when the old LUB/GLB algorithm would have
// succeeded but the new code (which is stricter) gives an error.
// succeeded but the new code (which requires equality) gives an
// error. However, now that we handle subtyping correctly, we no
// longer get an error, because we recognize these two types as
// equivalent!
//
// compile-pass

fn foo(
x: fn(&u8, &u8),
y: for<'a> fn(&'a u8, &'a u8),
) {
let z = match 22 { //~ ERROR incompatible types
let z = match 22 {
0 => x,
_ => y,
};
Expand Down
17 changes: 0 additions & 17 deletions src/test/ui/lub-glb/old-lub-glb-hr.stderr

This file was deleted.

9 changes: 2 additions & 7 deletions src/test/ui/regions-fn-subtyping-return-static-fail.rs
Expand Up @@ -37,20 +37,15 @@ fn baz(x: &S) -> &S {
fn supply_F() {
want_F(foo);

// FIXME(#33684) -- this should be a subtype, but current alg. rejects it incorrectly
want_F(bar); //~ ERROR E0308
want_F(bar);

want_F(baz);
}

fn supply_G() {
want_G(foo);
want_G(bar);
want_G(baz);
//~^ ERROR mismatched types
//~| expected type `for<'cx> fn(&'cx S) -> &'static S`
//~| found type `for<'r> fn(&'r S) -> &'r S {baz}`
//~| expected concrete lifetime, found bound lifetime parameter 'cx
want_G(baz); //~ ERROR
}

pub fn main() {
Expand Down
28 changes: 11 additions & 17 deletions src/test/ui/regions-fn-subtyping-return-static-fail.stderr
@@ -1,21 +1,15 @@
error[E0308]: mismatched types
--> $DIR/regions-fn-subtyping-return-static-fail.rs:41:12
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter in generic type due to conflicting requirements
--> $DIR/regions-fn-subtyping-return-static-fail.rs:48:12
|
LL | want_F(bar); //~ ERROR E0308
| ^^^ expected concrete lifetime, found bound lifetime parameter 'cx
LL | want_G(baz); //~ ERROR
| ^^^
|
= note: expected type `for<'cx> fn(&'cx S) -> &'cx S`
found type `for<'a> fn(&'a S) -> &S {bar::<'_>}`
= note: first, the lifetime cannot outlive lifetime RePlaceholder(Placeholder { universe: U3, name: BrNamed(crate0:DefIndex(1:11), 'cx) })...
= note: ...but the lifetime must also be valid for the static lifetime...
= note: ...so that the expression is assignable:
expected for<'cx> fn(&'cx S) -> &'static S
found for<'r> fn(&'r S) -> &'r S

error[E0308]: mismatched types
--> $DIR/regions-fn-subtyping-return-static-fail.rs:49:12
|
LL | want_G(baz);
| ^^^ expected concrete lifetime, found bound lifetime parameter 'cx
|
= note: expected type `for<'cx> fn(&'cx S) -> &'static S`
found type `for<'r> fn(&'r S) -> &'r S {baz}`

error: aborting due to 2 previous errors
error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
For more information about this error, try `rustc --explain E0495`.

0 comments on commit c8e0a90

Please sign in to comment.