-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #88139 - lcnr:marker-trait-attr, r=nikomatsakis
marker_traits: require `EvaluatedToOk` during winnowing closes #84955, while it doesn't really fix it in a way that makes me happy it should prevent the issue for now and this test can't be reproduced anyways, so it doesn't make much sense to keep it open. fixes #84917 as only one of the impls depends on regions, so we now drop the ambiguous one instead of the correct one. cc https://rust-lang.zulipchat.com/#narrow/stream/144729-wg-traits/topic/winnowing.20soundly/near/247899832 r? `@nikomatsakis`
- Loading branch information
Showing
6 changed files
with
93 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/test/ui/marker_trait_attr/overlapping-impl-1-modulo-regions.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// check-pass | ||
#![feature(marker_trait_attr)] | ||
|
||
#[marker] | ||
pub trait F {} | ||
impl<T> F for T where T: Copy {} | ||
impl<T> F for T where T: 'static {} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#![feature(marker_trait_attr)] | ||
|
||
#[marker] | ||
trait A {} | ||
impl<'a> A for (&'static (), &'a ()) {} //~ ERROR type annotations needed | ||
impl<'a> A for (&'a (), &'static ()) {} //~ ERROR type annotations needed | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
error[E0283]: type annotations needed | ||
--> $DIR/region-overlap.rs:5:10 | ||
| | ||
LL | impl<'a> A for (&'static (), &'a ()) {} | ||
| ^ cannot infer type for tuple `(&'static (), &'a ())` | ||
| | ||
= note: cannot satisfy `(&'static (), &'a ()): A` | ||
note: required by a bound in `A` | ||
--> $DIR/region-overlap.rs:4:1 | ||
| | ||
LL | trait A {} | ||
| ^^^^^^^ required by this bound in `A` | ||
|
||
error[E0283]: type annotations needed | ||
--> $DIR/region-overlap.rs:6:10 | ||
| | ||
LL | impl<'a> A for (&'a (), &'static ()) {} | ||
| ^ cannot infer type for tuple `(&'a (), &'static ())` | ||
| | ||
= note: cannot satisfy `(&'a (), &'static ()): A` | ||
note: required by a bound in `A` | ||
--> $DIR/region-overlap.rs:4:1 | ||
| | ||
LL | trait A {} | ||
| ^^^^^^^ required by this bound in `A` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0283`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#![feature(marker_trait_attr)] | ||
|
||
#[marker] | ||
trait A {} | ||
|
||
trait B {} | ||
|
||
impl<T: A> B for T {} | ||
impl<T: B> A for T {} | ||
impl A for &str {} | ||
impl<T: A + B> A for (T,) {} | ||
trait TraitWithAssoc { | ||
type Assoc; | ||
} | ||
|
||
impl<T: A> TraitWithAssoc for T { | ||
type Assoc = T; | ||
} | ||
|
||
impl TraitWithAssoc for ((&str,),) { | ||
//~^ ERROR conflicting implementations | ||
type Assoc = ((&'static str,),); | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0119]: conflicting implementations of trait `TraitWithAssoc` for type `((&str,),)` | ||
--> $DIR/unsound-overlap.rs:20:1 | ||
| | ||
LL | impl<T: A> TraitWithAssoc for T { | ||
| ------------------------------- first implementation here | ||
... | ||
LL | impl TraitWithAssoc for ((&str,),) { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `((&str,),)` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0119`. |