-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect illegal hidden lifetimes in impl Trait
#49041
Detect illegal hidden lifetimes in impl Trait
#49041
Conversation
12f01cd
to
3901391
Compare
Ping from triage @cramertj! This PR needs your review. |
This seems fine to me so far, but I think @nikomatsakis was going to push some updates to the behavior of lifetimes inside of closures. @nikomatsakis is that still your plan? |
@cramertj I did that already |
Is the remaining travis failure ( |
@cramertj I saw it now, I'll go try and fix it |
3901391
to
60b9558
Compare
(@nikomatsakis travis is still mad) |
@cramertj yeah I didn't start trying to fix it yet :) |
But leave closure substs alone.
We used to make the upvar types in the closure `==` but that was stronger than we needed. Subtyping suffices, since we are copying the upvar value into the closure field. This in turn allows us to infer smaller lifetimes in captured values in some cases (like the example here), avoiding errors.
60b9558
to
9d5ec9e
Compare
@cramertj ok fixed now (I think) |
impl Trait
impl Trait
Travis still red. |
Yeah, spoke a bit prematurely. I fixed a few more things. |
(@nikomatsakis just in case you weren't aware, this is still red) |
@bors r+ p=10 |
📌 Commit 2e8a1ab has been approved by |
…etimes, r=cramertj Detect illegal hidden lifetimes in `impl Trait` This branch fixes #46541 -- however, it presently doesn't build because it also *breaks* a number of existing usages of impl Trait. I'm opening it as a WIP for now, just because we want to move on impl Trait, but I'll try to fix the problem in a bit. ~~(The problem is due to the fact that we apparently infer stricter lifetimes in closures that we need to; for example, if you capture a variable of type `&'a &'b u32`, we will put *precisely* those lifetimes into the closure, even if the closure would be happy with `&'a &'a u32`. This causes the present chance to affect things that are not invariant.)~~ fixed r? @cramertj
☀️ Test successful - status-appveyor, status-travis |
…atsakis Stabilize impl Trait Blocked on: - [x] rust-lang#49041 and - [ ] completion of FCP in rust-lang#34511 (comment) (3 days from now). I have not yet done any docs work for this-- I probably won't get to it until this weekend (might be a project for the flight to the all-hands).
Stabilize impl Trait Blocked on: - [x] #49041 and - [ ] completion of FCP in #34511 (comment) (3 days from now). I have not yet done any docs work for this-- I probably won't get to it until this weekend (might be a project for the flight to the all-hands).
This branch fixes #46541 -- however, it presently doesn't build because it also breaks a number of existing usages of impl Trait. I'm opening it as a WIP for now, just because we want to move on impl Trait, but I'll try to fix the problem in a bit.
(The problem is due to the fact that we apparently infer stricter lifetimes in closures that we need to; for example, if you capture a variable of typefixed&'a &'b u32
, we will put precisely those lifetimes into the closure, even if the closure would be happy with&'a &'a u32
. This causes the present chance to affect things that are not invariant.)r? @cramertj