+// run-rustfix
+#![allow(unreachable_code)]
+
fn some_func(a: Option<u32>) -> Option<u32> {
if a.is_none() {
return None;
self.opt
};
+ let _ = if let Some(x) = self.opt {
+ x
+ } else {
+ return None;
+ };
+
self.opt
}
}
}
Some(Vec::new())
}
+
+ pub fn if_let_ref_func(self) -> Option<Vec<u32>> {
+ let v: &Vec<_> = if let Some(ref v) = self.opt {
+ v
+ } else {
+ return None;
+ };
+
+ Some(v.clone())
+ }
+
+ pub fn if_let_mov_func(self) -> Option<Vec<u32>> {
+ let v = if let Some(v) = self.opt {
+ v
+ } else {
+ return None;
+ };
+
+ Some(v)
+ }
+}
+
+fn func() -> Option<i32> {
+ fn f() -> Option<String> {
+ Some(String::new())
+ }
+
+ if f().is_none() {
+ return None;
+ }
+
+ Some(0)
}
fn main() {
some_func(Some(42));
some_func(None);
+ some_other_func(Some(42));
let copy_struct = CopyStruct { opt: Some(54) };
copy_struct.func();
let so = SeemsOption::Some(45);
returns_something_similar_to_option(so);
+
+ func();
}