Closed
Description
Summary
The lint tells you to use Option<&T>
instead of &Option<&T>
because the former is Copy
so there's no point in passing around references. However, the lint seems to also triggers for &Option<&mut T>
and tells you to use Option<&mut T>
instead, which is not Copy
.
Lint Name
ref_option_ref
Reproducer
I tried this code:
fn foo(arg: &Option<&mut String>) {
println!("{:?}", arg);
}
I saw this happen:
since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>`
I expected to see this happen:
No lint warnings.
Version
rustc 1.64.0 (a55dd71d5 2022-09-19)
binary: rustc
commit-hash: a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52
commit-date: 2022-09-19
host: x86_64-pc-windows-msvc
release: 1.64.0
LLVM version: 14.0.6
Additional Labels
@rustbot label +l-suggestion-causes-error