Skip to content

Commit 0799be7

Browse files
authored
Rollup merge of rust-lang#5712 - ijijn:master, r=flip1995
Remove `bar` from blacklisted names changelog: Remove `bar` from blacklisted names fixes rust-lang#5225
2 parents 24b77ea + 454ed47 commit 0799be7

File tree

3 files changed

+53
-48
lines changed

3 files changed

+53
-48
lines changed

clippy_lints/src/utils/conf.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ macro_rules! define_Conf {
106106

107107
pub use self::helpers::Conf;
108108
define_Conf! {
109-
/// Lint: BLACKLISTED_NAME. The list of blacklisted names to lint about
110-
(blacklisted_names, "blacklisted_names": Vec<String>, ["foo", "bar", "baz", "quux"].iter().map(ToString::to_string).collect()),
109+
/// Lint: BLACKLISTED_NAME. The list of blacklisted names to lint about. NB: `bar` is not here since it has legitimate uses
110+
(blacklisted_names, "blacklisted_names": Vec<String>, ["foo", "baz", "quux"].iter().map(ToString::to_string).collect()),
111111
/// Lint: COGNITIVE_COMPLEXITY. The maximum cognitive complexity a function can have
112112
(cognitive_complexity_threshold, "cognitive_complexity_threshold": u64, 25),
113113
/// DEPRECATED LINT: CYCLOMATIC_COMPLEXITY. Use the Cognitive Complexity lint instead.

tests/ui/blacklisted_name.rs

+15-10
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,34 @@ fn test(foo: ()) {}
1212

1313
fn main() {
1414
let foo = 42;
15-
let bar = 42;
1615
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;
1721

18-
let barb = 42;
19-
let barbaric = 42;
22+
let food = 42;
23+
let foodstuffs = 42;
24+
let bazaar = 42;
2025

2126
match (42, Some(1337), Some(0)) {
22-
(foo, Some(bar), baz @ Some(_)) => (),
27+
(foo, Some(baz), quux @ Some(_)) => (),
2328
_ => (),
2429
}
2530
}
2631

2732
fn issue_1647(mut foo: u8) {
28-
let mut bar = 0;
29-
if let Some(mut baz) = Some(42) {}
33+
let mut baz = 0;
34+
if let Some(mut quux) = Some(42) {}
3035
}
3136

3237
fn issue_1647_ref() {
33-
let ref bar = 0;
34-
if let Some(ref baz) = Some(42) {}
38+
let ref baz = 0;
39+
if let Some(ref quux) = Some(42) {}
3540
}
3641

3742
fn issue_1647_ref_mut() {
38-
let ref mut bar = 0;
39-
if let Some(ref mut baz) = Some(42) {}
43+
let ref mut baz = 0;
44+
if let Some(ref mut quux) = Some(42) {}
4045
}

tests/ui/blacklisted_name.stderr

+36-36
Original file line numberDiff line numberDiff line change
@@ -12,77 +12,77 @@ error: use of a blacklisted/placeholder name `foo`
1212
LL | let foo = 42;
1313
| ^^^
1414

15-
error: use of a blacklisted/placeholder name `bar`
15+
error: use of a blacklisted/placeholder name `baz`
1616
--> $DIR/blacklisted_name.rs:15:9
1717
|
18-
LL | let bar = 42;
18+
LL | let baz = 42;
1919
| ^^^
2020

21-
error: use of a blacklisted/placeholder name `baz`
21+
error: use of a blacklisted/placeholder name `quux`
2222
--> $DIR/blacklisted_name.rs:16:9
2323
|
24-
LL | let baz = 42;
25-
| ^^^
24+
LL | let quux = 42;
25+
| ^^^^
2626

2727
error: use of a blacklisted/placeholder name `foo`
28-
--> $DIR/blacklisted_name.rs:22:10
28+
--> $DIR/blacklisted_name.rs:27:10
2929
|
30-
LL | (foo, Some(bar), baz @ Some(_)) => (),
30+
LL | (foo, Some(baz), quux @ Some(_)) => (),
3131
| ^^^
3232

33-
error: use of a blacklisted/placeholder name `bar`
34-
--> $DIR/blacklisted_name.rs:22:20
33+
error: use of a blacklisted/placeholder name `baz`
34+
--> $DIR/blacklisted_name.rs:27:20
3535
|
36-
LL | (foo, Some(bar), baz @ Some(_)) => (),
36+
LL | (foo, Some(baz), quux @ Some(_)) => (),
3737
| ^^^
3838

39-
error: use of a blacklisted/placeholder name `baz`
40-
--> $DIR/blacklisted_name.rs:22:26
39+
error: use of a blacklisted/placeholder name `quux`
40+
--> $DIR/blacklisted_name.rs:27:26
4141
|
42-
LL | (foo, Some(bar), baz @ Some(_)) => (),
43-
| ^^^
42+
LL | (foo, Some(baz), quux @ Some(_)) => (),
43+
| ^^^^
4444

4545
error: use of a blacklisted/placeholder name `foo`
46-
--> $DIR/blacklisted_name.rs:27:19
46+
--> $DIR/blacklisted_name.rs:32:19
4747
|
4848
LL | fn issue_1647(mut foo: u8) {
4949
| ^^^
5050

51-
error: use of a blacklisted/placeholder name `bar`
52-
--> $DIR/blacklisted_name.rs:28:13
51+
error: use of a blacklisted/placeholder name `baz`
52+
--> $DIR/blacklisted_name.rs:33:13
5353
|
54-
LL | let mut bar = 0;
54+
LL | let mut baz = 0;
5555
| ^^^
5656

57-
error: use of a blacklisted/placeholder name `baz`
58-
--> $DIR/blacklisted_name.rs:29:21
57+
error: use of a blacklisted/placeholder name `quux`
58+
--> $DIR/blacklisted_name.rs:34:21
5959
|
60-
LL | if let Some(mut baz) = Some(42) {}
61-
| ^^^
60+
LL | if let Some(mut quux) = Some(42) {}
61+
| ^^^^
6262

63-
error: use of a blacklisted/placeholder name `bar`
64-
--> $DIR/blacklisted_name.rs:33:13
63+
error: use of a blacklisted/placeholder name `baz`
64+
--> $DIR/blacklisted_name.rs:38:13
6565
|
66-
LL | let ref bar = 0;
66+
LL | let ref baz = 0;
6767
| ^^^
6868

69-
error: use of a blacklisted/placeholder name `baz`
70-
--> $DIR/blacklisted_name.rs:34:21
69+
error: use of a blacklisted/placeholder name `quux`
70+
--> $DIR/blacklisted_name.rs:39:21
7171
|
72-
LL | if let Some(ref baz) = Some(42) {}
73-
| ^^^
72+
LL | if let Some(ref quux) = Some(42) {}
73+
| ^^^^
7474

75-
error: use of a blacklisted/placeholder name `bar`
76-
--> $DIR/blacklisted_name.rs:38:17
75+
error: use of a blacklisted/placeholder name `baz`
76+
--> $DIR/blacklisted_name.rs:43:17
7777
|
78-
LL | let ref mut bar = 0;
78+
LL | let ref mut baz = 0;
7979
| ^^^
8080

81-
error: use of a blacklisted/placeholder name `baz`
82-
--> $DIR/blacklisted_name.rs:39:25
81+
error: use of a blacklisted/placeholder name `quux`
82+
--> $DIR/blacklisted_name.rs:44:25
8383
|
84-
LL | if let Some(ref mut baz) = Some(42) {}
85-
| ^^^
84+
LL | if let Some(ref mut quux) = Some(42) {}
85+
| ^^^^
8686

8787
error: aborting due to 14 previous errors
8888

0 commit comments

Comments
 (0)