Skip to content

Commit

Permalink
add tests and slight formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Rageking8 committed Oct 27, 2022
1 parent 1898c34 commit 2f2a97e
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// check-pass
#![feature(marker_trait_attr)]

#[marker]
trait Marker {}

impl Marker for &'static () {}
impl Marker for &'static () {}

fn main() {}
Original file line number Diff line number Diff line change
@@ -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() {}
Original file line number Diff line number Diff line change
@@ -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`.
3 changes: 2 additions & 1 deletion src/test/ui/marker_trait_attr/overlap-marker-trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/marker_trait_attr/overlap-marker-trait.stderr
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down

0 comments on commit 2f2a97e

Please sign in to comment.