Skip to content
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

Walk un-shifted nested impl Trait in trait when setting up default trait method assumptions #109240

Merged
merged 2 commits into from
Mar 21, 2023

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Mar 16, 2023

Fixes a double subtraction in some binder math in return-position impl Trait in trait handling code.

Fixes #109239

@rustbot
Copy link
Collaborator

rustbot commented Mar 16, 2023

r? @wesleywiser

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 16, 2023
@@ -275,8 +278,14 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ImplTraitInTraitFinder<'_, 'tcx> {
// We have entered some binders as we've walked into the
// bounds of the RPITIT. Shift these binders back out when
// constructing the top-level projection predicate.
let alias_ty = self.tcx.fold_regions(alias_ty, |re, _| {
let shifted_alias_ty = self.tcx.fold_regions(alias_ty, |re, depth| {
Copy link
Member Author

@compiler-errors compiler-errors Mar 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we turn alias_ty into shifted_alias_ty, we shift all the binders from self.depth to ty::INNERMOST so we have no escaping bound vars in the projection we collect at 285.

So when we walk the type's bounds on line 309, conceptually alias_ty's substs are technically only now one binder deep, so shifting any nested impl traits would result in us shifting to a negative de bruijn index.

@bors
Copy link
Contributor

bors commented Mar 17, 2023

☔ The latest upstream changes (presumably #109253) made this pull request unmergeable. Please resolve the merge conflicts.

@oli-obk
Copy link
Contributor

oli-obk commented Mar 18, 2023

r? @oli-obk

@rustbot rustbot assigned oli-obk and unassigned wesleywiser Mar 18, 2023
.tcx
.type_of(alias_ty.def_id)
.subst(self.tcx, alias_ty.substs)
self.tcx.type_of(shifted_alias_ty.def_id).subst(self.tcx, shifted_alias_ty.substs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we really need a alias_ty.type_of(tcx) method, this code snippet exists way too often 😆

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add it :D

@oli-obk
Copy link
Contributor

oli-obk commented Mar 20, 2023

@bors r+

@bors
Copy link
Contributor

bors commented Mar 20, 2023

📌 Commit 239ec6c has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 20, 2023
@oli-obk
Copy link
Contributor

oli-obk commented Mar 20, 2023

@bors rollup

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Mar 21, 2023
… r=oli-obk

Walk un-shifted nested `impl Trait` in trait when setting up default trait method assumptions

Fixes a double subtraction in some binder math in return-position `impl Trait` in trait handling code.

Fixes rust-lang#109239
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 21, 2023
… r=oli-obk

Walk un-shifted nested `impl Trait` in trait when setting up default trait method assumptions

Fixes a double subtraction in some binder math in return-position `impl Trait` in trait handling code.

Fixes rust-lang#109239
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 21, 2023
… r=oli-obk

Walk un-shifted nested `impl Trait` in trait when setting up default trait method assumptions

Fixes a double subtraction in some binder math in return-position `impl Trait` in trait handling code.

Fixes rust-lang#109239
Noratrieb added a commit to Noratrieb/rust that referenced this pull request Mar 21, 2023
… r=oli-obk

Walk un-shifted nested `impl Trait` in trait when setting up default trait method assumptions

Fixes a double subtraction in some binder math in return-position `impl Trait` in trait handling code.

Fixes rust-lang#109239
Noratrieb added a commit to Noratrieb/rust that referenced this pull request Mar 21, 2023
… r=oli-obk

Walk un-shifted nested `impl Trait` in trait when setting up default trait method assumptions

Fixes a double subtraction in some binder math in return-position `impl Trait` in trait handling code.

Fixes rust-lang#109239
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 21, 2023
Rollup of 10 pull requests

Successful merges:

 - rust-lang#106434 (Document `Iterator::sum/product` for Option/Result)
 - rust-lang#108326 (Implement read_buf for a few more types)
 - rust-lang#108842 (Enforce non-lifetime-binders in supertrait preds are not object safe)
 - rust-lang#108896 (new solver: make all goal evaluation able to be automatically rerun )
 - rust-lang#109124 (Add `dist.compression-profile` option to control compression speed)
 - rust-lang#109240 (Walk un-shifted nested `impl Trait` in trait when setting up default trait method assumptions)
 - rust-lang#109385 (fix typo)
 - rust-lang#109386 (add myself to mailmap)
 - rust-lang#109390 (Custom MIR: Support aggregate expressions)
 - rust-lang#109408 (not *all* retags might be explicit in Runtime MIR)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 66ba60a into rust-lang:master Mar 21, 2023
@rustbot rustbot added this to the 1.70.0 milestone Mar 21, 2023
@compiler-errors compiler-errors deleted the dont-binder-twice branch August 11, 2023 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE: value <= 0xFFFF_FF00
5 participants