Skip to content

Commit 11c84c6

Browse files
committed
Nit: improve comment to explain why we wait until regionck
1 parent 15739b8 commit 11c84c6

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/librustc/infer/outlives/obligations.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,19 @@
5555
//! type-check the closure body (e.g., here it informs us that `T`
5656
//! outlives the late-bound region `'a`).
5757
//!
58-
//! > That said, in writing this, I have come to wonder: this
59-
//! inference dependency, I think, is only interesting for
60-
//! late-bound regions in the closure -- if the region appears free
61-
//! in the closure signature, then the relationship must be known to
62-
//! the caller (here, `foo`), and hence could be verified earlier
63-
//! up. Moreover, we infer late-bound regions quite early on right
64-
//! now, i.e., only when the expected signature is known. So we
65-
//! *may* be able to sidestep this. Regardless, once the NLL
66-
//! transition is complete, this concern will be gone. -nmatsakis
58+
//! Note that by delaying the gathering of implied bounds until all
59+
//! inference information is known, we may find relationships between
60+
//! bound regions and other regions in the environment. For example,
61+
//! when we first check a closure like the one expected as argument
62+
//! to `foo`:
63+
//!
64+
//! ```
65+
//! fn foo<U, F: for<'a> FnMut(&'a U)>(_f: F) {}
66+
//! ```
67+
//!
68+
//! the type of the closure's first argument would be `&'a ?U`. We
69+
//! might later infer `?U` to something like `&'b u32`, which would
70+
//! imply that `'b: 'a`.
6771
6872
use hir::def_id::DefId;
6973
use infer::{self, GenericKind, InferCtxt, RegionObligation, SubregionOrigin, VerifyBound};

0 commit comments

Comments
 (0)