pub struct Adjustment<'db> {
pub kind: Adjust,
pub target: Ty<'db>,
}Expand description
Represents coercing a value to a different type of value.
We transform values by following a number of Adjust steps in order.
See the documentation on variants of Adjust for more details.
Here are some common scenarios:
-
The simplest cases are where a pointer is not adjusted fat vs thin. Here the pointer will be dereferenced N times (where a dereference can happen to raw or borrowed pointers or any smart pointer which implements Deref, including Box<_>). The types of dereferences is given by
autoderefs. It can then be auto-referenced zero or one times, indicated byautoref, to either a raw or borrowed pointer. In these cases unsize isfalse. -
A thin-to-fat coercion involves unsizing the underlying data. We start with a thin pointer, deref a number of times, unsize the underlying data, then autoref. The ‘unsize’ phase may change a fixed length array to a dynamically sized one, a concrete object to a trait object, or statically sized struct to a dynamically sized one. E.g., &[i32; 4] -> &i32 is represented by:
ⓘDeref(None) -> [i32; 4], Borrow(AutoBorrow::Ref) -> &[i32; 4], Unsize -> &[i32],Note that for a struct, the ‘deep’ unsizing of the struct is not recorded. E.g.,
struct Foo<T> { it: T }we can coerce &Foo<[i32; 4]> to &Foo<i32> The autoderef and -ref are the same as in the above example, but the type stored inunsizeisFoo<[i32]>, we don’t store any further detail about the underlying conversions from[i32; 4]to[i32]. -
Coercing a
Box<T>toBox<dyn Trait>is an interesting special case. In that case, we have the pointer we need coming in, so there are no autoderefs, and no autoref. Instead we just do theUnsizetransformation. At some point, of course,Boxshould move out of the compiler, in which case this is analogous to transforming a struct. E.g., Box<[i32; 4]> -> Box<i32> is anAdjust::Unsizewith the targetBox<[i32]>.
Fields§
§kind: Adjust§target: Ty<'db>Implementations§
Source§impl<'db> Adjustment<'db>
impl<'db> Adjustment<'db>
pub fn borrow( interner: DbInterner<'db>, m: Mutability, ty: Ty<'db>, lt: Region<'db>, ) -> Self
Trait Implementations§
Source§impl<'db> Clone for Adjustment<'db>
impl<'db> Clone for Adjustment<'db>
Source§fn clone(&self) -> Adjustment<'db>
fn clone(&self) -> Adjustment<'db>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'db> Debug for Adjustment<'db>
impl<'db> Debug for Adjustment<'db>
Source§impl<'db> Hash for Adjustment<'db>
impl<'db> Hash for Adjustment<'db>
Source§impl<'db> PartialEq for Adjustment<'db>
impl<'db> PartialEq for Adjustment<'db>
Source§impl<'db> TypeFoldable<DbInterner<'db>> for Adjustment<'db>
impl<'db> TypeFoldable<DbInterner<'db>> for Adjustment<'db>
Source§fn try_fold_with<__F: FallibleTypeFolder<DbInterner<'db>>>(
self,
__folder: &mut __F,
) -> Result<Self, __F::Error>
fn try_fold_with<__F: FallibleTypeFolder<DbInterner<'db>>>( self, __folder: &mut __F, ) -> Result<Self, __F::Error>
Source§impl<'db> TypeVisitable<DbInterner<'db>> for Adjustment<'db>
impl<'db> TypeVisitable<DbInterner<'db>> for Adjustment<'db>
Source§fn visit_with<__V: TypeVisitor<DbInterner<'db>>>(
&self,
__visitor: &mut __V,
) -> __V::Result
fn visit_with<__V: TypeVisitor<DbInterner<'db>>>( &self, __visitor: &mut __V, ) -> __V::Result
Source§impl<'db> Update for Adjustment<'db>
impl<'db> Update for Adjustment<'db>
impl<'db> Eq for Adjustment<'db>
impl<'db> StructuralPartialEq for Adjustment<'db>
Auto Trait Implementations§
impl<'db> Freeze for Adjustment<'db>
impl<'db> RefUnwindSafe for Adjustment<'db>
impl<'db> Send for Adjustment<'db>
impl<'db> Sync for Adjustment<'db>
impl<'db> Unpin for Adjustment<'db>
impl<'db> UnwindSafe for Adjustment<'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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<I, T> TypeVisitableExt<I> for Twhere
I: Interner,
T: TypeVisitable<I>,
impl<I, T> TypeVisitableExt<I> for Twhere
I: Interner,
T: TypeVisitable<I>,
fn has_type_flags(&self, flags: TypeFlags) -> bool
§fn has_vars_bound_at_or_above(&self, binder: DebruijnIndex) -> bool
fn has_vars_bound_at_or_above(&self, binder: DebruijnIndex) -> bool
true if self has any late-bound regions that are either
bound by binder or bound by some binder outside of binder.
If binder is ty::INNERMOST, this indicates whether
there are any late-bound regions that appear free.fn error_reported(&self) -> Result<(), <I as Interner>::ErrorGuaranteed>
§fn has_vars_bound_above(&self, binder: DebruijnIndex) -> bool
fn has_vars_bound_above(&self, binder: DebruijnIndex) -> bool
true if this type has any regions that escape binder (and
hence are not bound by it).§fn has_escaping_bound_vars(&self) -> bool
fn has_escaping_bound_vars(&self) -> bool
true if this type has regions that are not a part of the type.
For example, for<'a> fn(&'a i32) return false, while fn(&'a i32)
would return true. The latter can occur when traversing through the
former. Read morefn has_aliases(&self) -> bool
fn has_opaque_types(&self) -> bool
fn has_coroutines(&self) -> bool
fn references_error(&self) -> bool
fn has_non_region_param(&self) -> bool
fn has_infer_regions(&self) -> bool
fn has_infer_types(&self) -> bool
fn has_non_region_infer(&self) -> bool
fn has_infer(&self) -> bool
fn has_placeholders(&self) -> bool
fn has_non_region_placeholders(&self) -> bool
fn has_param(&self) -> bool
§fn has_free_regions(&self) -> bool
fn has_free_regions(&self) -> bool
fn has_erased_regions(&self) -> bool
§fn has_erasable_regions(&self) -> bool
fn has_erasable_regions(&self) -> bool
§fn is_global(&self) -> bool
fn is_global(&self) -> bool
§fn has_bound_regions(&self) -> bool
fn has_bound_regions(&self) -> bool
§fn has_non_region_bound_vars(&self) -> bool
fn has_non_region_bound_vars(&self) -> bool
§fn has_bound_vars(&self) -> bool
fn has_bound_vars(&self) -> bool
§fn still_further_specializable(&self) -> bool
fn still_further_specializable(&self) -> bool
impl
specialization.