mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-19 01:24:05 +00:00
28 lines
660 B
Rust
28 lines
660 B
Rust
#![warn(clippy::manual_unwrap_or_default)]
|
|
#![allow(clippy::unnecessary_literal_unwrap)]
|
|
|
|
fn main() {
|
|
let x: Option<Vec<String>> = None;
|
|
x.unwrap_or_default();
|
|
|
|
let x: Option<Vec<String>> = None;
|
|
x.unwrap_or_default();
|
|
|
|
let x: Option<String> = None;
|
|
x.unwrap_or_default();
|
|
|
|
let x: Option<Vec<String>> = None;
|
|
x.unwrap_or_default();
|
|
|
|
let x: Option<Vec<String>> = None;
|
|
x.unwrap_or_default();
|
|
}
|
|
|
|
// Issue #12531
|
|
unsafe fn no_deref_ptr(a: Option<i32>, b: *const Option<i32>) -> i32 {
|
|
match a {
|
|
// `*b` being correct depends on `a == Some(_)`
|
|
Some(_) => (*b).unwrap_or_default(),
|
|
_ => 0,
|
|
}
|
|
}
|