-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Walk un-shifted nested impl Trait
in trait when setting up default trait method assumptions
#109240
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
r? @wesleywiser (rustbot has picked a reviewer for you, use r? to override) |
compiler/rustc_ty_utils/src/ty.rs
Outdated
@@ -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| { |
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.
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.
☔ The latest upstream changes (presumably #109253) made this pull request unmergeable. Please resolve the merge conflicts. |
r? @oli-obk |
bc3ae85
to
239ec6c
Compare
.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) |
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.
we really need a alias_ty.type_of(tcx)
method, this code snippet exists way too often 😆
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 can add it :D
@bors r+ |
@bors rollup |
… 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
… 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
… 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
… 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
… 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
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
Fixes a double subtraction in some binder math in return-position
impl Trait
in trait handling code.Fixes #109239