]> git.lizzy.rs Git - rust.git/blob - src/test/ui/overlap-permitted-for-annotated-marker-traits.rs
Pin panic-in-drop=abort test to old pass manager
[rust.git] / src / test / ui / overlap-permitted-for-annotated-marker-traits.rs
1 // run-pass
2 // Tests for RFC 1268: we allow overlapping impls of marker traits,
3 // that is, traits with #[marker]. In this case, a type `T` is
4 // `MyMarker` if it is either `Debug` or `Display`.
5
6 #![feature(marker_trait_attr)]
7
8 use std::fmt::{Debug, Display};
9
10 #[marker] trait MyMarker {}
11
12 impl<T: Debug> MyMarker for T {}
13 impl<T: Display> MyMarker for T {}
14
15 fn foo<T: MyMarker>(t: T) -> T {
16     t
17 }
18
19 fn main() {
20     // Debug && Display:
21     assert_eq!(1, foo(1));
22     assert_eq!(2.0, foo(2.0));
23
24     // Debug && !Display:
25     assert_eq!(vec![1], foo(vec![1]));
26 }