Skip to content

base tests: switch to nightly toolchain before checking formatting of tests with rustfmt #3586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions ci/base-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,29 @@ cd ..
./util/dev update_lints --check
cargo +nightly fmt --all -- --check


#avoid loop spam
set +x
# make sure tests are formatted

# some lints are sensitive to formatting, exclude some files
needs_formatting=false
tests_need_reformatting="false"
# switch to nightly
rustup default nightly
# avoid loop spam and allow cmds with exit status != 0
set +ex

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
rustfmt ${file} --check || echo "${file} needs reformatting!" ; needs_formatting=true
rustfmt ${file} --check
if [ $? -ne 0 ]; then
echo "${file} needs reformatting!"
tests_need_reformatting="true"
fi
done

if [ "${needs_reformatting}" = true ] ; then
set -ex # reset

if [ "${tests_need_reformatting}" == "true" ] ; then
echo "Tests need reformatting!"
exit 2
fi
set -x

# switch back to master
rustup default master
1 change: 0 additions & 1 deletion tests/ui/cast_alignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

//! Test casts for alignment issues


#![feature(rustc_private)]
extern crate libc;

Expand Down
8 changes: 4 additions & 4 deletions tests/ui/cast_alignment.stderr
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`)
--> $DIR/cast_alignment.rs:22:5
--> $DIR/cast_alignment.rs:21:5
|
22 | (&1u8 as *const u8) as *const u16;
21 | (&1u8 as *const u8) as *const u16;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::cast-ptr-alignment` implied by `-D warnings`

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

error: aborting due to 2 previous errors
Expand Down
3 changes: 1 addition & 2 deletions tests/ui/implicit_return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ fn test_loop_with_nests() -> bool {
loop {
if true {
break true;
}
else {
} else {
let _ = true;
}
}
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/implicit_return.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ error: missing return statement
| ^^^^^^^^^^ help: change `break` to `return` as shown: `return true`

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

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

error: aborting due to 10 previous errors
Expand Down
8 changes: 6 additions & 2 deletions tests/ui/new_without_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,18 @@ pub struct Allow(Foo);

impl Allow {
#[allow(clippy::new_without_default)]
pub fn new() -> Self { unimplemented!() }
pub fn new() -> Self {
unimplemented!()
}
}

pub struct AllowDerive;

impl AllowDerive {
#[allow(clippy::new_without_default_derive)]
pub fn new() -> Self { unimplemented!() }
pub fn new() -> Self {
unimplemented!()
}
}

fn main() {}
8 changes: 6 additions & 2 deletions tests/ui/partialeq_ne_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ impl PartialEq for Foo {
struct Bar;

impl PartialEq for Bar {
fn eq(&self, _: &Bar) -> bool { true }
fn eq(&self, _: &Bar) -> bool {
true
}
#[allow(clippy::partialeq_ne_impl)]
fn ne(&self, _: &Bar) -> bool { false }
fn ne(&self, _: &Bar) -> bool {
false
}
}

fn main() {}
3 changes: 1 addition & 2 deletions tests/ui/redundant_field_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ fn main() {
}

fn issue_3476() {
fn foo<T>() {
}
fn foo<T>() {}

struct S {
foo: fn(),
Expand Down
1 change: 0 additions & 1 deletion tests/ui/unused_io_amount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

use std::io;


fn try_macro<T: io::Read + io::Write>(s: &mut T) -> io::Result<()> {
try!(s.write(b"test"));
let mut buf = [0u8; 4];
Expand Down
24 changes: 12 additions & 12 deletions tests/ui/unused_io_amount.stderr
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
error: handle written amount returned or use `Write::write_all` instead
--> $DIR/unused_io_amount.rs:17:5
--> $DIR/unused_io_amount.rs:16:5
|
17 | try!(s.write(b"test"));
16 | try!(s.write(b"test"));
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::unused-io-amount` implied by `-D warnings`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

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

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

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

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

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

error: aborting due to 6 previous errors
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/vec_box_sized.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
struct SizedStruct {
_a: i32,
_a: i32,
}

struct UnsizedStruct {
_a: [i32],
_a: [i32],
}

struct StructWithVecBox {
sized_type: Vec<Box<SizedStruct>>,
sized_type: Vec<Box<SizedStruct>>,
}

struct StructWithVecBoxButItsUnsized {
unsized_type: Vec<Box<UnsizedStruct>>,
unsized_type: Vec<Box<UnsizedStruct>>,
}

fn main() {}
2 changes: 1 addition & 1 deletion tests/ui/vec_box_sized.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: `Vec<T>` is already on the heap, the boxing is unnecessary.
--> $DIR/vec_box_sized.rs:10:14
--> $DIR/vec_box_sized.rs:10:17
|
10 | sized_type: Vec<Box<SizedStruct>>,
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec<SizedStruct>`
Expand Down