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

fix universe map in ifcx.instantiate_canonical_* #99814

Merged
merged 2 commits into from
Nov 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions compiler/rustc_infer/src/infer/canonical/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
/// inference variables and applies it to the canonical value.
/// Returns both the instantiated result *and* the substitution S.
///
/// This is only meant to be invoked as part of constructing an
/// This can be invoked as part of constructing an
/// inference context at the start of a query (see
/// `InferCtxtBuilder::enter_with_canonical`). It basically
/// brings the canonical value "into scope" within your new infcx.
Expand All @@ -63,8 +63,11 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
// in them, so this code has no effect, but it is looking
// forward to the day when we *do* want to carry universes
// through into queries.
let universes: IndexVec<ty::UniverseIndex, _> = std::iter::once(ty::UniverseIndex::ROOT)
Copy link
Contributor

Choose a reason for hiding this comment

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

Currently reading about Universes/Placeholders and am curious, why can we do that? Why can't we encounter canonicalized variables with UniverseIndex::Root inside instantiate_canonical_vars?

.chain((0..canonical.max_universe.as_u32()).map(|_| self.create_next_universe()))
//
// Instantiate the root-universe content into the current universe,
// and create fresh universes for the higher universes.
let universes: IndexVec<ty::UniverseIndex, _> = std::iter::once(self.universe())
nikomatsakis marked this conversation as resolved.
Show resolved Hide resolved
.chain((1..=canonical.max_universe.as_u32()).map(|_| self.create_next_universe()))
.collect();

let canonical_inference_vars =
Expand Down