2024-03-09 18:12:15 -06:00
|
|
|
#![warn(clippy::manual_unwrap_or_default)]
|
2024-03-08 15:04:31 -06:00
|
|
|
#![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();
|
|
|
|
}
|
2024-03-22 06:21:35 -05:00
|
|
|
|
|
|
|
// 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,
|
|
|
|
}
|
|
|
|
}
|
2024-03-27 03:28:15 -05:00
|
|
|
|
|
|
|
const fn issue_12568(opt: Option<bool>) -> bool {
|
|
|
|
match opt {
|
|
|
|
Some(s) => s,
|
|
|
|
None => false,
|
|
|
|
}
|
|
|
|
}
|