Skip to content

Commit a0ccf99

Browse files
nikomatsakisJohnHeitmann
authored andcommitted
tests: cases where we now do the right thing but did not before
Fixes rust-lang#33684
1 parent c1cd912 commit a0ccf99

19 files changed

+137
-137
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
error[E0308]: mismatched types
1+
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter 'a in generic type due to conflicting requirements
22
--> $DIR/hr-subtype.rs:39:26
33
|
44
LL | gimme::<$t1>(None::<$t2>);
5-
| ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a
5+
| ^^^^^^^^^^^
66
...
77
LL | / check! { bound_a_b_ret_a_vs_bound_a_ret_a: (for<'a,'b> fn(&'a u32, &'b u32) -> &'a u32,
88
LL | | for<'a> fn(&'a u32, &'a u32) -> &'a u32) }
99
| |_________________________________________________________________________________________- in this macro invocation
1010
|
11-
= note: expected type `std::option::Option<for<'a, 'b> fn(&'a u32, &'b u32) -> &'a u32>`
12-
found type `std::option::Option<for<'a> fn(&'a u32, &'a u32) -> &'a u32>`
11+
= note: first, the lifetime cannot outlive lifetime RePlaceholder(Placeholder { universe: U1, name: BrNamed(crate0:DefIndex(1:26), 'b) })...
12+
= note: ...but the lifetime must also be valid for lifetime RePlaceholder(Placeholder { universe: U1, name: BrNamed(crate0:DefIndex(1:25), 'a) })...
13+
= note: ...so that the expression is assignable:
14+
expected std::option::Option<for<'a, 'b> fn(&'a u32, &'b u32) -> &'a u32>
15+
found std::option::Option<for<'a> fn(&'a u32, &'a u32) -> &'a u32>
1316

1417
error: aborting due to previous error
1518

16-
For more information about this error, try `rustc --explain E0308`.
19+
For more information about this error, try `rustc --explain E0495`.
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
error[E0308]: mismatched types
2-
--> $DIR/hr-subtype.rs:39:26
1+
error: compilation successful
2+
--> $DIR/hr-subtype.rs:96:1
33
|
4-
LL | gimme::<$t1>(None::<$t2>);
5-
| ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a
6-
...
7-
LL | / check! { bound_a_b_vs_bound_a: (for<'a,'b> fn(&'a u32, &'b u32),
8-
LL | | for<'a> fn(&'a u32, &'a u32)) }
9-
| |__________________________________________________________________- in this macro invocation
10-
|
11-
= note: expected type `std::option::Option<for<'a, 'b> fn(&'a u32, &'b u32)>`
12-
found type `std::option::Option<for<'a> fn(&'a u32, &'a u32)>`
4+
LL | / fn main() {
5+
LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful
6+
LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful
7+
LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful
8+
... |
9+
LL | | //[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^^ ERROR compilation successful
10+
LL | | }
11+
| |_^
1312

1413
error: aborting due to previous error
1514

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

src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_a.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
error: compilation successful
2-
--> $DIR/hr-subtype.rs:100:1
2+
--> $DIR/hr-subtype.rs:96:1
33
|
44
LL | / fn main() {
55
LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful
66
LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful
77
LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful
8-
LL | | //[bound_co_a_vs_bound_co_b]~^^^^ ERROR compilation successful
9-
LL | | //[free_x_vs_free_x]~^^^^^ ERROR compilation successful
8+
... |
9+
LL | | //[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^^ ERROR compilation successful
1010
LL | | }
1111
| |_^
1212

src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_b.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
error: compilation successful
2-
--> $DIR/hr-subtype.rs:100:1
2+
--> $DIR/hr-subtype.rs:96:1
33
|
44
LL | / fn main() {
55
LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful
66
LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful
77
LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful
8-
LL | | //[bound_co_a_vs_bound_co_b]~^^^^ ERROR compilation successful
9-
LL | | //[free_x_vs_free_x]~^^^^^ ERROR compilation successful
8+
... |
9+
LL | | //[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^^ ERROR compilation successful
1010
LL | | }
1111
| |_^
1212

src/test/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.stderr

+11-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,24 @@ error[E0308]: mismatched types
22
--> $DIR/hr-subtype.rs:39:26
33
|
44
LL | gimme::<$t1>(None::<$t2>);
5-
| ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a
5+
| ^^^^^^^^^^^ lifetime mismatch
66
...
77
LL | / check! { bound_a_vs_free_x: (for<'a> fn(&'a u32),
88
LL | | fn(&'x u32)) }
99
| |___________________________________________- in this macro invocation
1010
|
1111
= note: expected type `std::option::Option<for<'a> fn(&'a u32)>`
1212
found type `std::option::Option<fn(&'x u32)>`
13+
= note: lifetime RePlaceholder(Placeholder { universe: U1, name: BrNamed(crate0:DefIndex(1:23), 'a) })...
14+
note: ...does not necessarily outlive the lifetime 'x as defined on the function body at 48:22
15+
--> $DIR/hr-subtype.rs:48:22
16+
|
17+
LL | fn supertype<'x,'y:'x,'z:'y>() {
18+
| ^^
19+
...
20+
LL | / check! { bound_a_vs_free_x: (for<'a> fn(&'a u32),
21+
LL | | fn(&'x u32)) }
22+
| |___________________________________________- in this macro invocation
1323

1424
error: aborting due to previous error
1525

Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
error[E0308]: mismatched types
2-
--> $DIR/hr-subtype.rs:39:26
1+
error: compilation successful
2+
--> $DIR/hr-subtype.rs:96:1
33
|
4-
LL | gimme::<$t1>(None::<$t2>);
5-
| ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a
6-
...
7-
LL | / check! { bound_co_a_b_vs_bound_co_a: (for<'a,'b> fn(Co<'a>, Co<'b>),
8-
LL | | for<'a> fn(Co<'a>, Co<'a>)) }
9-
| |______________________________________________________________________- in this macro invocation
10-
|
11-
= note: expected type `std::option::Option<for<'a, 'b> fn(Co<'a>, Co<'b>)>`
12-
found type `std::option::Option<for<'a> fn(Co<'a>, Co<'a>)>`
4+
LL | / fn main() {
5+
LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful
6+
LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful
7+
LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful
8+
... |
9+
LL | | //[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^^ ERROR compilation successful
10+
LL | | }
11+
| |_^
1312

1413
error: aborting due to previous error
1514

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

1413
error: aborting due to previous error
1514

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

src/test/ui/hr-subtype/hr-subtype.bound_co_a_vs_bound_co_b.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
error: compilation successful
2-
--> $DIR/hr-subtype.rs:100:1
2+
--> $DIR/hr-subtype.rs:96:1
33
|
44
LL | / fn main() {
55
LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful
66
LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful
77
LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful
8-
LL | | //[bound_co_a_vs_bound_co_b]~^^^^ ERROR compilation successful
9-
LL | | //[free_x_vs_free_x]~^^^^^ ERROR compilation successful
8+
... |
9+
LL | | //[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^^ ERROR compilation successful
1010
LL | | }
1111
| |_^
1212

Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
error[E0308]: mismatched types
2-
--> $DIR/hr-subtype.rs:39:26
1+
error: compilation successful
2+
--> $DIR/hr-subtype.rs:96:1
33
|
4-
LL | gimme::<$t1>(None::<$t2>);
5-
| ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a
6-
...
7-
LL | / check! { bound_contra_a_contra_b_ret_co_a: (for<'a,'b> fn(Contra<'a>, Contra<'b>) -> Co<'a>,
8-
LL | | for<'a> fn(Contra<'a>, Contra<'a>) -> Co<'a>) }
9-
| |______________________________________________________________________________________________- in this macro invocation
10-
|
11-
= note: expected type `std::option::Option<for<'a, 'b> fn(Contra<'a>, Contra<'b>) -> Co<'a>>`
12-
found type `std::option::Option<for<'a> fn(Contra<'a>, Contra<'a>) -> Co<'a>>`
4+
LL | / fn main() {
5+
LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful
6+
LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful
7+
LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful
8+
... |
9+
LL | | //[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^^ ERROR compilation successful
10+
LL | | }
11+
| |_^
1312

1413
error: aborting due to previous error
1514

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

1417
error: aborting due to previous error
1518

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

src/test/ui/hr-subtype/hr-subtype.bound_inv_a_vs_bound_inv_b.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
error: compilation successful
2-
--> $DIR/hr-subtype.rs:100:1
2+
--> $DIR/hr-subtype.rs:96:1
33
|
44
LL | / fn main() {
55
LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful
66
LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful
77
LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful
8-
LL | | //[bound_co_a_vs_bound_co_b]~^^^^ ERROR compilation successful
9-
LL | | //[free_x_vs_free_x]~^^^^^ ERROR compilation successful
8+
... |
9+
LL | | //[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^^ ERROR compilation successful
1010
LL | | }
1111
| |_^
1212

src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_x.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
error: compilation successful
2-
--> $DIR/hr-subtype.rs:100:1
2+
--> $DIR/hr-subtype.rs:96:1
33
|
44
LL | / fn main() {
55
LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful
66
LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful
77
LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful
8-
LL | | //[bound_co_a_vs_bound_co_b]~^^^^ ERROR compilation successful
9-
LL | | //[free_x_vs_free_x]~^^^^^ ERROR compilation successful
8+
... |
9+
LL | | //[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^^ ERROR compilation successful
1010
LL | | }
1111
| |_^
1212

src/test/ui/hr-subtype/hr-subtype.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,17 @@ macro_rules! check {
3131
#[cfg($rev)]
3232
fn subtype<'x,'y:'x,'z:'y>() {
3333
gimme::<$t2>(None::<$t1>);
34-
//[free_inv_x_vs_free_inv_y]~^ ERROR mismatched types
34+
//[free_inv_x_vs_free_inv_y]~^ ERROR
3535
}
3636

3737
#[cfg($rev)]
3838
fn supertype<'x,'y:'x,'z:'y>() {
3939
gimme::<$t1>(None::<$t2>);
40-
//[bound_a_vs_free_x]~^ ERROR mismatched types
41-
//[free_x_vs_free_y]~^^ ERROR mismatched types
42-
//[bound_inv_a_b_vs_bound_inv_a]~^^^ ERROR mismatched types
43-
//[bound_a_b_ret_a_vs_bound_a_ret_a]~^^^^ ERROR mismatched types
44-
//[free_inv_x_vs_free_inv_y]~^^^^^ ERROR mismatched types
45-
//[bound_a_b_vs_bound_a]~^^^^^^ ERROR mismatched types
46-
//[bound_co_a_b_vs_bound_co_a]~^^^^^^^ ERROR mismatched types
47-
//[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^ ERROR mismatched types
48-
//[bound_co_a_co_b_ret_contra_a]~^^^^^^^^^ ERROR mismatched types
40+
//[bound_a_vs_free_x]~^ ERROR
41+
//[free_x_vs_free_y]~^^ ERROR
42+
//[bound_inv_a_b_vs_bound_inv_a]~^^^ ERROR
43+
//[bound_a_b_ret_a_vs_bound_a_ret_a]~^^^^ ERROR
44+
//[free_inv_x_vs_free_inv_y]~^^^^^ ERROR
4945
}
5046
}
5147
}
@@ -103,4 +99,8 @@ fn main() {
10399
//[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful
104100
//[bound_co_a_vs_bound_co_b]~^^^^ ERROR compilation successful
105101
//[free_x_vs_free_x]~^^^^^ ERROR compilation successful
102+
//[bound_a_b_vs_bound_a]~^^^^^^ ERROR compilation successful
103+
//[bound_co_a_co_b_ret_contra_a]~^^^^^^^ ERROR compilation successful
104+
//[bound_co_a_b_vs_bound_co_a]~^^^^^^^^ ERROR compilation successful
105+
//[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^^ ERROR compilation successful
106106
}

src/test/ui/lub-glb/old-lub-glb-hr.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
// Test that we give a note when the old LUB/GLB algorithm would have
2-
// succeeded but the new code (which is stricter) gives an error.
2+
// succeeded but the new code (which requires equality) gives an
3+
// error. However, now that we handle subtyping correctly, we no
4+
// longer get an error, because we recognize these two types as
5+
// equivalent!
6+
//
7+
// compile-pass
38

49
fn foo(
510
x: fn(&u8, &u8),
611
y: for<'a> fn(&'a u8, &'a u8),
712
) {
8-
let z = match 22 { //~ ERROR incompatible types
13+
let z = match 22 {
914
0 => x,
1015
_ => y,
1116
};

src/test/ui/lub-glb/old-lub-glb-hr.stderr

-17
This file was deleted.

src/test/ui/regions-fn-subtyping-return-static-fail.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,15 @@ fn baz(x: &S) -> &S {
3737
fn supply_F() {
3838
want_F(foo);
3939

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

4342
want_F(baz);
4443
}
4544

4645
fn supply_G() {
4746
want_G(foo);
4847
want_G(bar);
49-
want_G(baz);
50-
//~^ ERROR mismatched types
51-
//~| expected type `for<'cx> fn(&'cx S) -> &'static S`
52-
//~| found type `for<'r> fn(&'r S) -> &'r S {baz}`
53-
//~| expected concrete lifetime, found bound lifetime parameter 'cx
48+
want_G(baz); //~ ERROR
5449
}
5550

5651
pub fn main() {
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
1-
error[E0308]: mismatched types
2-
--> $DIR/regions-fn-subtyping-return-static-fail.rs:41:12
1+
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter in generic type due to conflicting requirements
2+
--> $DIR/regions-fn-subtyping-return-static-fail.rs:48:12
33
|
4-
LL | want_F(bar); //~ ERROR E0308
5-
| ^^^ expected concrete lifetime, found bound lifetime parameter 'cx
4+
LL | want_G(baz); //~ ERROR
5+
| ^^^
66
|
7-
= note: expected type `for<'cx> fn(&'cx S) -> &'cx S`
8-
found type `for<'a> fn(&'a S) -> &S {bar::<'_>}`
7+
= note: first, the lifetime cannot outlive lifetime RePlaceholder(Placeholder { universe: U3, name: BrNamed(crate0:DefIndex(1:11), 'cx) })...
8+
= note: ...but the lifetime must also be valid for the static lifetime...
9+
= note: ...so that the expression is assignable:
10+
expected for<'cx> fn(&'cx S) -> &'static S
11+
found for<'r> fn(&'r S) -> &'r S
912

10-
error[E0308]: mismatched types
11-
--> $DIR/regions-fn-subtyping-return-static-fail.rs:49:12
12-
|
13-
LL | want_G(baz);
14-
| ^^^ expected concrete lifetime, found bound lifetime parameter 'cx
15-
|
16-
= note: expected type `for<'cx> fn(&'cx S) -> &'static S`
17-
found type `for<'r> fn(&'r S) -> &'r S {baz}`
18-
19-
error: aborting due to 2 previous errors
13+
error: aborting due to previous error
2014

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

0 commit comments

Comments
 (0)