2 #![allow(unreachable_code)]
4 #![allow(clippy::unnecessary_wraps)]
6 fn some_func(a: Option<u32>) -> Option<u32> {
12 fn some_other_func(a: Option<u32>) -> Option<u32> {
21 pub enum SeemsOption<T> {
26 impl<T> SeemsOption<T> {
27 pub fn is_none(&self) -> bool {
29 SeemsOption::None => true,
30 SeemsOption::Some(_) => false,
35 fn returns_something_similar_to_option(a: SeemsOption<u32>) -> SeemsOption<u32> {
37 return SeemsOption::None;
43 pub struct CopyStruct {
49 pub fn func(&self) -> Option<u32> {
54 let _ = Some(self.opt?);
63 pub struct MoveStruct {
64 pub opt: Option<Vec<u32>>,
68 pub fn ref_func(&self) -> Option<Vec<u32>> {
74 pub fn mov_func_reuse(self) -> Option<Vec<u32>> {
80 pub fn mov_func_no_use(self) -> Option<Vec<u32>> {
85 pub fn if_let_ref_func(self) -> Option<Vec<u32>> {
86 let v: &Vec<_> = self.opt.as_ref()?;
91 pub fn if_let_mov_func(self) -> Option<Vec<u32>> {
98 fn func() -> Option<i32> {
99 fn f() -> Option<String> {
108 fn func_returning_result() -> Result<i32, i32> {
112 fn result_func(x: Result<i32, i32>) -> Result<i32, i32> {
118 let y = if let Ok(x) = x {
126 let _ = if let Ok(x) = func_returning_result() {
133 if func_returning_result().is_err() {
134 return func_returning_result();
138 let _ = if let Err(e) = x { Err(e) } else { Ok(0) };
150 fn obj(_: i32) -> Result<(), NotOption> {
151 Err(NotOption::First)
154 fn f() -> NotOption {
156 return NotOption::None;
163 fn err_immediate_return() -> Result<i32, i32> {
164 func_returning_result()?;
168 fn err_immediate_return_and_do_something() -> Result<i32, i32> {
169 func_returning_result()?;
175 fn no_immediate_return() -> Result<i32, i32> {
176 if let Err(err) = func_returning_result() {
184 fn mixed_result_and_option() -> Option<i32> {
185 if let Err(err) = func_returning_result() {
192 fn else_if_check() -> Result<i32, i32> {
195 } else if let Err(e) = func_returning_result() {
203 #[allow(clippy::manual_map)]
205 fn option_map() -> Option<bool> {
206 if let Some(a) = Some(false) {
213 pub struct PatternedError {
218 fn pattern() -> Result<(), PatternedError> {
221 if let Err(err @ PatternedError { flag: true }) = res {
230 // should not lint, `?` operator not available in const context
231 const fn issue9175(option: Option<()>) -> Option<()> {
232 if option.is_none() {