-
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
fixes move analysis #49392
fixes move analysis #49392
Conversation
librustc_mir/transform/elaborate_drops.rs — drop of untracked, uninitialized value Fix #48962 r? @nikomatsakis
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Ping from triage, @nikomatsakis ! Will you have time to review this soon? |
src/librustc_mir/borrow_check/mod.rs
Outdated
@@ -1454,8 +1492,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { | |||
Place::Projection(ref proj) => { | |||
let Projection { ref base, ref elem } = **proj; | |||
match *elem { | |||
ProjectionElem::Deref | | |||
// assigning to *P requires `P` initialized. | |||
ProjectionElem::Index(_/*operand*/) | | |||
ProjectionElem::ConstantIndex { .. } | | |||
// assigning to P[i] requires `P` initialized. |
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 comment is wrong. Should be
// assigning to P[i] requires P to be valid
src/librustc_mir/borrow_check/mod.rs
Outdated
@@ -1465,6 +1501,12 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { | |||
// FIXME: is this true even if P is a adt with a dtor? | |||
{ } | |||
|
|||
ProjectionElem::Deref => { |
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.
Should have a comment
// assigning to (*P) requires P to be initialized
src/librustc_mir/borrow_check/mod.rs
Outdated
ProjectionElem::Deref => { | ||
self.check_if_path_is_moved( | ||
context, InitializationRequiringAction::Use, | ||
(base, span), flow_state); |
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.
You can add a break
here if you want - we already force the base to be initialized, so there is no need to further check.
Maybe in that case you would also not need the new error deduplication code.
@@ -1320,18 +1324,17 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { | |||
// |
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.
Maybe rename check_if_path_is_moved
to check_if_full_path_is_moved
?
Sorry for the delay in reviewing. This is a bit of an embarrassing bug. If adding a |
@arielb1 Unfortunately adding a break won't fix duplicate errors. Let's have expression
the first error is printed from |
@retep007 In that case, could you deduplicate based on |
.contains(&root_place.clone()) | ||
{ | ||
debug!( | ||
"report_use_of_moved_or_uninitialized place: {:?} errors was suppressed", |
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.
english fix: error about {:?}
suppressed.
I think this code is OK, but I didn't touch this code long enough that I would rather |
@arielb1 I also think that second error actually says better what's the problem, but It would require to first refactor how the errors are reported.
Second:
|
place_span: (&Place<'tcx>, Span), | ||
flow_state: &Flows<'cx, 'gcx, 'tcx>, | ||
) { | ||
// FIXME: analogous code in check_loans first maps `place` to |
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.
what code are you referring to exactly?
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.
Exactly same code let place = self.base_path(place_span.0);
is in check_if_full_path_is_moved
also with the comment. So If somebody decides to refactor this he will probably do both check_if_full_path_is_moved
, check_if_path_or_subpath_is_moved
This code looks good to me! |
@bors r=nikomatsakis |
@retep007: 🔑 Insufficient privileges: Not in reviewers |
@nikomatsakis Could you also accept it by bors? |
@bors r=nikomatsakis |
📌 Commit 9056c7a has been approved by |
@bors p=6 |
fixes move analysis Fixed compiler error by correct checking when dereferencing Fix #48962 r? @nikomatsakis
☀️ Test successful - status-appveyor, status-travis |
Fixed compiler error by correct checking when dereferencing
Fix #48962
r? @nikomatsakis