X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=src%2Ftools%2Fclippy%2Ftests%2Fui%2Fmanual_filter.fixed;h=ef6780dc96d9c8f74ec38a3d90767d0b3307710f;hb=f25598a0c1bc63ebebc8fddfc72a3668f66863df;hp=3553291b87df6731aca2e71f905ed63eef21cda7;hpb=3c25461fe7bfa681160dfae3ca0617fbdaa450c3;p=rustc.git diff --git a/src/tools/clippy/tests/ui/manual_filter.fixed b/src/tools/clippy/tests/ui/manual_filter.fixed index 3553291b87..ef6780dc96 100644 --- a/src/tools/clippy/tests/ui/manual_filter.fixed +++ b/src/tools/clippy/tests/ui/manual_filter.fixed @@ -116,4 +116,45 @@ fn main() { }, None => None, }; + + match Some(20) { + // Don't Lint, because `Some(3*x)` is not `None` + None => None, + Some(x) => { + if x > 0 { + Some(3 * x) + } else { + Some(x) + } + }, + }; + + // Don't lint: https://github.com/rust-lang/rust-clippy/issues/10088 + let result = if let Some(a) = maybe_some() { + if let Some(b) = maybe_some() { + Some(a + b) + } else { + Some(a) + } + } else { + None + }; + + let allowed_integers = vec![3, 4, 5, 6]; + // Don't lint, since there's a side effect in the else branch + match Some(21) { + Some(x) => { + if allowed_integers.contains(&x) { + Some(x) + } else { + println!("Invalid integer: {x:?}"); + None + } + }, + None => None, + }; +} + +fn maybe_some() -> Option { + Some(0) }