Skip to content

Commit e2608fc

Browse files
committed
Auto merge of #3529 - matthiaskrgr:rustfmt_tests, r=phansch
rustfmt tests also fails CI if tests turn out to not be formatted properly.
2 parents 82e6dbb + 36266b3 commit e2608fc

File tree

457 files changed

+6772
-6655
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

457 files changed

+6772
-6655
lines changed

ci/base-tests.sh

+18
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,21 @@ cd clippy_dev && cargo test && cd ..
2929
# Perform various checks for lint registration
3030
./util/dev update_lints --check
3131
cargo +nightly fmt --all -- --check
32+
33+
34+
#avoid loop spam
35+
set +ex
36+
# make sure tests are formatted
37+
38+
# some lints are sensitive to formatting, exclude some files
39+
needs_formatting=false
40+
for file in `find tests -not -path "tests/ui/methods.rs" -not -path "tests/ui/format.rs" -not -path "tests/ui/formatting.rs" -not -path "tests/ui/empty_line_after_outer_attribute.rs" -not -path "tests/ui/double_parens.rs" -not -path "tests/ui/doc.rs" -not -path "tests/ui/unused_unit.rs" | grep "\.rs$"` ; do
41+
rustfmt ${file} --check || echo "${file} needs reformatting!" ; needs_formatting=true
42+
done
43+
44+
if [ "${needs_reformatting}" = true] ; then
45+
echo "Tests need reformatting!"
46+
exit 2
47+
fi
48+
49+
set -ex

tests/auxiliary/test_macro.rs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
1110
pub trait A {}
1211

1312
macro_rules! __implicit_hasher_test_macro {

tests/run-pass/associated-constant-ice.rs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
1110
pub trait Trait {
1211
const CONSTANT: u8;
1312
}

tests/run-pass/cc_seme.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
1110
#[allow(dead_code)]
1211
enum Baz {
1312
One,
@@ -19,18 +18,15 @@ struct Test {
1918
b: Baz,
2019
}
2120

22-
fn main() { }
21+
fn main() {}
2322

2423
pub fn foo() {
2524
use Baz::*;
2625
let x = Test { t: Some(0), b: One };
2726

2827
match x {
2928
Test { t: Some(_), b: One } => unreachable!(),
30-
Test {
31-
t: Some(42),
32-
b: Two,
33-
} => unreachable!(),
29+
Test { t: Some(42), b: Two } => unreachable!(),
3430
Test { t: None, .. } => unreachable!(),
3531
Test { .. } => unreachable!(),
3632
}

tests/run-pass/enum-glob-import-crate.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
11-
12-
1310
#![deny(clippy::all)]
1411
#![allow(unused_imports)]
1512

1613
use std::*;
1714

18-
fn main() { }
15+
fn main() {}

tests/run-pass/ice-1588.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,14 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
11-
12-
1310
#![allow(clippy::all)]
1411

1512
fn main() {
1613
match 1 {
17-
1 => {}
14+
1 => {},
1815
2 => {
1916
[0; 1];
20-
}
21-
_ => {}
17+
},
18+
_ => {},
2219
}
2320
}

tests/run-pass/ice-1782.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,28 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
1110
#![allow(dead_code, unused_variables)]
1211

1312
/// Should not trigger an ICE in `SpanlessEq` / `consts::constant`
1413
///
1514
/// Issue: https://github.com/rust-lang/rust-clippy/issues/1782
16-
1715
use std::{mem, ptr};
1816

1917
fn spanless_eq_ice() {
2018
let txt = "something";
2119
match txt {
22-
"something" => unsafe { ptr::write(ptr::null_mut() as *mut u32, mem::transmute::<[u8; 4], _>([0, 0, 0, 255])) },
23-
_ => unsafe { ptr::write(ptr::null_mut() as *mut u32, mem::transmute::<[u8; 4], _>([13, 246, 24, 255])) },
20+
"something" => unsafe {
21+
ptr::write(
22+
ptr::null_mut() as *mut u32,
23+
mem::transmute::<[u8; 4], _>([0, 0, 0, 255]),
24+
)
25+
},
26+
_ => unsafe {
27+
ptr::write(
28+
ptr::null_mut() as *mut u32,
29+
mem::transmute::<[u8; 4], _>([13, 246, 24, 255]),
30+
)
31+
},
2432
}
2533
}
2634

tests/run-pass/ice-1969.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
11-
12-
1310
#![allow(clippy::all)]
1411

15-
fn main() { }
12+
fn main() {}
1613

1714
pub trait Convert {
1815
type Action: From<*const f64>;

tests/run-pass/ice-2499.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
11-
12-
1310
#![allow(dead_code, clippy::char_lit_as_u8, clippy::needless_bool)]
1411

1512
/// Should not trigger an ICE in `SpanlessHash` / `consts::constant`
@@ -20,15 +17,17 @@ fn f(s: &[u8]) -> bool {
2017
let t = s[0] as char;
2118

2219
match t {
23-
'E' | 'W' => {}
24-
'T' => if s[0..4] != ['0' as u8; 4] {
25-
return false;
26-
} else {
27-
return true;
20+
'E' | 'W' => {},
21+
'T' => {
22+
if s[0..4] != ['0' as u8; 4] {
23+
return false;
24+
} else {
25+
return true;
26+
}
2827
},
2928
_ => {
3029
return false;
31-
}
30+
},
3231
}
3332
true
3433
}

tests/run-pass/ice-2594.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
1110
#![allow(dead_code, unused_variables)]
1211

1312
/// Should not trigger an ICE in `SpanlessHash` / `consts::constant`
@@ -21,7 +20,7 @@ fn spanless_hash_ice() {
2120
match txt {
2221
"something" => {
2322
let mut headers = [empty_header; 1];
24-
}
23+
},
2524
"" => (),
2625
_ => (),
2726
}

tests/run-pass/ice-2727.rs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
1110
pub fn f(new: fn()) {
1211
new();
1312
}

tests/run-pass/ice-2760.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
11-
12-
13-
#![allow(unused_variables, clippy::blacklisted_name,
14-
clippy::needless_pass_by_value, dead_code)]
10+
#![allow(
11+
unused_variables,
12+
clippy::blacklisted_name,
13+
clippy::needless_pass_by_value,
14+
dead_code
15+
)]
1516

1617
// This should not compile-fail with:
1718
//

tests/run-pass/ice-2774.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
11-
12-
1310
use std::collections::HashSet;
1411

1512
// See https://github.com/rust-lang/rust-clippy/issues/2774
@@ -26,18 +23,14 @@ pub struct Foo {}
2623
// This should not cause a 'cannot relate bound region' ICE
2724
pub fn add_barfoos_to_foos<'a>(bars: &HashSet<&'a Bar>) {
2825
let mut foos = HashSet::new();
29-
foos.extend(
30-
bars.iter().map(|b| &b.foo)
31-
);
26+
foos.extend(bars.iter().map(|b| &b.foo));
3227
}
3328

3429
#[allow(clippy::implicit_hasher)]
3530
// Also this should not cause a 'cannot relate bound region' ICE
3631
pub fn add_barfoos_to_foos2(bars: &HashSet<&Bar>) {
3732
let mut foos = HashSet::new();
38-
foos.extend(
39-
bars.iter().map(|b| &b.foo)
40-
);
33+
foos.extend(bars.iter().map(|b| &b.foo));
4134
}
4235

4336
fn main() {}

tests/run-pass/ice-2865.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
1110
#[allow(dead_code)]
1211
struct Ice {
13-
size: String
12+
size: String,
1413
}
1514

1615
impl<'a> From<String> for Ice {

tests/run-pass/ice-3151.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
1110
#[derive(Clone)]
1211
pub struct HashMap<V, S> {
1312
hash_builder: S,
@@ -17,7 +16,7 @@ pub struct HashMap<V, S> {
1716
#[derive(Clone)]
1817
pub struct RawTable<V> {
1918
size: usize,
20-
val: V
19+
val: V,
2120
}
2221

23-
fn main() {}
22+
fn main() {}

tests/run-pass/ice-700.rs

-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
11-
12-
1310
#![deny(clippy::all)]
1411

1512
fn core() {}

tests/run-pass/ice_exacte_size.rs

-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
11-
12-
1310
#![deny(clippy::all)]
1411

1512
#[allow(dead_code)]

tests/run-pass/if_same_then_else.rs

-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
11-
12-
1310
#![deny(clippy::if_same_then_else)]
1411

1512
fn main() {}

tests/run-pass/issue-2862.rs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
1110
pub trait FooMap {
1211
fn map<B, F: Fn() -> B>(&self, f: F) -> B;
1312
}

tests/run-pass/issue-825.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,23 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
1110
#![allow(warnings)]
1211

1312
// this should compile in a reasonable amount of time
1413
fn rust_type_id(name: &str) {
15-
if "bool" == &name[..] || "uint" == &name[..] || "u8" == &name[..] || "u16" == &name[..] || "u32" == &name[..]
16-
|| "f32" == &name[..] || "f64" == &name[..] || "i8" == &name[..] || "i16" == &name[..]
17-
|| "i32" == &name[..] || "i64" == &name[..] || "Self" == &name[..] || "str" == &name[..]
14+
if "bool" == &name[..]
15+
|| "uint" == &name[..]
16+
|| "u8" == &name[..]
17+
|| "u16" == &name[..]
18+
|| "u32" == &name[..]
19+
|| "f32" == &name[..]
20+
|| "f64" == &name[..]
21+
|| "i8" == &name[..]
22+
|| "i16" == &name[..]
23+
|| "i32" == &name[..]
24+
|| "i64" == &name[..]
25+
|| "Self" == &name[..]
26+
|| "str" == &name[..]
1827
{
1928
unreachable!();
2029
}

tests/run-pass/issues_loop_mut_cond.rs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
1110
#![allow(dead_code)]
1211

1312
/// Issue: https://github.com/rust-lang/rust-clippy/issues/2596

tests/run-pass/match_same_arms_const.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
11-
12-
1310
#![deny(clippy::match_same_arms)]
1411

1512
const PRICE_OF_SWEETS: u32 = 5;
@@ -21,7 +18,7 @@ pub fn price(thing: &str) -> u32 {
2118
"rolo" => PRICE_OF_SWEETS,
2219
"advice" => PRICE_OF_KINDNESS,
2320
"juice" => PRICE_OF_DRINKS,
24-
_ => panic!()
21+
_ => panic!(),
2522
}
2623
}
2724

tests/run-pass/mut_mut_macro.rs

-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
11-
12-
1310
#![deny(clippy::mut_mut, clippy::zero_ptr, clippy::cmp_nan)]
1411
#![allow(dead_code)]
1512

0 commit comments

Comments
 (0)