Implement selection for Unsize for better coercion behavior#113353
Merged
bors merged 2 commits intorust-lang:masterfrom Jul 13, 2023
Merged
Implement selection for Unsize for better coercion behavior#113353bors merged 2 commits intorust-lang:masterfrom
Unsize for better coercion behavior#113353bors merged 2 commits intorust-lang:masterfrom
Conversation
Collaborator
|
Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor |
Unsize for better coercion behavior
compiler-errors
commented
Jul 5, 2023
lcnr
reviewed
Jul 7, 2023
lcnr
reviewed
Jul 7, 2023
Contributor
There was a problem hiding this comment.
please ICE here to detect mismatches
Contributor
Author
There was a problem hiding this comment.
We cannot ICE here because this goal is selected during coercion, so we legitimately may see, e.g. [T; N]: Unsize<_> during selection.
One more point towards having a typeck and codegen mode for selection...
Contributor
Author
There was a problem hiding this comment.
Left a fixme anyways.
Collaborator
|
☔ The latest upstream changes (presumably #113308) made this pull request unmergeable. Please resolve the merge conflicts. |
772b9fe to
df22cc2
Compare
df22cc2 to
a071044
Compare
Contributor
Author
|
You said r=me after nits, which I think I have addressed. @bors r=lcnr rollup (new solver) |
Collaborator
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Jul 12, 2023
Implement selection for `Unsize` for better coercion behavior In order for much of coercion to succeed, we need to be able to deal with partial ambiguity of `Unsize` traits during selection. However, I pessimistically implemented selection in the new trait solver to just bail out with ambiguity if it was a built-in impl: https://github.com/rust-lang/rust/blob/9227ff28aff55b252314076fcf21c9a66f10ac1e/compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs#L126 This implements a proper "rematch" procedure for dealing with built-in `Unsize` goals, so that even if the goal is ambiguous, we are able to get nested obligations which are used in the coercion selection-like loop: https://github.com/rust-lang/rust/blob/9227ff28aff55b252314076fcf21c9a66f10ac1e/compiler/rustc_hir_typeck/src/coercion.rs#L702 Second commit just moves a `resolve_vars_if_possible` call to fix a bug where we weren't detecting a trait upcasting to occur. r? `@lcnr`
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jul 13, 2023
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#113353 (Implement selection for `Unsize` for better coercion behavior) - rust-lang#113553 (Make Placeholder, GeneratorWitness*, Infer and Error unreachable on SMIR rustc_ty_to_ty) - rust-lang#113598 (Update cargo) - rust-lang#113603 (Test simd-wide-sum for codegen error) - rust-lang#113613 (Allow to have `-` in rustdoc-json test file name) - rust-lang#113615 (llvm-wrapper: adapt for LLVM API change) - rust-lang#113616 (Fix bootstrap.py uname error) r? `@ghost` `@rustbot` modify labels: rollup
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In order for much of coercion to succeed, we need to be able to deal with partial ambiguity of
Unsizetraits during selection. However, I pessimistically implemented selection in the new trait solver to just bail out with ambiguity if it was a built-in impl:rust/compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs
Line 126 in 9227ff2
This implements a proper "rematch" procedure for dealing with built-in
Unsizegoals, so that even if the goal is ambiguous, we are able to get nested obligations which are used in the coercion selection-like loop:rust/compiler/rustc_hir_typeck/src/coercion.rs
Line 702 in 9227ff2
Second commit just moves a
resolve_vars_if_possiblecall to fix a bug where we weren't detecting a trait upcasting to occur.r? @lcnr