about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEduard-Mihai Burtescu <edy.burt@gmail.com>2019-11-27 13:59:59 +0200
committerEduard-Mihai Burtescu <edy.burt@gmail.com>2019-12-03 15:55:21 +0200
commitc2f4c57296f0d929618baed0b0d6eb594abf01eb (patch)
treeebc654ad31710cf004d22ffc974dfd6c16ec288e
parent9da14a82c6d2b69eb191c13776f2974d292168e9 (diff)
downloadrust-c2f4c57296f0d929618baed0b0d6eb594abf01eb.tar.gz
rust-c2f4c57296f0d929618baed0b0d6eb594abf01eb.zip
rustc: add docs to FnAbi::{of_fn_ptr,of_instance} and InstanceDef::Virtual.
-rw-r--r--src/librustc/ty/instance.rs6
-rw-r--r--src/librustc/ty/layout.rs11
2 files changed, 16 insertions, 1 deletions
diff --git a/src/librustc/ty/instance.rs b/src/librustc/ty/instance.rs
index f270d3d3a2a..801dfa81ef1 100644
--- a/src/librustc/ty/instance.rs
+++ b/src/librustc/ty/instance.rs
@@ -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`
diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs
index 4d48c784145..7f93e8c91e9 100644
--- a/src/librustc/ty/layout.rs
+++ b/src/librustc/ty/layout.rs
@@ -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>,