fn receiver_is_valid<'tcx>(
    wfcx: &WfCheckingCtxt<'_, 'tcx>,
    span: Span,
    receiver_ty: Ty<'tcx>,
    self_ty: Ty<'tcx>,
    arbitrary_self_types_enabled: bool
) -> bool
Expand description

Returns whether receiver_ty would be considered a valid receiver type for self_ty. If arbitrary_self_types is enabled, receiver_ty must transitively deref to self_ty, possibly through a *const/mut T raw pointer. If the feature is not enabled, the requirements are more strict: receiver_ty must implement Receiver and directly implement Deref<Target = self_ty>.

N.B., there are cases this function returns true but causes an error to be emitted, particularly when receiver_ty derefs to a type that is the same as self_ty but has the wrong lifetime. Be careful of this if you are calling this function speculatively.