1
Fork 0

ProjectionTy.item_def_id -> ProjectionTy.def_id

This commit is contained in:
Michael Goulet 2022-11-26 21:21:20 +00:00
parent 7f3af72606
commit 5c6afb850c
50 changed files with 164 additions and 186 deletions

View file

@ -419,8 +419,8 @@ impl<'tcx> ToTrace<'tcx> for ty::ProjectionTy<'tcx> {
a: Self,
b: Self,
) -> TypeTrace<'tcx> {
let a_ty = tcx.mk_projection(a.item_def_id, a.substs);
let b_ty = tcx.mk_projection(b.item_def_id, b.substs);
let a_ty = tcx.mk_projection(a.def_id, a.substs);
let b_ty = tcx.mk_projection(b.def_id, b.substs);
TypeTrace {
cause: cause.clone(),
values: Terms(ExpectedFound::new(a_is_expected, a_ty.into(), b_ty.into())),

View file

@ -342,9 +342,9 @@ impl<'tcx> InferCtxt<'tcx> {
let (def_id, substs) = match *ty.kind() {
ty::Opaque(ty::OpaqueTy { def_id, substs }) => (def_id, substs),
ty::Projection(data)
if self.tcx.def_kind(data.item_def_id) == DefKind::ImplTraitPlaceholder =>
if self.tcx.def_kind(data.def_id) == DefKind::ImplTraitPlaceholder =>
{
(data.item_def_id, data.substs)
(data.def_id, data.substs)
}
_ => return None,
};
@ -358,7 +358,7 @@ impl<'tcx> InferCtxt<'tcx> {
.kind()
.map_bound(|kind| match kind {
ty::PredicateKind::Clause(ty::Clause::Projection(projection_predicate))
if projection_predicate.projection_ty.item_def_id == item_def_id =>
if projection_predicate.projection_ty.def_id == item_def_id =>
{
projection_predicate.term.ty()
}
@ -1743,11 +1743,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
)
}
(true, ty::Projection(proj))
if self.tcx.def_kind(proj.item_def_id)
if self.tcx.def_kind(proj.def_id)
== DefKind::ImplTraitPlaceholder =>
{
let sm = self.tcx.sess.source_map();
let pos = sm.lookup_char_pos(self.tcx.def_span(proj.item_def_id).lo());
let pos = sm.lookup_char_pos(self.tcx.def_span(proj.def_id).lo());
format!(
" (trait associated opaque type at <{}:{}:{}>)",
sm.filename_for_diagnostics(&pos.file.name),

View file

@ -509,7 +509,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
(
hir::ItemKind::OpaqueTy(hir::OpaqueTy { bounds: last_bounds, .. }),
hir::ItemKind::OpaqueTy(hir::OpaqueTy { bounds: exp_bounds, .. }),
) if iter::zip(*last_bounds, *exp_bounds).all(|(left, right)| {
) if std::iter::zip(*last_bounds, *exp_bounds).all(|(left, right)| {
match (left, right) {
(
hir::GenericBound::Trait(tl, ml),

View file

@ -490,10 +490,10 @@ where
}
ty::Projection(proj)
if self.tcx.def_kind(proj.item_def_id) == DefKind::ImplTraitPlaceholder =>
if self.tcx.def_kind(proj.def_id) == DefKind::ImplTraitPlaceholder =>
{
// Skip lifetime paramters that are not captures.
let variances = self.tcx.variances_of(proj.item_def_id);
let variances = self.tcx.variances_of(proj.def_id);
for (v, s) in std::iter::zip(variances, proj.substs.iter()) {
if *v != ty::Variance::Bivariant {
@ -568,7 +568,7 @@ impl<'tcx> InferCtxt<'tcx> {
// FIXME(RPITIT): Don't replace RPITITs with inference vars.
ty::Projection(projection_ty)
if !projection_ty.has_escaping_bound_vars()
&& tcx.def_kind(projection_ty.item_def_id)
&& tcx.def_kind(projection_ty.def_id)
!= DefKind::ImplTraitPlaceholder =>
{
self.infer_projection(
@ -588,7 +588,7 @@ impl<'tcx> InferCtxt<'tcx> {
}
// FIXME(RPITIT): This can go away when we move to associated types
ty::Projection(proj)
if def_id.to_def_id() == proj.item_def_id && substs == proj.substs =>
if def_id.to_def_id() == proj.def_id && substs == proj.substs =>
{
hidden_ty
}

View file

@ -355,11 +355,11 @@ where
origin,
region,
GenericKind::Projection(projection_ty),
projection_ty.item_def_id,
projection_ty.def_id,
projection_ty.substs,
false,
|ty| match ty.kind() {
ty::Projection(projection_ty) => (projection_ty.item_def_id, projection_ty.substs),
ty::Projection(projection_ty) => (projection_ty.def_id, projection_ty.substs),
_ => bug!("expected only projection types from env, not {:?}", ty),
},
);

View file

@ -178,7 +178,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
),
Component::Projection(projection_ty) => self.projection_opaque_bounds(
GenericKind::Projection(projection_ty),
projection_ty.item_def_id,
projection_ty.def_id,
projection_ty.substs,
visited,
),

View file

@ -21,7 +21,7 @@ impl<'tcx> InferCtxt<'tcx> {
recursion_depth: usize,
obligations: &mut Vec<PredicateObligation<'tcx>>,
) -> Ty<'tcx> {
let def_id = projection_ty.item_def_id;
let def_id = projection_ty.def_id;
let ty_var = self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::NormalizeProjectionType,
span: self.tcx.def_span(def_id),

View file

@ -773,7 +773,7 @@ impl<'tcx> GenericKind<'tcx> {
pub fn to_ty(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
match *self {
GenericKind::Param(ref p) => p.to_ty(tcx),
GenericKind::Projection(ref p) => tcx.mk_projection(p.item_def_id, p.substs),
GenericKind::Projection(ref p) => tcx.mk_projection(p.def_id, p.substs),
GenericKind::Opaque(def_id, substs) => tcx.mk_opaque(def_id, substs),
}
}

View file

@ -259,8 +259,7 @@ impl<'tcx> Elaborator<'tcx> {
Component::Projection(projection) => {
// We might end up here if we have `Foo<<Bar as Baz>::Assoc>: 'a`.
// With this, we can deduce that `<Bar as Baz>::Assoc: 'a`.
let ty =
tcx.mk_projection(projection.item_def_id, projection.substs);
let ty = tcx.mk_projection(projection.def_id, projection.substs);
Some(ty::PredicateKind::Clause(ty::Clause::TypeOutlives(
ty::OutlivesPredicate(ty, r_min),
)))