mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-13 12:36:47 +00:00
test formatting: don't format tests/ui/formatting.rs
This commit is contained in:
parent
7bcc2cd9c8
commit
0a6e568f07
@ -35,7 +35,7 @@ set +ex
|
||||
|
||||
# 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/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
|
||||
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
|
||||
|
||||
|
@ -7,57 +7,59 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#![warn(clippy::all)]
|
||||
#![allow(unused_variables)]
|
||||
#![allow(unused_assignments)]
|
||||
#![allow(clippy::if_same_then_else)]
|
||||
#![allow(clippy::deref_addrof)]
|
||||
|
||||
fn foo() -> bool {
|
||||
true
|
||||
}
|
||||
fn foo() -> bool { true }
|
||||
|
||||
fn main() {
|
||||
// weird `else if` formatting:
|
||||
if foo() {}
|
||||
if foo() {}
|
||||
if foo() {
|
||||
} if foo() {
|
||||
}
|
||||
|
||||
let _ = {
|
||||
// if as the last expression
|
||||
let _ = { // if as the last expression
|
||||
let _ = 0;
|
||||
|
||||
if foo() {}
|
||||
if foo() {
|
||||
} else {
|
||||
} if foo() {
|
||||
}
|
||||
else {
|
||||
}
|
||||
};
|
||||
|
||||
let _ = {
|
||||
// if in the middle of a block
|
||||
if foo() {}
|
||||
let _ = { // if in the middle of a block
|
||||
if foo() {
|
||||
} else {
|
||||
} if foo() {
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
let _ = 0;
|
||||
};
|
||||
|
||||
if foo() {
|
||||
} else if foo() {
|
||||
// the span of the above error should continue here
|
||||
} else
|
||||
if foo() { // the span of the above error should continue here
|
||||
}
|
||||
|
||||
if foo() {
|
||||
} else if foo() {
|
||||
// the span of the above error should continue here
|
||||
}
|
||||
else
|
||||
if foo() { // the span of the above error should continue here
|
||||
}
|
||||
|
||||
// those are ok:
|
||||
if foo() {}
|
||||
if foo() {}
|
||||
|
||||
if foo() {
|
||||
} else if foo() {
|
||||
}
|
||||
if foo() {
|
||||
}
|
||||
|
||||
if foo() {
|
||||
@ -65,16 +67,22 @@ fn main() {
|
||||
}
|
||||
|
||||
if foo() {
|
||||
} else if foo() {
|
||||
}
|
||||
else if foo() {
|
||||
}
|
||||
|
||||
if foo() {
|
||||
}
|
||||
else if
|
||||
foo() {}
|
||||
|
||||
// weird op_eq formatting:
|
||||
let mut a = 42;
|
||||
a = -35;
|
||||
a = *&191;
|
||||
a =- 35;
|
||||
a =* &191;
|
||||
|
||||
let mut b = true;
|
||||
b = !false;
|
||||
b =! false;
|
||||
|
||||
// those are ok:
|
||||
a = -35;
|
||||
@ -83,30 +91,37 @@ fn main() {
|
||||
|
||||
// possible missing comma in an array
|
||||
let _ = &[
|
||||
-1,
|
||||
-2,
|
||||
-3 // <= no comma here
|
||||
-4,
|
||||
-5,
|
||||
-6,
|
||||
-1, -2, -3 // <= no comma here
|
||||
-4, -5, -6
|
||||
];
|
||||
let _ = &[
|
||||
-1,
|
||||
-2,
|
||||
-3 // <= no comma here
|
||||
*4,
|
||||
-5,
|
||||
-6,
|
||||
-1, -2, -3 // <= no comma here
|
||||
*4, -5, -6
|
||||
];
|
||||
|
||||
// those are ok:
|
||||
let _ = &[-1, -2, -3, -4, -5, -6];
|
||||
let _ = &[-1, -2, -3, -4, -5, -6];
|
||||
let _ = &[1 + 2, 3 + 4, 5 + 6];
|
||||
let _ = &[
|
||||
-1, -2, -3,
|
||||
-4, -5, -6
|
||||
];
|
||||
let _ = &[
|
||||
-1, -2, -3,
|
||||
-4, -5, -6,
|
||||
];
|
||||
let _ = &[
|
||||
1 + 2, 3 +
|
||||
4, 5 + 6,
|
||||
];
|
||||
|
||||
// don't lint for bin op without unary equiv
|
||||
// issue 3244
|
||||
vec![1 / 2];
|
||||
vec![
|
||||
1
|
||||
/ 2,
|
||||
];
|
||||
// issue 3396
|
||||
vec![true | false];
|
||||
vec![
|
||||
true
|
||||
| false,
|
||||
];
|
||||
}
|
||||
|
@ -1,19 +1,90 @@
|
||||
error: possibly missing a comma here
|
||||
--> $DIR/formatting.rs:88:11
|
||||
error: this looks like an `else if` but the `else` is missing
|
||||
--> $DIR/formatting.rs:25:6
|
||||
|
|
||||
88 | -3 // <= no comma here
|
||||
| ^
|
||||
25 | } if foo() {
|
||||
| ^
|
||||
|
|
||||
= note: `-D clippy::suspicious-else-formatting` implied by `-D warnings`
|
||||
= note: to remove this lint, add the missing `else` or add a new line before the second `if`
|
||||
|
||||
error: this looks like an `else if` but the `else` is missing
|
||||
--> $DIR/formatting.rs:32:10
|
||||
|
|
||||
32 | } if foo() {
|
||||
| ^
|
||||
|
|
||||
= note: to remove this lint, add the missing `else` or add a new line before the second `if`
|
||||
|
||||
error: this looks like an `else if` but the `else` is missing
|
||||
--> $DIR/formatting.rs:40:10
|
||||
|
|
||||
40 | } if foo() {
|
||||
| ^
|
||||
|
|
||||
= note: to remove this lint, add the missing `else` or add a new line before the second `if`
|
||||
|
||||
error: this is an `else if` but the formatting might hide it
|
||||
--> $DIR/formatting.rs:49:6
|
||||
|
|
||||
49 | } else
|
||||
| ______^
|
||||
50 | | if foo() { // the span of the above error should continue here
|
||||
| |____^
|
||||
|
|
||||
= note: to remove this lint, remove the `else` or remove the new line between `else` and `if`
|
||||
|
||||
error: this is an `else if` but the formatting might hide it
|
||||
--> $DIR/formatting.rs:54:6
|
||||
|
|
||||
54 | }
|
||||
| ______^
|
||||
55 | | else
|
||||
56 | | if foo() { // the span of the above error should continue here
|
||||
| |____^
|
||||
|
|
||||
= note: to remove this lint, remove the `else` or remove the new line between `else` and `if`
|
||||
|
||||
error: this looks like you are trying to use `.. -= ..`, but you really are doing `.. = (- ..)`
|
||||
--> $DIR/formatting.rs:81:6
|
||||
|
|
||||
81 | a =- 35;
|
||||
| ^^^^
|
||||
|
|
||||
= note: `-D clippy::suspicious-assignment-formatting` implied by `-D warnings`
|
||||
= note: to remove this lint, use either `-=` or `= -`
|
||||
|
||||
error: this looks like you are trying to use `.. *= ..`, but you really are doing `.. = (* ..)`
|
||||
--> $DIR/formatting.rs:82:6
|
||||
|
|
||||
82 | a =* &191;
|
||||
| ^^^^
|
||||
|
|
||||
= note: to remove this lint, use either `*=` or `= *`
|
||||
|
||||
error: this looks like you are trying to use `.. != ..`, but you really are doing `.. = (! ..)`
|
||||
--> $DIR/formatting.rs:85:6
|
||||
|
|
||||
85 | b =! false;
|
||||
| ^^^^
|
||||
|
|
||||
= note: to remove this lint, use either `!=` or `= !`
|
||||
|
||||
error: possibly missing a comma here
|
||||
--> $DIR/formatting.rs:94:19
|
||||
|
|
||||
94 | -1, -2, -3 // <= no comma here
|
||||
| ^
|
||||
|
|
||||
= note: `-D clippy::possible-missing-comma` implied by `-D warnings`
|
||||
= note: to remove this lint, add a comma or write the expr in a single line
|
||||
|
||||
error: possibly missing a comma here
|
||||
--> $DIR/formatting.rs:96:11
|
||||
--> $DIR/formatting.rs:98:19
|
||||
|
|
||||
96 | -3 // <= no comma here
|
||||
| ^
|
||||
98 | -1, -2, -3 // <= no comma here
|
||||
| ^
|
||||
|
|
||||
= note: to remove this lint, add a comma or write the expr in a single line
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user