]>
git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/collapsible_match.rs
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
{
100 fn negative_cases(res_opt
: Result
<Option
<u32>, String
>, res_res
: Result
<Result
<u32, String
>, String
>) {
101 while let Some(x
) = make() {
106 // no wild pattern in outer match
108 Ok(val
) => match val
{
115 // inner branch is not wild or None
117 Ok(val
) => match val
{
124 // statement before inner match
136 // statement after inner match
148 // wild branches do not match
150 Ok(val
) => match val
{
160 // binding used in if guard
162 Ok(val
) if val
.is_some() => match val
{
169 // binding used in inner match body
171 Ok(val
) => match val
{
172 Some(_
) => take(val
),
178 // if guard on inner match
181 Ok(val
) => match val
{
182 Some(n
) if make() => foo(n
),
188 Ok(val
) => match val
{
190 _
if make() => return,
196 // differing macro contexts
207 Ok(val
) => mac
!(val
),
218 match make
::<E
<Option
<u32>>>() {
219 E
::A(val
) | E
::B(val
) => match val
{
225 match make
::<Option
<E
<u32>>>() {
226 Some(val
) => match val
{
227 E
::A(val
) | E
::B(val
) => foo(val
),
232 if let Ok(val
) = res_opt
{
233 if let Some(n
) = val
{
236 println
!("{:?}", val
);
240 let _
: &dyn std
::any
::Any
= match &Some(Some(1)) {
245 // else branch looks the same but the binding is different
254 fn foo
<T
, U
>(t
: T
) -> U
{