1 #![warn(clippy::collapsible_match)]
2 #![allow(clippy::needless_return, clippy::no_effect, clippy::single_match)]
4 fn lint_cases(opt_opt: Option<Option<u32>>, res_opt: Result<Option<u32>, String>) {
16 Ok(val) => match val {
24 if let Ok(val) = res_opt {
25 if let Some(n) = val {
30 // if let else, if let else
31 if let Ok(val) = res_opt {
32 if let Some(n) = val {
42 if let Ok(val) = res_opt {
52 if let Some(n) = val {
60 if let Ok(val) = res_opt {
72 if let Some(n) = val {
81 // None in inner match same as outer wild branch
83 Ok(val) => match val {
90 // None in outer match same as inner wild branch
92 Some(val) => match val {
99 // if guards on outer match
102 Ok(val) if make() => match val {
109 Ok(val) => match val {
113 _ if make() => return,
121 ($outer:expr => $pat:pat, $e:expr => $inner_pat:pat, $then:expr) => {
131 // Lint this since the patterns are not defined by the macro.
132 // Allows the lint to work on if_chain! for example.
133 // Fixing the lint requires knowledge of the specific macro, but we optimistically assume that
134 // there is still a better way to write this.
135 mac!(res_opt => Ok(val), val => Some(n), foo(n));
139 fn negative_cases(res_opt: Result<Option<u32>, String>, res_res: Result<Result<u32, String>, String>) {
140 // no wild pattern in outer match
142 Ok(val) => match val {
149 // inner branch is not wild or None
151 Ok(val) => match val {
158 // statement before inner match
170 // statement after inner match
182 // wild branches do not match
184 Ok(val) => match val {
194 // binding used in if guard
196 Ok(val) if val.is_some() => match val {
203 // binding used in inner match body
205 Ok(val) => match val {
206 Some(_) => take(val),
212 // if guard on inner match
215 Ok(val) => match val {
216 Some(n) if make() => foo(n),
222 Ok(val) => match val {
224 _ if make() => return,
230 // differing macro contexts
241 Ok(val) => mac!(val),
252 match make::<E<Option<u32>>>() {
253 E::A(val) | E::B(val) => match val {
259 match make::<Option<E<u32>>>() {
260 Some(val) => match val {
261 E::A(val) | E::B(val) => foo(val),
272 fn foo<T, U>(t: T) -> U {