mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-15 01:17:16 +00:00
22 lines
472 B
Rust
22 lines
472 B
Rust
|
#![warn(clippy::option_as_ref_cloned)]
|
||
|
#![allow(clippy::clone_on_copy)]
|
||
|
|
||
|
fn main() {
|
||
|
let mut x = Some(String::new());
|
||
|
|
||
|
let _: Option<String> = x.clone();
|
||
|
let _: Option<String> = x.clone();
|
||
|
|
||
|
let y = x.as_ref();
|
||
|
let _: Option<&String> = y.clone();
|
||
|
|
||
|
macro_rules! cloned_recv {
|
||
|
() => {
|
||
|
x.as_ref()
|
||
|
};
|
||
|
}
|
||
|
|
||
|
// Don't lint when part of the expression is from a macro
|
||
|
let _: Option<String> = cloned_recv!().cloned();
|
||
|
}
|