Skip to content

make PlaceholderConst not store the type of the const #100032

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

Merged
merged 2 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
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
17 changes: 11 additions & 6 deletions compiler/rustc_infer/src/infer/canonical/canonicalizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,9 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
}
ty::ConstKind::Placeholder(placeholder) => {
return self.canonicalize_const_var(
CanonicalVarInfo { kind: CanonicalVarKind::PlaceholderConst(placeholder) },
CanonicalVarInfo {
kind: CanonicalVarKind::PlaceholderConst(placeholder, ct.ty()),
},
ct,
);
}
Expand Down Expand Up @@ -695,11 +697,14 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
..placeholder
})
}
CanonicalVarKind::PlaceholderConst(placeholder) => {
CanonicalVarKind::PlaceholderConst(ty::Placeholder {
universe: reverse_universe_map[&placeholder.universe],
..placeholder
})
CanonicalVarKind::PlaceholderConst(placeholder, t) => {
CanonicalVarKind::PlaceholderConst(
ty::Placeholder {
universe: reverse_universe_map[&placeholder.universe],
..placeholder
},
t,
)
}
},
})
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_infer/src/infer/canonical/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
)
.into(),

CanonicalVarKind::PlaceholderConst(ty::PlaceholderConst { universe, name }) => {
CanonicalVarKind::PlaceholderConst(ty::PlaceholderConst { universe, name }, ty) => {
let universe_mapped = universe_map(universe);
let placeholder_mapped = ty::PlaceholderConst { universe: universe_mapped, name };
self.tcx
.mk_const(ty::ConstS {
kind: ty::ConstKind::Placeholder(placeholder_mapped),
ty: name.ty,
ty,
})
.into()
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/higher_ranked/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
self.tcx.mk_const(ty::ConstS {
kind: ty::ConstKind::Placeholder(ty::PlaceholderConst {
universe: next_universe,
name: ty::BoundConst { var: bound_var, ty },
name: bound_var,
}),
ty,
})
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2069,7 +2069,7 @@ fn replace_param_and_infer_substs_with_placeholder<'tcx>(
ty,
kind: ty::ConstKind::Placeholder(ty::PlaceholderConst {
universe: ty::UniverseIndex::ROOT,
name: ty::BoundConst { ty, var: ty::BoundVar::from_usize(idx) },
name: ty::BoundVar::from_usize(idx),
}),
})
.into()
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/infer/canonical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl<'tcx> CanonicalVarInfo<'tcx> {
CanonicalVarKind::Region(_) => true,
CanonicalVarKind::PlaceholderRegion(..) => false,
CanonicalVarKind::Const(..) => true,
CanonicalVarKind::PlaceholderConst(_) => false,
CanonicalVarKind::PlaceholderConst(_, _) => false,
}
}
}
Expand Down Expand Up @@ -133,7 +133,7 @@ pub enum CanonicalVarKind<'tcx> {
Const(ty::UniverseIndex, Ty<'tcx>),

/// A "placeholder" that represents "any const".
PlaceholderConst(ty::PlaceholderConst<'tcx>),
PlaceholderConst(ty::PlaceholderConst<'tcx>, Ty<'tcx>),
}

impl<'tcx> CanonicalVarKind<'tcx> {
Expand All @@ -148,7 +148,7 @@ impl<'tcx> CanonicalVarKind<'tcx> {
CanonicalVarKind::Region(ui) => ui,
CanonicalVarKind::PlaceholderRegion(placeholder) => placeholder.universe,
CanonicalVarKind::Const(ui, _) => ui,
CanonicalVarKind::PlaceholderConst(placeholder) => placeholder.universe,
CanonicalVarKind::PlaceholderConst(placeholder, _) => placeholder.universe,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ pub struct BoundConst<'tcx> {
pub ty: Ty<'tcx>,
}

pub type PlaceholderConst<'tcx> = Placeholder<BoundConst<'tcx>>;
pub type PlaceholderConst<'tcx> = Placeholder<BoundVar>;

/// A `DefId` which, in case it is a const argument, is potentially bundled with
/// the `DefId` of the generic parameter it instantiates.
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_trait_selection/src/traits/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,10 +744,7 @@ impl<'tcx> TypeFolder<'tcx> for BoundVarReplacer<'_, 'tcx> {
}
ty::ConstKind::Bound(debruijn, bound_const) if debruijn >= self.current_index => {
let universe = self.universe_for(debruijn);
let p = ty::PlaceholderConst {
universe,
name: ty::BoundConst { var: bound_const, ty: ct.ty() },
};
let p = ty::PlaceholderConst { universe, name: bound_const };
self.mapped_consts.insert(p, bound_const);
self.infcx
.tcx
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_traits/src/chalk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub(crate) fn evaluate_goal<'tcx>(
chalk_ir::UniverseIndex { counter: ui.index() },
),
CanonicalVarKind::Const(_ui, _ty) => unimplemented!(),
CanonicalVarKind::PlaceholderConst(_pc) => unimplemented!(),
CanonicalVarKind::PlaceholderConst(_pc, _ty) => unimplemented!(),
}),
),
value: obligation.value.lower_into(interner),
Expand Down