Skip to content
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

MIR borrowck error message talks about "cannot move out of borrowed_content" (instead of "borrowed content") #46018

Closed
arielb1 opened this issue Nov 15, 2017 · 2 comments
Labels
A-borrow-checker Area: The borrow checker A-diagnostics Area: Messages for errors, warnings, and lints E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@arielb1
Copy link
Contributor

arielb1 commented Nov 15, 2017

let move_data: MoveData<'tcx> = match MoveData::gather_moves(input_mir, tcx, param_env) {
Ok(move_data) => move_data,
Err((move_data, move_errors)) => {
for move_error in move_errors {
let (span, kind): (Span, IllegalMoveOriginKind) = match move_error {
MoveError::UnionMove { .. } =>
unimplemented!("dont know how to report union move errors yet."),
MoveError::IllegalMove { cannot_move_out_of: o } => (o.span, o.kind),
};
let origin = Origin::Mir;
let mut err = match kind {
IllegalMoveOriginKind::Static =>
tcx.cannot_move_out_of(span, "static item", origin),
IllegalMoveOriginKind::BorrowedContent =>
tcx.cannot_move_out_of(span, "borrowed_content", origin),
IllegalMoveOriginKind::InteriorOfTypeWithDestructor { container_ty: ty } =>
tcx.cannot_move_out_of_interior_of_drop(span, ty, origin),
IllegalMoveOriginKind::InteriorOfSliceOrArray { ty, is_index } =>
tcx.cannot_move_out_of_interior_noncopy(span, ty, is_index, origin),
};
err.emit();
}
move_data
}

This appears e.g. in

struct S;
fn main() {
    let a = &mut S;
    let b = *a;
}

and also in the test src/test/compile-fail/borrowck/borrowck-for-loop-correct-cmt-for-pattern.rs

@arielb1 arielb1 added A-borrow-checker Area: The borrow checker A-diagnostics Area: Messages for errors, warnings, and lints E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. WG-compiler-nll labels Nov 15, 2017
@anrddh
Copy link

anrddh commented Nov 16, 2017

I can take care of this!

kennytm added a commit to kennytm/rust that referenced this issue Nov 20, 2017
Fix typo in MIR "cannot move out of borrowed content"

I believe this all we need to change (rust-lang#46018). Anyway, do let me know if there is anything else that needs to changed as well!
@ritiek
Copy link
Member

ritiek commented Nov 24, 2017

This issue can be closed now.

@arielb1 arielb1 closed this as completed Dec 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-borrow-checker Area: The borrow checker A-diagnostics Area: Messages for errors, warnings, and lints E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

3 participants