-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclippy-control.toml
More file actions
153 lines (134 loc) · 3.19 KB
/
clippy-control.toml
File metadata and controls
153 lines (134 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# ## let_and_return = allow
#
# Allow patterns like
#
# let foo = {
# some_expression
# };
#
# foo
#
# ### Rationale
#
# Giving variables names can improve readability.
"let_and_return" = "allow"
# ## arithmetic_side_effects = deny
#
# Don't allow implicit arithmetic overflow.
#
# ### Rationale
#
# Most Rust code should explicitly handle overflow.
"arithmetic_side_effects" = "deny"
# ## "collapsible_else_if" = "allow"
#
# Allow `else` blocks that contain only `if` blocks.
#
# if foo {
# ...
# } else {
# if bar {
# ...
# }
# }
#
# Clippy prefers to write this
#
# if foo {
# ...
# } else if bar {
# ...
# }
#
# Sometimes it's nice for a bare `else` to explicitly
# convey that there are no other cases further
# down the code listing.
"collapsible_else_if" = "allow"
# ## "map_flatten" = "allow"
#
# Allow iterator chains of `map` followed by `flatten`.
#
# Flattening the result of `map` unwraps any `Some`
# values and ignores `None` values. This same
# behavor is provided my `filter_map`, which
# clippy prefers.
#
# source_map.chunks(db).iter().map(|chunk| {
# let chunk_lex = lex_chunk(db, chunk.C());
# parse_chunk(db, chunk_lex).clause(db)
# }).flatten().collect();
#
# vs.
#
# source_map.chunks(db).iter().filter_map(|chunk| {
# let chunk_lex = lex_chunk(db, chunk.C());
# parse_chunk(db, chunk_lex).clause(db)
# }).collect();
#
# `map` -> `flatten` is preferable because each step
# is focused on doing one thing, first mapping then flattening,
# rather than the combined map and flatten behavior of `filter_map`.
# Easier to think about one thing at a time.
"map_flatten" = "allow"
# ## "unnecessary_filter_map" = "allow"
#
# Allow `filter_map` when `filter` would work.
#
# let tokens = chunk_lex.tokens(db).iter()
# .filter_map(|token| {
# match token.kind(db) {
# TokenKind::Whitespace => None,
# TokenKind::Comment => None,
# _ => Some(token),
# }
# });
#
# vs.
#
# let tokens = chunk_lex.tokens(db).iter()
# .filter(|token| {
# match token.kind(db) {
# TokenKind::Whitespace => false,
# TokenKind::Comment => false,
# _ => true,
# }
# });
#
# `filter_map` may be prefered because `filter`
# relies on `true` and `false`, and it`s not immediately
# obvious what they mean: which one is "keep" and which
# is "discard"?
# Good suggestion, but not always wanted.
"unnecessary_filter_map" = "allow"
# ## "single_match" = "allow"
#
# Allow matches with a single non-empty arm
# instead of `if let`.
#
# match term {
# ir::Term::Error => break,
# _ => {}
# }
#
# vs.
#
# if let ir::Term::Error = term {
# break;
# }
#
# There may be cases where one prefers
# the more verbose version.
# Unconfident about this one.
"single_match" = "allow"
# ## "toplevel_ref_arg" = "allow"
#
# Allow `let ref`.
#
# let ref out_dir = book_out_dir(book);
#
# vs.
#
# let out_dir = &book_out_dir(book);
#
# `let ref` is clear and pretty.
"toplevel_ref_arg" = "allow"