Skip to content

Commit 8206b39

Browse files
committed
Auto merge of #155392 - WaffleLapkin:alias-termmm, r=<try>
`AliasTerm` refactor
2 parents 2f201bc + 3112204 commit 8206b39

56 files changed

Lines changed: 411 additions & 349 deletions

File tree

Some content is hidden

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

compiler/rustc_borrowck/src/region_infer/opaque_types/member_constraints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for CollectMemberConstraintsVisitor<'_, '_,
177177
| ty::Coroutine(def_id, args) => self.visit_closure_args(def_id, args),
178178

179179
ty::Alias(ty::AliasTy { kind, args, .. })
180-
if let Some(variances) = self.cx().opt_alias_variances(kind, kind.def_id()) =>
180+
if let Some(variances) = self.cx().opt_alias_variances(kind) =>
181181
{
182182
// Skip lifetime parameters that are not captured, since they do
183183
// not need member constraints registered for them; we'll erase

compiler/rustc_borrowck/src/region_infer/opaque_types/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for ToArgRegionsFolder<'_, 'tcx> {
501501
}
502502

503503
ty::Alias(ty::AliasTy { kind, args, .. })
504-
if let Some(variances) = tcx.opt_alias_variances(kind, kind.def_id()) =>
504+
if let Some(variances) = tcx.opt_alias_variances(kind) =>
505505
{
506506
let args = tcx.mk_args_from_iter(std::iter::zip(variances, args.iter()).map(
507507
|(&v, s)| {

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2720,7 +2720,7 @@ fn param_env_with_gat_bounds<'tcx>(
27202720
_ => predicates.push(
27212721
ty::Binder::bind_with_vars(
27222722
ty::ProjectionPredicate {
2723-
projection_term: ty::AliasTerm::new_from_args(
2723+
projection_term: ty::AliasTerm::new_from_def_id(
27242724
tcx,
27252725
trait_ty.def_id,
27262726
rebased_args,

compiler/rustc_hir_analysis/src/check/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,10 @@ fn bounds_from_generic_predicates<'tcx>(
369369
let mut projections_str = vec![];
370370
for projection in &projections {
371371
let p = projection.skip_binder();
372-
if bound == tcx.parent(p.projection_term.def_id)
372+
if bound == tcx.parent(p.projection_term.def_id())
373373
&& p.projection_term.self_ty() == ty
374374
{
375-
let name = tcx.item_name(p.projection_term.def_id);
375+
let name = tcx.item_name(p.projection_term.def_id());
376376
projections_str.push(format!("{} = {}", name, p.term));
377377
}
378378
}

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1633,7 +1633,7 @@ pub(super) fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, def_id:
16331633
.map_bound(|pred| {
16341634
pred.term.as_const().map(|ct| {
16351635
let assoc_const_ty = tcx
1636-
.type_of(pred.projection_term.def_id)
1636+
.type_of(pred.projection_term.def_id())
16371637
.instantiate(tcx, pred.projection_term.args);
16381638
ty::ClauseKind::ConstArgHasType(ct, assoc_const_ty)
16391639
})

compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
526526
);
527527
debug!(?alias_args);
528528

529-
ty::AliasTerm::new_from_args(tcx, assoc_item.def_id, alias_args)
529+
ty::AliasTerm::new_from_def_id(tcx, assoc_item.def_id, alias_args)
530530
})
531531
};
532532

@@ -543,7 +543,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
543543
hir::Term::Ty(ty) => self.lower_ty(ty).into(),
544544
hir::Term::Const(ct) => {
545545
let ty = projection_term.map_bound(|alias| {
546-
tcx.type_of(alias.def_id).instantiate(tcx, alias.args)
546+
tcx.type_of(alias.def_id()).instantiate(tcx, alias.args)
547547
});
548548
let ty = check_assoc_const_binding_type(
549549
self,

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
13571357
&item_segment,
13581358
trait_ref.args,
13591359
);
1360-
ty::AliasTerm::new_from_args(
1360+
ty::AliasTerm::new_from_def_id(
13611361
tcx,
13621362
assoc_item.def_id,
13631363
alias_args,
@@ -1367,7 +1367,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
13671367
// FIXME(mgca): code duplication with other places we lower
13681368
// the rhs' of associated const bindings
13691369
let ty = projection_term.map_bound(|alias| {
1370-
tcx.type_of(alias.def_id).instantiate(tcx, alias.args)
1370+
tcx.type_of(alias.def_id()).instantiate(tcx, alias.args)
13711371
});
13721372
let ty = bounds::check_assoc_const_binding_type(
13731373
self,

compiler/rustc_hir_typeck/src/closure.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,11 +1082,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10821082
// The `Future` trait has only one associated item, `Output`,
10831083
// so check that this is what we see.
10841084
let output_assoc_item = self.tcx.associated_item_def_ids(trait_def_id)[0];
1085-
if output_assoc_item != predicate.projection_term.def_id {
1085+
if output_assoc_item != predicate.projection_term.def_id() {
10861086
span_bug!(
10871087
cause_span,
10881088
"projecting associated item `{:?}` from future, which is not Output `{:?}`",
1089-
predicate.projection_term.def_id,
1089+
predicate.projection_term.kind,
10901090
output_assoc_item,
10911091
);
10921092
}

compiler/rustc_infer/src/infer/outlives/for_liveness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ where
9393
} else {
9494
// Skip lifetime parameters that are not captured, since they do
9595
// not need to be live.
96-
let variances = tcx.opt_alias_variances(kind, kind.def_id());
96+
let variances = tcx.opt_alias_variances(kind);
9797

9898
for (idx, s) in args.iter().enumerate() {
9999
if variances.map(|variances| variances[idx]) != Some(ty::Bivariant) {

compiler/rustc_infer/src/infer/outlives/obligations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ where
474474
&& (alias_ty.has_infer_regions() || matches!(kind, ty::Opaque { .. }))
475475
{
476476
debug!("no declared bounds");
477-
let opt_variances = self.tcx.opt_alias_variances(kind, kind.def_id());
477+
let opt_variances = self.tcx.opt_alias_variances(kind);
478478
self.args_must_outlive(alias_ty.args, origin, region, opt_variances);
479479
return;
480480
}

0 commit comments

Comments
 (0)