Skip to content

Commit 0232114

Browse files
committed
rustc: add docs to FnAbi::{of_fn_ptr,of_instance} and InstanceDef::Virtual.
1 parent 3315d70 commit 0232114

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/librustc/ty/instance.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ pub enum InstanceDef<'tcx> {
4242
/// `DefId` is `FnTrait::call_*`.
4343
FnPtrShim(DefId, Ty<'tcx>),
4444

45-
/// `<dyn Trait as Trait>::fn`
45+
/// `<dyn Trait as Trait>::fn`, "direct calls" of which are implicitly
46+
/// codegen'd as virtual calls.
47+
///
48+
/// NB: if this is reified to a `fn` pointer, a `ReifyShim` is used
49+
/// (see `ReifyShim` above for more details on that).
4650
Virtual(DefId, usize),
4751

4852
/// `<[mut closure] as FnOnce>::call_once`

src/librustc/ty/layout.rs

+11
Original file line numberDiff line numberDiff line change
@@ -2417,8 +2417,19 @@ where
24172417
+ HasTyCtxt<'tcx>
24182418
+ HasParamEnv<'tcx>,
24192419
{
2420+
/// Compute a `FnAbi` suitable for indirect calls, i.e. to `fn` pointers.
2421+
///
2422+
/// NB: this doesn't handle virtual calls - those should use `FnAbi::of_instance`
2423+
/// instead, where the instance is a `InstanceDef::Virtual`.
24202424
fn of_fn_ptr(cx: &C, sig: ty::PolyFnSig<'tcx>, extra_args: &[Ty<'tcx>]) -> Self;
2425+
2426+
/// Compute a `FnAbi` suitable for declaring/defining an `fn` instance, and for
2427+
/// direct calls to an `fn`.
2428+
///
2429+
/// NB: that includes virtual calls, which are represented by "direct calls"
2430+
/// to a `InstanceDef::Virtual` instance (of `<dyn Trait as Trait>::fn`).
24212431
fn of_instance(cx: &C, instance: ty::Instance<'tcx>, extra_args: &[Ty<'tcx>]) -> Self;
2432+
24222433
fn new_internal(
24232434
cx: &C,
24242435
sig: ty::PolyFnSig<'tcx>,

0 commit comments

Comments
 (0)