Skip to main content

InferenceTable

Struct InferenceTable 

Source
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>

Source

pub(crate) fn autoderef( &self, base_ty: Ty<'db>, span: Span, ) -> GeneralAutoderef<'db, DefaultAutoderefCtx<'_, 'db>, usize>

Source

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>

Source

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.

Source

pub(crate) fn interner(&self) -> DbInterner<'db>

Source

pub(crate) fn type_is_copy_modulo_regions(&self, ty: Ty<'db>) -> bool

Source

pub(crate) fn type_is_sized_modulo_regions(&self, ty: Ty<'db>) -> bool

Source

pub(crate) fn type_is_use_cloned_modulo_regions(&self, ty: Ty<'db>) -> bool

Source

pub(crate) fn type_var_is_sized(&self, self_ty: TyVid) -> bool

Source

pub(super) fn obligations_for_self_ty( &self, self_ty: TyVid, ) -> SmallVec<[Obligation<'db, Predicate<'db>>; 4]>

Source

fn predicate_has_self_ty( &self, predicate: Predicate<'db>, expected_vid: TyVid, ) -> bool

Source

fn type_matches_expected_vid(&self, expected_vid: TyVid, ty: Ty<'db>) -> bool

Source

pub(super) fn set_diverging(&mut self, ty: Ty<'db>)

Source

pub(crate) fn next_ty_var(&self, span: Span) -> Ty<'db>

Source

pub(crate) fn next_const_var(&self, span: Span) -> Const<'db>

Source

pub(crate) fn next_int_var(&self) -> Ty<'db>

Source

pub(crate) fn next_float_var(&self) -> Ty<'db>

Source

pub(crate) fn new_maybe_never_var(&mut self, span: Span) -> Ty<'db>

Source

pub(crate) fn next_region_var(&self, span: Span) -> Region<'db>

Source

pub(crate) fn var_for_def( &self, id: GenericParamId, span: Span, ) -> GenericArg<'db>

Source

pub(crate) fn at<'a>(&'a self, cause: &'a ObligationCause) -> At<'a, 'db>

Source

pub(crate) fn shallow_resolve(&self, ty: Ty<'db>) -> Ty<'db>

Source

pub(crate) fn resolve_vars_if_possible<T: TypeFoldable<DbInterner<'db>>>( &self, t: T, ) -> T

Source

pub(crate) fn resolve_vars_with_obligations<T>(&mut self, t: T) -> T
where T: TypeFoldable<DbInterner<'db>>,

Source

pub(crate) fn fresh_args_for_item( &self, span: Span, def: SolverDefId<'db>, ) -> GenericArgs<'db>

Create a GenericArgs full of infer vars for def.

Source

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.

Source

pub(crate) fn try_structurally_resolve_const( &mut self, sp: Span, ct: Const<'db>, ) -> Const<'db>

Source

pub(crate) fn snapshot(&mut self) -> CombinedSnapshot

Source

pub(crate) fn rollback_to(&mut self, snapshot: CombinedSnapshot)

Source

pub(crate) fn commit_if_ok<T, E>( &mut self, f: impl FnOnce(&mut InferenceTable<'db>) -> Result<T, E>, ) -> Result<T, E>

Source

pub(crate) fn register_bound( &mut self, ty: Ty<'db>, def_id: TraitId, cause: ObligationCause, )

Source

pub(crate) fn register_infer_ok<T>(&mut self, infer_ok: InferOk<'db, T>) -> T

Source

pub(crate) fn select_obligations_where_possible(&mut self)

Source

pub(super) fn register_predicate( &mut self, obligation: Obligation<'db, Predicate<'db>>, )

Source

pub(crate) fn register_predicates<I>(&mut self, obligations: I)
where I: IntoIterator<Item = Obligation<'db, Predicate<'db>>>,

Source

pub(crate) fn register_wf_obligation( &mut self, term: Term<'db>, cause: ObligationCause, )

checking later, during regionck, that arg is well-formed.

Source

pub(crate) fn add_wf_bounds(&mut self, span: Span, args: GenericArgs<'db>)

Registers obligations that all args are well-formed.

Source

pub(super) fn insert_type_vars<T>(&mut self, ty: T) -> T
where T: TypeFoldable<DbInterner<'db>>,

Source

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.

Source

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).

Source

fn emit_trait_errors(&mut self, diagnostics: &mut ThinVec<InferenceDiagnostic>)

Source§

impl<'db> InferenceTable<'db>

Source

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§

Source§

impl Debug for InferenceTable<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T, R> CollectAndApply<T, R> for T

§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

§

type Output = R

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> IntoBox<dyn Any> for T
where T: Any,

§

fn into_box(self) -> Box<dyn Any>

Convert self into the appropriate boxed form.
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Lookup<T> for T

§

fn into_owned(self) -> T

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<I, T, U> Upcast<I, U> for T
where U: UpcastFrom<I, T>,

§

fn upcast(self, interner: I) -> U

§

impl<I, T> UpcastFrom<I, T> for T

§

fn upcast_from(from: T, _tcx: I) -> T

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more