]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/manual_unwrap_or.rs
fix invalid code suggestion in `manual_unwrap_or`, due to macro expansion
[rust.git] / tests / ui / manual_unwrap_or.rs
index 6750662c58c079b277902586fcc9554e1e2f7b65..66006b6c616f08f9e1858e53ef451b57b26c130f 100644 (file)
@@ -1,6 +1,6 @@
 // run-rustfix
 #![allow(dead_code)]
-#![allow(unused_variables, clippy::unnecessary_wrap)]
+#![allow(unused_variables, clippy::unnecessary_wraps)]
 
 fn option_unwrap_or() {
     // int case
@@ -175,4 +175,34 @@ fn method(self) -> Option<i32> {
     };
 }
 
+// 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() {}