Files
rust/tests/ui/coherence/occurs-check/opaques.rs

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

36 lines
732 B
Rust
Raw Normal View History

2024-09-21 07:05:19 +00:00
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
2023-12-14 13:11:28 +01:00
//@[next] compile-flags: -Znext-solver
2023-10-23 16:53:11 +02:00
// A regression test for #105787
#![feature(type_alias_impl_trait)]
pub type Alias<T> = impl Sized;
#[define_opaque(Alias)]
pub fn cast<T>(x: Container<Alias<T>, T>) -> Container<T, T> {
//[next]~^ ERROR type annotations needed
x
2023-10-23 16:53:11 +02:00
}
struct Container<T: Trait<U>, U> {
x: <T as Trait<U>>::Assoc,
}
trait Trait<T> {
type Assoc;
}
impl<T> Trait<T> for T {
type Assoc = Box<u32>;
}
impl<T> Trait<T> for Alias<T> {
2024-09-21 07:02:51 +00:00
//~^ ERROR conflicting implementations of trait
2023-10-23 16:53:11 +02:00
type Assoc = usize;
}
fn main() {
let x: Box<u32> = cast::<()>(Container { x: 0 }).x;
2023-10-23 16:53:11 +02:00
println!("{}", *x);
}