Skip to content

suggestions for or_fun_call can cause a borrowck error: #6761

Open

Description

error[E0500]: closure requires unique access to `this` but it is already borrowed
    --> src/simple_api/mod.rs:1150:55
     |
1147 |         unsafe fn get_last_buffer(this: &mut Key) -> &mut Vec<u8> {
     |                                         - let's call the lifetime of this reference `'1`
...
1150 |             this.subscripts.last_mut().unwrap_or_else(|| this.variable.as_mut_vec())
     |             ------------------------------------------^^----------------------------
     |             |                                         |  |
     |             |                                         |  second borrow occurs due to use of `this` in closure
     |             |                                         closure construction occurs here
     |             borrow occurs here
     |             returning this value requires that `this.subscripts` is borrowed for `'1`

Originally posted by @jyn514 in #6675 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingE-hardCall for participation: This a hard problem and requires more experience or effort to work onI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedL-suggestionLint: Improving, adding or fixing lint suggestions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions