]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/coherence-impls-copy.rs
New upstream version 1.12.0+dfsg1
[rustc.git] / src / test / compile-fail / coherence-impls-copy.rs
1 // Copyright 2015 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.
4 //
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.
10
11 #![feature(optin_builtin_traits)]
12
13 use std::marker::Copy;
14
15 enum TestE {
16 A
17 }
18
19 struct MyType;
20
21 struct NotSync;
22 impl !Sync for NotSync {}
23
24 impl Copy for TestE {}
25 impl Clone for TestE { fn clone(&self) -> Self { *self } }
26
27 impl Copy for MyType {}
28
29 impl Copy for &'static mut MyType {}
30 //~^ ERROR the trait `Copy` may not be implemented for this type
31 //~| NOTE type is not a structure or enumeration
32 impl Clone for MyType { fn clone(&self) -> Self { *self } }
33
34 impl Copy for (MyType, MyType) {}
35 //~^ ERROR the trait `Copy` may not be implemented for this type
36 //~| NOTE type is not a structure or enumeration
37 //~| ERROR only traits defined in the current crate can be implemented for arbitrary types
38 //~| NOTE impl doesn't use types inside crate
39 //~| NOTE the impl does not reference any types defined in this crate
40
41 impl Copy for &'static NotSync {}
42 //~^ ERROR the trait `Copy` may not be implemented for this type
43 //~| NOTE type is not a structure or enumeration
44
45 impl Copy for [MyType] {}
46 //~^ ERROR the trait `Copy` may not be implemented for this type
47 //~| NOTE type is not a structure or enumeration
48 //~| ERROR only traits defined in the current crate can be implemented for arbitrary types
49 //~| NOTE impl doesn't use types inside crate
50 //~| NOTE the impl does not reference any types defined in this crate
51
52 impl Copy for &'static [NotSync] {}
53 //~^ ERROR the trait `Copy` may not be implemented for this type
54 //~| NOTE type is not a structure or enumeration
55 //~| ERROR only traits defined in the current crate can be implemented for arbitrary types
56 //~| NOTE impl doesn't use types inside crate
57 //~| NOTE the impl does not reference any types defined in this crate
58
59 fn main() {
60 }