Skip to content

Commit b72e451

Browse files
committed
Auto merge of #9684 - kraktus:ref_option_ref, r=xFrednet
`ref_option_ref` do not lint when inner reference is mutable changelog: FP: [`ref_option_ref`]: No longer lints if the inner reference is mutable fix #9682
2 parents b2e5a71 + 615b761 commit b72e451

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Diff for: clippy_lints/src/ref_option_ref.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ impl<'tcx> LateLintPass<'tcx> for RefOptionRef {
5252
GenericArg::Type(inner_ty) => Some(inner_ty),
5353
_ => None,
5454
});
55-
if let TyKind::Rptr(_, _) = inner_ty.kind;
55+
if let TyKind::Rptr(_, ref inner_mut_ty) = inner_ty.kind;
56+
if inner_mut_ty.mutbl == Mutability::Not;
5657

5758
then {
5859
span_lint_and_sugg(

Diff for: tests/ui/ref_option_ref.rs

+5
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,8 @@ impl RefOptTrait for u32 {
4545
fn main() {
4646
let x: &Option<&u32> = &None;
4747
}
48+
49+
fn issue9682(arg: &Option<&mut String>) {
50+
// Should not lint, as the inner ref is mutable making it non `Copy`
51+
println!("{arg:?}");
52+
}

0 commit comments

Comments
 (0)