Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test where we ignore hr implied bounds #107255

Merged
merged 1 commit into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/ui/regions/higher-ranked-implied.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// FIXME: This test should pass as the first two fields add implied bounds that
// `'a` is equal to `'b` while the last one should simply use that fact. With
// the current implementation this errors. We have to be careful as implied bounds
// are only sound if they're also correctly checked.

struct Inv<T>(*mut T); // `T` is invariant.
type A = for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'a ()>);
type B = for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'b ()>);

fn main() {
let x: A = |_, _, _| ();
let y: B = x; //~ ERROR mismatched types
let _: A = y; //~ ERROR mismatched types
}
21 changes: 21 additions & 0 deletions tests/ui/regions/higher-ranked-implied.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
error[E0308]: mismatched types
--> $DIR/higher-ranked-implied.rs:12:16
|
LL | let y: B = x;
| ^ one type is more general than the other
|
= note: expected fn pointer `for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'b ()>)`
found fn pointer `for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'a ()>)`

error[E0308]: mismatched types
--> $DIR/higher-ranked-implied.rs:13:16
|
LL | let _: A = y;
| ^ one type is more general than the other
|
= note: expected fn pointer `for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'a ()>)`
found fn pointer `for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'b ()>)`

error: aborting due to 2 previous errors

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