Struct rustc_infer::infer::canonical::canonicalizer::Canonicalizer
source · struct Canonicalizer<'cx, 'tcx> {
infcx: Option<&'cx InferCtxt<'tcx>>,
tcx: TyCtxt<'tcx>,
variables: SmallVec<[CanonicalVarInfo<'tcx>; 8]>,
query_state: &'cx mut OriginalQueryValues<'tcx>,
indices: FxHashMap<GenericArg<'tcx>, BoundVar>,
canonicalize_mode: &'cx dyn CanonicalizeMode,
needs_canonical_flags: TypeFlags,
binder_index: DebruijnIndex,
}
Fields§
§infcx: Option<&'cx InferCtxt<'tcx>>
Set to None
to disable the resolution of inference variables.
tcx: TyCtxt<'tcx>
§variables: SmallVec<[CanonicalVarInfo<'tcx>; 8]>
§query_state: &'cx mut OriginalQueryValues<'tcx>
§indices: FxHashMap<GenericArg<'tcx>, BoundVar>
§canonicalize_mode: &'cx dyn CanonicalizeMode
§needs_canonical_flags: TypeFlags
§binder_index: DebruijnIndex
Implementations§
source§impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx>
impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx>
sourcefn canonicalize<V>(
value: V,
infcx: Option<&InferCtxt<'tcx>>,
tcx: TyCtxt<'tcx>,
canonicalize_region_mode: &dyn CanonicalizeMode,
query_state: &mut OriginalQueryValues<'tcx>,
) -> Canonical<'tcx, V>where
V: TypeFoldable<TyCtxt<'tcx>>,
fn canonicalize<V>(
value: V,
infcx: Option<&InferCtxt<'tcx>>,
tcx: TyCtxt<'tcx>,
canonicalize_region_mode: &dyn CanonicalizeMode,
query_state: &mut OriginalQueryValues<'tcx>,
) -> Canonical<'tcx, V>where
V: TypeFoldable<TyCtxt<'tcx>>,
The main canonicalize
method, shared impl of
canonicalize_query
and canonicalize_response
.
fn canonicalize_with_base<U, V>(
base: Canonical<'tcx, U>,
value: V,
infcx: Option<&InferCtxt<'tcx>>,
tcx: TyCtxt<'tcx>,
canonicalize_region_mode: &dyn CanonicalizeMode,
query_state: &mut OriginalQueryValues<'tcx>,
) -> Canonical<'tcx, (U, V)>where
V: TypeFoldable<TyCtxt<'tcx>>,
sourcefn canonical_var(
&mut self,
info: CanonicalVarInfo<'tcx>,
kind: GenericArg<'tcx>,
) -> BoundVar
fn canonical_var( &mut self, info: CanonicalVarInfo<'tcx>, kind: GenericArg<'tcx>, ) -> BoundVar
Creates a canonical variable replacing kind
from the input,
or returns an existing variable if kind
has already been
seen. kind
is expected to be an unbound variable (or
potentially a free region).
sourcefn universe_canonicalized_variables(
self,
) -> SmallVec<[CanonicalVarInfo<'tcx>; 8]>
fn universe_canonicalized_variables( self, ) -> SmallVec<[CanonicalVarInfo<'tcx>; 8]>
Replaces the universe indexes used in var_values
with their index in
query_state.universe_map
. This minimizes the maximum universe used in
the canonicalized value.
sourcefn canonical_var_for_region_in_root_universe(
&mut self,
r: Region<'tcx>,
) -> Region<'tcx>
fn canonical_var_for_region_in_root_universe( &mut self, r: Region<'tcx>, ) -> Region<'tcx>
Shorthand helper that creates a canonical region variable for
r
(always in the root universe). The reason that we always
put these variables into the root universe is because this
method is used during query construction: in that case, we
are taking all the regions and just putting them into the most
generic context we can. This may generate solutions that don’t
fit (e.g., that equate some region variable with a placeholder
it can’t name) on the caller side, but that’s ok, the caller
can figure that out. In the meantime, it maximizes our
caching.
(This works because unification never fails – and hence trait selection is never affected – due to a universe mismatch.)
sourcefn canonical_var_for_region(
&mut self,
info: CanonicalVarInfo<'tcx>,
r: Region<'tcx>,
) -> Region<'tcx>
fn canonical_var_for_region( &mut self, info: CanonicalVarInfo<'tcx>, r: Region<'tcx>, ) -> Region<'tcx>
Creates a canonical variable (with the given info
)
representing the region r
; return a region referencing it.
sourcefn canonicalize_ty_var(
&mut self,
info: CanonicalVarInfo<'tcx>,
ty_var: Ty<'tcx>,
) -> Ty<'tcx>
fn canonicalize_ty_var( &mut self, info: CanonicalVarInfo<'tcx>, ty_var: Ty<'tcx>, ) -> Ty<'tcx>
Given a type variable ty_var
of the given kind, first check
if ty_var
is bound to anything; if so, canonicalize
that. Otherwise, create a new canonical variable for
ty_var
.
sourcefn canonicalize_const_var(
&mut self,
info: CanonicalVarInfo<'tcx>,
const_var: Const<'tcx>,
) -> Const<'tcx>
fn canonicalize_const_var( &mut self, info: CanonicalVarInfo<'tcx>, const_var: Const<'tcx>, ) -> Const<'tcx>
Given a type variable const_var
of the given kind, first check
if const_var
is bound to anything; if so, canonicalize
that. Otherwise, create a new canonical variable for
const_var
.
Trait Implementations§
source§impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx>
impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx>
fn cx(&self) -> TyCtxt<'tcx>
fn fold_binder<T>(&mut self, t: Binder<'tcx, T>) -> Binder<'tcx, T>where
T: TypeFoldable<TyCtxt<'tcx>>,
fn fold_region(&mut self, r: Region<'tcx>) -> Region<'tcx>
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx>
fn fold_const(&mut self, ct: Const<'tcx>) -> Const<'tcx>
fn fold_predicate( &mut self, p: <I as Interner>::Predicate, ) -> <I as Interner>::Predicate
Auto Trait Implementations§
impl<'cx, 'tcx> Freeze for Canonicalizer<'cx, 'tcx>
impl<'cx, 'tcx> !RefUnwindSafe for Canonicalizer<'cx, 'tcx>
impl<'cx, 'tcx> !Send for Canonicalizer<'cx, 'tcx>
impl<'cx, 'tcx> !Sync for Canonicalizer<'cx, 'tcx>
impl<'cx, 'tcx> Unpin for Canonicalizer<'cx, 'tcx>
impl<'cx, 'tcx> !UnwindSafe for Canonicalizer<'cx, '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, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
source§impl<I, F> FallibleTypeFolder<I> for Fwhere
I: Interner,
F: TypeFolder<I>,
impl<I, F> FallibleTypeFolder<I> for Fwhere
I: Interner,
F: TypeFolder<I>,
type Error = !
fn cx(&self) -> I
fn try_fold_binder<T>(&mut self, t: Binder<I, T>) -> Result<Binder<I, T>, !>where
T: TypeFoldable<I>,
fn try_fold_ty( &mut self, t: <I as Interner>::Ty, ) -> Result<<I as Interner>::Ty, !>
fn try_fold_region( &mut self, r: <I as Interner>::Region, ) -> Result<<I as Interner>::Region, !>
fn try_fold_const( &mut self, c: <I as Interner>::Const, ) -> Result<<I as Interner>::Const, !>
fn try_fold_predicate( &mut self, p: <I as Interner>::Predicate, ) -> Result<<I as Interner>::Predicate, !>
source§impl<T> Filterable for T
impl<T> Filterable for T
source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
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 moresource§impl<P> IntoQueryParam<P> for P
impl<P> IntoQueryParam<P> for P
fn into_query_param(self) -> P
source§impl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
source§impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
source§impl<I, T> UpcastFrom<I, T> for T
impl<I, T> UpcastFrom<I, T> for T
fn upcast_from(from: T, _tcx: I) -> T
source§impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed, ) -> T
source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 280 bytes