Skip to content

Commit 1d93c61

Browse files
committed
add a doc comment on receiver_is_valid
1 parent 153f5a7 commit 1d93c61

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/librustc_typeck/check/wfcheck.rs

+8
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,14 @@ fn check_method_receiver<'fcx, 'gcx, 'tcx>(fcx: &FnCtxt<'fcx, 'gcx, 'tcx>,
795795
}
796796
}
797797

798+
/// returns true if `receiver_ty` would be considered a valid receiver type for `self_ty`. If
799+
/// `arbitrary_self_types` is enabled, `receiver_ty` must transitively deref to `self_ty`, possibly
800+
/// through a `*const/mut T` raw pointer. If the feature is not enabled, the requirements are more
801+
/// strict: `receiver_ty` must implement `Receiver` and directly implement `Deref<Target=self_ty>`.
802+
///
803+
/// NB: there are cases this function returns `true` but then causes an error to be raised later,
804+
/// particularly when `receiver_ty` derefs to a type that is the same as `self_ty` but has the
805+
/// wrong lifetime.
798806
fn receiver_is_valid<'fcx, 'tcx, 'gcx>(
799807
fcx: &FnCtxt<'fcx, 'gcx, 'tcx>,
800808
span: Span,

0 commit comments

Comments
 (0)