2019-03-30 17:06:09 -05:00
|
|
|
// run-pass
|
|
|
|
|
2017-12-03 11:55:22 -06:00
|
|
|
#![feature(trait_alias)]
|
|
|
|
|
2018-10-24 19:03:25 -05:00
|
|
|
use std::marker::PhantomData;
|
|
|
|
|
|
|
|
trait Empty {}
|
|
|
|
trait EmptyAlias = Empty;
|
|
|
|
trait CloneDefault = Clone + Default;
|
|
|
|
trait SendSyncAlias = Send + Sync;
|
|
|
|
trait WhereSendAlias = where Self: Send;
|
|
|
|
trait SendEqAlias<T> = Send where T: PartialEq<Self>;
|
|
|
|
trait I32Iterator = Iterator<Item = i32>;
|
|
|
|
|
|
|
|
#[allow(dead_code)]
|
|
|
|
struct Foo<T: SendSyncAlias>(PhantomData<T>);
|
|
|
|
#[allow(dead_code)]
|
|
|
|
struct Bar<T>(PhantomData<T>) where T: SendSyncAlias;
|
|
|
|
|
2019-05-28 13:46:13 -05:00
|
|
|
impl dyn EmptyAlias {}
|
2018-10-24 19:03:25 -05:00
|
|
|
|
|
|
|
impl<T: SendSyncAlias> Empty for T {}
|
2017-10-02 07:27:45 -05:00
|
|
|
|
2018-10-24 19:03:25 -05:00
|
|
|
fn a<T: CloneDefault>() -> (T, T) {
|
2017-10-02 07:27:45 -05:00
|
|
|
let one = T::default();
|
|
|
|
let two = one.clone();
|
|
|
|
(one, two)
|
|
|
|
}
|
|
|
|
|
2018-10-24 19:03:25 -05:00
|
|
|
fn b(x: &impl SendEqAlias<i32>) -> bool {
|
|
|
|
22_i32 == *x
|
|
|
|
}
|
|
|
|
|
|
|
|
fn c<T: I32Iterator>(x: &mut T) -> Option<i32> {
|
|
|
|
x.next()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn d<T: SendSyncAlias>() {
|
|
|
|
is_send_and_sync::<T>();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn is_send_and_sync<T: Send + Sync>() {}
|
|
|
|
|
2017-10-02 07:27:45 -05:00
|
|
|
fn main() {
|
2018-10-24 19:03:25 -05:00
|
|
|
let both = a::<i32>();
|
2017-10-02 07:27:45 -05:00
|
|
|
assert_eq!(both.0, 0);
|
|
|
|
assert_eq!(both.1, 0);
|
2018-10-24 19:03:25 -05:00
|
|
|
let both: (i32, i32) = a();
|
2017-10-02 07:27:45 -05:00
|
|
|
assert_eq!(both.0, 0);
|
|
|
|
assert_eq!(both.1, 0);
|
2018-10-24 19:03:25 -05:00
|
|
|
|
|
|
|
assert!(b(&22));
|
|
|
|
|
|
|
|
assert_eq!(c(&mut vec![22].into_iter()), Some(22));
|
|
|
|
|
|
|
|
d::<i32>();
|
2017-10-02 07:27:45 -05:00
|
|
|
}
|