]> git.lizzy.rs Git - rust.git/blob - src/test/ui/coherence/coherence-impl-trait-for-marker-trait-positive.rs
Merge commit 'ea199bacef07213dbe008841b89c450e3bf0c638' into rustfmt-sync
[rust.git] / src / test / ui / coherence / coherence-impl-trait-for-marker-trait-positive.rs
1 #![feature(auto_traits)]
2 #![feature(negative_impls)]
3
4 // Test for issue #56934 - that it is impossible to redundantly
5 // implement an auto-trait for a trait object type that contains it.
6
7 // Positive impl variant.
8
9 auto trait Marker1 {}
10 auto trait Marker2 {}
11
12 trait Object: Marker1 {}
13
14 // A supertrait marker is illegal...
15 impl Marker1 for dyn Object + Marker2 { }   //~ ERROR E0371
16 // ...and also a direct component.
17 impl Marker2 for dyn Object + Marker2 { }   //~ ERROR E0371
18
19 // But implementing a marker if it is not present is OK.
20 impl Marker2 for dyn Object {} // OK
21
22 // A non-principal trait-object type is orphan even in its crate.
23 unsafe impl Send for dyn Marker2 {} //~ ERROR E0117
24
25 // And impl'ing a remote marker for a local trait object is forbidden
26 // by one of these special orphan-like rules.
27 unsafe impl Send for dyn Object {} //~ ERROR E0321
28 unsafe impl Send for dyn Object + Marker2 {} //~ ERROR E0321
29
30 fn main() { }