pub struct PredicateSearcher<'tcx> {
tcx: TyCtxt<'tcx>,
param_env: ParamEnv<'tcx>,
candidates: HashMap<PolyTraitPredicate<'tcx>, Candidate<'tcx>>,
}
Expand description
Stores a set of predicates along with where they came from.
Fields§
§tcx: TyCtxt<'tcx>
§param_env: ParamEnv<'tcx>
§candidates: HashMap<PolyTraitPredicate<'tcx>, Candidate<'tcx>>
Local clauses available in the current context.
Implementations§
source§impl<'tcx> PredicateSearcher<'tcx>
impl<'tcx> PredicateSearcher<'tcx>
sourcepub fn new_for_owner(tcx: TyCtxt<'tcx>, owner_id: DefId) -> Self
pub fn new_for_owner(tcx: TyCtxt<'tcx>, owner_id: DefId) -> Self
Initialize the elaborator with the predicates accessible within this item.
sourcefn extend(&mut self, candidates: impl IntoIterator<Item = Candidate<'tcx>>)
fn extend(&mut self, candidates: impl IntoIterator<Item = Candidate<'tcx>>)
Insert new candidates and all their parent predicates. This deduplicates predicates to avoid divergence.
sourcefn extend_parents(&mut self, new_candidates: Vec<Candidate<'tcx>>)
fn extend_parents(&mut self, new_candidates: Vec<Candidate<'tcx>>)
Add the parents of these candidates. This is a separate function to avoid polymorphic recursion due to the closures capturing the type parameters of this function.
sourcefn add_associated_type_refs(
&mut self,
ty: Binder<'tcx, Ty<'tcx>>,
warn: &impl Fn(&str),
) -> Result<(), String>
fn add_associated_type_refs( &mut self, ty: Binder<'tcx, Ty<'tcx>>, warn: &impl Fn(&str), ) -> Result<(), String>
If the type is a trait associated type, we add any relevant bounds to our context.
sourcefn resolve_local(
&mut self,
target: PolyTraitPredicate<'tcx>,
warn: &impl Fn(&str),
) -> Result<Option<Candidate<'tcx>>, String>
fn resolve_local( &mut self, target: PolyTraitPredicate<'tcx>, warn: &impl Fn(&str), ) -> Result<Option<Candidate<'tcx>>, String>
Resolve a local clause by looking it up in this set. If the predicate applies to an associated type, we add the relevant implied associated type bounds to the set as well.
sourcepub fn resolve(
&mut self,
tref: &PolyTraitRef<'tcx>,
warn: &impl Fn(&str),
) -> Result<ImplExpr<'tcx>, String>
pub fn resolve( &mut self, tref: &PolyTraitRef<'tcx>, warn: &impl Fn(&str), ) -> Result<ImplExpr<'tcx>, String>
Resolve the given trait reference in the local context.
sourcepub fn resolve_item_predicates(
&mut self,
def_id: DefId,
generics: GenericArgsRef<'tcx>,
warn: &impl Fn(&str),
) -> Result<Vec<ImplExpr<'tcx>>, String>
pub fn resolve_item_predicates( &mut self, def_id: DefId, generics: GenericArgsRef<'tcx>, warn: &impl Fn(&str), ) -> Result<Vec<ImplExpr<'tcx>>, String>
Resolve the predicates required by the given item.
Auto Trait Implementations§
impl<'tcx> Freeze for PredicateSearcher<'tcx>
impl<'tcx> !RefUnwindSafe for PredicateSearcher<'tcx>
impl<'tcx> !Send for PredicateSearcher<'tcx>
impl<'tcx> !Sync for PredicateSearcher<'tcx>
impl<'tcx> Unpin for PredicateSearcher<'tcx>
impl<'tcx> !UnwindSafe for PredicateSearcher<'tcx>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more