forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
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 rust-lang#117164 - fmease:orphan-norm, r=<try>
Normalize trait ref before orphan check & consider ty params in alias types to be uncovered Fixes rust-lang#99554. r? lcnr
- Loading branch information
Showing
15 changed files
with
314 additions
and
38 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
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
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
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
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
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
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,2 @@ | ||
pub trait Trait0<T, U, V> {} | ||
pub trait Trait1<T, U> {} |
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,24 @@ | ||
// Projections can cover type parameters if they normalize to a (local) type that covers them. | ||
// This ensures that we don't perform an overly strict check on | ||
// projections like in closed PR #100555 which did a syntactic | ||
// check for type parameters in projections without normalizing | ||
// first which would've lead to real-word regressions. | ||
|
||
// check-pass | ||
// revisions: classic next | ||
//[next] compile-flags: -Ztrait-solver=next | ||
|
||
// aux-crate:foreign=parametrized-trait.rs | ||
// edition:2021 | ||
|
||
trait Project { type Output; } | ||
|
||
impl<T> Project for T { | ||
type Output = Local; | ||
} | ||
|
||
struct Local; | ||
|
||
impl<T> foreign::Trait1<Local, T> for <T as Project>::Output {} | ||
|
||
fn main() {} |
30 changes: 30 additions & 0 deletions
30
tests/ui/coherence/orphan-check-projection-doesnt-cover.classic.stderr
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,30 @@ | ||
error[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`) | ||
--> $DIR/orphan-check-projection-doesnt-cover.rs:21:6 | ||
| | ||
LL | impl<T> foreign::Trait0<Local, T, ()> for <T as Identity>::Output {} | ||
| ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`) | ||
| | ||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type | ||
= note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last | ||
|
||
error[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`) | ||
--> $DIR/orphan-check-projection-doesnt-cover.rs:24:6 | ||
| | ||
LL | impl<T> foreign::Trait0<<T as Identity>::Output, Local, T> for Option<T> {} | ||
| ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`) | ||
| | ||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type | ||
= note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last | ||
|
||
error[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`) | ||
--> $DIR/orphan-check-projection-doesnt-cover.rs:36:6 | ||
| | ||
LL | impl<T: Deferred> foreign::Trait1<Local, T> for <T as Deferred>::Output {} | ||
| ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`) | ||
| | ||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type | ||
= note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0210`. |
Oops, something went wrong.