Skip to content

cannot move out of borrowed content error is bad when self is borrowed #43161

Open
@nrc

Description

@nrc

E.g., consider a struct with a field build_queue which is owned. In a &self function I call request_build which takes self by value. I get the error:

error[E0507]: cannot move out of borrowed content
   --> src/actions/mod.rs:151:9
    |
151 |         self.build_queue.request_build(project_path, priority, move |result| {
    |         ^^^^ cannot move out of borrowed content

This is not very useful since it does not indicate why a move is happening and the squiggle is indicating the wrong thing. I think the squiggle should be under self.build_queue rather than just self and that there should be a note referring to the definition of request_build and indicating the by-value self which causes the move.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-borrow-checkerArea: The borrow checkerA-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions