//@ run-pass #![feature(trait_alias)] use std::marker::PhantomData; trait Empty {} //~ WARN trait `Empty` is never used trait EmptyAlias = Empty; trait CloneDefault = Clone + Default; trait SendSyncAlias = Send + Sync; trait WhereSendAlias = where Self: Send; trait SendEqAlias = Send where T: PartialEq; trait I32Iterator = Iterator; #[allow(dead_code)] struct Foo(PhantomData); #[allow(dead_code)] struct Bar(PhantomData) where T: SendSyncAlias; impl dyn EmptyAlias {} impl Empty for T {} fn a() -> (T, T) { let one = T::default(); let two = one.clone(); (one, two) } fn b(x: &impl SendEqAlias) -> bool { 22_i32 == *x } fn c(x: &mut T) -> Option { x.next() } fn d() { is_send_and_sync::(); } fn is_send_and_sync() {} fn main() { let both = a::(); assert_eq!(both.0, 0); assert_eq!(both.1, 0); let both: (i32, i32) = a(); assert_eq!(both.0, 0); assert_eq!(both.1, 0); assert!(b(&22)); assert_eq!(c(&mut vec![22].into_iter()), Some(22)); d::(); }