about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2017-11-14 17:12:16 -0500
committerNiko Matsakis <niko@alum.mit.edu>2017-11-16 05:58:00 -0500
commit11c84c6625d5e9374aa4f8a60b67c3c4a6f233b6 (patch)
treebd126d2c5644cc1c7e04ae40fde3af7fb1a64307
parent15739b820f95ea213870790e67ee04dc359192d1 (diff)
downloadrust-11c84c6625d5e9374aa4f8a60b67c3c4a6f233b6.tar.gz
rust-11c84c6625d5e9374aa4f8a60b67c3c4a6f233b6.zip
Nit: improve comment to explain why we wait until regionck
-rw-r--r--src/librustc/infer/outlives/obligations.rs22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/librustc/infer/outlives/obligations.rs b/src/librustc/infer/outlives/obligations.rs
index 32f09795668..6680de522e5 100644
--- a/src/librustc/infer/outlives/obligations.rs
+++ b/src/librustc/infer/outlives/obligations.rs
@@ -55,15 +55,19 @@
 //! type-check the closure body (e.g., here it informs us that `T`
 //! outlives the late-bound region `'a`).
 //!
-//! > That said, in writing this, I have come to wonder: this
-//!   inference dependency, I think, is only interesting for
-//!   late-bound regions in the closure -- if the region appears free
-//!   in the closure signature, then the relationship must be known to
-//!   the caller (here, `foo`), and hence could be verified earlier
-//!   up. Moreover, we infer late-bound regions quite early on right
-//!   now, i.e., only when the expected signature is known.  So we
-//!   *may* be able to sidestep this. Regardless, once the NLL
-//!   transition is complete, this concern will be gone. -nmatsakis
+//! Note that by delaying the gathering of implied bounds until all
+//! inference information is known, we may find relationships between
+//! bound regions and other regions in the environment. For example,
+//! when we first check a closure like the one expected as argument
+//! to `foo`:
+//!
+//! ```
+//! fn foo<U, F: for<'a> FnMut(&'a U)>(_f: F) {}
+//! ```
+//!
+//! the type of the closure's first argument would be `&'a ?U`.  We
+//! might later infer `?U` to something like `&'b u32`, which would
+//! imply that `'b: 'a`.
 
 use hir::def_id::DefId;
 use infer::{self, GenericKind, InferCtxt, RegionObligation, SubregionOrigin, VerifyBound};