]> git.lizzy.rs Git - rust.git/commitdiff
add comment clarifying what edges are needed
authorNiko Matsakis <niko@alum.mit.edu>
Thu, 17 Mar 2016 13:55:10 +0000 (09:55 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Fri, 18 Mar 2016 20:38:29 +0000 (16:38 -0400)
src/librustc_typeck/check/coercion.rs

index 1f7265bdb4ddfbcc8119544a36befa1b2ed97d51..a2c0b5b89342c353b8cf9f752007afd5d283bf1d 100644 (file)
@@ -278,6 +278,14 @@ fn coerce_borrowed_pointer<'a, E, I>(&self,
             //   want to use that target type region (`'b`) because --
             //   for the program to type-check -- it must be the
             //   smaller of the two.
+            //   - One fine point. It may be surprising that we can
+            //     use `'b` without relating `'a` and `'b`. The reason
+            //     that this is ok is that what we produce is
+            //     effectively a `&'b *x` expression (if you could
+            //     annotate the region of a borrow), and regionck has
+            //     code that adds edges from the region of a borrow
+            //     (`'b`, here) into the regions in the borrowed
+            //     expression (`*x`, here).  (Search for "link".)
             // - if in lub mode, things can get fairly complicated. The
             //   easiest thing is just to make a fresh
             //   region variable [4], which effectively means we defer