Skip to content

Commit 1d8dd5b

Browse files
committed
Fix tests
1 parent 4728151 commit 1d8dd5b

10 files changed

+150
-89
lines changed

clippy_lints/src/utils/conf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ macro_rules! define_Conf {
107107
pub use self::helpers::Conf;
108108
define_Conf! {
109109
/// DEPRECATED LINT: BLACKLISTED_NAME. Use the Disallowed Names lint instead.
110-
(blacklisted_names, "blacklisted_names": Vec<String>, ["foo", "baz", "quux"].iter().map(ToString::to_string).collect()),
110+
(blacklisted_names, "blacklisted_names": Vec<String>, vec![]),
111111
/// Lint: DISALLOWED_NAME. The list of disallowed names to lint about. NB: `bar` is not here since it has legitimate uses
112112
(disallowed_names, "disallowed_names": Vec<String>, ["foo", "baz", "quux"].iter().map(ToString::to_string).collect()),
113113
/// Lint: COGNITIVE_COMPLEXITY. The maximum cognitive complexity a function can have
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: error reading Clippy's configuration file `$DIR/clippy.toml`: unknown field `foobar`, expected one of `disallowed-names`, `cognitive-complexity-threshold`, `cyclomatic-complexity-threshold`, `doc-valid-idents`, `too-many-arguments-threshold`, `type-complexity-threshold`, `single-char-binding-names-threshold`, `too-large-for-stack`, `enum-variant-name-threshold`, `enum-variant-size-threshold`, `verbose-bit-mask-threshold`, `literal-representation-threshold`, `trivial-copy-size-limit`, `too-many-lines-threshold`, `array-size-threshold`, `vec-box-size-threshold`, `max-trait-bounds`, `max-struct-bools`, `max-fn-params-bools`, `warn-on-all-wildcard-imports`, `third-party` at line 5 column 1
1+
error: error reading Clippy's configuration file `$DIR/clippy.toml`: unknown field `foobar`, expected one of `blacklisted-names`, `disallowed-names`, `cognitive-complexity-threshold`, `cyclomatic-complexity-threshold`, `doc-valid-idents`, `too-many-arguments-threshold`, `type-complexity-threshold`, `single-char-binding-names-threshold`, `too-large-for-stack`, `enum-variant-name-threshold`, `enum-variant-size-threshold`, `verbose-bit-mask-threshold`, `literal-representation-threshold`, `trivial-copy-size-limit`, `too-many-lines-threshold`, `array-size-threshold`, `vec-box-size-threshold`, `max-trait-bounds`, `max-struct-bools`, `max-fn-params-bools`, `warn-on-all-wildcard-imports`, `third-party` at line 5 column 1
22

33
error: aborting due to previous error
44

tests/ui/blacklisted_name.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
unused_mut,
77
unused_variables
88
)]
9-
#![warn(clippy::disallowed_name)]
9+
#![warn(clippy::blacklisted_name)]
1010

1111
fn test(foo: ()) {}
1212

tests/ui/blacklisted_name.stderr

+10-82
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,16 @@
1-
error: use of a disallowed/placeholder name `foo`
2-
--> $DIR/disallowed_name.rs:11:9
1+
error: lint `clippy::blacklisted_name` has been renamed to `clippy::disallowed_name`
2+
--> $DIR/blacklisted_name.rs:9:9
33
|
4-
LL | fn test(foo: ()) {}
5-
| ^^^
4+
LL | #![warn(clippy::blacklisted_name)]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_name`
66
|
7-
= note: `-D clippy::disallowed-name` implied by `-D warnings`
7+
= note: `-D renamed-and-removed-lints` implied by `-D warnings`
88

9-
error: use of a disallowed/placeholder name `foo`
10-
--> $DIR/disallowed_name.rs:14:9
9+
error: lint `clippy::blacklisted_name` has been renamed to `clippy::disallowed_name`
10+
--> $DIR/blacklisted_name.rs:9:9
1111
|
12-
LL | let foo = 42;
13-
| ^^^
12+
LL | #![warn(clippy::blacklisted_name)]
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_name`
1414

15-
error: use of a disallowed/placeholder name `baz`
16-
--> $DIR/disallowed_name.rs:15:9
17-
|
18-
LL | let baz = 42;
19-
| ^^^
20-
21-
error: use of a disallowed/placeholder name `quux`
22-
--> $DIR/disallowed_name.rs:16:9
23-
|
24-
LL | let quux = 42;
25-
| ^^^^
26-
27-
error: use of a disallowed/placeholder name `foo`
28-
--> $DIR/disallowed_name.rs:27:10
29-
|
30-
LL | (foo, Some(baz), quux @ Some(_)) => (),
31-
| ^^^
32-
33-
error: use of a disallowed/placeholder name `baz`
34-
--> $DIR/disallowed_name.rs:27:20
35-
|
36-
LL | (foo, Some(baz), quux @ Some(_)) => (),
37-
| ^^^
38-
39-
error: use of a disallowed/placeholder name `quux`
40-
--> $DIR/disallowed_name.rs:27:26
41-
|
42-
LL | (foo, Some(baz), quux @ Some(_)) => (),
43-
| ^^^^
44-
45-
error: use of a disallowed/placeholder name `foo`
46-
--> $DIR/disallowed_name.rs:32:19
47-
|
48-
LL | fn issue_1647(mut foo: u8) {
49-
| ^^^
50-
51-
error: use of a disallowed/placeholder name `baz`
52-
--> $DIR/disallowed_name.rs:33:13
53-
|
54-
LL | let mut baz = 0;
55-
| ^^^
56-
57-
error: use of a disallowed/placeholder name `quux`
58-
--> $DIR/disallowed_name.rs:34:21
59-
|
60-
LL | if let Some(mut quux) = Some(42) {}
61-
| ^^^^
62-
63-
error: use of a disallowed/placeholder name `baz`
64-
--> $DIR/disallowed_name.rs:38:13
65-
|
66-
LL | let ref baz = 0;
67-
| ^^^
68-
69-
error: use of a disallowed/placeholder name `quux`
70-
--> $DIR/disallowed_name.rs:39:21
71-
|
72-
LL | if let Some(ref quux) = Some(42) {}
73-
| ^^^^
74-
75-
error: use of a disallowed/placeholder name `baz`
76-
--> $DIR/disallowed_name.rs:43:17
77-
|
78-
LL | let ref mut baz = 0;
79-
| ^^^
80-
81-
error: use of a disallowed/placeholder name `quux`
82-
--> $DIR/disallowed_name.rs:44:25
83-
|
84-
LL | if let Some(ref mut quux) = Some(42) {}
85-
| ^^^^
86-
87-
error: aborting due to 14 previous errors
15+
error: aborting due to 2 previous errors
8816

tests/ui/disallowed_name.rs

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#![allow(
2+
dead_code,
3+
clippy::similar_names,
4+
clippy::single_match,
5+
clippy::toplevel_ref_arg,
6+
unused_mut,
7+
unused_variables
8+
)]
9+
#![warn(clippy::disallowed_name)]
10+
11+
fn test(foo: ()) {}
12+
13+
fn main() {
14+
let foo = 42;
15+
let baz = 42;
16+
let quux = 42;
17+
// Unlike these others, `bar` is actually considered an acceptable name.
18+
// Among many other legitimate uses, bar commonly refers to a period of time in music.
19+
// See https://github.com/rust-lang/rust-clippy/issues/5225.
20+
let bar = 42;
21+
22+
let food = 42;
23+
let foodstuffs = 42;
24+
let bazaar = 42;
25+
26+
match (42, Some(1337), Some(0)) {
27+
(foo, Some(baz), quux @ Some(_)) => (),
28+
_ => (),
29+
}
30+
}
31+
32+
fn issue_1647(mut foo: u8) {
33+
let mut baz = 0;
34+
if let Some(mut quux) = Some(42) {}
35+
}
36+
37+
fn issue_1647_ref() {
38+
let ref baz = 0;
39+
if let Some(ref quux) = Some(42) {}
40+
}
41+
42+
fn issue_1647_ref_mut() {
43+
let ref mut baz = 0;
44+
if let Some(ref mut quux) = Some(42) {}
45+
}

tests/ui/disallowed_name.stderr

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
error: use of a disallowed/placeholder name `foo`
2+
--> $DIR/disallowed_name.rs:11:9
3+
|
4+
LL | fn test(foo: ()) {}
5+
| ^^^
6+
|
7+
= note: `-D clippy::disallowed-name` implied by `-D warnings`
8+
9+
error: use of a disallowed/placeholder name `foo`
10+
--> $DIR/disallowed_name.rs:14:9
11+
|
12+
LL | let foo = 42;
13+
| ^^^
14+
15+
error: use of a disallowed/placeholder name `baz`
16+
--> $DIR/disallowed_name.rs:15:9
17+
|
18+
LL | let baz = 42;
19+
| ^^^
20+
21+
error: use of a disallowed/placeholder name `quux`
22+
--> $DIR/disallowed_name.rs:16:9
23+
|
24+
LL | let quux = 42;
25+
| ^^^^
26+
27+
error: use of a disallowed/placeholder name `foo`
28+
--> $DIR/disallowed_name.rs:27:10
29+
|
30+
LL | (foo, Some(baz), quux @ Some(_)) => (),
31+
| ^^^
32+
33+
error: use of a disallowed/placeholder name `baz`
34+
--> $DIR/disallowed_name.rs:27:20
35+
|
36+
LL | (foo, Some(baz), quux @ Some(_)) => (),
37+
| ^^^
38+
39+
error: use of a disallowed/placeholder name `quux`
40+
--> $DIR/disallowed_name.rs:27:26
41+
|
42+
LL | (foo, Some(baz), quux @ Some(_)) => (),
43+
| ^^^^
44+
45+
error: use of a disallowed/placeholder name `foo`
46+
--> $DIR/disallowed_name.rs:32:19
47+
|
48+
LL | fn issue_1647(mut foo: u8) {
49+
| ^^^
50+
51+
error: use of a disallowed/placeholder name `baz`
52+
--> $DIR/disallowed_name.rs:33:13
53+
|
54+
LL | let mut baz = 0;
55+
| ^^^
56+
57+
error: use of a disallowed/placeholder name `quux`
58+
--> $DIR/disallowed_name.rs:34:21
59+
|
60+
LL | if let Some(mut quux) = Some(42) {}
61+
| ^^^^
62+
63+
error: use of a disallowed/placeholder name `baz`
64+
--> $DIR/disallowed_name.rs:38:13
65+
|
66+
LL | let ref baz = 0;
67+
| ^^^
68+
69+
error: use of a disallowed/placeholder name `quux`
70+
--> $DIR/disallowed_name.rs:39:21
71+
|
72+
LL | if let Some(ref quux) = Some(42) {}
73+
| ^^^^
74+
75+
error: use of a disallowed/placeholder name `baz`
76+
--> $DIR/disallowed_name.rs:43:17
77+
|
78+
LL | let ref mut baz = 0;
79+
| ^^^
80+
81+
error: use of a disallowed/placeholder name `quux`
82+
--> $DIR/disallowed_name.rs:44:25
83+
|
84+
LL | if let Some(ref mut quux) = Some(42) {}
85+
| ^^^^
86+
87+
error: aborting due to 14 previous errors
88+

tests/ui/let_if_seq.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: `if _ { .. } else { .. }` is an expression
2-
--> $DIR/let_if_seq.rs:63:5
2+
--> $DIR/let_if_seq.rs:58:5
33
|
44
LL | / let mut foo = 0;
55
LL | | if f() {
@@ -11,7 +11,7 @@ LL | | }
1111
= note: you might not need `mut` at all
1212

1313
error: `if _ { .. } else { .. }` is an expression
14-
--> $DIR/let_if_seq.rs:68:5
14+
--> $DIR/let_if_seq.rs:63:5
1515
|
1616
LL | / let mut bar = 0;
1717
LL | | if f() {
@@ -25,7 +25,7 @@ LL | | }
2525
= note: you might not need `mut` at all
2626

2727
error: `if _ { .. } else { .. }` is an expression
28-
--> $DIR/let_if_seq.rs:76:5
28+
--> $DIR/let_if_seq.rs:71:5
2929
|
3030
LL | / let quz;
3131
LL | | if f() {
@@ -36,7 +36,7 @@ LL | | }
3636
| |_____^ help: it is more idiomatic to write: `let quz = if f() { 42 } else { 0 };`
3737

3838
error: `if _ { .. } else { .. }` is an expression
39-
--> $DIR/let_if_seq.rs:105:5
39+
--> $DIR/let_if_seq.rs:100:5
4040
|
4141
LL | / let mut baz = 0;
4242
LL | | if f() {

0 commit comments

Comments
 (0)