]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/issue-26905.rs
Auto merge of #28816 - petrochenkov:unistruct, r=nrc
[rust.git] / src / test / run-pass / issue-26905.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![feature(unsize, coerce_unsized)]
12
13 // Verfies that PhantomData is ignored for DST coercions
14
15 use std::marker::{Unsize, PhantomData};
16 use std::ops::CoerceUnsized;
17
18 struct MyRc<T: ?Sized> {
19     _ptr: *const T,
20     _boo: PhantomData<T>,
21 }
22
23 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<MyRc<U>> for MyRc<T>{ }
24
25 fn main() {
26     let data = [1, 2, 3];
27     let iter = data.iter();
28     let x = MyRc { _ptr: &iter, _boo: PhantomData };
29     let _y: MyRc<Iterator<Item=&u32>> = x;
30 }
31