mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-08 09:38:26 +03:00
ref_option_ref do not lint when inner reference is mutable
As it makes the `Option` Non Copy
This commit is contained in:
@@ -52,7 +52,8 @@ fn check_ty(&mut self, cx: &LateContext<'tcx>, ty: &'tcx Ty<'tcx>) {
|
||||
GenericArg::Type(inner_ty) => Some(inner_ty),
|
||||
_ => None,
|
||||
});
|
||||
if let TyKind::Rptr(_, _) = inner_ty.kind;
|
||||
if let TyKind::Rptr(_, ref inner_mut_ty) = inner_ty.kind;
|
||||
if inner_mut_ty.mutbl == Mutability::Not;
|
||||
|
||||
then {
|
||||
span_lint_and_sugg(
|
||||
|
||||
@@ -45,3 +45,8 @@ fn foo(&self, _: Self::A) {}
|
||||
fn main() {
|
||||
let x: &Option<&u32> = &None;
|
||||
}
|
||||
|
||||
fn issue9682(arg: &Option<&mut String>) {
|
||||
// Should not lint, as the inner ref is mutable making it non `Copy`
|
||||
println!("{arg:?}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user