Auto merge of #110031 - compiler-errors:generic-elaboration, r=b-naber
Make elaboration generic over input Combines all the `elaborate_*` family of functions into just one, which is an iterator over the same type that you pass in (e.g. elaborating `Predicate` gives `Predicate`s, elaborating `Obligation`s gives `Obligation`s, etc.)
This commit is contained in:
commit
f8ed97ecc1
22 changed files with 163 additions and 164 deletions
|
@ -33,9 +33,9 @@ use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKin
|
|||
use rustc_middle::middle::stability::AllowUnstable;
|
||||
use rustc_middle::ty::fold::FnMutDelegate;
|
||||
use rustc_middle::ty::subst::{self, GenericArgKind, InternalSubsts, SubstsRef};
|
||||
use rustc_middle::ty::DynKind;
|
||||
use rustc_middle::ty::GenericParamDefKind;
|
||||
use rustc_middle::ty::{self, Const, IsSuggestable, Ty, TyCtxt, TypeVisitableExt};
|
||||
use rustc_middle::ty::{DynKind, ToPredicate};
|
||||
use rustc_session::lint::builtin::{AMBIGUOUS_ASSOCIATED_ITEMS, BARE_TRAIT_OBJECTS};
|
||||
use rustc_span::edit_distance::find_best_match_for_name;
|
||||
use rustc_span::edition::Edition;
|
||||
|
@ -1526,8 +1526,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
|
||||
for (base_trait_ref, span, constness) in regular_traits_refs_spans {
|
||||
assert_eq!(constness, ty::BoundConstness::NotConst);
|
||||
|
||||
for pred in traits::elaborate_trait_ref(tcx, base_trait_ref) {
|
||||
let base_pred: ty::Predicate<'tcx> = base_trait_ref.to_predicate(tcx);
|
||||
for pred in traits::elaborate(tcx, [base_pred]) {
|
||||
debug!("conv_object_ty_poly_trait_ref: observing object predicate `{:?}`", pred);
|
||||
|
||||
let bound_predicate = pred.kind();
|
||||
|
|
|
@ -2034,7 +2034,7 @@ pub(super) fn check_type_bounds<'tcx>(
|
|||
ObligationCause::new(impl_ty_span, impl_ty_def_id, code)
|
||||
};
|
||||
|
||||
let obligations = tcx
|
||||
let obligations: Vec<_> = tcx
|
||||
.bound_explicit_item_bounds(trait_ty.def_id)
|
||||
.subst_iter_copied(tcx, rebased_substs)
|
||||
.map(|(concrete_ty_bound, span)| {
|
||||
|
@ -2044,7 +2044,7 @@ pub(super) fn check_type_bounds<'tcx>(
|
|||
.collect();
|
||||
debug!("check_type_bounds: item_bounds={:?}", obligations);
|
||||
|
||||
for mut obligation in util::elaborate_obligations(tcx, obligations) {
|
||||
for mut obligation in util::elaborate(tcx, obligations) {
|
||||
let normalized_predicate =
|
||||
ocx.normalize(&normalize_cause, normalize_param_env, obligation.predicate);
|
||||
debug!("compare_projection_bounds: normalized predicate = {:?}", normalized_predicate);
|
||||
|
|
|
@ -1908,7 +1908,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
|
|||
|
||||
let predicates_with_span = tcx.predicates_of(self.body_def_id).predicates.iter().copied();
|
||||
// Check elaborated bounds.
|
||||
let implied_obligations = traits::elaborate_predicates_with_span(tcx, predicates_with_span);
|
||||
let implied_obligations = traits::elaborate(tcx, predicates_with_span);
|
||||
|
||||
for (pred, obligation_span) in implied_obligations {
|
||||
// We lower empty bounds like `Vec<dyn Copy>:` as
|
||||
|
|
|
@ -130,7 +130,7 @@ pub(super) fn item_bounds(
|
|||
tcx: TyCtxt<'_>,
|
||||
def_id: DefId,
|
||||
) -> ty::EarlyBinder<&'_ ty::List<ty::Predicate<'_>>> {
|
||||
let bounds = tcx.mk_predicates_from_iter(util::elaborate_predicates(
|
||||
let bounds = tcx.mk_predicates_from_iter(util::elaborate(
|
||||
tcx,
|
||||
tcx.explicit_item_bounds(def_id).iter().map(|&(bound, _span)| bound),
|
||||
));
|
||||
|
|
|
@ -318,15 +318,14 @@ fn check_predicates<'tcx>(
|
|||
span: Span,
|
||||
) {
|
||||
let instantiated = tcx.predicates_of(impl1_def_id).instantiate(tcx, impl1_substs);
|
||||
let impl1_predicates: Vec<_> =
|
||||
traits::elaborate_predicates_with_span(tcx, instantiated.into_iter()).collect();
|
||||
let impl1_predicates: Vec<_> = traits::elaborate(tcx, instantiated.into_iter()).collect();
|
||||
|
||||
let mut impl2_predicates = if impl2_node.is_from_trait() {
|
||||
// Always applicable traits have to be always applicable without any
|
||||
// assumptions.
|
||||
Vec::new()
|
||||
} else {
|
||||
traits::elaborate_predicates(
|
||||
traits::elaborate(
|
||||
tcx,
|
||||
tcx.predicates_of(impl2_node.def_id())
|
||||
.instantiate(tcx, impl2_substs)
|
||||
|
@ -371,11 +370,10 @@ fn check_predicates<'tcx>(
|
|||
.unwrap();
|
||||
|
||||
assert!(!obligations.needs_infer());
|
||||
impl2_predicates.extend(
|
||||
traits::elaborate_obligations(tcx, obligations).map(|obligation| obligation.predicate),
|
||||
)
|
||||
impl2_predicates
|
||||
.extend(traits::elaborate(tcx, obligations).map(|obligation| obligation.predicate))
|
||||
}
|
||||
impl2_predicates.extend(traits::elaborate_predicates(tcx, always_applicable_traits));
|
||||
impl2_predicates.extend(traits::elaborate(tcx, always_applicable_traits));
|
||||
|
||||
for (predicate, span) in impl1_predicates {
|
||||
if !impl2_predicates.iter().any(|pred2| trait_predicates_eq(tcx, predicate, *pred2, span)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue