1 // Copyright 2016 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 // This test is for #29859, we need to ensure auto traits,
12 // (also known previously as default traits), do not have
13 // supertraits. Since the compiler synthesizes these
14 // instances on demand, we are essentially enabling
15 // users to write axioms if we view trait selection,
18 // For example the below test allows us to add the rule:
19 // forall (T : Type), T : Copy
21 // Providing a copy instance for *any* type, which
22 // is most definitely unsound. Imagine copying a
23 // type that contains a mutable reference, enabling
26 // You can imagine an even more dangerous test,
27 // which currently compiles on nightly.
31 // let (a, b) = copy(&mut i);
32 // println!("{:?} {:?}", a, b);
35 #![feature(optin_builtin_traits)]
37 auto trait Magic: Copy {} //~ ERROR E0568
38 impl<T:Magic> Magic for T {}
40 fn copy<T: Magic>(x: T) -> (T, T) { (x, x) }
46 let (a, b) = copy(NoClone);
47 println!("{:?} {:?}", a, b);