Get rid of elaborate_trait_ref{s} too
This commit is contained in:
parent
758bedc104
commit
2cd0729d63
4 changed files with 14 additions and 23 deletions
|
@ -33,9 +33,9 @@ use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKin
|
||||||
use rustc_middle::middle::stability::AllowUnstable;
|
use rustc_middle::middle::stability::AllowUnstable;
|
||||||
use rustc_middle::ty::fold::FnMutDelegate;
|
use rustc_middle::ty::fold::FnMutDelegate;
|
||||||
use rustc_middle::ty::subst::{self, GenericArgKind, InternalSubsts, SubstsRef};
|
use rustc_middle::ty::subst::{self, GenericArgKind, InternalSubsts, SubstsRef};
|
||||||
use rustc_middle::ty::DynKind;
|
|
||||||
use rustc_middle::ty::GenericParamDefKind;
|
use rustc_middle::ty::GenericParamDefKind;
|
||||||
use rustc_middle::ty::{self, Const, IsSuggestable, Ty, TyCtxt, TypeVisitableExt};
|
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_session::lint::builtin::{AMBIGUOUS_ASSOCIATED_ITEMS, BARE_TRAIT_OBJECTS};
|
||||||
use rustc_span::edit_distance::find_best_match_for_name;
|
use rustc_span::edit_distance::find_best_match_for_name;
|
||||||
use rustc_span::edition::Edition;
|
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 {
|
for (base_trait_ref, span, constness) in regular_traits_refs_spans {
|
||||||
assert_eq!(constness, ty::BoundConstness::NotConst);
|
assert_eq!(constness, ty::BoundConstness::NotConst);
|
||||||
|
let base_pred: ty::Predicate<'tcx> = base_trait_ref.to_predicate(tcx);
|
||||||
for pred in traits::elaborate_trait_ref(tcx, base_trait_ref) {
|
for pred in traits::elaborate(tcx, [base_pred]) {
|
||||||
debug!("conv_object_ty_poly_trait_ref: observing object predicate `{:?}`", pred);
|
debug!("conv_object_ty_poly_trait_ref: observing object predicate `{:?}`", pred);
|
||||||
|
|
||||||
let bound_predicate = pred.kind();
|
let bound_predicate = pred.kind();
|
||||||
|
|
|
@ -166,20 +166,6 @@ impl<'tcx> Elaboratable<'tcx> for (ty::Predicate<'tcx>, Span) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn elaborate_trait_ref<'tcx>(
|
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
trait_ref: ty::PolyTraitRef<'tcx>,
|
|
||||||
) -> Elaborator<'tcx, ty::Predicate<'tcx>> {
|
|
||||||
elaborate(tcx, std::iter::once(trait_ref.without_const().to_predicate(tcx)))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn elaborate_trait_refs<'tcx>(
|
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
trait_refs: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
|
|
||||||
) -> Elaborator<'tcx, ty::Predicate<'tcx>> {
|
|
||||||
elaborate(tcx, trait_refs.map(|trait_ref| trait_ref.to_predicate(tcx)))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn elaborate<'tcx, O: Elaboratable<'tcx>>(
|
pub fn elaborate<'tcx, O: Elaboratable<'tcx>>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
obligations: impl IntoIterator<Item = O>,
|
obligations: impl IntoIterator<Item = O>,
|
||||||
|
@ -364,17 +350,21 @@ pub fn supertraits<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
trait_ref: ty::PolyTraitRef<'tcx>,
|
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||||
) -> impl Iterator<Item = ty::PolyTraitRef<'tcx>> {
|
) -> impl Iterator<Item = ty::PolyTraitRef<'tcx>> {
|
||||||
FilterToTraits::new(elaborate_trait_ref(tcx, trait_ref))
|
let pred: ty::Predicate<'tcx> = trait_ref.to_predicate(tcx);
|
||||||
|
FilterToTraits::new(elaborate(tcx, [pred]))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn transitive_bounds<'tcx>(
|
pub fn transitive_bounds<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
trait_refs: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
|
trait_refs: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
|
||||||
) -> impl Iterator<Item = ty::PolyTraitRef<'tcx>> {
|
) -> impl Iterator<Item = ty::PolyTraitRef<'tcx>> {
|
||||||
FilterToTraits::new(elaborate_trait_refs(tcx, trait_refs))
|
FilterToTraits::new(elaborate(
|
||||||
|
tcx,
|
||||||
|
trait_refs.map(|trait_ref| -> ty::Predicate<'tcx> { trait_ref.to_predicate(tcx) }),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A specialized variant of `elaborate_trait_refs` that only elaborates trait references that may
|
/// A specialized variant of `elaborate` that only elaborates trait references that may
|
||||||
/// define the given associated type `assoc_name`. It uses the
|
/// define the given associated type `assoc_name`. It uses the
|
||||||
/// `super_predicates_that_define_assoc_type` query to avoid enumerating super-predicates that
|
/// `super_predicates_that_define_assoc_type` query to avoid enumerating super-predicates that
|
||||||
/// aren't related to `assoc_item`. This is used when resolving types like `Self::Item` or
|
/// aren't related to `assoc_item`. This is used when resolving types like `Self::Item` or
|
||||||
|
|
|
@ -58,7 +58,7 @@ pub use self::specialize::{specialization_graph, translate_substs, OverlapError}
|
||||||
pub use self::structural_match::{
|
pub use self::structural_match::{
|
||||||
search_for_adt_const_param_violation, search_for_structural_match_violation,
|
search_for_adt_const_param_violation, search_for_structural_match_violation,
|
||||||
};
|
};
|
||||||
pub use self::util::{elaborate, elaborate_trait_ref, elaborate_trait_refs};
|
pub use self::util::elaborate;
|
||||||
pub use self::util::{expand_trait_aliases, TraitAliasExpander};
|
pub use self::util::{expand_trait_aliases, TraitAliasExpander};
|
||||||
pub use self::util::{get_vtable_index_of_object_method, impl_item_is_final, upcast_choices};
|
pub use self::util::{get_vtable_index_of_object_method, impl_item_is_final, upcast_choices};
|
||||||
pub use self::util::{
|
pub use self::util::{
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
//! - not reference the erased type `Self` except for in this receiver;
|
//! - not reference the erased type `Self` except for in this receiver;
|
||||||
//! - not have generic type parameters.
|
//! - not have generic type parameters.
|
||||||
|
|
||||||
use super::{elaborate, elaborate_trait_ref};
|
use super::elaborate;
|
||||||
|
|
||||||
use crate::infer::TyCtxtInferExt;
|
use crate::infer::TyCtxtInferExt;
|
||||||
use crate::traits::query::evaluate_obligation::InferCtxtExt;
|
use crate::traits::query::evaluate_obligation::InferCtxtExt;
|
||||||
|
@ -666,7 +666,8 @@ fn object_ty_for_trait<'tcx>(
|
||||||
});
|
});
|
||||||
debug!(?trait_predicate);
|
debug!(?trait_predicate);
|
||||||
|
|
||||||
let mut elaborated_predicates: Vec<_> = elaborate_trait_ref(tcx, trait_ref)
|
let pred: ty::Predicate<'tcx> = trait_ref.to_predicate(tcx);
|
||||||
|
let mut elaborated_predicates: Vec<_> = elaborate(tcx, [pred])
|
||||||
.filter_map(|pred| {
|
.filter_map(|pred| {
|
||||||
debug!(?pred);
|
debug!(?pred);
|
||||||
let pred = pred.to_opt_poly_projection_pred()?;
|
let pred = pred.to_opt_poly_projection_pred()?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue