X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=tests%2Fui%2Fmanual_unwrap_or.rs;h=66006b6c616f08f9e1858e53ef451b57b26c130f;hb=84003aa7a18f2673b20340dd20344dda8265ba7a;hp=df534031f54c32c83991357f07cb3826f021323c;hpb=8e988e1c66eb775b9be9c1106911fa736872f313;p=rust.git diff --git a/tests/ui/manual_unwrap_or.rs b/tests/ui/manual_unwrap_or.rs index df534031f54..66006b6c616 100644 --- a/tests/ui/manual_unwrap_or.rs +++ b/tests/ui/manual_unwrap_or.rs @@ -1,6 +1,6 @@ // run-rustfix #![allow(dead_code)] -#![allow(unused_variables)] +#![allow(unused_variables, clippy::unnecessary_wraps)] fn option_unwrap_or() { // int case @@ -175,4 +175,34 @@ fn method(self) -> Option { }; } +// don't lint in const fn +const fn const_fn_option_unwrap_or() { + match Some(1) { + Some(s) => s, + None => 0, + }; +} + +const fn const_fn_result_unwrap_or() { + match Ok::<&str, &str>("Alice") { + Ok(s) => s, + Err(_) => "Bob", + }; +} + +mod issue6965 { + macro_rules! some_macro { + () => { + if 1 > 2 { Some(1) } else { None } + }; + } + + fn test() { + let _ = match some_macro!() { + Some(val) => val, + None => 0, + }; + } +} + fn main() {}