about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2019-10-02 14:32:19 -0400
committerNiko Matsakis <niko@alum.mit.edu>2019-10-02 14:32:19 -0400
commit5d64b3d329cdd0452dc2fde1435998bd3e036538 (patch)
tree79031b38b3143a46163d61e17c2fa6756e274be2
parenta9991321135e0b6cfcc95c91b738879f68c4cf7c (diff)
downloadrust-5d64b3d329cdd0452dc2fde1435998bd3e036538.tar.gz
rust-5d64b3d329cdd0452dc2fde1435998bd3e036538.zip
document `ret_coercion` and `ret_coercion_span`
-rw-r--r--src/librustc_typeck/check/mod.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index 3ccb5f2ee5b..b1de54c692d 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -562,7 +562,19 @@ pub struct FnCtxt<'a, 'tcx> {
     // if type checking is run in parallel.
     err_count_on_creation: usize,
 
+    /// If `Some`, this stores coercion information for returned
+    /// expressions. If `None`, this is in a context where return is
+    /// inappropriate, such as a const expression.
+    ///
+    /// This is a `RefCell<DynamicCoerceMany>`, which means that we
+    /// can track all the return expressions and then use them to
+    /// compute a useful coercion from the set, similar to a match
+    /// expression or other branching context. You can use methods
+    /// like `expected_ty` to access the declared return type (if
+    /// any).
     ret_coercion: Option<RefCell<DynamicCoerceMany<'tcx>>>,
+
+    /// First span of a return site that we find. Used in error messages.
     ret_coercion_span: RefCell<Option<Span>>,
 
     yield_ty: Option<Ty<'tcx>>,