-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #12693 - GuillaumeGomez:run-on-self-needless_pass_by_re…
…f_mut, r=Manishearth Emit the `needless_pass_by_ref_mut` lint on `self` arguments as well Fixes #12589. Fixes #9591. The first commit fixes a bug I uncovered while working on this: sometimes, the mutable borrow "event" happens before the alias one, which makes some argument detected as not used mutably even if they are. The fix was simply to fill the map with the aliases afterwards. The second commit removes the restriction to not run `self` argument for the `needless_pass_by_ref_mut` lint. changelog: emit the `needless_pass_by_ref_mut` lint on `self` arguments as well r? `@Manishearth`
- Loading branch information
Showing
6 changed files
with
180 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// If both `inner_async3` and `inner_async4` are present, aliases are declared after | ||
// they're used in `inner_async4` for some reasons... This test ensures that no | ||
// only `v` is marked as not used mutably in `inner_async4`. | ||
|
||
#![allow(clippy::redundant_closure_call)] | ||
#![warn(clippy::needless_pass_by_ref_mut)] | ||
|
||
pub async fn inner_async3(x: &i32, y: &mut u32) { | ||
//~^ ERROR: this argument is a mutable reference, but not used mutably | ||
async { | ||
*y += 1; | ||
} | ||
.await; | ||
} | ||
|
||
pub async fn inner_async4(u: &mut i32, v: &u32) { | ||
//~^ ERROR: this argument is a mutable reference, but not used mutably | ||
async { | ||
*u += 1; | ||
} | ||
.await; | ||
} | ||
|
||
fn main() {} |
Oops, something went wrong.