add tests and slight formatting

This commit is contained in:
Rageking8 2022-10-27 10:11:49 +08:00
parent 1898c34e92
commit 2f2a97ee16
6 changed files with 56 additions and 4 deletions

View File

@ -0,0 +1,10 @@
// check-pass
#![feature(marker_trait_attr)]
#[marker]
trait Marker {}
impl Marker for &'static () {}
impl Marker for &'static () {}
fn main() {}

View File

@ -0,0 +1,9 @@
#![feature(marker_trait_attr)]
#[marker]
trait Marker {}
impl Marker for &'_ () {} //~ ERROR type annotations needed
impl Marker for &'_ () {} //~ ERROR type annotations needed
fn main() {}

View File

@ -0,0 +1,31 @@
error[E0283]: type annotations needed: cannot satisfy `&(): Marker`
--> $DIR/overlap-marker-trait-with-underscore-lifetime.rs:6:6
|
LL | impl Marker for &'_ () {}
| ^^^^^^
|
note: multiple `impl`s satisfying `&(): Marker` found
--> $DIR/overlap-marker-trait-with-underscore-lifetime.rs:6:1
|
LL | impl Marker for &'_ () {}
| ^^^^^^^^^^^^^^^^^^^^^^
LL | impl Marker for &'_ () {}
| ^^^^^^^^^^^^^^^^^^^^^^
error[E0283]: type annotations needed: cannot satisfy `&(): Marker`
--> $DIR/overlap-marker-trait-with-underscore-lifetime.rs:7:6
|
LL | impl Marker for &'_ () {}
| ^^^^^^
|
note: multiple `impl`s satisfying `&(): Marker` found
--> $DIR/overlap-marker-trait-with-underscore-lifetime.rs:6:1
|
LL | impl Marker for &'_ () {}
| ^^^^^^^^^^^^^^^^^^^^^^
LL | impl Marker for &'_ () {}
| ^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0283`.

View File

@ -7,7 +7,8 @@
use std::fmt::{Debug, Display};
#[marker] trait Marker {}
#[marker]
trait Marker {}
impl<T: Debug> Marker for T {}
impl<T: Display> Marker for T {}

View File

@ -1,11 +1,11 @@
error[E0277]: the trait bound `NotDebugOrDisplay: Marker` is not satisfied
--> $DIR/overlap-marker-trait.rs:27:17
--> $DIR/overlap-marker-trait.rs:28:17
|
LL | is_marker::<NotDebugOrDisplay>();
| ^^^^^^^^^^^^^^^^^ the trait `Marker` is not implemented for `NotDebugOrDisplay`
|
note: required by a bound in `is_marker`
--> $DIR/overlap-marker-trait.rs:15:17
--> $DIR/overlap-marker-trait.rs:16:17
|
LL | fn is_marker<T: Marker>() { }
| ^^^^^^ required by this bound in `is_marker`

View File

@ -7,7 +7,8 @@
use std::fmt::{Debug, Display};
#[marker] trait MyMarker {}
#[marker]
trait MyMarker {}
impl<T: Debug> MyMarker for T {}
impl<T: Display> MyMarker for T {}