-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Nightly regression: Incorrect "parameter type may not live long enough" warning #29048
Comments
(this may be a compiler issue or a lang issue; tagging with both teams until that Q is resolved) |
Another testcase, which I think is the same issue: pub struct Chan;
pub struct ChanSelect<'c, T> {
chans: Vec<(&'c Chan, T)>,
}
impl<'c, T> ChanSelect<'c, T> {
pub fn add_recv_ret(&mut self, chan: &'c Chan, ret: T)
{
self.chans.push((chan, ret));
}
}
fn main() {} |
triage: I-nominated |
I've not fully investigated, but problem is almost certainly a missing call to outlives, similar to #29006 |
Hmm, problem seems to be related to a late-bound region instantiated during the probing phase. We wind up adding a region obligation. I will continue investigating, but definitely the fact that probe leaks variables is worrisome (I may also be getting a bit confused). (As an aside, I wonder if rewriting region inference isn't part of the fix here; the current contraction behavior isn't really doing anyone any favors, and there are many other known deficiencies.) |
I think this would be fixed by #26324 - I should try to check. |
triage: P-high Assigning to myself. The problem has to do with a lifetime parameter being created as part of the autoderef loop during method probing. Best fix might be to isolate probing, if we can, but there are other workarounds we could put in place. Improving region compilation would be good too. Not sure what I think is the preferred fix just now. |
Annoyingly, the problem variables aren't used in a stack-like way, so #26324 etc. can't really work, unless we refactor method probing. |
So I tend to agree that a transactional approach is the right thing here (and, indeed, |
OK, I've verified that modifying the region inference scheme does indeed solve the regression, though I agree that it's sort of a workaround, in that we really ought not to be solving these constraints in the first place. |
empty region, and they complicate region inference to no particular end. They also lead in some cases to spurious errors like rust-lang#29048 (though in some cases these errors are helpful in tracking down missing constraints).
This fixes #29048 (though I think adding better transactional support would be a better fix for that issue, but that is more difficult). It also simplifies region inference and changes the model to a pure data flow one, as discussed in [this internals thread](https://internals.rust-lang.org/t/rough-thoughts-on-the-impl-of-region-inference-mir-etc/2800). I am not 100% sure though if this PR is the right thing to do -- or at least maybe not at this moment, so thoughts on that would be appreciated. r? @pnkfelix cc @arielb1
empty region, and they complicate region inference to no particular end. They also lead in some cases to spurious errors like rust-lang#29048 (though in some cases these errors are helpful in tracking down missing constraints).
Testcase:
This gives no warnings on beta or stable.
The text was updated successfully, but these errors were encountered: