2019-03-30 22:06:09 +00:00
|
|
|
//@ run-pass
|
|
|
|
|
2017-12-03 17:55:22 +00:00
|
|
|
#![feature(trait_alias)]
|
|
|
|
|
2018-10-25 00:03:25 +00:00
|
|
|
use std::marker::PhantomData;
|
|
|
|
|
2024-02-07 02:42:01 +00:00
|
|
|
trait Empty {} //~ WARN trait `Empty` is never used
|
2018-10-25 00:03:25 +00:00
|
|
|
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 18:46:13 +00:00
|
|
|
impl dyn EmptyAlias {}
|
2018-10-25 00:03:25 +00:00
|
|
|
|
|
|
|
impl<T: SendSyncAlias> Empty for T {}
|
2017-10-02 12:27:45 +00:00
|
|
|
|
2018-10-25 00:03:25 +00:00
|
|
|
fn a<T: CloneDefault>() -> (T, T) {
|
2017-10-02 12:27:45 +00:00
|
|
|
let one = T::default();
|
|
|
|
let two = one.clone();
|
|
|
|
(one, two)
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:03:25 +00: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 12:27:45 +00:00
|
|
|
fn main() {
|
2018-10-25 00:03:25 +00:00
|
|
|
let both = a::<i32>();
|
2017-10-02 12:27:45 +00:00
|
|
|
assert_eq!(both.0, 0);
|
|
|
|
assert_eq!(both.1, 0);
|
2018-10-25 00:03:25 +00:00
|
|
|
let both: (i32, i32) = a();
|
2017-10-02 12:27:45 +00:00
|
|
|
assert_eq!(both.0, 0);
|
|
|
|
assert_eq!(both.1, 0);
|
2018-10-25 00:03:25 +00:00
|
|
|
|
|
|
|
assert!(b(&22));
|
|
|
|
|
|
|
|
assert_eq!(c(&mut vec![22].into_iter()), Some(22));
|
|
|
|
|
|
|
|
d::<i32>();
|
2017-10-02 12:27:45 +00:00
|
|
|
}
|