struct Coerce<D> {
delegate: D,
use_lub: bool,
allow_two_phase: AllowTwoPhase,
coerce_never: bool,
cause: ObligationCause,
}Fields§
§delegate: D§use_lub: bool§allow_two_phase: AllowTwoPhaseDetermines whether or not allow_two_phase_borrow is set on any autoref adjustments we create while coercing. We don’t want to allow deref coercions to create two-phase borrows, at least initially, but we do need two-phase borrows for function argument reborrows. See rust#47489 and rust#48598 See docs on the “AllowTwoPhase” type for a more detailed discussion
coerce_never: boolWhether we allow NeverToAny coercions. This is unsound if we’re
coercing a place expression without it counting as a read in the MIR.
This is a side-effect of HIR not really having a great distinction
between places and values.
cause: ObligationCauseImplementations§
Source§impl<'db, D> Coerce<D>where
D: CoerceDelegate<'db>,
impl<'db, D> Coerce<D>where
D: CoerceDelegate<'db>,
fn infcx(&self) -> &InferCtxt<'db>
fn param_env(&self) -> ParamEnv<'db>
fn interner(&self) -> DbInterner<'db>
fn db(&self) -> &'db dyn HirDatabase
pub(crate) fn commit_if_ok<T, E>( &mut self, f: impl FnOnce(&mut Self) -> Result<T, E>, ) -> Result<T, E>
fn unify_raw(&self, a: Ty<'db>, b: Ty<'db>) -> InferResult<'db, Ty<'db>>
Sourcefn unify(
&mut self,
a: Ty<'db>,
b: Ty<'db>,
) -> InferResult<'db, (Vec<Adjustment>, Ty<'db>)>
fn unify( &mut self, a: Ty<'db>, b: Ty<'db>, ) -> InferResult<'db, (Vec<Adjustment>, Ty<'db>)>
Unify two types (using sub or lub).
Sourcefn unify_and(
&mut self,
a: Ty<'db>,
b: Ty<'db>,
adjustments: impl IntoIterator<Item = Adjustment>,
final_adjustment: Adjust,
) -> InferResult<'db, (Vec<Adjustment>, Ty<'db>)>
fn unify_and( &mut self, a: Ty<'db>, b: Ty<'db>, adjustments: impl IntoIterator<Item = Adjustment>, final_adjustment: Adjust, ) -> InferResult<'db, (Vec<Adjustment>, Ty<'db>)>
Unify two types (using sub or lub) and produce a specific coercion.
fn coerce( &mut self, a: Ty<'db>, b: Ty<'db>, ) -> InferResult<'db, (Vec<Adjustment>, Ty<'db>)>
Sourcefn coerce_from_inference_variable(
&mut self,
a: Ty<'db>,
b: Ty<'db>,
) -> InferResult<'db, (Vec<Adjustment>, Ty<'db>)>
fn coerce_from_inference_variable( &mut self, a: Ty<'db>, b: Ty<'db>, ) -> InferResult<'db, (Vec<Adjustment>, Ty<'db>)>
Coercing from an inference variable. In this case, we have no information
about the source type, so we can’t really do a true coercion and we always
fall back to subtyping (unify_and).
Sourcefn coerce_borrowed_pointer(
&mut self,
a: Ty<'db>,
b: Ty<'db>,
r_b: Region<'db>,
mutbl_b: Mutability,
) -> InferResult<'db, (Vec<Adjustment>, Ty<'db>)>
fn coerce_borrowed_pointer( &mut self, a: Ty<'db>, b: Ty<'db>, r_b: Region<'db>, mutbl_b: Mutability, ) -> InferResult<'db, (Vec<Adjustment>, Ty<'db>)>
Reborrows &mut A to &mut B and &(mut) A to &B.
To match A with B, autoderef will be performed,
calling deref/deref_mut where necessary.
Sourcefn coerce_unsized(
&mut self,
source: Ty<'db>,
target: Ty<'db>,
) -> InferResult<'db, (Vec<Adjustment>, Ty<'db>)>
fn coerce_unsized( &mut self, source: Ty<'db>, target: Ty<'db>, ) -> InferResult<'db, (Vec<Adjustment>, Ty<'db>)>
Performs [unsized coercion] by emulating a fulfillment loop on a
CoerceUnsized goal until all CoerceUnsized and Unsize goals
are successfully selected.
fn coerce_from_safe_fn( &mut self, fn_ty_a: PolyFnSig<'db>, b: Ty<'db>, adjustment: Option<Adjust>, ) -> InferResult<'db, (Vec<Adjustment>, Ty<'db>)>
fn coerce_from_fn_pointer( &mut self, fn_ty_a: PolyFnSig<'db>, b: Ty<'db>, ) -> InferResult<'db, (Vec<Adjustment>, Ty<'db>)>
fn coerce_from_fn_item( &mut self, a: Ty<'db>, b: Ty<'db>, ) -> InferResult<'db, (Vec<Adjustment>, Ty<'db>)>
Sourcefn coerce_closure_to_fn(
&mut self,
a: Ty<'db>,
closure_def_id_a: InternedClosureId<'db>,
args_a: GenericArgs<'db>,
b: Ty<'db>,
) -> InferResult<'db, (Vec<Adjustment>, Ty<'db>)>
fn coerce_closure_to_fn( &mut self, a: Ty<'db>, closure_def_id_a: InternedClosureId<'db>, args_a: GenericArgs<'db>, b: Ty<'db>, ) -> InferResult<'db, (Vec<Adjustment>, Ty<'db>)>
Attempts to coerce from the type of a non-capturing closure into a function pointer.
fn coerce_raw_ptr( &mut self, a: Ty<'db>, b: Ty<'db>, mutbl_b: Mutability, ) -> InferResult<'db, (Vec<Adjustment>, Ty<'db>)>
Auto Trait Implementations§
impl<D> Freeze for Coerce<D>where
D: Freeze,
impl<D> RefUnwindSafe for Coerce<D>where
D: RefUnwindSafe,
impl<D> Send for Coerce<D>where
D: Send,
impl<D> Sync for Coerce<D>where
D: Sync,
impl<D> Unpin for Coerce<D>where
D: Unpin,
impl<D> UnsafeUnpin for Coerce<D>where
D: UnsafeUnpin,
impl<D> UnwindSafe for Coerce<D>where
D: UnwindSafe,
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