diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2021-04-08 10:56:03 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2021-04-08 10:56:03 -0400 |
| commit | c1dc0b7bbc239290388d2365c6d0b282e299bdbc (patch) | |
| tree | 6686450c01a7a706ba0d0af66a492243f93f0dff /compiler/rustc_resolve | |
| parent | 1a14315975224951bc993455783678154afade09 (diff) | |
| download | rust-c1dc0b7bbc239290388d2365c6d0b282e299bdbc.tar.gz rust-c1dc0b7bbc239290388d2365c6d0b282e299bdbc.zip | |
add comments
Diffstat (limited to 'compiler/rustc_resolve')
| -rw-r--r-- | compiler/rustc_resolve/src/late/lifetimes.rs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/compiler/rustc_resolve/src/late/lifetimes.rs b/compiler/rustc_resolve/src/late/lifetimes.rs index a6dceddb435..91bc8ab5ef4 100644 --- a/compiler/rustc_resolve/src/late/lifetimes.rs +++ b/compiler/rustc_resolve/src/late/lifetimes.rs @@ -2343,7 +2343,18 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { Scope::TraitRefBoundary { s, .. } => { // We've exited nested poly trait refs; mark that we are no longer in nested trait refs. - // We don't increase the late depth because this isn't a `Binder` scope + // We don't increase the late depth because this isn't a `Binder` scope. + // + // This came up in #83737, which boiled down to a case like this: + // + // ``` + // F: for<> Fn(&()) -> Box<dyn for<> Future<Output = ()> + Unpin>, + // // ^^^^^ + + // ``` + // + // Here, as we traverse upwards from the `dyn for<>` binder, we want to reset `in_poly_trait_ref` + // to false, so that we avoid excess contaenation when we encounter the outer `for<>` binder. in_poly_trait_ref = false; scope = s; } @@ -2369,6 +2380,17 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { // We've already seen a binder that is a poly trait ref and this one is too, // that means that they are nested and we are concatenating the bound vars; // don't increase the late depth. + // + // This happens specifically with associated trait bounds like the following: + // + // ``` + // for<'a> T: Iterator<Item: for<'b> Foo<'a, 'b>> + // ``` + // + // In this case, as we traverse `for<'b>`, we would increment `late_depth` but + // set `in_poly_trait_ref` to true. Then when we traverse `for<'a>`, we would + // not increment `late_depth` again. (NB: Niko thinks this logic is actually + // wrong.) (true, true) => {} // We've exited nested poly trait refs; add one to the late depth and mark // that we are no longer in nested trait refs |
