Skip to content

Commit 7d45d8a

Browse files
committed
Split match_single_binding tests in 2 files (too many lines for CI)
1 parent 00a2d7a commit 7d45d8a

6 files changed

+109
-90
lines changed

tests/ui/match_single_binding.fixed

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -115,33 +115,4 @@ fn main() {
115115
// =>
116116
_ => println!("Not an array index start"),
117117
}
118-
// Lint (additional curly braces needed, see #6572)
119-
struct AppendIter<I>
120-
where
121-
I: Iterator,
122-
{
123-
inner: Option<(I, <I as Iterator>::Item)>,
124-
}
125-
126-
#[allow(dead_code)]
127-
fn size_hint<I: Iterator>(iter: &AppendIter<I>) -> (usize, Option<usize>) {
128-
match &iter.inner {
129-
Some((iter, _item)) => {
130-
let (min, max) = iter.size_hint();
131-
(min.saturating_add(1), max.and_then(|max| max.checked_add(1)))
132-
},
133-
None => (0, Some(0)),
134-
}
135-
}
136-
// Lint (no additional curly braces needed)
137-
let opt = Some((5, 2));
138-
let get_tup = || -> (i32, i32) { (1, 2) };
139-
match opt {
140-
#[rustfmt::skip]
141-
Some((first, _second)) => {
142-
let (a, b) = get_tup();
143-
println!("a {:?} and b {:?}", a, b);
144-
},
145-
None => println!("nothing"),
146-
}
147118
}

tests/ui/match_single_binding.rs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -132,33 +132,4 @@ fn main() {
132132
// =>
133133
_ => println!("Not an array index start"),
134134
}
135-
// Lint (additional curly braces needed, see #6572)
136-
struct AppendIter<I>
137-
where
138-
I: Iterator,
139-
{
140-
inner: Option<(I, <I as Iterator>::Item)>,
141-
}
142-
143-
#[allow(dead_code)]
144-
fn size_hint<I: Iterator>(iter: &AppendIter<I>) -> (usize, Option<usize>) {
145-
match &iter.inner {
146-
Some((iter, _item)) => match iter.size_hint() {
147-
(min, max) => (min.saturating_add(1), max.and_then(|max| max.checked_add(1))),
148-
},
149-
None => (0, Some(0)),
150-
}
151-
}
152-
// Lint (no additional curly braces needed)
153-
let opt = Some((5, 2));
154-
let get_tup = || -> (i32, i32) { (1, 2) };
155-
match opt {
156-
#[rustfmt::skip]
157-
Some((first, _second)) => {
158-
match get_tup() {
159-
(a, b) => println!("a {:?} and b {:?}", a, b),
160-
}
161-
},
162-
None => println!("nothing"),
163-
}
164135
}

tests/ui/match_single_binding.stderr

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -178,36 +178,5 @@ LL | | _ => println!("Single branch"),
178178
LL | | }
179179
| |_____^ help: consider using the match body instead: `println!("Single branch");`
180180

181-
error: this match could be written as a `let` statement
182-
--> $DIR/match_single_binding.rs:146:36
183-
|
184-
LL | Some((iter, _item)) => match iter.size_hint() {
185-
| ____________________________________^
186-
LL | | (min, max) => (min.saturating_add(1), max.and_then(|max| max.checked_add(1))),
187-
LL | | },
188-
| |_____________^
189-
|
190-
help: consider using `let` statement
191-
|
192-
LL | Some((iter, _item)) => {
193-
LL | let (min, max) = iter.size_hint();
194-
LL | (min.saturating_add(1), max.and_then(|max| max.checked_add(1)))
195-
LL | },
196-
|
197-
198-
error: this match could be written as a `let` statement
199-
--> $DIR/match_single_binding.rs:158:13
200-
|
201-
LL | / match get_tup() {
202-
LL | | (a, b) => println!("a {:?} and b {:?}", a, b),
203-
LL | | }
204-
| |_____________^
205-
|
206-
help: consider using `let` statement
207-
|
208-
LL | let (a, b) = get_tup();
209-
LL | println!("a {:?} and b {:?}", a, b);
210-
|
211-
212-
error: aborting due to 14 previous errors
181+
error: aborting due to 12 previous errors
213182

tests/ui/match_single_binding2.fixed

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// run-rustfix
2+
3+
#![warn(clippy::match_single_binding)]
4+
#![allow(unused_variables)]
5+
6+
fn main() {
7+
// Lint (additional curly braces needed, see #6572)
8+
struct AppendIter<I>
9+
where
10+
I: Iterator,
11+
{
12+
inner: Option<(I, <I as Iterator>::Item)>,
13+
}
14+
15+
#[allow(dead_code)]
16+
fn size_hint<I: Iterator>(iter: &AppendIter<I>) -> (usize, Option<usize>) {
17+
match &iter.inner {
18+
Some((iter, _item)) => {
19+
let (min, max) = iter.size_hint();
20+
(min.saturating_add(1), max.and_then(|max| max.checked_add(1)))
21+
},
22+
None => (0, Some(0)),
23+
}
24+
}
25+
26+
// Lint (no additional curly braces needed)
27+
let opt = Some((5, 2));
28+
let get_tup = || -> (i32, i32) { (1, 2) };
29+
match opt {
30+
#[rustfmt::skip]
31+
Some((first, _second)) => {
32+
let (a, b) = get_tup();
33+
println!("a {:?} and b {:?}", a, b);
34+
},
35+
None => println!("nothing"),
36+
}
37+
}

tests/ui/match_single_binding2.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// run-rustfix
2+
3+
#![warn(clippy::match_single_binding)]
4+
#![allow(unused_variables)]
5+
6+
fn main() {
7+
// Lint (additional curly braces needed, see #6572)
8+
struct AppendIter<I>
9+
where
10+
I: Iterator,
11+
{
12+
inner: Option<(I, <I as Iterator>::Item)>,
13+
}
14+
15+
#[allow(dead_code)]
16+
fn size_hint<I: Iterator>(iter: &AppendIter<I>) -> (usize, Option<usize>) {
17+
match &iter.inner {
18+
Some((iter, _item)) => match iter.size_hint() {
19+
(min, max) => (min.saturating_add(1), max.and_then(|max| max.checked_add(1))),
20+
},
21+
None => (0, Some(0)),
22+
}
23+
}
24+
25+
// Lint (no additional curly braces needed)
26+
let opt = Some((5, 2));
27+
let get_tup = || -> (i32, i32) { (1, 2) };
28+
match opt {
29+
#[rustfmt::skip]
30+
Some((first, _second)) => {
31+
match get_tup() {
32+
(a, b) => println!("a {:?} and b {:?}", a, b),
33+
}
34+
},
35+
None => println!("nothing"),
36+
}
37+
}

tests/ui/match_single_binding2.stderr

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
error: this match could be written as a `let` statement
2+
--> $DIR/match_single_binding2.rs:18:36
3+
|
4+
LL | Some((iter, _item)) => match iter.size_hint() {
5+
| ____________________________________^
6+
LL | | (min, max) => (min.saturating_add(1), max.and_then(|max| max.checked_add(1))),
7+
LL | | },
8+
| |_____________^
9+
|
10+
= note: `-D clippy::match-single-binding` implied by `-D warnings`
11+
help: consider using `let` statement
12+
|
13+
LL | Some((iter, _item)) => {
14+
LL | let (min, max) = iter.size_hint();
15+
LL | (min.saturating_add(1), max.and_then(|max| max.checked_add(1)))
16+
LL | },
17+
|
18+
19+
error: this match could be written as a `let` statement
20+
--> $DIR/match_single_binding2.rs:31:13
21+
|
22+
LL | / match get_tup() {
23+
LL | | (a, b) => println!("a {:?} and b {:?}", a, b),
24+
LL | | }
25+
| |_____________^
26+
|
27+
help: consider using `let` statement
28+
|
29+
LL | let (a, b) = get_tup();
30+
LL | println!("a {:?} and b {:?}", a, b);
31+
|
32+
33+
error: aborting due to 2 previous errors
34+

0 commit comments

Comments
 (0)