]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/traits-negative-impls.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / compile-fail / traits-negative-impls.rs
CommitLineData
85aaf69f
SL
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
18use std::marker::Send;
19
20struct Outer<T: Send>(T);
21
85aaf69f
SL
22struct Outer2<T>(T);
23
24unsafe impl<T: Send> Sync for Outer2<T> {}
25
26fn is_send<T: Send>(_: T) {}
27fn is_sync<T: Sync>(_: T) {}
28
29fn dummy() {
62682a34
SL
30 struct TestType;
31 impl !Send for TestType {}
32
85aaf69f 33 Outer(TestType);
54a0048b
SL
34 //~^ ERROR `dummy::TestType: std::marker::Send` is not satisfied
35 //~| ERROR `dummy::TestType: std::marker::Send` is not satisfied
e9174d1e
SL
36}
37
38fn dummy1b() {
39 struct TestType;
40 impl !Send for TestType {}
85aaf69f
SL
41
42 is_send(TestType);
54a0048b 43 //~^ ERROR `dummy1b::TestType: std::marker::Send` is not satisfied
e9174d1e
SL
44}
45
46fn dummy1c() {
47 struct TestType;
48 impl !Send for TestType {}
85aaf69f
SL
49
50 is_send((8, TestType));
54a0048b 51 //~^ ERROR `dummy1c::TestType: std::marker::Send` is not satisfied
85aaf69f
SL
52}
53
54fn dummy2() {
62682a34
SL
55 struct TestType;
56 impl !Send for TestType {}
57
85aaf69f 58 is_send(Box::new(TestType));
54a0048b 59 //~^ ERROR `dummy2::TestType: std::marker::Send` is not satisfied
85aaf69f
SL
60}
61
62fn dummy3() {
62682a34
SL
63 struct TestType;
64 impl !Send for TestType {}
65
85aaf69f 66 is_send(Box::new(Outer2(TestType)));
54a0048b 67 //~^ ERROR `dummy3::TestType: std::marker::Send` is not satisfied
85aaf69f
SL
68}
69
70fn main() {
62682a34
SL
71 struct TestType;
72 impl !Send for TestType {}
73
85aaf69f
SL
74 // This will complain about a missing Send impl because `Sync` is implement *just*
75 // for T that are `Send`. Look at #20366 and #19950
76 is_sync(Outer2(TestType));
54a0048b 77 //~^ ERROR `main::TestType: std::marker::Send` is not satisfied
85aaf69f 78}