Skip to content

Commit 5c6afb8

Browse files
ProjectionTy.item_def_id -> ProjectionTy.def_id
1 parent 7f3af72 commit 5c6afb8

File tree

50 files changed

+164
-186
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+164
-186
lines changed

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ fn push_debuginfo_type_name<'tcx>(
235235
let projection_bounds: SmallVec<[_; 4]> = trait_data
236236
.projection_bounds()
237237
.map(|bound| {
238-
let ExistentialProjection { item_def_id, term, .. } =
238+
let ExistentialProjection { def_id: item_def_id, term, .. } =
239239
tcx.erase_late_bound_regions(bound);
240240
// FIXME(associated_const_equality): allow for consts here
241241
(item_def_id, term.ty().unwrap())

compiler/rustc_const_eval/src/util/type_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
5959
ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did: def_id, .. }, _)), substs)
6060
| ty::FnDef(def_id, substs)
6161
| ty::Opaque(ty::OpaqueTy { def_id, substs })
62-
| ty::Projection(ty::ProjectionTy { item_def_id: def_id, substs })
62+
| ty::Projection(ty::ProjectionTy { def_id, substs })
6363
| ty::Closure(def_id, substs)
6464
| ty::Generator(def_id, substs, _) => self.print_def_path(def_id, substs),
6565
ty::Foreign(def_id) => self.print_def_path(def_id, &[]),

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,10 +1146,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
11461146

11471147
debug!(?substs_trait_ref_and_assoc_item);
11481148

1149-
ty::ProjectionTy {
1150-
item_def_id: assoc_item.def_id,
1151-
substs: substs_trait_ref_and_assoc_item,
1152-
}
1149+
ty::ProjectionTy { def_id: assoc_item.def_id, substs: substs_trait_ref_and_assoc_item }
11531150
});
11541151

11551152
if !speculative {
@@ -1195,7 +1192,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
11951192
// the "projection predicate" for:
11961193
//
11971194
// `<T as Iterator>::Item = u32`
1198-
let assoc_item_def_id = projection_ty.skip_binder().item_def_id;
1195+
let assoc_item_def_id = projection_ty.skip_binder().def_id;
11991196
let def_kind = tcx.def_kind(assoc_item_def_id);
12001197
match (def_kind, term.unpack()) {
12011198
(hir::def::DefKind::AssocTy, ty::TermKind::Ty(_))

compiler/rustc_hir_analysis/src/check/compare_method.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -572,9 +572,9 @@ impl<'tcx> TypeFolder<'tcx> for ImplTraitInTraitCollector<'_, 'tcx> {
572572

573573
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
574574
if let ty::Projection(proj) = ty.kind()
575-
&& self.tcx().def_kind(proj.item_def_id) == DefKind::ImplTraitPlaceholder
575+
&& self.tcx().def_kind(proj.def_id) == DefKind::ImplTraitPlaceholder
576576
{
577-
if let Some((ty, _)) = self.types.get(&proj.item_def_id) {
577+
if let Some((ty, _)) = self.types.get(&proj.def_id) {
578578
return *ty;
579579
}
580580
//FIXME(RPITIT): Deny nested RPITIT in substs too
@@ -586,9 +586,9 @@ impl<'tcx> TypeFolder<'tcx> for ImplTraitInTraitCollector<'_, 'tcx> {
586586
span: self.span,
587587
kind: TypeVariableOriginKind::MiscVariable,
588588
});
589-
self.types.insert(proj.item_def_id, (infer_ty, proj.substs));
589+
self.types.insert(proj.def_id, (infer_ty, proj.substs));
590590
// Recurse into bounds
591-
for (pred, pred_span) in self.tcx().bound_explicit_item_bounds(proj.item_def_id).subst_iter_copied(self.tcx(), proj.substs) {
591+
for (pred, pred_span) in self.tcx().bound_explicit_item_bounds(proj.def_id).subst_iter_copied(self.tcx(), proj.substs) {
592592
let pred = pred.fold_with(self);
593593
let pred = self.ocx.normalize(
594594
&ObligationCause::misc(self.span, self.body_id),
@@ -601,7 +601,7 @@ impl<'tcx> TypeFolder<'tcx> for ImplTraitInTraitCollector<'_, 'tcx> {
601601
ObligationCause::new(
602602
self.span,
603603
self.body_id,
604-
ObligationCauseCode::BindingObligation(proj.item_def_id, pred_span),
604+
ObligationCauseCode::BindingObligation(proj.def_id, pred_span),
605605
),
606606
self.param_env,
607607
pred,
@@ -1735,7 +1735,7 @@ pub fn check_type_bounds<'tcx>(
17351735
let mut predicates = param_env.caller_bounds().iter().collect::<Vec<_>>();
17361736
match impl_ty_value.kind() {
17371737
ty::Projection(proj)
1738-
if proj.item_def_id == trait_ty.def_id && proj.substs == rebased_substs =>
1738+
if proj.def_id == trait_ty.def_id && proj.substs == rebased_substs =>
17391739
{
17401740
// Don't include this predicate if the projected type is
17411741
// exactly the same as the projection. This can occur in
@@ -1747,7 +1747,7 @@ pub fn check_type_bounds<'tcx>(
17471747
ty::Binder::bind_with_vars(
17481748
ty::ProjectionPredicate {
17491749
projection_ty: ty::ProjectionTy {
1750-
item_def_id: trait_ty.def_id,
1750+
def_id: trait_ty.def_id,
17511751
substs: rebased_substs,
17521752
},
17531753
term: impl_ty_value.into(),

compiler/rustc_hir_analysis/src/check/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,7 @@ fn bounds_from_generic_predicates<'tcx>(
352352
// insert the associated types where they correspond, but for now let's be "lazy" and
353353
// propose this instead of the following valid resugaring:
354354
// `T: Trait, Trait::Assoc = K` → `T: Trait<Assoc = K>`
355-
where_clauses.push(format!(
356-
"{} = {}",
357-
tcx.def_path_str(p.projection_ty.item_def_id),
358-
p.term,
359-
));
355+
where_clauses.push(format!("{} = {}", tcx.def_path_str(p.projection_ty.def_id), p.term,));
360356
}
361357
let where_clauses = if where_clauses.is_empty() {
362358
String::new()

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ impl<'tcx> TypeVisitor<'tcx> for GATSubstCollector<'tcx> {
759759

760760
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
761761
match t.kind() {
762-
ty::Projection(p) if p.item_def_id == self.gat => {
762+
ty::Projection(p) if p.def_id == self.gat => {
763763
for (idx, subst) in p.substs.iter().enumerate() {
764764
match subst.unpack() {
765765
GenericArgKind::Lifetime(lt) if !lt.is_late_bound() => {
@@ -1593,11 +1593,11 @@ fn check_return_position_impl_trait_in_trait_bounds<'tcx>(
15931593
for arg in fn_output.walk() {
15941594
if let ty::GenericArgKind::Type(ty) = arg.unpack()
15951595
&& let ty::Projection(proj) = ty.kind()
1596-
&& tcx.def_kind(proj.item_def_id) == DefKind::ImplTraitPlaceholder
1597-
&& tcx.impl_trait_in_trait_parent(proj.item_def_id) == fn_def_id.to_def_id()
1596+
&& tcx.def_kind(proj.def_id) == DefKind::ImplTraitPlaceholder
1597+
&& tcx.impl_trait_in_trait_parent(proj.def_id) == fn_def_id.to_def_id()
15981598
{
1599-
let span = tcx.def_span(proj.item_def_id);
1600-
let bounds = wfcx.tcx().explicit_item_bounds(proj.item_def_id);
1599+
let span = tcx.def_span(proj.def_id);
1600+
let bounds = wfcx.tcx().explicit_item_bounds(proj.def_id);
16011601
let wf_obligations = bounds.iter().flat_map(|&(bound, bound_span)| {
16021602
let bound = ty::EarlyBinder(bound).subst(tcx, proj.substs);
16031603
let normalized_bound = wfcx.normalize(span, None, bound);

compiler/rustc_hir_analysis/src/collect/predicates_of.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ pub(super) fn explicit_predicates_of<'tcx>(
413413
// supertrait).
414414
if let ty::Projection(projection) = ty.kind() {
415415
projection.substs == trait_identity_substs
416-
&& tcx.associated_item(projection.item_def_id).container_id(tcx) == def_id
416+
&& tcx.associated_item(projection.def_id).container_id(tcx) == def_id
417417
} else {
418418
false
419419
}

compiler/rustc_hir_analysis/src/collect/type_of.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub(super) fn opt_const_param_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<
6969
// as a precaution for if it's ever allowed to elide lifetimes in GAT's. It currently isn't
7070
// but it can't hurt to be safe ^^
7171
if let ty::Projection(projection) = ty.kind() {
72-
let generics = tcx.generics_of(projection.item_def_id);
72+
let generics = tcx.generics_of(projection.def_id);
7373

7474
let arg_index = segment
7575
.args

compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ fn insert_required_predicates_to_be_wf<'tcx>(
202202
debug!("Projection");
203203
check_explicit_predicates(
204204
tcx,
205-
tcx.parent(obj.item_def_id),
205+
tcx.parent(obj.def_id),
206206
obj.substs,
207207
required_predicates,
208208
explicit_map,

compiler/rustc_hir_analysis/src/outlives/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub(crate) fn insert_outlives_predicate<'tcx>(
9090
// ```
9191
//
9292
// Here we want to add an explicit `where <T as Iterator>::Item: 'a`.
93-
let ty: Ty<'tcx> = tcx.mk_projection(proj_ty.item_def_id, proj_ty.substs);
93+
let ty: Ty<'tcx> = tcx.mk_projection(proj_ty.def_id, proj_ty.substs);
9494
required_predicates
9595
.entry(ty::OutlivesPredicate(ty.into(), outlived_region))
9696
.or_insert(span);

compiler/rustc_hir_analysis/src/variance/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,13 @@ fn variance_of_opaque(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Varianc
110110

111111
#[instrument(level = "trace", skip(self), ret)]
112112
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
113-
match t.kind() {
114-
ty::Opaque(def_id, substs) => self.visit_opaque(*def_id, substs),
113+
// FIXME(alias): merge these
114+
match t.kind() {
115+
ty::Opaque(ty::OpaqueTy { def_id, substs }) => self.visit_opaque(*def_id, substs),
115116
ty::Projection(proj)
116-
if self.tcx.def_kind(proj.item_def_id) == DefKind::ImplTraitPlaceholder =>
117+
if self.tcx.def_kind(proj.def_id) == DefKind::ImplTraitPlaceholder =>
117118
{
118-
self.visit_opaque(proj.item_def_id, proj.substs)
119+
self.visit_opaque(proj.def_id, proj.substs)
119120
}
120121
_ => t.super_visit_with(self),
121122
}
@@ -167,7 +168,7 @@ fn variance_of_opaque(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Varianc
167168
}
168169
}
169170
ty::PredicateKind::Clause(ty::Clause::Projection(ty::ProjectionPredicate {
170-
projection_ty: ty::ProjectionTy { substs, item_def_id: _ },
171+
projection_ty: ty::ProjectionTy { substs, def_id: _ },
171172
term,
172173
})) => {
173174
for subst in &substs[1..] {

compiler/rustc_hir_typeck/src/closure.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -684,10 +684,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
684684
.find_map(|(p, s)| get_future_output(p, s))?,
685685
ty::Error(_) => return None,
686686
ty::Projection(proj)
687-
if self.tcx.def_kind(proj.item_def_id) == DefKind::ImplTraitPlaceholder =>
687+
if self.tcx.def_kind(proj.def_id) == DefKind::ImplTraitPlaceholder =>
688688
{
689689
self.tcx
690-
.bound_explicit_item_bounds(proj.item_def_id)
690+
.bound_explicit_item_bounds(proj.def_id)
691691
.subst_iter_copied(self.tcx, proj.substs)
692692
.find_map(|(p, s)| get_future_output(p, s))?
693693
}
@@ -743,11 +743,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
743743
// The `Future` trait has only one associated item, `Output`,
744744
// so check that this is what we see.
745745
let output_assoc_item = self.tcx.associated_item_def_ids(future_trait)[0];
746-
if output_assoc_item != predicate.projection_ty.item_def_id {
746+
if output_assoc_item != predicate.projection_ty.def_id {
747747
span_bug!(
748748
cause_span,
749749
"projecting associated item `{:?}` from future, which is not Output `{:?}`",
750-
predicate.projection_ty.item_def_id,
750+
predicate.projection_ty.def_id,
751751
output_assoc_item,
752752
);
753753
}

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
177177
ty::Opaque(ty::OpaqueTy { def_id, substs }) => {
178178
self.tcx.bound_item_bounds(def_id).subst(self.tcx, substs).iter().find_map(|pred| {
179179
if let ty::PredicateKind::Clause(ty::Clause::Projection(proj)) = pred.kind().skip_binder()
180-
&& Some(proj.projection_ty.item_def_id) == self.tcx.lang_items().fn_once_output()
180+
&& Some(proj.projection_ty.def_id) == self.tcx.lang_items().fn_once_output()
181181
// args tuple will always be substs[1]
182182
&& let ty::Tuple(args) = proj.projection_ty.substs.type_at(1).kind()
183183
{
@@ -194,7 +194,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
194194
ty::Dynamic(data, _, ty::Dyn) => {
195195
data.iter().find_map(|pred| {
196196
if let ty::ExistentialPredicate::Projection(proj) = pred.skip_binder()
197-
&& Some(proj.item_def_id) == self.tcx.lang_items().fn_once_output()
197+
&& Some(proj.def_id) == self.tcx.lang_items().fn_once_output()
198198
// for existential projection, substs are shifted over by 1
199199
&& let ty::Tuple(args) = proj.substs.type_at(0).kind()
200200
{
@@ -212,7 +212,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
212212
let def_id = self.tcx.generics_of(self.body_id.owner).type_param(&param, self.tcx).def_id;
213213
self.tcx.predicates_of(self.body_id.owner).predicates.iter().find_map(|(pred, _)| {
214214
if let ty::PredicateKind::Clause(ty::Clause::Projection(proj)) = pred.kind().skip_binder()
215-
&& Some(proj.projection_ty.item_def_id) == self.tcx.lang_items().fn_once_output()
215+
&& Some(proj.projection_ty.def_id) == self.tcx.lang_items().fn_once_output()
216216
&& proj.projection_ty.self_ty() == found
217217
// args tuple will always be substs[1]
218218
&& let ty::Tuple(args) = proj.projection_ty.substs.type_at(1).kind()

compiler/rustc_hir_typeck/src/method/suggest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
559559

560560
let quiet_projection_ty = ty::ProjectionTy {
561561
substs: substs_with_infer_self,
562-
item_def_id: projection_ty.item_def_id,
562+
def_id: projection_ty.def_id,
563563
};
564564

565565
let term = pred.skip_binder().term;
@@ -2269,7 +2269,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
22692269
t.def_id() == info.def_id
22702270
}
22712271
ty::PredicateKind::Clause(ty::Clause::Projection(p)) => {
2272-
p.projection_ty.item_def_id == info.def_id
2272+
p.projection_ty.def_id == info.def_id
22732273
}
22742274
_ => false,
22752275
}

compiler/rustc_infer/src/infer/at.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,8 @@ impl<'tcx> ToTrace<'tcx> for ty::ProjectionTy<'tcx> {
419419
a: Self,
420420
b: Self,
421421
) -> TypeTrace<'tcx> {
422-
let a_ty = tcx.mk_projection(a.item_def_id, a.substs);
423-
let b_ty = tcx.mk_projection(b.item_def_id, b.substs);
422+
let a_ty = tcx.mk_projection(a.def_id, a.substs);
423+
let b_ty = tcx.mk_projection(b.def_id, b.substs);
424424
TypeTrace {
425425
cause: cause.clone(),
426426
values: Terms(ExpectedFound::new(a_is_expected, a_ty.into(), b_ty.into())),

compiler/rustc_infer/src/infer/error_reporting/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,9 @@ impl<'tcx> InferCtxt<'tcx> {
342342
let (def_id, substs) = match *ty.kind() {
343343
ty::Opaque(ty::OpaqueTy { def_id, substs }) => (def_id, substs),
344344
ty::Projection(data)
345-
if self.tcx.def_kind(data.item_def_id) == DefKind::ImplTraitPlaceholder =>
345+
if self.tcx.def_kind(data.def_id) == DefKind::ImplTraitPlaceholder =>
346346
{
347-
(data.item_def_id, data.substs)
347+
(data.def_id, data.substs)
348348
}
349349
_ => return None,
350350
};
@@ -358,7 +358,7 @@ impl<'tcx> InferCtxt<'tcx> {
358358
.kind()
359359
.map_bound(|kind| match kind {
360360
ty::PredicateKind::Clause(ty::Clause::Projection(projection_predicate))
361-
if projection_predicate.projection_ty.item_def_id == item_def_id =>
361+
if projection_predicate.projection_ty.def_id == item_def_id =>
362362
{
363363
projection_predicate.term.ty()
364364
}
@@ -1743,11 +1743,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
17431743
)
17441744
}
17451745
(true, ty::Projection(proj))
1746-
if self.tcx.def_kind(proj.item_def_id)
1746+
if self.tcx.def_kind(proj.def_id)
17471747
== DefKind::ImplTraitPlaceholder =>
17481748
{
17491749
let sm = self.tcx.sess.source_map();
1750-
let pos = sm.lookup_char_pos(self.tcx.def_span(proj.item_def_id).lo());
1750+
let pos = sm.lookup_char_pos(self.tcx.def_span(proj.def_id).lo());
17511751
format!(
17521752
" (trait associated opaque type at <{}:{}:{}>)",
17531753
sm.filename_for_diagnostics(&pos.file.name),

compiler/rustc_infer/src/infer/error_reporting/suggest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
509509
(
510510
hir::ItemKind::OpaqueTy(hir::OpaqueTy { bounds: last_bounds, .. }),
511511
hir::ItemKind::OpaqueTy(hir::OpaqueTy { bounds: exp_bounds, .. }),
512-
) if iter::zip(*last_bounds, *exp_bounds).all(|(left, right)| {
512+
) if std::iter::zip(*last_bounds, *exp_bounds).all(|(left, right)| {
513513
match (left, right) {
514514
(
515515
hir::GenericBound::Trait(tl, ml),

compiler/rustc_infer/src/infer/opaque_types.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,10 +490,10 @@ where
490490
}
491491

492492
ty::Projection(proj)
493-
if self.tcx.def_kind(proj.item_def_id) == DefKind::ImplTraitPlaceholder =>
493+
if self.tcx.def_kind(proj.def_id) == DefKind::ImplTraitPlaceholder =>
494494
{
495495
// Skip lifetime paramters that are not captures.
496-
let variances = self.tcx.variances_of(proj.item_def_id);
496+
let variances = self.tcx.variances_of(proj.def_id);
497497

498498
for (v, s) in std::iter::zip(variances, proj.substs.iter()) {
499499
if *v != ty::Variance::Bivariant {
@@ -568,7 +568,7 @@ impl<'tcx> InferCtxt<'tcx> {
568568
// FIXME(RPITIT): Don't replace RPITITs with inference vars.
569569
ty::Projection(projection_ty)
570570
if !projection_ty.has_escaping_bound_vars()
571-
&& tcx.def_kind(projection_ty.item_def_id)
571+
&& tcx.def_kind(projection_ty.def_id)
572572
!= DefKind::ImplTraitPlaceholder =>
573573
{
574574
self.infer_projection(
@@ -588,7 +588,7 @@ impl<'tcx> InferCtxt<'tcx> {
588588
}
589589
// FIXME(RPITIT): This can go away when we move to associated types
590590
ty::Projection(proj)
591-
if def_id.to_def_id() == proj.item_def_id && substs == proj.substs =>
591+
if def_id.to_def_id() == proj.def_id && substs == proj.substs =>
592592
{
593593
hidden_ty
594594
}

0 commit comments

Comments
 (0)