rust/tests/ui/match_single_binding2.fixed
Yuri Astrakhan eb3970285b fallout: fix tests to allow uninlined_format_args
In order to switch `clippy::uninlined_format_args` from pedantic to
style, all existing tests must not raise a warning. I did not want to
change the actual tests, so this is a relatively minor change that:

* add `#![allow(clippy::uninlined_format_args)]` where needed
* normalizes all allow/deny/warn attributes
   * all allow attributes are grouped together
   * sorted alphabetically
   * the `clippy::*` attributes are listed separate from the other ones.
   * deny and warn attributes are listed before the allowed ones

changelog: none
2022-10-02 15:13:22 -04:00

54 lines
1.3 KiB
Rust

// run-rustfix
#![warn(clippy::match_single_binding)]
#![allow(unused_variables)]
#![allow(clippy::uninlined_format_args)]
fn main() {
// Lint (additional curly braces needed, see #6572)
struct AppendIter<I>
where
I: Iterator,
{
inner: Option<(I, <I as Iterator>::Item)>,
}
#[allow(dead_code)]
fn size_hint<I: Iterator>(iter: &AppendIter<I>) -> (usize, Option<usize>) {
match &iter.inner {
Some((iter, _item)) => {
let (min, max) = iter.size_hint();
(min.saturating_add(1), max.and_then(|max| max.checked_add(1)))
},
None => (0, Some(0)),
}
}
// Lint (no additional curly braces needed)
let opt = Some((5, 2));
let get_tup = || -> (i32, i32) { (1, 2) };
match opt {
#[rustfmt::skip]
Some((first, _second)) => {
let (a, b) = get_tup();
println!("a {:?} and b {:?}", a, b);
},
None => println!("nothing"),
}
fn side_effects() {}
// Lint (scrutinee has side effects)
// issue #7094
side_effects();
println!("Side effects");
// Lint (scrutinee has side effects)
// issue #7094
let x = 1;
match x {
0 => 1,
_ => 2,
};
println!("Single branch");
}