rust/tests/ui/traits/new-solver/equating-projection-cyclically.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
526 B
Rust
Raw Normal View History

2023-02-26 23:23:26 -06:00
// compile-flags: -Ztrait-solver=next
trait Test {
type Assoc;
}
2023-06-27 16:13:50 -05:00
fn transform<T: Test>(x: Inv<T>) -> Inv<T::Assoc> {
2023-02-26 23:23:26 -06:00
todo!()
}
impl Test for i32 {
type Assoc = i32;
}
impl Test for String {
type Assoc = String;
}
2023-06-27 16:13:50 -05:00
struct Inv<T>(Option<*mut T>);
2023-02-26 23:23:26 -06:00
fn main() {
2023-06-27 16:13:50 -05:00
let mut x: Inv<_> = Inv(None);
// This ends up equating `Inv<?x>` with `Inv<<?x as Test>::Assoc>`
// which fails the occurs check when generalizing `?x`.
2023-02-26 23:23:26 -06:00
x = transform(x);
2023-06-27 16:13:50 -05:00
//~^ ERROR mismatched types
x = Inv::<i32>(None);
2023-02-26 23:23:26 -06:00
}