Skip to content

Commit 2cd0729

Browse files
Get rid of elaborate_trait_ref{s} too
1 parent 758bedc commit 2cd0729

File tree

4 files changed

+14
-23
lines changed

4 files changed

+14
-23
lines changed

compiler/rustc_hir_analysis/src/astconv/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKin
3333
use rustc_middle::middle::stability::AllowUnstable;
3434
use rustc_middle::ty::fold::FnMutDelegate;
3535
use rustc_middle::ty::subst::{self, GenericArgKind, InternalSubsts, SubstsRef};
36-
use rustc_middle::ty::DynKind;
3736
use rustc_middle::ty::GenericParamDefKind;
3837
use rustc_middle::ty::{self, Const, IsSuggestable, Ty, TyCtxt, TypeVisitableExt};
38+
use rustc_middle::ty::{DynKind, ToPredicate};
3939
use rustc_session::lint::builtin::{AMBIGUOUS_ASSOCIATED_ITEMS, BARE_TRAIT_OBJECTS};
4040
use rustc_span::edit_distance::find_best_match_for_name;
4141
use rustc_span::edition::Edition;
@@ -1526,8 +1526,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
15261526

15271527
for (base_trait_ref, span, constness) in regular_traits_refs_spans {
15281528
assert_eq!(constness, ty::BoundConstness::NotConst);
1529-
1530-
for pred in traits::elaborate_trait_ref(tcx, base_trait_ref) {
1529+
let base_pred: ty::Predicate<'tcx> = base_trait_ref.to_predicate(tcx);
1530+
for pred in traits::elaborate(tcx, [base_pred]) {
15311531
debug!("conv_object_ty_poly_trait_ref: observing object predicate `{:?}`", pred);
15321532

15331533
let bound_predicate = pred.kind();

compiler/rustc_infer/src/traits/util.rs

+7-17
Original file line numberDiff line numberDiff line change
@@ -166,20 +166,6 @@ impl<'tcx> Elaboratable<'tcx> for (ty::Predicate<'tcx>, Span) {
166166
}
167167
}
168168

169-
pub fn elaborate_trait_ref<'tcx>(
170-
tcx: TyCtxt<'tcx>,
171-
trait_ref: ty::PolyTraitRef<'tcx>,
172-
) -> Elaborator<'tcx, ty::Predicate<'tcx>> {
173-
elaborate(tcx, std::iter::once(trait_ref.without_const().to_predicate(tcx)))
174-
}
175-
176-
pub fn elaborate_trait_refs<'tcx>(
177-
tcx: TyCtxt<'tcx>,
178-
trait_refs: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
179-
) -> Elaborator<'tcx, ty::Predicate<'tcx>> {
180-
elaborate(tcx, trait_refs.map(|trait_ref| trait_ref.to_predicate(tcx)))
181-
}
182-
183169
pub fn elaborate<'tcx, O: Elaboratable<'tcx>>(
184170
tcx: TyCtxt<'tcx>,
185171
obligations: impl IntoIterator<Item = O>,
@@ -364,17 +350,21 @@ pub fn supertraits<'tcx>(
364350
tcx: TyCtxt<'tcx>,
365351
trait_ref: ty::PolyTraitRef<'tcx>,
366352
) -> impl Iterator<Item = ty::PolyTraitRef<'tcx>> {
367-
FilterToTraits::new(elaborate_trait_ref(tcx, trait_ref))
353+
let pred: ty::Predicate<'tcx> = trait_ref.to_predicate(tcx);
354+
FilterToTraits::new(elaborate(tcx, [pred]))
368355
}
369356

370357
pub fn transitive_bounds<'tcx>(
371358
tcx: TyCtxt<'tcx>,
372359
trait_refs: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
373360
) -> impl Iterator<Item = ty::PolyTraitRef<'tcx>> {
374-
FilterToTraits::new(elaborate_trait_refs(tcx, trait_refs))
361+
FilterToTraits::new(elaborate(
362+
tcx,
363+
trait_refs.map(|trait_ref| -> ty::Predicate<'tcx> { trait_ref.to_predicate(tcx) }),
364+
))
375365
}
376366

377-
/// A specialized variant of `elaborate_trait_refs` that only elaborates trait references that may
367+
/// A specialized variant of `elaborate` that only elaborates trait references that may
378368
/// define the given associated type `assoc_name`. It uses the
379369
/// `super_predicates_that_define_assoc_type` query to avoid enumerating super-predicates that
380370
/// aren't related to `assoc_item`. This is used when resolving types like `Self::Item` or

compiler/rustc_trait_selection/src/traits/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub use self::specialize::{specialization_graph, translate_substs, OverlapError}
5858
pub use self::structural_match::{
5959
search_for_adt_const_param_violation, search_for_structural_match_violation,
6060
};
61-
pub use self::util::{elaborate, elaborate_trait_ref, elaborate_trait_refs};
61+
pub use self::util::elaborate;
6262
pub use self::util::{expand_trait_aliases, TraitAliasExpander};
6363
pub use self::util::{get_vtable_index_of_object_method, impl_item_is_final, upcast_choices};
6464
pub use self::util::{

compiler/rustc_trait_selection/src/traits/object_safety.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//! - not reference the erased type `Self` except for in this receiver;
99
//! - not have generic type parameters.
1010
11-
use super::{elaborate, elaborate_trait_ref};
11+
use super::elaborate;
1212

1313
use crate::infer::TyCtxtInferExt;
1414
use crate::traits::query::evaluate_obligation::InferCtxtExt;
@@ -666,7 +666,8 @@ fn object_ty_for_trait<'tcx>(
666666
});
667667
debug!(?trait_predicate);
668668

669-
let mut elaborated_predicates: Vec<_> = elaborate_trait_ref(tcx, trait_ref)
669+
let pred: ty::Predicate<'tcx> = trait_ref.to_predicate(tcx);
670+
let mut elaborated_predicates: Vec<_> = elaborate(tcx, [pred])
670671
.filter_map(|pred| {
671672
debug!(?pred);
672673
let pred = pred.to_opt_poly_projection_pred()?;

0 commit comments

Comments
 (0)