-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Don't try to prove opaque type bounds twice on the same types #114094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,20 @@ | ||
error[E0275]: overflow evaluating the requirement `<i32 as std::ops::Add>::Output == issue10041::X` | ||
--> $DIR/new_ret_no_self_overflow.rs:20:25 | ||
error: methods called `new` usually return `Self` | ||
--> $DIR/new_ret_no_self_overflow.rs:9:9 | ||
| | ||
LL | pub fn new() -> X { | ||
| ^ | ||
LL | / pub fn new() -> impl PartialOrd { | ||
LL | | 0i32 | ||
LL | | } | ||
| |_________^ | ||
| | ||
= note: `-D clippy::new-ret-no-self` implied by `-D warnings` | ||
|
||
error: methods called `new` usually return `Self` | ||
--> $DIR/new_ret_no_self_overflow.rs:20:9 | ||
| | ||
LL | / pub fn new() -> X { | ||
LL | | 0i32 | ||
LL | | } | ||
| |_________^ | ||
|
||
error: aborting due to previous error | ||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0275`. |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
10 changes: 10 additions & 0 deletions
10
tests/ui/type-alias-impl-trait/self-referential-in-fn-trait.next.stderr
This file contains hidden or 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,10 @@ | ||
error: unconstrained opaque type | ||
--> $DIR/self-referential-in-fn-trait.rs:13:16 | ||
| | ||
LL | type Foo<'a> = impl Fn() -> Foo<'a>; | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `Foo` must be used in combination with a concrete type within the same module | ||
|
||
error: aborting due to previous error | ||
|
10 changes: 10 additions & 0 deletions
10
tests/ui/type-alias-impl-trait/self-referential-in-fn-trait.old.stderr
This file contains hidden or 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,10 @@ | ||
error: unconstrained opaque type | ||
--> $DIR/self-referential-in-fn-trait.rs:13:16 | ||
| | ||
LL | type Foo<'a> = impl Fn() -> Foo<'a>; | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `Foo` must be used in combination with a concrete type within the same module | ||
|
||
error: aborting due to previous error | ||
|
25 changes: 25 additions & 0 deletions
25
tests/ui/type-alias-impl-trait/self-referential-in-fn-trait.rs
This file contains hidden or 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 @@ | ||
//! This test checks that we do not | ||
//! end up with an infinite recursion, | ||
//! a cycle error or an overflow when | ||
//! encountering an opaque type that has | ||
//! an associated type that is just itself | ||
//! again. | ||
|
||
#![feature(type_alias_impl_trait)] | ||
// revisions: next old working | ||
//[next] compile-flags: -Ztrait-solver=next | ||
//[working] check-pass | ||
|
||
type Foo<'a> = impl Fn() -> Foo<'a>; | ||
//[old,next]~^ ERROR: unconstrained opaque type | ||
|
||
fn crash<'a>(_: &'a (), x: Foo<'a>) -> Foo<'a> { | ||
x | ||
} | ||
|
||
#[cfg(working)] | ||
fn foo<'a>() -> Foo<'a> { | ||
foo | ||
} | ||
|
||
fn main() {} |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does this behave on the new trait solver? I think the new trait solver does re-prove bounds even if it's unifying with an existing opaque:
rust/compiler/rustc_trait_selection/src/solve/eval_ctxt.rs
Lines 896 to 902 in bd9785c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it works (see new commit), but I haven't run any logs yet to see what it is doing, and whether anything is different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonder why it's not cycling. I bet it's because of lazy norm. Anyways, I guess it shouldn't matter, unless we make sure we don't commit to something that breaks the new solver.