Skip to content

Commit

Permalink
Auto merge of rust-lang#8552 - Jarcho:ptr_arg_8495, r=xFrednet
Browse files Browse the repository at this point in the history
Don't lint `ptr_arg` on `&mut Cow<_>`

fixes: rust-lang#8495

changelog: Don't lint `ptr_arg` on `&mut Cow<_>`
  • Loading branch information
bors committed Mar 17, 2022
2 parents 65e5cd0 + 851e715 commit 8d5c0ea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clippy_lints/src/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
DerefTy::Path,
None,
),
Some(sym::Cow) => {
Some(sym::Cow) if mutability == Mutability::Not => {
let ty_name = name.args
.and_then(|args| {
args.args.iter().find_map(|a| match a {
Expand Down
7 changes: 7 additions & 0 deletions tests/ui/ptr_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,10 @@ fn two_vecs(a: &mut Vec<u32>, b: &mut Vec<u32>) {
a.push(0);
b.push(1);
}

// Issue #8495
fn cow_conditional_to_mut(a: &mut Cow<str>) {
if a.is_empty() {
a.to_mut().push_str("foo");
}
}

0 comments on commit 8d5c0ea

Please sign in to comment.