]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-26905.rs
Merge commit '6ed6f1e6a1a8f414ba7e6d9b8222e7e5a1686e42' into clippyup
[rust.git] / src / test / ui / issues / issue-26905.rs
1 #![feature(unsize, coerce_unsized)]
2
3 // Verfies that non-PhantomData ZSTs still cause coercions to fail.
4 // They might have additional semantics that we don't want to bulldoze.
5
6 use std::marker::{Unsize, PhantomData};
7 use std::ops::CoerceUnsized;
8
9 struct NotPhantomData<T: ?Sized>(PhantomData<T>);
10
11 struct MyRc<T: ?Sized> {
12     _ptr: *const T,
13     _boo: NotPhantomData<T>,
14 }
15
16 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<MyRc<U>> for MyRc<T>{ } //~ERROR
17
18 fn main() {
19     let data = [1, 2, 3];
20     let iter = data.iter();
21     let x = MyRc { _ptr: &iter, _boo: NotPhantomData(PhantomData) };
22     let _y: MyRc<dyn Iterator<Item=&u32>> = x;
23 }