]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/traits-negative-impls.rs
Imported Upstream version 1.2.0+dfsg1
[rustc.git] / src / test / compile-fail / traits-negative-impls.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 // The dummy functions are used to avoid adding new cfail files.
12 // What happens is that the compiler attempts to squash duplicates and some
13 // errors are not reported. This way, we make sure that, for each function, different
14 // typeck phases are involved and all errors are reported.
15
16 #![feature(optin_builtin_traits)]
17
18 use std::marker::Send;
19
20 struct Outer<T: Send>(T);
21
22 struct Outer2<T>(T);
23
24 unsafe impl<T: Send> Sync for Outer2<T> {}
25
26 fn is_send<T: Send>(_: T) {}
27 fn is_sync<T: Sync>(_: T) {}
28
29 fn dummy() {
30 struct TestType;
31 impl !Send for TestType {}
32
33 Outer(TestType);
34 //~^ ERROR the trait `core::marker::Send` is not implemented for the type `dummy::TestType`
35
36 is_send(TestType);
37 //~^ ERROR the trait `core::marker::Send` is not implemented for the type `dummy::TestType`
38
39 is_send((8, TestType));
40 //~^ ERROR the trait `core::marker::Send` is not implemented for the type `dummy::TestType`
41 }
42
43 fn dummy2() {
44 struct TestType;
45 impl !Send for TestType {}
46
47 is_send(Box::new(TestType));
48 //~^ ERROR the trait `core::marker::Send` is not implemented for the type `dummy2::TestType`
49 }
50
51 fn dummy3() {
52 struct TestType;
53 impl !Send for TestType {}
54
55 is_send(Box::new(Outer2(TestType)));
56 //~^ ERROR the trait `core::marker::Send` is not implemented for the type `dummy3::TestType`
57 }
58
59 fn main() {
60 struct TestType;
61 impl !Send for TestType {}
62
63 // This will complain about a missing Send impl because `Sync` is implement *just*
64 // for T that are `Send`. Look at #20366 and #19950
65 is_sync(Outer2(TestType));
66 //~^ ERROR the trait `core::marker::Send` is not implemented for the type `main::TestType`
67 }