-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #126258 - oli-obk:recursive_rpit, r=lcnr
Do not define opaque types when selecting impls fixes #126117 r? `@lcnr` for inconsistency with next solver
- Loading branch information
Showing
22 changed files
with
140 additions
and
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
error[E0282]: type annotations needed | ||
--> $DIR/recursive-bound-eval.rs:20:13 | ||
| | ||
LL | move || recursive_fn().parse() | ||
| ^^^^^^^^^^^^^^ cannot infer type | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0282`. |
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 @@ | ||
//! Test that we can evaluate nested obligations when invoking methods on recursive calls on | ||
//! an RPIT. | ||
//@revisions: next current | ||
//@[next] compile-flags: -Znext-solver | ||
|
||
//@[current] check-pass | ||
|
||
pub trait Parser<E> { | ||
fn parse(&self) -> E; | ||
} | ||
|
||
impl<E, T: Fn() -> E> Parser<E> for T { | ||
fn parse(&self) -> E { | ||
self() | ||
} | ||
} | ||
|
||
pub fn recursive_fn<E>() -> impl Parser<E> { | ||
move || recursive_fn().parse() | ||
//[next]~^ 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
12 changes: 9 additions & 3 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,9 +1,15 @@ | ||
error[E0275]: overflow evaluating the requirement `Bar: PartialEq<(Foo, i32)>` | ||
error[E0277]: can't compare `Bar` with `(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 E0275`. | ||
For more information about this error, try `rustc --explain E0277`. |
11 changes: 11 additions & 0 deletions
11
tests/ui/type-alias-impl-trait/constrain_in_projection.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,11 @@ | ||
error[E0277]: the trait bound `Foo: Trait<Bar>` is not satisfied | ||
--> $DIR/constrain_in_projection.rs:24:14 | ||
| | ||
LL | let x = <Foo as Trait<Bar>>::Assoc::default(); | ||
| ^^^ the trait `Trait<Bar>` is not implemented for `Foo` | ||
| | ||
= help: the trait `Trait<()>` is implemented for `Foo` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
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: 6 additions & 12 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,19 +1,13 @@ | ||
error[E0283]: type annotations needed: cannot satisfy `Foo: Trait<Bar>` | ||
error[E0277]: the trait bound `Foo: Trait<Bar>` is not satisfied | ||
--> $DIR/constrain_in_projection2.rs:27:14 | ||
| | ||
LL | let x = <Foo as Trait<Bar>>::Assoc::default(); | ||
| ^^^ help: use the fully qualified path to an implementation: `<Type as Trait>::Assoc` | ||
| ^^^ the trait `Trait<Bar>` is not implemented for `Foo` | ||
| | ||
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` | ||
= help: the following other types implement trait `Trait<T>`: | ||
<Foo as Trait<()>> | ||
<Foo as Trait<u32>> | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0283`. | ||
For more information about this error, try `rustc --explain E0277`. |
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
2 changes: 1 addition & 1 deletion
2
...s-impl-trait/nested-tait-inference.stderr → ...rait/nested-tait-inference.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
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
19 changes: 9 additions & 10 deletions
19
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 |
---|---|---|
@@ -1,17 +1,16 @@ | ||
error[E0283]: type annotations needed: cannot satisfy `(): Foo<FooX>` | ||
error[E0277]: the trait bound `(): Foo<FooX>` is not satisfied | ||
--> $DIR/nested-tait-inference2.rs:17:13 | ||
| | ||
LL | fn foo() -> impl Foo<FooX> { | ||
| ^^^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^^^ the trait `Foo<FooX>` is not implemented for `()` | ||
LL | | ||
LL | () | ||
| -- return type was inferred to be `()` here | ||
| | ||
note: multiple `impl`s satisfying `(): Foo<FooX>` found | ||
--> $DIR/nested-tait-inference2.rs:14:1 | ||
| | ||
LL | impl Foo<()> for () {} | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
LL | impl Foo<u32> for () {} | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
= help: the following other types implement trait `Foo<A>`: | ||
<() as Foo<()>> | ||
<() as Foo<u32>> | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0283`. | ||
For more information about this error, try `rustc --explain E0277`. |
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
14 changes: 14 additions & 0 deletions
14
tests/ui/type-alias-impl-trait/self-referential-2.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,14 @@ | ||
error[E0277]: can't compare `i32` with `Foo` | ||
--> $DIR/self-referential-2.rs:10:13 | ||
| | ||
LL | fn bar() -> Bar { | ||
| ^^^ no implementation for `i32 == Foo` | ||
LL | 42_i32 | ||
| ------ return type was inferred to be `i32` here | ||
| | ||
= help: the trait `PartialEq<Foo>` is not implemented for `i32` | ||
= help: the trait `PartialEq` is implemented for `i32` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
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,14 +1,14 @@ | ||
//@ revisions: current next | ||
//@ ignore-compare-mode-next-solver (explicit revisions) | ||
//@[next] compile-flags: -Znext-solver | ||
//@ check-pass | ||
//@[next] check-pass | ||
#![feature(type_alias_impl_trait)] | ||
|
||
type Foo = impl std::fmt::Debug; | ||
type Bar = impl PartialEq<Foo>; | ||
|
||
fn bar() -> Bar { | ||
42_i32 | ||
42_i32 //[current]~^ ERROR can't compare `i32` with `Foo` | ||
} | ||
|
||
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
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,11 +1,15 @@ | ||
error[E0275]: overflow normalizing the type alias `Bar<'a, 'b>` | ||
error[E0277]: can't compare `&i32` with `Bar<'a, 'b>` | ||
--> $DIR/self-referential-3.rs:7:31 | ||
| | ||
LL | fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { | ||
| ^^^^^^^^^^^ | ||
| ^^^^^^^^^^^ no implementation for `&i32 == Bar<'a, 'b>` | ||
LL | | ||
LL | i | ||
| - return type was inferred to be `&i32` here | ||
| | ||
= note: in case this is a recursive type alias, consider using a struct, enum, or union instead | ||
= help: the trait `PartialEq<Bar<'a, 'b>>` is not implemented for `&i32` | ||
= help: the trait `PartialEq` is implemented for `i32` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0275`. | ||
For more information about this error, try `rustc --explain E0277`. |