Skip to content

Commit

Permalink
Auto merge of #3529 - matthiaskrgr:rustfmt_tests, r=phansch
Browse files Browse the repository at this point in the history
rustfmt tests

also fails CI if tests turn out to not be formatted properly.
  • Loading branch information
bors committed Dec 12, 2018
2 parents 82e6dbb + 36266b3 commit e2608fc
Show file tree
Hide file tree
Showing 457 changed files with 6,772 additions and 6,655 deletions.
18 changes: 18 additions & 0 deletions ci/base-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,21 @@ cd clippy_dev && cargo test && cd ..
# Perform various checks for lint registration
./util/dev update_lints --check
cargo +nightly fmt --all -- --check


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

# some lints are sensitive to formatting, exclude some files
needs_formatting=false
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
done

if [ "${needs_reformatting}" = true] ; then
echo "Tests need reformatting!"
exit 2
fi

set -ex
1 change: 0 additions & 1 deletion tests/auxiliary/test_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.


pub trait A {}

macro_rules! __implicit_hasher_test_macro {
Expand Down
1 change: 0 additions & 1 deletion tests/run-pass/associated-constant-ice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.


pub trait Trait {
const CONSTANT: u8;
}
Expand Down
8 changes: 2 additions & 6 deletions tests/run-pass/cc_seme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.


#[allow(dead_code)]
enum Baz {
One,
Expand All @@ -19,18 +18,15 @@ struct Test {
b: Baz,
}

fn main() { }
fn main() {}

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

match x {
Test { t: Some(_), b: One } => unreachable!(),
Test {
t: Some(42),
b: Two,
} => unreachable!(),
Test { t: Some(42), b: Two } => unreachable!(),
Test { t: None, .. } => unreachable!(),
Test { .. } => unreachable!(),
}
Expand Down
5 changes: 1 addition & 4 deletions tests/run-pass/enum-glob-import-crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.




#![deny(clippy::all)]
#![allow(unused_imports)]

use std::*;

fn main() { }
fn main() {}
9 changes: 3 additions & 6 deletions tests/run-pass/ice-1588.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.




#![allow(clippy::all)]

fn main() {
match 1 {
1 => {}
1 => {},
2 => {
[0; 1];
}
_ => {}
},
_ => {},
}
}
16 changes: 12 additions & 4 deletions tests/run-pass/ice-1782.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,28 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.


#![allow(dead_code, unused_variables)]

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

fn spanless_eq_ice() {
let txt = "something";
match txt {
"something" => unsafe { ptr::write(ptr::null_mut() as *mut u32, mem::transmute::<[u8; 4], _>([0, 0, 0, 255])) },
_ => unsafe { ptr::write(ptr::null_mut() as *mut u32, mem::transmute::<[u8; 4], _>([13, 246, 24, 255])) },
"something" => unsafe {
ptr::write(
ptr::null_mut() as *mut u32,
mem::transmute::<[u8; 4], _>([0, 0, 0, 255]),
)
},
_ => unsafe {
ptr::write(
ptr::null_mut() as *mut u32,
mem::transmute::<[u8; 4], _>([13, 246, 24, 255]),
)
},
}
}

Expand Down
5 changes: 1 addition & 4 deletions tests/run-pass/ice-1969.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.




#![allow(clippy::all)]

fn main() { }
fn main() {}

pub trait Convert {
type Action: From<*const f64>;
Expand Down
17 changes: 8 additions & 9 deletions tests/run-pass/ice-2499.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.




#![allow(dead_code, clippy::char_lit_as_u8, clippy::needless_bool)]

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

match t {
'E' | 'W' => {}
'T' => if s[0..4] != ['0' as u8; 4] {
return false;
} else {
return true;
'E' | 'W' => {},
'T' => {
if s[0..4] != ['0' as u8; 4] {
return false;
} else {
return true;
}
},
_ => {
return false;
}
},
}
true
}
Expand Down
3 changes: 1 addition & 2 deletions tests/run-pass/ice-2594.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.


#![allow(dead_code, unused_variables)]

/// Should not trigger an ICE in `SpanlessHash` / `consts::constant`
Expand All @@ -21,7 +20,7 @@ fn spanless_hash_ice() {
match txt {
"something" => {
let mut headers = [empty_header; 1];
}
},
"" => (),
_ => (),
}
Expand Down
1 change: 0 additions & 1 deletion tests/run-pass/ice-2727.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.


pub fn f(new: fn()) {
new();
}
Expand Down
11 changes: 6 additions & 5 deletions tests/run-pass/ice-2760.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.




#![allow(unused_variables, clippy::blacklisted_name,
clippy::needless_pass_by_value, dead_code)]
#![allow(
unused_variables,
clippy::blacklisted_name,
clippy::needless_pass_by_value,
dead_code
)]

// This should not compile-fail with:
//
Expand Down
11 changes: 2 additions & 9 deletions tests/run-pass/ice-2774.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.




use std::collections::HashSet;

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

#[allow(clippy::implicit_hasher)]
// Also this should not cause a 'cannot relate bound region' ICE
pub fn add_barfoos_to_foos2(bars: &HashSet<&Bar>) {
let mut foos = HashSet::new();
foos.extend(
bars.iter().map(|b| &b.foo)
);
foos.extend(bars.iter().map(|b| &b.foo));
}

fn main() {}
3 changes: 1 addition & 2 deletions tests/run-pass/ice-2865.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.


#[allow(dead_code)]
struct Ice {
size: String
size: String,
}

impl<'a> From<String> for Ice {
Expand Down
5 changes: 2 additions & 3 deletions tests/run-pass/ice-3151.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.


#[derive(Clone)]
pub struct HashMap<V, S> {
hash_builder: S,
Expand All @@ -17,7 +16,7 @@ pub struct HashMap<V, S> {
#[derive(Clone)]
pub struct RawTable<V> {
size: usize,
val: V
val: V,
}

fn main() {}
fn main() {}
3 changes: 0 additions & 3 deletions tests/run-pass/ice-700.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.




#![deny(clippy::all)]

fn core() {}
Expand Down
3 changes: 0 additions & 3 deletions tests/run-pass/ice_exacte_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.




#![deny(clippy::all)]

#[allow(dead_code)]
Expand Down
3 changes: 0 additions & 3 deletions tests/run-pass/if_same_then_else.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.




#![deny(clippy::if_same_then_else)]

fn main() {}
Expand Down
1 change: 0 additions & 1 deletion tests/run-pass/issue-2862.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.


pub trait FooMap {
fn map<B, F: Fn() -> B>(&self, f: F) -> B;
}
Expand Down
17 changes: 13 additions & 4 deletions tests/run-pass/issue-825.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,23 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.


#![allow(warnings)]

// this should compile in a reasonable amount of time
fn rust_type_id(name: &str) {
if "bool" == &name[..] || "uint" == &name[..] || "u8" == &name[..] || "u16" == &name[..] || "u32" == &name[..]
|| "f32" == &name[..] || "f64" == &name[..] || "i8" == &name[..] || "i16" == &name[..]
|| "i32" == &name[..] || "i64" == &name[..] || "Self" == &name[..] || "str" == &name[..]
if "bool" == &name[..]
|| "uint" == &name[..]
|| "u8" == &name[..]
|| "u16" == &name[..]
|| "u32" == &name[..]
|| "f32" == &name[..]
|| "f64" == &name[..]
|| "i8" == &name[..]
|| "i16" == &name[..]
|| "i32" == &name[..]
|| "i64" == &name[..]
|| "Self" == &name[..]
|| "str" == &name[..]
{
unreachable!();
}
Expand Down
1 change: 0 additions & 1 deletion tests/run-pass/issues_loop_mut_cond.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.


#![allow(dead_code)]

/// Issue: https://github.com/rust-lang/rust-clippy/issues/2596
Expand Down
5 changes: 1 addition & 4 deletions tests/run-pass/match_same_arms_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.




#![deny(clippy::match_same_arms)]

const PRICE_OF_SWEETS: u32 = 5;
Expand All @@ -21,7 +18,7 @@ pub fn price(thing: &str) -> u32 {
"rolo" => PRICE_OF_SWEETS,
"advice" => PRICE_OF_KINDNESS,
"juice" => PRICE_OF_DRINKS,
_ => panic!()
_ => panic!(),
}
}

Expand Down
3 changes: 0 additions & 3 deletions tests/run-pass/mut_mut_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.




#![deny(clippy::mut_mut, clippy::zero_ptr, clippy::cmp_nan)]
#![allow(dead_code)]

Expand Down
Loading

0 comments on commit e2608fc

Please sign in to comment.