Skip to content

Commit

Permalink
Rollup merge of rust-lang#127439 - compiler-errors:uplift-elaborate, …
Browse files Browse the repository at this point in the history
…r=lcnr

Uplift elaboration into `rustc_type_ir`

Allows us to deduplicate and consolidate elaboration (including these stupid elaboration duplicate fns i added for pretty printing like 3 years ago) so I'm pretty hyped about this change :3

r? lcnr
  • Loading branch information
jieyouxu committed Jul 8, 2024
2 parents 88eca34 + 15d16f1 commit dda162c
Show file tree
Hide file tree
Showing 29 changed files with 506 additions and 522 deletions.
23 changes: 11 additions & 12 deletions compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, trait_def_id: LocalDefId) {
param_env,
item_def_id,
tcx.explicit_item_bounds(item_def_id)
.instantiate_identity_iter_copied()
.iter_identity_copied()
.collect::<Vec<_>>(),
&FxIndexSet::default(),
gat_def_id,
Expand Down Expand Up @@ -1205,17 +1205,16 @@ fn check_associated_type_bounds(wfcx: &WfCheckingCtxt<'_, '_>, item: ty::AssocIt
let bounds = wfcx.tcx().explicit_item_bounds(item.def_id);

debug!("check_associated_type_bounds: bounds={:?}", bounds);
let wf_obligations =
bounds.instantiate_identity_iter_copied().flat_map(|(bound, bound_span)| {
let normalized_bound = wfcx.normalize(span, None, bound);
traits::wf::clause_obligations(
wfcx.infcx,
wfcx.param_env,
wfcx.body_def_id,
normalized_bound,
bound_span,
)
});
let wf_obligations = bounds.iter_identity_copied().flat_map(|(bound, bound_span)| {
let normalized_bound = wfcx.normalize(span, None, bound);
traits::wf::clause_obligations(
wfcx.infcx,
wfcx.param_env,
wfcx.body_def_id,
normalized_bound,
bound_span,
)
});

wfcx.register_obligations(wf_obligations);
}
Expand Down
9 changes: 4 additions & 5 deletions compiler/rustc_hir_typeck/src/coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1752,10 +1752,8 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
fcx.probe(|_| {
let ocx = ObligationCtxt::new(fcx);
ocx.register_obligations(
fcx.tcx
.item_super_predicates(rpit_def_id)
.instantiate_identity_iter()
.filter_map(|clause| {
fcx.tcx.item_super_predicates(rpit_def_id).iter_identity().filter_map(
|clause| {
let predicate = clause
.kind()
.map_bound(|clause| match clause {
Expand All @@ -1776,7 +1774,8 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
fcx.param_env,
predicate,
))
}),
},
),
);
ocx.select_where_possible().is_empty()
})
Expand Down
Loading

0 comments on commit dda162c

Please sign in to comment.