Auto merge of #8552 - Jarcho:ptr_arg_8495, r=xFrednet

Don't lint `ptr_arg` on `&mut Cow<_>`

fixes: #8495

changelog: Don't lint `ptr_arg` on `&mut Cow<_>`
This commit is contained in:
bors 2022-03-17 17:05:26 +00:00
commit 8d5c0eadde
2 changed files with 8 additions and 1 deletions

View file

@ -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 {

View file

@ -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");
}
}