Skip to content

reborrow or copy-then-borrow #13967

Open
@bingmatv

Description

@bingmatv

What it does

Warn when the code tries to copy the value behind a reference, then borrow the copy.

Advantage

No response

Drawbacks

No response

Example

fn main() {
    let a = &[0u8; 2];
    let r = &mut { *a };
}

Similar to https://users.rust-lang.org/t/runtime-speed-when-converting-as-bytes-or-as-ref-to-be-mut/123712/10 that tries to convert a reference to mutably borrow.

Metadata

Metadata

Assignees

Labels

A-lintArea: New lints

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions