-
Notifications
You must be signed in to change notification settings - Fork 13.9k
AliasRelate: don't discard constraints on overflow #148069
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
Draft
lcnr
wants to merge
3
commits into
rust-lang:master
Choose a base branch
from
lcnr:alias-relate-no-discard-constraints
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
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
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
49 changes: 49 additions & 0 deletions
49
tests/ui/traits/next-solver/alias-relate/no-discard-constraints-on-ambiguity.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,49 @@ | ||
| //@ compile-flags: -Znext-solver | ||
| //@ check-pass | ||
|
|
||
| // Regression test for trait-system-refactor-initiative#246. | ||
|
|
||
| struct MarkedStruct; | ||
| pub trait MarkerTrait {} | ||
| impl MarkerTrait for MarkedStruct {} | ||
|
|
||
| // Necessary indirection to get a cycle with `PathKind::Unknown` | ||
| struct ChainStruct; | ||
| trait ChainTrait {} | ||
| impl ChainTrait for ChainStruct where MarkedStruct: MarkerTrait {} | ||
|
|
||
| pub struct FooStruct; | ||
| pub trait FooTrait { | ||
| type Output; | ||
| } | ||
| pub struct FooOut; | ||
| impl FooTrait for FooStruct | ||
| where | ||
| ChainStruct: ChainTrait, | ||
| { | ||
| type Output = FooOut; | ||
| } | ||
|
|
||
| pub trait Trait<T> { | ||
| type Output; | ||
| } | ||
|
|
||
| // prove <<FooStruct as FooTrait>::Output as Trait<K>>::Output: MarkerTrait | ||
| // normalize <<FooStruct as FooTrait>::Output as Trait<K>>::Output | ||
| // `<?fresh_infer as Trait<K>>::Output` remains ambiguous, so this alias is never rigid | ||
| // alias-relate <FooStruct as FooTrait>::Output ?fresh_infer | ||
| // does not constrain `?fresh_infer` as `keep_constraints` is `false` | ||
| // normalize <FooStruct as FooTrait>::Output | ||
| // result `FooOut` with overflow | ||
| // prove ChainStruct: ChainTrait | ||
| // prove MarkedStruct: MarkerTrait | ||
| // impl trivial (ignored) | ||
| // where-clause requires normalize <<FooStruct as FooTrait>::Output as Trait<K>>::Output overflow | ||
| pub fn foo<K>() | ||
| where | ||
| FooOut: Trait<K>, | ||
| <<FooStruct as FooTrait>::Output as Trait<K>>::Output: MarkerTrait, | ||
| { | ||
| } | ||
|
|
||
| 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
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
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.
right so here you'd have previously discarded (since
AliasRelategotCurrentGoalKind::Miscbut now you take this top branch). I'm not 100% sure why you also go here forNormalizesTo. That'd have previously discarded.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.
they wouldn't have, because for
NormalizesTowe use theshallow_certaintydue to the abovematch (self.current_goal_kind, shallow_certainty). That's subtle thoughUh 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.
maybe document it?
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.
Or somehow combine the two checks, such that all the ways in which we care about
self.current_goal_kindare handled exhaustively. I'm not sure that ends up working though, could also turn out more confusing rather than lessThere 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 tried: combining doesn't produce a nice check, maybe just document?