pub(crate) struct InferenceTable<'db> {
pub(crate) db: &'db dyn HirDatabase,
pub(crate) param_env: ParamEnv<'db>,
pub(crate) infer_ctxt: InferCtxt<'db>,
pub(super) fulfillment_cx: FulfillmentCtxt<'db>,
pub(super) diverging_type_vars: FxHashSet<Ty<'db>>,
pub(super) trait_errors: Vec<NextSolverError<'db>>,
}Fields§
§db: &'db dyn HirDatabase§param_env: ParamEnv<'db>§infer_ctxt: InferCtxt<'db>§fulfillment_cx: FulfillmentCtxt<'db>§diverging_type_vars: FxHashSet<Ty<'db>>§trait_errors: Vec<NextSolverError<'db>>Implementations§
Source§impl<'db> InferenceTable<'db>
impl<'db> InferenceTable<'db>
pub(crate) fn autoderef( &self, base_ty: Ty<'db>, span: Span, ) -> GeneralAutoderef<'db, DefaultAutoderefCtx<'_, 'db>, usize> ⓘ
pub(crate) fn autoderef_with_tracking( &self, base_ty: Ty<'db>, span: Span, ) -> GeneralAutoderef<'db, DefaultAutoderefCtx<'_, 'db>, Vec<(Ty<'db>, AutoderefKind)>> ⓘ
Source§impl<'db> InferenceTable<'db>
impl<'db> InferenceTable<'db>
Sourcepub(crate) fn new(
db: &'db dyn HirDatabase,
trait_env: ParamEnv<'db>,
krate: Crate,
owner: ExpressionStoreOwnerId,
) -> Self
pub(crate) fn new( db: &'db dyn HirDatabase, trait_env: ParamEnv<'db>, krate: Crate, owner: ExpressionStoreOwnerId, ) -> Self
Inside hir-ty you should use this for inference only, and always pass owner.
Outside it, always pass owner = None.
pub(crate) fn interner(&self) -> DbInterner<'db>
pub(crate) fn type_is_copy_modulo_regions(&self, ty: Ty<'db>) -> bool
pub(crate) fn type_is_sized_modulo_regions(&self, ty: Ty<'db>) -> bool
pub(crate) fn type_is_use_cloned_modulo_regions(&self, ty: Ty<'db>) -> bool
pub(crate) fn type_var_is_sized(&self, self_ty: TyVid) -> bool
pub(super) fn obligations_for_self_ty( &self, self_ty: TyVid, ) -> SmallVec<[Obligation<'db, Predicate<'db>>; 4]>
fn predicate_has_self_ty( &self, predicate: Predicate<'db>, expected_vid: TyVid, ) -> bool
fn type_matches_expected_vid(&self, expected_vid: TyVid, ty: Ty<'db>) -> bool
pub(super) fn set_diverging(&mut self, ty: Ty<'db>)
pub(crate) fn next_ty_var(&self, span: Span) -> Ty<'db>
pub(crate) fn next_const_var(&self, span: Span) -> Const<'db>
pub(crate) fn next_int_var(&self) -> Ty<'db>
pub(crate) fn next_float_var(&self) -> Ty<'db>
pub(crate) fn new_maybe_never_var(&mut self, span: Span) -> Ty<'db>
pub(crate) fn next_region_var(&self, span: Span) -> Region<'db>
pub(crate) fn var_for_def( &self, id: GenericParamId, span: Span, ) -> GenericArg<'db>
pub(crate) fn at<'a>(&'a self, cause: &'a ObligationCause) -> At<'a, 'db>
pub(crate) fn shallow_resolve(&self, ty: Ty<'db>) -> Ty<'db>
pub(crate) fn resolve_vars_if_possible<T: TypeFoldable<DbInterner<'db>>>( &self, t: T, ) -> T
pub(crate) fn resolve_vars_with_obligations<T>(&mut self, t: T) -> Twhere
T: TypeFoldable<DbInterner<'db>>,
Sourcepub(crate) fn fresh_args_for_item(
&self,
span: Span,
def: SolverDefId<'db>,
) -> GenericArgs<'db>
pub(crate) fn fresh_args_for_item( &self, span: Span, def: SolverDefId<'db>, ) -> GenericArgs<'db>
Create a GenericArgs full of infer vars for def.
Sourcepub(crate) fn try_structurally_resolve_type(
&mut self,
span: Span,
ty: Ty<'db>,
) -> Ty<'db>
pub(crate) fn try_structurally_resolve_type( &mut self, span: Span, ty: Ty<'db>, ) -> Ty<'db>
Try to resolve ty to a structural type, normalizing aliases.
In case there is still ambiguity, the returned type may be an inference
variable. This is different from structurally_resolve_type which errors
in this case.
pub(crate) fn try_structurally_resolve_const( &mut self, sp: Span, ct: Const<'db>, ) -> Const<'db>
pub(crate) fn snapshot(&mut self) -> CombinedSnapshot
pub(crate) fn rollback_to(&mut self, snapshot: CombinedSnapshot)
pub(crate) fn commit_if_ok<T, E>( &mut self, f: impl FnOnce(&mut InferenceTable<'db>) -> Result<T, E>, ) -> Result<T, E>
pub(crate) fn register_bound( &mut self, ty: Ty<'db>, def_id: TraitId, cause: ObligationCause, )
pub(crate) fn register_infer_ok<T>(&mut self, infer_ok: InferOk<'db, T>) -> T
pub(crate) fn select_obligations_where_possible(&mut self)
pub(super) fn register_predicate( &mut self, obligation: Obligation<'db, Predicate<'db>>, )
pub(crate) fn register_predicates<I>(&mut self, obligations: I)
Sourcepub(crate) fn register_wf_obligation(
&mut self,
term: Term<'db>,
cause: ObligationCause,
)
pub(crate) fn register_wf_obligation( &mut self, term: Term<'db>, cause: ObligationCause, )
checking later, during regionck, that arg is well-formed.
Sourcepub(crate) fn add_wf_bounds(&mut self, span: Span, args: GenericArgs<'db>)
pub(crate) fn add_wf_bounds(&mut self, span: Span, args: GenericArgs<'db>)
Registers obligations that all args are well-formed.
pub(super) fn insert_type_vars<T>(&mut self, ty: T) -> Twhere
T: TypeFoldable<DbInterner<'db>>,
Sourcepub(crate) fn process_user_written_ty(&mut self, ty: Ty<'db>) -> Ty<'db>
pub(crate) fn process_user_written_ty(&mut self, ty: Ty<'db>) -> Ty<'db>
Whenever you lower a user-written type, you should call this.
Sourcepub(crate) fn process_remote_user_written_ty(&mut self, ty: Ty<'db>) -> Ty<'db>
pub(crate) fn process_remote_user_written_ty(&mut self, ty: Ty<'db>) -> Ty<'db>
The difference of this method from process_user_written_ty() is that this method doesn’t register a well-formed obligation,
while process_user_written_ty() should (but doesn’t currently).
fn emit_trait_errors(&mut self, diagnostics: &mut ThinVec<InferenceDiagnostic>)
Source§impl<'db> InferenceTable<'db>
impl<'db> InferenceTable<'db>
Sourcepub(crate) fn lookup_method_for_operator(
&self,
cause: ObligationCause,
trait_def_id: TraitId,
method_item: FunctionId,
self_ty: Ty<'db>,
opt_rhs_ty: Option<Ty<'db>>,
treat_opaques: TreatNotYetDefinedOpaques,
) -> Option<InferOk<'db, MethodCallee<'db>>>
pub(crate) fn lookup_method_for_operator( &self, cause: ObligationCause, trait_def_id: TraitId, method_item: FunctionId, self_ty: Ty<'db>, opt_rhs_ty: Option<Ty<'db>>, treat_opaques: TreatNotYetDefinedOpaques, ) -> Option<InferOk<'db, MethodCallee<'db>>>
lookup_method_in_trait is used for overloaded operators.
It does a very narrow slice of what the normal probe/confirm path does.
In particular, it doesn’t really do any probing: it simply constructs
an obligation for a particular trait with the given self type and checks
whether that trait is implemented.
Trait Implementations§
Auto Trait Implementations§
impl<'db> !Freeze for InferenceTable<'db>
impl<'db> !RefUnwindSafe for InferenceTable<'db>
impl<'db> !Send for InferenceTable<'db>
impl<'db> !Sync for InferenceTable<'db>
impl<'db> Unpin for InferenceTable<'db>
impl<'db> UnsafeUnpin for InferenceTable<'db>
impl<'db> !UnwindSafe for InferenceTable<'db>
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
§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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