-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
A-lintArea: New lintsArea: New lints
Description
What it does
It warns against using &mut
in an parameter where &
would suffice.
Lint Name
unnecessary-mut-ref
Category
suspicious
Advantage
Less mut
means less fights with the borrow checker. It can also lead to more opportunities for parallelization.
This lint could also catch bugs where the user intended to mutate an argument but forgot too.
Drawbacks
A user may want to create an API where they reserve the right to mutate an argument, but does not do so yet.
We should not warn when implementing a trait
.
Example
fn foo(&mut self, y: &mut i32) -> i32 {
self.x + *y
}
Could be written as:
fn foo(&self, y: &i32) -> i32 {
self.x + *y
}
martinthomson, didibear, capickett, jeffy1009, bitnorbert and 24 more
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lints