]> git.lizzy.rs Git - rust.git/blob - src/test/ui/overlap-marker-trait.rs
Auto merge of #62748 - luca-barbieri:optimize-refcell-borrow, r=RalfJung
[rust.git] / src / test / ui / overlap-marker-trait.rs
1 // Test for RFC 1268: we allow overlapping impls of marker traits,
2 // that is, traits without items. In this case, a type `T` is
3 // `MyMarker` if it is either `Debug` or `Display`. This test just
4 // checks that we don't consider **all** types to be `MyMarker`.  See
5 // also the companion test in
6 // `run-pass/overlap-permitted-for-marker-traits.rs`.
7
8 #![feature(overlapping_marker_traits)]
9 #![feature(optin_builtin_traits)]
10
11 use std::fmt::{Debug, Display};
12
13 trait Marker {}
14
15 impl<T: Debug> Marker for T {}
16 impl<T: Display> Marker for T {}
17
18 fn is_marker<T: Marker>() { }
19
20 struct NotDebugOrDisplay;
21
22 fn main() {
23     // Debug && Display:
24     is_marker::<i32>();
25
26     // Debug && !Display:
27     is_marker::<Vec<i32>>();
28
29     // !Debug && !Display
30     is_marker::<NotDebugOrDisplay>(); //~ ERROR
31 }