File: negated-auto-traits-error.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (68 lines) | stat: -rw-r--r-- 1,732 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// The dummy functions are used to avoid adding new cfail files.
// What happens is that the compiler attempts to squash duplicates and some
// errors are not reported. This way, we make sure that, for each function, different
// typeck phases are involved and all errors are reported.

#![feature(negative_impls)]

use std::marker::Send;

struct Outer<T: Send>(T);

struct Outer2<T>(T);

unsafe impl<T: Send> Sync for Outer2<T> {}

fn is_send<T: Send>(_: T) {}
fn is_sync<T: Sync>(_: T) {}

fn dummy() {
    struct TestType;
    impl !Send for TestType {}

    Outer(TestType);
    //~^ ERROR `dummy::TestType` cannot be sent between threads safely
    //~| ERROR `dummy::TestType` cannot be sent between threads safely
}

fn dummy1b() {
    struct TestType;
    impl !Send for TestType {}

    is_send(TestType);
    //~^ ERROR `dummy1b::TestType` cannot be sent between threads safely
}

fn dummy1c() {
    struct TestType;
    impl !Send for TestType {}

    is_send((8, TestType));
    //~^ ERROR `dummy1c::TestType` cannot be sent between threads safely
}

fn dummy2() {
    struct TestType;
    impl !Send for TestType {}

    is_send(Box::new(TestType));
    //~^ ERROR `dummy2::TestType` cannot be sent between threads safely
}

fn dummy3() {
    struct TestType;
    impl !Send for TestType {}

    is_send(Box::new(Outer2(TestType)));
    //~^ ERROR `dummy3::TestType` cannot be sent between threads safely
}

fn main() {
    struct TestType;
    impl !Send for TestType {}

    // This will complain about a missing Send impl because `Sync` is implement *just*
    // for T that are `Send`. Look at #20366 and #19950
    is_sync(Outer2(TestType));
    //~^ ERROR `main::TestType` cannot be sent between threads safely
}