1 // This test is for #29859, we need to ensure auto traits,
2 // (also known previously as default traits), do not have
3 // supertraits. Since the compiler synthesizes these
4 // instances on demand, we are essentially enabling
5 // users to write axioms if we view trait selection,
8 // For example the below test allows us to add the rule:
9 // forall (T : Type), T : Copy
11 // Providing a copy instance for *any* type, which
12 // is most definitely unsound. Imagine copying a
13 // type that contains a mutable reference, enabling
16 // You can imagine an even more dangerous test,
17 // which currently compiles on nightly.
21 // let (a, b) = copy(&mut i);
22 // println!("{:?} {:?}", a, b);
25 #![feature(auto_traits)]
26 #![feature(negative_impls)]
28 auto trait Magic: Copy {} //~ ERROR E0568
29 impl<T:Magic> Magic for T {}
31 fn copy<T: Magic>(x: T) -> (T, T) { (x, x) }
37 let (a, b) = copy(NoClone);
38 println!("{:?} {:?}", a, b);