mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
get rid of a bit more calls to poly_select
This commit is contained in:
parent
018c3e2c09
commit
3f8919c09b
@ -318,11 +318,11 @@ impl<'tcx> Key for (LocalDefId, DefId, SubstsRef<'tcx>) {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Key for (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>) {
|
||||
impl<'tcx> Key for (ty::ParamEnv<'tcx>, ty::TraitRef<'tcx>) {
|
||||
type CacheSelector = DefaultCacheSelector<Self>;
|
||||
|
||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||
tcx.def_span(self.1.def_id())
|
||||
tcx.def_span(self.1.def_id)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1278,7 +1278,7 @@ rustc_queries! {
|
||||
}
|
||||
|
||||
query codegen_select_candidate(
|
||||
key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)
|
||||
key: (ty::ParamEnv<'tcx>, ty::TraitRef<'tcx>)
|
||||
) -> Result<&'tcx ImplSource<'tcx, ()>, CodegenObligationError> {
|
||||
cache_on_disk_if { true }
|
||||
desc { |tcx| "computing candidate for `{}`", key.1 }
|
||||
|
@ -31,12 +31,12 @@ fn custom_coerce_unsize_info<'tcx>(
|
||||
source_ty: Ty<'tcx>,
|
||||
target_ty: Ty<'tcx>,
|
||||
) -> CustomCoerceUnsized {
|
||||
let trait_ref = ty::Binder::dummy(ty::TraitRef::from_lang_item(
|
||||
let trait_ref = ty::TraitRef::from_lang_item(
|
||||
tcx.tcx,
|
||||
LangItem::CoerceUnsized,
|
||||
tcx.span,
|
||||
[source_ty, target_ty],
|
||||
));
|
||||
);
|
||||
|
||||
match tcx.codegen_select_candidate((ty::ParamEnv::reveal_all(), trait_ref)) {
|
||||
Ok(traits::ImplSource::UserDefined(traits::ImplSourceUserDefinedData {
|
||||
|
@ -91,11 +91,11 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
||||
let infcx = tcx.infer_ctxt().build();
|
||||
let mut selcx = SelectionContext::new(&infcx);
|
||||
for polarity in [true, false] {
|
||||
let result = selcx.poly_select(&Obligation::new(
|
||||
let result = selcx.select(&Obligation::new(
|
||||
tcx,
|
||||
ObligationCause::dummy(),
|
||||
orig_env,
|
||||
ty::Binder::dummy(ty::TraitPredicate {
|
||||
ty::TraitPredicate {
|
||||
trait_ref,
|
||||
constness: ty::BoundConstness::NotConst,
|
||||
polarity: if polarity {
|
||||
@ -103,7 +103,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
||||
} else {
|
||||
ImplPolarity::Negative
|
||||
},
|
||||
}),
|
||||
},
|
||||
));
|
||||
if let Ok(Some(ImplSource::UserDefined(_))) = result {
|
||||
debug!(
|
||||
|
@ -362,7 +362,7 @@ pub(crate) fn vtable_trait_upcasting_coercion_new_vptr_slot<'tcx>(
|
||||
|
||||
let trait_ref = ty::TraitRef::new(tcx, unsize_trait_did, [source, target]);
|
||||
|
||||
match tcx.codegen_select_candidate((ty::ParamEnv::reveal_all(), ty::Binder::dummy(trait_ref))) {
|
||||
match tcx.codegen_select_candidate((ty::ParamEnv::reveal_all(), trait_ref)) {
|
||||
Ok(ImplSource::TraitUpcasting(implsrc_traitcasting)) => {
|
||||
implsrc_traitcasting.vtable_vptr_slot
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ use rustc_trait_selection::traits::{
|
||||
/// This also expects that `trait_ref` is fully normalized.
|
||||
pub fn codegen_select_candidate<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
(param_env, trait_ref): (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>),
|
||||
(param_env, trait_ref): (ty::ParamEnv<'tcx>, ty::TraitRef<'tcx>),
|
||||
) -> Result<&'tcx ImplSource<'tcx, ()>, CodegenObligationError> {
|
||||
// We expect the input to be fully normalized.
|
||||
debug_assert_eq!(trait_ref, tcx.normalize_erasing_regions(param_env, trait_ref));
|
||||
@ -35,7 +35,7 @@ pub fn codegen_select_candidate<'tcx>(
|
||||
let obligation_cause = ObligationCause::dummy();
|
||||
let obligation = Obligation::new(tcx, obligation_cause, param_env, trait_ref);
|
||||
|
||||
let selection = match selcx.poly_select(&obligation) {
|
||||
let selection = match selcx.select(&obligation) {
|
||||
Ok(Some(selection)) => selection,
|
||||
Ok(None) => return Err(CodegenObligationError::Ambiguity),
|
||||
Err(Unimplemented) => return Err(CodegenObligationError::Unimplemented),
|
||||
|
@ -80,7 +80,7 @@ fn resolve_associated_item<'tcx>(
|
||||
|
||||
let trait_ref = ty::TraitRef::from_method(tcx, trait_id, rcvr_substs);
|
||||
|
||||
let vtbl = match tcx.codegen_select_candidate((param_env, ty::Binder::dummy(trait_ref))) {
|
||||
let vtbl = match tcx.codegen_select_candidate((param_env, trait_ref)) {
|
||||
Ok(vtbl) => vtbl,
|
||||
Err(CodegenObligationError::Ambiguity) => {
|
||||
let reported = tcx.sess.delay_span_bug(
|
||||
|
Loading…
Reference in New Issue
Block a user