]> git.lizzy.rs Git - rust.git/blob - src/test/ui/marker_trait_attr/overlap-marker-trait.rs
Rollup merge of #57132 - daxpedda:master, r=steveklabnik
[rust.git] / src / test / ui / marker_trait_attr / overlap-marker-trait.rs
1 // Test for RFC 1268: we allow overlapping impls of marker traits,
2 // that is, traits with #[marker]. 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`.
5
6 #![feature(marker_trait_attr)]
7
8 use std::fmt::{Debug, Display};
9
10 #[marker] trait Marker {}
11
12 impl<T: Debug> Marker for T {}
13 impl<T: Display> Marker for T {}
14
15 fn is_marker<T: Marker>() { }
16
17 struct NotDebugOrDisplay;
18
19 fn main() {
20     // Debug && Display:
21     is_marker::<i32>();
22
23     // Debug && !Display:
24     is_marker::<Vec<i32>>();
25
26     // !Debug && !Display
27     is_marker::<NotDebugOrDisplay>(); //~ ERROR
28 }