summaryrefslogtreecommitdiffstats
path: root/src/test/ui/traits/issue-33140-hack-boundaries.rs
blob: d091162fced6b926ed6457a618946bc6f9f5c799 (plain)
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
69
70
#![feature(negative_impls)]
#![allow(order_dependent_trait_objects)]

// Check that the issue #33140 hack does not allow unintended things.

// OK
trait Trait0 {}

impl Trait0 for dyn Send {}
impl Trait0 for dyn Send {}

// Problem 1: associated types
trait Trait1 {
    fn my_fn(&self) {}
}

impl Trait1 for dyn Send {}
impl Trait1 for dyn Send {}
//~^ ERROR E0119

// Problem 2: negative impl
trait Trait2 {}

impl Trait2 for dyn Send {}
impl !Trait2 for dyn Send {}
//~^ ERROR E0751

// Problem 3: type parameter
trait Trait3<T: ?Sized> {}

impl Trait3<dyn Sync> for dyn Send {}
impl Trait3<dyn Sync> for dyn Send {}
//~^ ERROR E0119

// Problem 4a: not a trait object - generic
trait Trait4a {}

impl<T: ?Sized> Trait4a for T {}
impl Trait4a for dyn Send {}
//~^ ERROR E0119

// Problem 4b: not a trait object - misc
trait Trait4b {}

impl Trait4b for () {}
impl Trait4b for () {}
//~^ ERROR E0119

// Problem 4c: not a principal-less trait object
trait Trait4c {}

impl Trait4c for dyn Trait1 + Send {}
impl Trait4c for dyn Trait1 + Send {}
//~^ ERROR E0119

// Problem 4d: lifetimes
trait Trait4d {}

impl<'a> Trait4d for dyn Send + 'a {}
impl<'a> Trait4d for dyn Send + 'a {}
//~^ ERROR E0119

// Problem 5: where-clauses
trait Trait5 {}

impl Trait5 for dyn Send {}
impl Trait5 for dyn Send where u32: Copy {}
//~^ ERROR E0119

fn main() {}