2018-09-20 03:28:57 -04:00
|
|
|
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2018-10-03 23:40:21 -04:00
|
|
|
#![feature(unsize, dispatch_from_dyn)]
|
2018-09-20 03:28:57 -04:00
|
|
|
|
|
|
|
use std::{
|
2018-10-03 23:40:21 -04:00
|
|
|
ops::DispatchFromDyn,
|
2018-09-20 03:28:57 -04:00
|
|
|
marker::{Unsize, PhantomData},
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WrapperWithExtraField<T>(T, i32);
|
|
|
|
|
2018-10-03 23:40:21 -04:00
|
|
|
impl<T, U> DispatchFromDyn<WrapperWithExtraField<U>> for WrapperWithExtraField<T>
|
2018-09-20 03:28:57 -04:00
|
|
|
where
|
2018-10-03 23:40:21 -04:00
|
|
|
T: DispatchFromDyn<U>,
|
|
|
|
{} //~^^^ ERROR [E0378]
|
2018-09-20 03:28:57 -04:00
|
|
|
|
|
|
|
|
|
|
|
struct MultiplePointers<T: ?Sized>{
|
|
|
|
ptr1: *const T,
|
|
|
|
ptr2: *const T,
|
|
|
|
}
|
|
|
|
|
2018-10-03 23:40:21 -04:00
|
|
|
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<MultiplePointers<U>> for MultiplePointers<T>
|
2018-09-20 03:28:57 -04:00
|
|
|
where
|
|
|
|
T: Unsize<U>,
|
|
|
|
{} //~^^^ ERROR [E0378]
|
|
|
|
|
|
|
|
|
|
|
|
struct NothingToCoerce<T: ?Sized> {
|
|
|
|
data: PhantomData<T>,
|
|
|
|
}
|
|
|
|
|
2018-10-03 23:40:21 -04:00
|
|
|
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NothingToCoerce<T>> for NothingToCoerce<U> {}
|
2018-09-20 03:28:57 -04:00
|
|
|
//~^ ERROR [E0378]
|
|
|
|
|
2018-10-26 01:09:33 -04:00
|
|
|
#[repr(C)]
|
|
|
|
struct HasReprC<T: ?Sized>(Box<T>);
|
|
|
|
|
|
|
|
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<HasReprC<U>> for HasReprC<T>
|
|
|
|
where
|
|
|
|
T: Unsize<U>,
|
|
|
|
{} //~^^^ ERROR [E0378]
|
|
|
|
|
2018-09-20 03:28:57 -04:00
|
|
|
fn main() {}
|