]> git.lizzy.rs Git - rust.git/blob - src/test/ui/overlap-marker-trait.rs
Auto merge of #54624 - arielb1:evaluate-outlives, r=nikomatsakis
[rust.git] / src / test / ui / overlap-marker-trait.rs
1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // Test for RFC 1268: we allow overlapping impls of marker traits,
12 // that is, traits without items. In this case, a type `T` is
13 // `MyMarker` if it is either `Debug` or `Display`. This test just
14 // checks that we don't consider **all** types to be `MyMarker`.  See
15 // also the companion test in
16 // `run-pass/overlap-permitted-for-marker-traits.rs`.
17
18 #![feature(overlapping_marker_traits)]
19 #![feature(optin_builtin_traits)]
20
21 use std::fmt::{Debug, Display};
22
23 trait Marker {}
24
25 impl<T: Debug> Marker for T {}
26 impl<T: Display> Marker for T {}
27
28 fn is_marker<T: Marker>() { }
29
30 struct NotDebugOrDisplay;
31
32 fn main() {
33     // Debug && Display:
34     is_marker::<i32>();
35
36     // Debug && !Display:
37     is_marker::<Vec<i32>>();
38
39     // !Debug && !Display
40     is_marker::<NotDebugOrDisplay>(); //~ ERROR
41 }