1 // Copyright 2018 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.
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.
11 #![feature(trait_alias)]
13 use std::marker::PhantomData;
16 trait EmptyAlias = Empty;
17 trait CloneDefault = Clone + Default;
18 trait SendSyncAlias = Send + Sync;
19 trait WhereSendAlias = where Self: Send;
20 trait SendEqAlias<T> = Send where T: PartialEq<Self>;
21 trait I32Iterator = Iterator<Item = i32>;
24 struct Foo<T: SendSyncAlias>(PhantomData<T>);
26 struct Bar<T>(PhantomData<T>) where T: SendSyncAlias;
30 impl<T: SendSyncAlias> Empty for T {}
32 fn a<T: CloneDefault>() -> (T, T) {
33 let one = T::default();
34 let two = one.clone();
38 fn b(x: &impl SendEqAlias<i32>) -> bool {
42 fn c<T: I32Iterator>(x: &mut T) -> Option<i32> {
46 fn d<T: SendSyncAlias>() {
47 is_send_and_sync::<T>();
50 fn is_send_and_sync<T: Send + Sync>() {}
53 let both = a::<i32>();
54 assert_eq!(both.0, 0);
55 assert_eq!(both.1, 0);
56 let both: (i32, i32) = a();
57 assert_eq!(both.0, 0);
58 assert_eq!(both.1, 0);
62 assert_eq!(c(&mut vec![22].into_iter()), Some(22));