Skip to content

Commit 36e3b2e

Browse files
committed
Auto merge of #3586 - matthiaskrgr:test_fmt_fix, r=oli-obk
base tests: switch to nightly toolchain before checking formatting of tests with rustfmt this errored because rustfmt is not available on the master toolchain
2 parents 721f688 + 38fabcb commit 36e3b2e

12 files changed

+56
-42
lines changed

ci/base-tests.sh

+17-7
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,29 @@ cd ..
3535
./util/dev update_lints --check
3636
cargo +nightly fmt --all -- --check
3737

38-
39-
#avoid loop spam
40-
set +x
4138
# make sure tests are formatted
4239

4340
# some lints are sensitive to formatting, exclude some files
44-
needs_formatting=false
41+
tests_need_reformatting="false"
42+
# switch to nightly
43+
rustup default nightly
44+
# avoid loop spam and allow cmds with exit status != 0
45+
set +ex
46+
4547
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
46-
rustfmt ${file} --check || echo "${file} needs reformatting!" ; needs_formatting=true
48+
rustfmt ${file} --check
49+
if [ $? -ne 0 ]; then
50+
echo "${file} needs reformatting!"
51+
tests_need_reformatting="true"
52+
fi
4753
done
4854

49-
if [ "${needs_reformatting}" = true ] ; then
55+
set -ex # reset
56+
57+
if [ "${tests_need_reformatting}" == "true" ] ; then
5058
echo "Tests need reformatting!"
5159
exit 2
5260
fi
53-
set -x
61+
62+
# switch back to master
63+
rustup default master

tests/ui/cast_alignment.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
//! Test casts for alignment issues
1111
12-
1312
#![feature(rustc_private)]
1413
extern crate libc;
1514

tests/ui/cast_alignment.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`)
2-
--> $DIR/cast_alignment.rs:22:5
2+
--> $DIR/cast_alignment.rs:21:5
33
|
4-
22 | (&1u8 as *const u8) as *const u16;
4+
21 | (&1u8 as *const u8) as *const u16;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::cast-ptr-alignment` implied by `-D warnings`
88

99
error: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`)
10-
--> $DIR/cast_alignment.rs:23:5
10+
--> $DIR/cast_alignment.rs:22:5
1111
|
12-
23 | (&mut 1u8 as *mut u8) as *mut u16;
12+
22 | (&mut 1u8 as *mut u8) as *mut u16;
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1414

1515
error: aborting due to 2 previous errors

tests/ui/implicit_return.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ fn test_loop_with_nests() -> bool {
5656
loop {
5757
if true {
5858
break true;
59-
}
60-
else {
59+
} else {
6160
let _ = true;
6261
}
6362
}

tests/ui/implicit_return.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ error: missing return statement
4949
| ^^^^^^^^^^ help: change `break` to `return` as shown: `return true`
5050

5151
error: missing return statement
52-
--> $DIR/implicit_return.rs:68:18
52+
--> $DIR/implicit_return.rs:67:18
5353
|
54-
68 | let _ = || { true };
54+
67 | let _ = || { true };
5555
| ^^^^ help: add `return` as shown: `return true`
5656

5757
error: missing return statement
58-
--> $DIR/implicit_return.rs:69:16
58+
--> $DIR/implicit_return.rs:68:16
5959
|
60-
69 | let _ = || true;
60+
68 | let _ = || true;
6161
| ^^^^ help: add `return` as shown: `return true`
6262

6363
error: aborting due to 10 previous errors

tests/ui/new_without_default.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,18 @@ pub struct Allow(Foo);
143143

144144
impl Allow {
145145
#[allow(clippy::new_without_default)]
146-
pub fn new() -> Self { unimplemented!() }
146+
pub fn new() -> Self {
147+
unimplemented!()
148+
}
147149
}
148150

149151
pub struct AllowDerive;
150152

151153
impl AllowDerive {
152154
#[allow(clippy::new_without_default_derive)]
153-
pub fn new() -> Self { unimplemented!() }
155+
pub fn new() -> Self {
156+
unimplemented!()
157+
}
154158
}
155159

156160
fn main() {}

tests/ui/partialeq_ne_impl.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ impl PartialEq for Foo {
2323
struct Bar;
2424

2525
impl PartialEq for Bar {
26-
fn eq(&self, _: &Bar) -> bool { true }
26+
fn eq(&self, _: &Bar) -> bool {
27+
true
28+
}
2729
#[allow(clippy::partialeq_ne_impl)]
28-
fn ne(&self, _: &Bar) -> bool { false }
30+
fn ne(&self, _: &Bar) -> bool {
31+
false
32+
}
2933
}
3034

3135
fn main() {}

tests/ui/redundant_field_names.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ fn main() {
7070
}
7171

7272
fn issue_3476() {
73-
fn foo<T>() {
74-
}
73+
fn foo<T>() {}
7574

7675
struct S {
7776
foo: fn(),

tests/ui/unused_io_amount.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
use std::io;
1414

15-
1615
fn try_macro<T: io::Read + io::Write>(s: &mut T) -> io::Result<()> {
1716
try!(s.write(b"test"));
1817
let mut buf = [0u8; 4];

tests/ui/unused_io_amount.stderr

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
error: handle written amount returned or use `Write::write_all` instead
2-
--> $DIR/unused_io_amount.rs:17:5
2+
--> $DIR/unused_io_amount.rs:16:5
33
|
4-
17 | try!(s.write(b"test"));
4+
16 | try!(s.write(b"test"));
55
| ^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::unused-io-amount` implied by `-D warnings`
88
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
99

1010
error: handle read amount returned or use `Read::read_exact` instead
11-
--> $DIR/unused_io_amount.rs:19:5
11+
--> $DIR/unused_io_amount.rs:18:5
1212
|
13-
19 | try!(s.read(&mut buf));
13+
18 | try!(s.read(&mut buf));
1414
| ^^^^^^^^^^^^^^^^^^^^^^^
1515
|
1616
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
1717

1818
error: handle written amount returned or use `Write::write_all` instead
19-
--> $DIR/unused_io_amount.rs:24:5
19+
--> $DIR/unused_io_amount.rs:23:5
2020
|
21-
24 | s.write(b"test")?;
21+
23 | s.write(b"test")?;
2222
| ^^^^^^^^^^^^^^^^^
2323

2424
error: handle read amount returned or use `Read::read_exact` instead
25-
--> $DIR/unused_io_amount.rs:26:5
25+
--> $DIR/unused_io_amount.rs:25:5
2626
|
27-
26 | s.read(&mut buf)?;
27+
25 | s.read(&mut buf)?;
2828
| ^^^^^^^^^^^^^^^^^
2929

3030
error: handle written amount returned or use `Write::write_all` instead
31-
--> $DIR/unused_io_amount.rs:31:5
31+
--> $DIR/unused_io_amount.rs:30:5
3232
|
33-
31 | s.write(b"test").unwrap();
33+
30 | s.write(b"test").unwrap();
3434
| ^^^^^^^^^^^^^^^^^^^^^^^^^
3535

3636
error: handle read amount returned or use `Read::read_exact` instead
37-
--> $DIR/unused_io_amount.rs:33:5
37+
--> $DIR/unused_io_amount.rs:32:5
3838
|
39-
33 | s.read(&mut buf).unwrap();
39+
32 | s.read(&mut buf).unwrap();
4040
| ^^^^^^^^^^^^^^^^^^^^^^^^^
4141

4242
error: aborting due to 6 previous errors

tests/ui/vec_box_sized.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
struct SizedStruct {
2-
_a: i32,
2+
_a: i32,
33
}
44

55
struct UnsizedStruct {
6-
_a: [i32],
6+
_a: [i32],
77
}
88

99
struct StructWithVecBox {
10-
sized_type: Vec<Box<SizedStruct>>,
10+
sized_type: Vec<Box<SizedStruct>>,
1111
}
1212

1313
struct StructWithVecBoxButItsUnsized {
14-
unsized_type: Vec<Box<UnsizedStruct>>,
14+
unsized_type: Vec<Box<UnsizedStruct>>,
1515
}
1616

1717
fn main() {}

tests/ui/vec_box_sized.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: `Vec<T>` is already on the heap, the boxing is unnecessary.
2-
--> $DIR/vec_box_sized.rs:10:14
2+
--> $DIR/vec_box_sized.rs:10:17
33
|
44
10 | sized_type: Vec<Box<SizedStruct>>,
55
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec<SizedStruct>`

0 commit comments

Comments
 (0)