rustc: add docs to FnAbi::{of_fn_ptr,of_instance} and InstanceDef::Virtual.

This commit is contained in:
Eduard-Mihai Burtescu 2019-11-27 13:59:59 +02:00
parent 9da14a82c6
commit c2f4c57296
2 changed files with 16 additions and 1 deletions

View File

@ -42,7 +42,11 @@ pub enum InstanceDef<'tcx> {
/// `DefId` is `FnTrait::call_*`.
FnPtrShim(DefId, Ty<'tcx>),
/// `<dyn Trait as Trait>::fn`
/// `<dyn Trait as Trait>::fn`, "direct calls" of which are implicitly
/// codegen'd as virtual calls.
///
/// NB: if this is reified to a `fn` pointer, a `ReifyShim` is used
/// (see `ReifyShim` above for more details on that).
Virtual(DefId, usize),
/// `<[mut closure] as FnOnce>::call_once`

View File

@ -2417,8 +2417,19 @@ where
+ HasTyCtxt<'tcx>
+ HasParamEnv<'tcx>,
{
/// Compute a `FnAbi` suitable for indirect calls, i.e. to `fn` pointers.
///
/// NB: this doesn't handle virtual calls - those should use `FnAbi::of_instance`
/// instead, where the instance is a `InstanceDef::Virtual`.
fn of_fn_ptr(cx: &C, sig: ty::PolyFnSig<'tcx>, extra_args: &[Ty<'tcx>]) -> Self;
/// Compute a `FnAbi` suitable for declaring/defining an `fn` instance, and for
/// direct calls to an `fn`.
///
/// NB: that includes virtual calls, which are represented by "direct calls"
/// to a `InstanceDef::Virtual` instance (of `<dyn Trait as Trait>::fn`).
fn of_instance(cx: &C, instance: ty::Instance<'tcx>, extra_args: &[Ty<'tcx>]) -> Self;
fn new_internal(
cx: &C,
sig: ty::PolyFnSig<'tcx>,