Skip to content

Commit c20e0da

Browse files
authored
Rollup merge of #107255 - lcnr:implied-b-hr, r=oli-obk
add test where we ignore hr implied bounds r? types
2 parents 2ed3639 + e6e93e0 commit c20e0da

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// FIXME: This test should pass as the first two fields add implied bounds that
2+
// `'a` is equal to `'b` while the last one should simply use that fact. With
3+
// the current implementation this errors. We have to be careful as implied bounds
4+
// are only sound if they're also correctly checked.
5+
6+
struct Inv<T>(*mut T); // `T` is invariant.
7+
type A = for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'a ()>);
8+
type B = for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'b ()>);
9+
10+
fn main() {
11+
let x: A = |_, _, _| ();
12+
let y: B = x; //~ ERROR mismatched types
13+
let _: A = y; //~ ERROR mismatched types
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/higher-ranked-implied.rs:12:16
3+
|
4+
LL | let y: B = x;
5+
| ^ one type is more general than the other
6+
|
7+
= note: expected fn pointer `for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'b ()>)`
8+
found fn pointer `for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'a ()>)`
9+
10+
error[E0308]: mismatched types
11+
--> $DIR/higher-ranked-implied.rs:13:16
12+
|
13+
LL | let _: A = y;
14+
| ^ one type is more general than the other
15+
|
16+
= note: expected fn pointer `for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'a ()>)`
17+
found fn pointer `for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'b ()>)`
18+
19+
error: aborting due to 2 previous errors
20+
21+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)