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

Lines changed: 18 additions & 0 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 2 additions & 6 deletions
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

Lines changed: 1 addition & 4 deletions
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

Lines changed: 3 additions & 6 deletions
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

Lines changed: 12 additions & 4 deletions
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

Lines changed: 1 addition & 4 deletions
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

Lines changed: 8 additions & 9 deletions
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

Lines changed: 1 addition & 2 deletions
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
}

0 commit comments

Comments
 (0)