-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Un-shadow object bound candidate in NormalizesTo goal if self_ty is trait object
#148292
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
Merged
+46
−1
Merged
Changes from 1 commit
Commits
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
17 changes: 17 additions & 0 deletions
17
tests/ui/traits/next-solver/normalization-shadowing/use_object_if_empty_env.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,17 @@ | ||
| //@ compile-flags: -Znext-solver | ||
| //@ check-pass | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pls add |
||
| trait Trait { | ||
| type Assoc; | ||
| } | ||
|
|
||
| // We have param env candidate for the trait goal but not the projection. | ||
| // Under such circumstance, consider object candidate if the self_ty is trait object. | ||
| fn foo<T>(x: <dyn Trait<Assoc = T> as Trait>::Assoc) -> T | ||
| where | ||
| dyn Trait<Assoc = T>: Trait, | ||
| { | ||
| x | ||
| } | ||
|
|
||
| fn main() {} | ||
Oops, something went wrong.
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.
I think we should move this into
assemble_and_evaluate_candidatesas rn this doesn't handle cases where the self type is an alias, e.g. the following should still fail with ur PRUh oh!
There was an error while loading. Please reload this page.
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.
This doesn't fail (after fixing
?Sizedbound). And theAssocprojection's self_ty is not alias?The trait goal in param env has alias self_ty but it's irrelevant for the
NormalizesTogoal.Besides, the following doesn't fail either. Perhaps the self_ty is normalized somehow?
Nonetheless, I moved the code into
assemble_and_evaluate_candidatesand removed comments specific toNormalizesTogoal since trait goals also use this method.Uh oh!
There was an error while loading. Please reload this page.
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.
you're right. I messed up the example.
does the following fail with the old impl? I think the issue is that we otherwise first normalize the inner, and then the outer alias 🤔
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.
This doesn't fail with my first commit.
It turns out when we add
NormalizesTogoal for projectionAssoc, we also add a nestedAliasRelategoal for the inner projectionThis.And we evaluate the inner projection before the outer one.
Thus when we evaluate the
NormalizesTogoal ofAssoc, the self_ty is already normalized.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.
ah yeah. we never actually need to normalize the self type for normalization goals 😅 can you still add that one as a test?