1
Fork 0

Get rid of trait_ref_is_knowable from delegate

This commit is contained in:
Michael Goulet 2024-07-06 18:32:06 -04:00
parent a982471e07
commit ab27c2fa77
4 changed files with 4 additions and 21 deletions

View file

@ -1,4 +1,3 @@
use std::fmt::Debug;
use std::ops::Deref; use std::ops::Deref;
use rustc_type_ir::fold::TypeFoldable; use rustc_type_ir::fold::TypeFoldable;
@ -99,14 +98,6 @@ pub trait SolverDelegate:
fn reset_opaque_types(&self); fn reset_opaque_types(&self);
fn trait_ref_is_knowable<E: Debug>(
&self,
trait_ref: ty::TraitRef<Self::Interner>,
lazily_normalize_ty: impl FnMut(
<Self::Interner as Interner>::Ty,
) -> Result<<Self::Interner as Interner>::Ty, E>,
) -> Result<bool, E>;
fn fetch_eligible_assoc_item( fn fetch_eligible_assoc_item(
&self, &self,
param_env: <Self::Interner as Interner>::ParamEnv, param_env: <Self::Interner as Interner>::ParamEnv,

View file

@ -11,6 +11,7 @@ use rustc_type_ir::{self as ty, CanonicalVarValues, InferCtxtLike, Interner};
use rustc_type_ir_macros::{Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic}; use rustc_type_ir_macros::{Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic};
use tracing::{instrument, trace}; use tracing::{instrument, trace};
use crate::coherence;
use crate::delegate::SolverDelegate; use crate::delegate::SolverDelegate;
use crate::solve::inspect::{self, ProofTreeBuilder}; use crate::solve::inspect::{self, ProofTreeBuilder};
use crate::solve::search_graph::SearchGraph; use crate::solve::search_graph::SearchGraph;
@ -906,7 +907,8 @@ where
) -> Result<bool, NoSolution> { ) -> Result<bool, NoSolution> {
let delegate = self.delegate; let delegate = self.delegate;
let lazily_normalize_ty = |ty| self.structurally_normalize_ty(param_env, ty); let lazily_normalize_ty = |ty| self.structurally_normalize_ty(param_env, ty);
delegate.trait_ref_is_knowable(trait_ref, lazily_normalize_ty) coherence::trait_ref_is_knowable(&**delegate, trait_ref, lazily_normalize_ty)
.map(|is_knowable| is_knowable.is_ok())
} }
pub(super) fn fetch_eligible_assoc_item( pub(super) fn fetch_eligible_assoc_item(

View file

@ -15,7 +15,6 @@ use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt as _};
use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP}; use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
use rustc_type_ir::solve::{Certainty, NoSolution, SolverMode}; use rustc_type_ir::solve::{Certainty, NoSolution, SolverMode};
use crate::traits::coherence::trait_ref_is_knowable;
use crate::traits::specialization_graph; use crate::traits::specialization_graph;
#[repr(transparent)] #[repr(transparent)]
@ -200,15 +199,6 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
let _ = self.take_opaque_types(); let _ = self.take_opaque_types();
} }
fn trait_ref_is_knowable<E: std::fmt::Debug>(
&self,
trait_ref: ty::TraitRef<'tcx>,
lazily_normalize_ty: impl FnMut(Ty<'tcx>) -> Result<Ty<'tcx>, E>,
) -> Result<bool, E> {
trait_ref_is_knowable(&self.0, trait_ref, lazily_normalize_ty)
.map(|is_knowable| is_knowable.is_ok())
}
fn fetch_eligible_assoc_item( fn fetch_eligible_assoc_item(
&self, &self,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,

View file

@ -3,7 +3,7 @@ use crate::relate::Relate;
use crate::solve::{Goal, NoSolution, SolverMode}; use crate::solve::{Goal, NoSolution, SolverMode};
use crate::{self as ty, Interner}; use crate::{self as ty, Interner};
pub trait InferCtxtLike { pub trait InferCtxtLike: Sized {
type Interner: Interner; type Interner: Interner;
fn cx(&self) -> Self::Interner; fn cx(&self) -> Self::Interner;