-
Notifications
You must be signed in to change notification settings - Fork 13.3k
MIR borrowck: error message confuses locals and temporaries #46598
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
Conversation
I'm also not sure that the condition I'm checking is what I should be using for this, but it works.
I think it might also be worth splitting the |
I've fixed issues referenced in my previous comment and also fixed #46472 as mentioned in this Gitter comment. I think the function might be getting a bit a unwieldly since it's handling a bunch of cases. I've adjusted tests to allow the handful of places where spans are off by a character. |
src/librustc_mir/borrow_check/mod.rs
Outdated
err.emit(); | ||
match &self.describe_place(place) { | ||
Some(description) => { | ||
let mut err = self.tcx.path_does_not_live_long_enough( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't handle the case where a local needs to live until an end_span
, aka
let x = {
let y = 0;
&y
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should now be being handled.
📌 Commit e1723d2 has been approved by |
@bors p=0 This hasn't passed travis yet |
@bors r- Travis failed.
|
I've fixed the previous issue where a local might need to live until an |
I've updated the existing tests to use the new error messages. This should now pass Travis. |
src/librustc_mir/borrow_check/mod.rs
Outdated
// See test ui/issue-46471.rs for this case. | ||
RegionKind::ReEarlyBound(_) | RegionKind::ReFree(_) => proper_span, | ||
// See test compile-fail/issue-36082.rs for this case. | ||
_ if name == "borrowed value" => span, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use if !with_name
src/librustc_mir/borrow_check/mod.rs
Outdated
}; | ||
|
||
let mut err = self.tcx.path_does_not_live_long_enough(err_span, &name, Origin::Mir); | ||
match borrow.region { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There looks to be quite some connection between the span and the error message, so I would prefer to have 4 separate functions - 1 for each distinct error messagee
Travis is still failing.
If nothing goes wrong, #46558 will be merged soon, so you'll likely need to rebase. |
We're working on it. |
☔ The latest upstream changes (presumably #46558) made this pull request unmergeable. Please resolve the merge conflicts. |
All previous issues should be resolved and it's now rebased on top of the current master (or as of an hour ago). |
}, | ||
// This case should not happen. | ||
RegionKind::ReLateBound(_, _) | RegionKind::ReSkolemized(_, _) | | ||
RegionKind::ReErased => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: indentation
Alright, fifth time lucky. I've fixed the indentation and other requested changes from Gitter and updated the failing tests from the recent Travis run. |
That's cool! @bors r+ |
📌 Commit 3dbc11b has been approved by |
MIR borrowck: error message confuses locals and temporaries Fixes #46471 and fixes #46472 (see [this Gitter comment](https://gitter.im/rust-impl-period/WG-compiler-nll?at=5a2d5cb53ae2aa6b3facf0c2)). r? @arielb1
☀️ Test successful - status-appveyor, status-travis |
Fixes #46471 and fixes #46472 (see this Gitter comment).
r? @arielb1