Skip to content

Commit

Permalink
rustc: add docs to FnAbi::{of_fn_ptr,of_instance} and InstanceDef::Vi…
Browse files Browse the repository at this point in the history
…rtual.
  • Loading branch information
eddyb committed Dec 3, 2019
1 parent 9da14a8 commit c2f4c57
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/librustc/ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
11 changes: 11 additions & 0 deletions src/librustc/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down

0 comments on commit c2f4c57

Please sign in to comment.