about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2017-12-12 14:21:10 -0500
committerNiko Matsakis <niko@alum.mit.edu>2017-12-13 12:20:28 -0500
commitf6723a9592e69419b1325faf5ffbbad2f8a6291a (patch)
tree9c4eb1ae363695b248fe14b6280a135eff5cfbe5
parent7a20a3f1619db092ac935a247ff06c6e03f20255 (diff)
downloadrust-f6723a9592e69419b1325faf5ffbbad2f8a6291a.tar.gz
rust-f6723a9592e69419b1325faf5ffbbad2f8a6291a.zip
improve comments on `safe_to_unsafe_fn_ty` and `coerce_closure_fn_ty`
-rw-r--r--src/librustc/ty/context.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs
index 441dd792ee1..1d538e1c167 100644
--- a/src/librustc/ty/context.rs
+++ b/src/librustc/ty/context.rs
@@ -1708,7 +1708,9 @@ slice_interners!(
 );
 
 impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
-    /// Create an unsafe fn ty based on a safe fn ty.
+    /// Given a `fn` type, returns an equivalent `unsafe fn` type;
+    /// that is, a `fn` type that is equivalent in every way for being
+    /// unsafe.
     pub fn safe_to_unsafe_fn_ty(self, sig: PolyFnSig<'tcx>) -> Ty<'tcx> {
         assert_eq!(sig.unsafety(), hir::Unsafety::Normal);
         self.mk_fn_ptr(sig.map_bound(|sig| ty::FnSig {
@@ -1717,7 +1719,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
         }))
     }
 
-    /// Create an unsafe fn ty based on a safe fn ty.
+    /// Given a closure signature `sig`, returns an equivalent `fn`
+    /// type with the same signature. Detuples and so forth -- so
+    /// e.g. if we have a sig with `Fn<(u32, i32)>` then you would get
+    /// a `fn(u32, i32)`.
     pub fn coerce_closure_fn_ty(self, sig: PolyFnSig<'tcx>) -> Ty<'tcx> {
         let converted_sig = sig.map_bound(|s| {
             let params_iter = match s.inputs()[0].sty {
@@ -1731,8 +1736,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
                 s.output(),
                 s.variadic,
                 hir::Unsafety::Normal,
-                abi::Abi::Rust
-                )
+                abi::Abi::Rust,
+            )
         });
 
         self.mk_fn_ptr(converted_sig)