Skip to content

[wip] add condition to check if the value is moved #56811

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

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions src/librustc_mir/borrow_check/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,23 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
);

if !is_loop_move {
err.span_label(
span,
format!(
"value {} here after move",
desired_action.as_verb_in_past_tense()
),
);
if used_place.is_prefix_of(&moved_place) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be checking that if, for any of the MoveSite in move_site_vec, the Place associated with that MoveSite is a prefix of used_place. I describe how to get the Place for a MoveSite in the mentor instructions.

err.span_label(
span,
format!(
"value {} here after partial move",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be able to change the message based on an if rather than the entire span_label call? ie.

err.span_label(
    span,
    format!(
        "value {} here{}",
        desired_action.as_verb_in_past_tense(),
        if is_partial_move { " after partial move" } else { "" },
    )
);

desired_action.as_verb_in_past_tense()
),
);
} else {
err.span_label(
span,
format!(
"value {} here after move",
desired_action.as_verb_in_past_tense()
),
);
}
}

if let Some(ty) = self.retrieve_type_for_place(used_place) {
Expand Down