Struct rustc_infer::infer::canonical::canonicalizer::Canonicalizer
source · struct Canonicalizer<'cx, 'tcx> {
infcx: &'cx InferCtxt<'cx, '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: &'cx InferCtxt<'cx, '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
Implementations
sourceimpl<'cx, 'tcx> Canonicalizer<'cx, 'tcx>
impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx>
sourcefn canonicalize<V>(
value: V,
infcx: &InferCtxt<'_, 'tcx>,
tcx: TyCtxt<'tcx>,
canonicalize_region_mode: &dyn CanonicalizeMode,
query_state: &mut OriginalQueryValues<'tcx>
) -> Canonicalized<'tcx, V>where
V: TypeFoldable<'tcx>,
fn canonicalize<V>(
value: V,
infcx: &InferCtxt<'_, 'tcx>,
tcx: TyCtxt<'tcx>,
canonicalize_region_mode: &dyn CanonicalizeMode,
query_state: &mut OriginalQueryValues<'tcx>
) -> Canonicalized<'tcx, V>where
V: TypeFoldable<'tcx>,
The main canonicalize
method, shared impl of
canonicalize_query
and canonicalize_response
.
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 region_var_universe(&self, vid: RegionVid) -> UniverseIndex
fn region_var_universe(&self, vid: RegionVid) -> UniverseIndex
Returns the universe in which vid
is defined.
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
sourceimpl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx>
impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx>
fn tcx<'b>(&'b self) -> TyCtxt<'tcx>
fn fold_binder<T>(&mut self, t: Binder<'tcx, T>) -> Binder<'tcx, T>where
T: TypeFoldable<'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_unevaluated(
&mut self,
uv: Unevaluated<'tcx, Option<Promoted>>
) -> Unevaluated<'tcx, Option<Promoted>>
fn fold_predicate(&mut self, p: Predicate<'tcx>) -> Predicate<'tcx>
fn fold_mir_const(&mut self, c: ConstantKind<'tcx>) -> ConstantKind<'tcx>
Auto Trait Implementations
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>where
'tcx: 'cx,
impl<'cx, 'tcx> !UnwindSafe for Canonicalizer<'cx, 'tcx>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<'tcx, F> FallibleTypeFolder<'tcx> for Fwhere
F: TypeFolder<'tcx>,
impl<'tcx, F> FallibleTypeFolder<'tcx> for Fwhere
F: TypeFolder<'tcx>,
type Error = !
fn tcx(&'a self) -> TyCtxt<'tcx>
fn try_fold_binder<T>(
&mut self,
t: Binder<'tcx, T>
) -> Result<Binder<'tcx, T>, !>where
T: TypeFoldable<'tcx>,
fn try_fold_ty(&mut self, t: Ty<'tcx>) -> Result<Ty<'tcx>, !>
fn try_fold_region(&mut self, r: Region<'tcx>) -> Result<Region<'tcx>, !>
fn try_fold_const(&mut self, c: Const<'tcx>) -> Result<Const<'tcx>, !>
fn try_fold_unevaluated(
&mut self,
c: Unevaluated<'tcx, Option<Promoted>>
) -> Result<Unevaluated<'tcx, Option<Promoted>>, !>
fn try_fold_predicate(
&mut self,
p: Predicate<'tcx>
) -> Result<Predicate<'tcx>, !>
fn try_fold_mir_const(
&mut self,
c: ConstantKind<'tcx>
) -> Result<ConstantKind<'tcx>, !>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
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