]> git.lizzy.rs Git - rust.git/blob - tests/ui/unsized/issue-71659.rs
Rollup merge of #106570 - Xaeroxe:div-duration-tests, r=JohnTitor
[rust.git] / tests / ui / unsized / issue-71659.rs
1 #![feature(unsize)]
2
3 use std::marker::Unsize;
4
5 pub trait CastTo<T: ?Sized>: Unsize<T> {
6     fn cast_to(&self) -> &T;
7 }
8
9 impl<T: ?Sized, U: ?Sized + Unsize<T>> CastTo<T> for U {
10     fn cast_to(&self) -> &T {
11         self
12     }
13 }
14
15 impl<T: ?Sized> Cast for T {}
16 pub trait Cast {
17     fn cast<T: ?Sized>(&self) -> &T
18     where
19         Self: CastTo<T>,
20     {
21         self
22     }
23 }
24
25 pub trait Foo: CastTo<[i32]> {}
26 impl Foo for [i32; 0] {}
27
28 fn main() {
29     let x: &dyn Foo = &[];
30     let x = x.cast::<[i32]>();
31     //~^ ERROR: the trait bound `dyn Foo: CastTo<[i32]>` is not satisfied
32 }