forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When checking whether an impl applies, constrain hidden types of opaq…
…ue types. We already handle this case this way on the coherence side, and it matches the new solver's behaviour. While there is some breakage around type-alias-impl-trait (see new "type annotations needed" in tests/ui/type-alias-impl-trait/issue-84660-unsoundness.rs), no stable code breaks, and no new stable code is accepted.
- Loading branch information
Showing
23 changed files
with
127 additions
and
116 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
12 changes: 3 additions & 9 deletions
12
tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.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 |
---|---|---|
@@ -1,15 +1,9 @@ | ||
error[E0277]: can't compare `Bar` with `(Foo, i32)` | ||
error[E0275]: overflow evaluating the requirement `Bar: PartialEq<(Foo, i32)>` | ||
--> $DIR/recursive-type-alias-impl-trait-declaration.rs:13:13 | ||
| | ||
LL | fn foo() -> Foo { | ||
| ^^^ no implementation for `Bar == (Foo, i32)` | ||
LL | | ||
LL | Bar | ||
| --- return type was inferred to be `Bar` here | ||
| | ||
= help: the trait `PartialEq<(Foo, i32)>` is not implemented for `Bar` | ||
= help: the trait `PartialEq<(Bar, i32)>` is implemented for `Bar` | ||
| ^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. | ||
For more information about this error, try `rustc --explain E0275`. |
11 changes: 0 additions & 11 deletions
11
tests/ui/type-alias-impl-trait/constrain_in_projection.current.stderr
This file was deleted.
Oops, something went wrong.
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
18 changes: 12 additions & 6 deletions
18
tests/ui/type-alias-impl-trait/constrain_in_projection2.current.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 |
---|---|---|
@@ -1,13 +1,19 @@ | ||
error[E0277]: the trait bound `Foo: Trait<Bar>` is not satisfied | ||
error[E0283]: type annotations needed: cannot satisfy `Foo: Trait<Bar>` | ||
--> $DIR/constrain_in_projection2.rs:27:14 | ||
| | ||
LL | let x = <Foo as Trait<Bar>>::Assoc::default(); | ||
| ^^^ the trait `Trait<Bar>` is not implemented for `Foo` | ||
| ^^^ help: use the fully qualified path to an implementation: `<Type as Trait>::Assoc` | ||
| | ||
= help: the following other types implement trait `Trait<T>`: | ||
<Foo as Trait<()>> | ||
<Foo as Trait<u32>> | ||
note: multiple `impl`s satisfying `Foo: Trait<Bar>` found | ||
--> $DIR/constrain_in_projection2.rs:18:1 | ||
| | ||
LL | impl Trait<()> for Foo { | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
... | ||
LL | impl Trait<u32> for Foo { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
= note: associated types cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. | ||
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
2 changes: 1 addition & 1 deletion
2
...impl-trait/issue-84660-unsoundness.stderr → ...it/issue-84660-unsoundness.current.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
23 changes: 23 additions & 0 deletions
23
tests/ui/type-alias-impl-trait/issue-84660-unsoundness.next.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,23 @@ | ||
error[E0284]: type annotations needed: cannot satisfy `<Out as Trait<Bar, In>>::Out == ()` | ||
--> $DIR/issue-84660-unsoundness.rs:22:37 | ||
| | ||
LL | fn convert(_i: In) -> Self::Out { | ||
| _____________________________________^ | ||
LL | | | ||
LL | | unreachable!(); | ||
LL | | } | ||
| |_____^ cannot satisfy `<Out as Trait<Bar, In>>::Out == ()` | ||
|
||
error[E0119]: conflicting implementations of trait `Trait<Bar, _>` | ||
--> $DIR/issue-84660-unsoundness.rs:28:1 | ||
| | ||
LL | impl<In, Out> Trait<Bar, In> for Out { | ||
| ------------------------------------ first implementation here | ||
... | ||
LL | impl<In, Out> Trait<(), In> for Out { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0119, E0284. | ||
For more information about an error, try `rustc --explain E0119`. |
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 |
---|---|---|
@@ -1,18 +1,21 @@ | ||
#![feature(type_alias_impl_trait)] | ||
#![allow(dead_code)] | ||
|
||
//@ revisions: current next | ||
//@ ignore-compare-mode-next-solver (explicit revisions) | ||
//@[next] compile-flags: -Znext-solver | ||
//@check-pass | ||
|
||
use std::fmt::Debug; | ||
|
||
type FooX = impl Debug; | ||
|
||
trait Foo<A> { } | ||
trait Foo<A> {} | ||
|
||
impl Foo<()> for () { } | ||
impl Foo<()> for () {} | ||
|
||
fn foo() -> impl Foo<FooX> { | ||
//~^ ERROR: the trait bound `(): Foo<FooX>` is not satisfied | ||
// FIXME(type-alias-impl-trait): We could probably make this work. | ||
() | ||
} | ||
|
||
fn main() { } | ||
fn main() {} |
17 changes: 17 additions & 0 deletions
17
tests/ui/type-alias-impl-trait/nested-tait-inference2.current.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,17 @@ | ||
error[E0283]: type annotations needed: cannot satisfy `(): Foo<FooX>` | ||
--> $DIR/nested-tait-inference2.rs:17:13 | ||
| | ||
LL | fn foo() -> impl Foo<FooX> { | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
note: multiple `impl`s satisfying `(): Foo<FooX>` found | ||
--> $DIR/nested-tait-inference2.rs:14:1 | ||
| | ||
LL | impl Foo<()> for () {} | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
LL | impl Foo<u32> for () {} | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0283`. |
9 changes: 9 additions & 0 deletions
9
tests/ui/type-alias-impl-trait/nested-tait-inference2.next.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,9 @@ | ||
error[E0284]: type annotations needed: cannot satisfy `impl Foo<FooX> == ()` | ||
--> $DIR/nested-tait-inference2.rs:19:5 | ||
| | ||
LL | () | ||
| ^^ cannot satisfy `impl Foo<FooX> == ()` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0284`. |
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
16 changes: 0 additions & 16 deletions
16
tests/ui/type-alias-impl-trait/nested-tait-inference2.stderr
This file was deleted.
Oops, something went wrong.
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
14 changes: 0 additions & 14 deletions
14
tests/ui/type-alias-impl-trait/self-referential-2.current.stderr
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.