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

new lint: unnecessary_ref_mut #12361

Open
TennyZhuang opened this issue Feb 27, 2024 · 1 comment
Open

new lint: unnecessary_ref_mut #12361

TennyZhuang opened this issue Feb 27, 2024 · 1 comment
Assignees
Labels
A-lint Area: New lints

Comments

@TennyZhuang
Copy link
Contributor

TennyZhuang commented Feb 27, 2024

What it does

Check value that are matched by ref mut but only immutable methods are called.

Advantage

  • Reduce unnecessary mutability

Drawbacks

No response

Example

struct S;
impl S {
    fn f(&self) {}
}
fn main() {
    let mut x = Some(S);
    if let Some(ref mut y) = x {
        y.f();
    }
}

Could be written as:

struct S;
impl S {
    fn f(&self) {}
}
fn main() {
    let mut x = Some(S);
    if let Some(ref y) = x {
        y.f();
    }
}
@TennyZhuang TennyZhuang added the A-lint Area: New lints label Feb 27, 2024
@not-elm
Copy link

not-elm commented Feb 29, 2024

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

No branches or pull requests

2 participants