Fix #161802: Unsize bound aliasing T -> U in next solver - #161833
Draft
anmolxlight wants to merge 1 commit into
Draft
Fix #161802: Unsize bound aliasing T -> U in next solver#161833anmolxlight wants to merge 1 commit into
anmolxlight wants to merge 1 commit into
Conversation
The method `from_sized<T: Unsize<U>>` where `U` is from `impl<U> Ptr<U>` was incorrectly resolving `T` as `U` inside the body (`*mut T` became `*mut U`, causing `ptr::write(data, o)` to infer `U` and fail with E0308/E0277). This only reproduced with `-Znext-solver=globally` (now default nightly), `-Znext-solver=coherence` passed, so the bug predates the 2026-08-21 enable commit 526c36b. Root cause is in `ArgFolder::shift_vars_through_binders` handling of early-bound Params inside a Binder for the where-clause. The fix ensures Params are not De Bruijn-shifted. Fixes rust-lang#161802
Collaborator
|
The job Click to see the possible cause of the failure (guessed by this bot) |
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.
Fixes #161802
Problem
Ptr<U>::from_sized<T: Unsize<U>>whereTis method generic andUisimplgeneric was incorrectly resolvingTasUinside the body with-Znext-solver=globally(now default nightly).let data = self.get() as *mut T; ptr::write(data, o)inferredUforptr::write'sT, failing with E0308/E0277.Reproduces with
nightly-2026-07-25 -Znext-solver=globally, passes with-Znext-solver=coherence, so bug predates the 2026-08-21 enable commit 526c36b and was just exposed by it.Root cause
ArgFolder::shift_vars_through_bindersincompiler/rustc_type_ir/src/binder.rswas handling thewhere T: Unsize<U>Binder (whereUis parent param index 0,Tis own index 1) with incorrect De Bruijn shifting whenbinders_passed>0. The fix ensures early-boundParams are not shifted.Test
Adds
tests/ui/issues/issue-161802.rswithcheck-passfor both solvers.Skipped: full new abstraction, extra dependency.
Add when: late-bound Unsize with lifetimes needs precise escaping check.