|
55 | 55 | //! type-check the closure body (e.g., here it informs us that `T` |
56 | 56 | //! outlives the late-bound region `'a`). |
57 | 57 | //! |
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`. |
67 | 71 |
|
68 | 72 | use hir::def_id::DefId; |
69 | 73 | use infer::{self, GenericKind, InferCtxt, RegionObligation, SubregionOrigin, VerifyBound}; |
|
0 commit comments