@@ -70,18 +70,26 @@ lto = "fat"
70
70
# ============================
71
71
#
72
72
# Lints
73
+ #
74
+ # - strict set of lints for a
75
+ # more consistent codebase
76
+ #
77
+ # - delegate as much as possible
78
+ # to automated tooling
73
79
#
74
80
# ============================
75
81
76
82
[lints .rust ]
83
+ # do not import if its already in scope
84
+ # e.g. `use std::option::Option::None`
77
85
redundant_imports = " warn"
78
86
# Documentation for all public items
79
87
missing_docs = " warn"
80
88
# `foo::bar::baz` => `bar::baz` if `bar` is in scope
81
89
unused_qualifications = " warn"
82
90
# detects rules of macros that weren't used
83
91
unused_macro_rules = " warn"
84
- # lints against e.g. undefinedd meta variables
92
+ # lints against e.g. undefined meta variables
85
93
meta_variable_misuse = " warn"
86
94
# all types must `#[derive(Copy)]`
87
95
missing_copy_implementations = " warn"
@@ -91,20 +99,6 @@ missing_debug_implementations = "warn"
91
99
[lints .clippy ]
92
100
pedantic = { priority = -1 , level = " warn" }
93
101
94
- # --- allowed lints
95
- #
96
- # `$a * $b + $c` is slower and less precise than `$a.mul_add($b, $c)`
97
- # but it is more readable, the gain in speed / precision
98
- # will be negligible in most situations
99
- suboptimal_flops = " allow"
100
- # arbitrary limit imposes unnecessary
101
- # restriction and can make code harder to follow
102
- too_many_lines = " allow"
103
- # if we need it const, make it const.
104
- # no need to make everything that can be const, const
105
- missing_const_for_fn = " allow"
106
- # ---
107
-
108
102
# --- more consistent ways of writing code
109
103
#
110
104
# `if $a { Some($b) } else { None }` => `$a.then(|| $b)`
@@ -118,22 +112,55 @@ redundant_test_prefix = "warn"
118
112
# `123832i64` => `123832_i64`
119
113
unseparated_literal_suffix = " warn"
120
114
# `Foo { a: _, b: 0, .. }` => `Foo { b: 0, .. }`
115
+ # do not bind unused by `_` when pattern matching, bind by `..` instead
121
116
unneeded_field_pattern = " warn"
117
+ # `Err(x)?` => `return Err(x)`
118
+ try_err = " warn"
119
+ # `#[test] fn` must be in `#[cfg(test)]`
120
+ tests_outside_test_module = " warn"
121
+ # functions ending in `.and_then` could be better expressed as `?`
122
+ return_and_then = " warn"
123
+ # `match (A { a }) { A { a, .. } => () }` => `match (A { a: 5 }) { A { a } => () }`
124
+ rest_pat_in_fully_bound_structs = " warn"
125
+ # do not use differing names from the trait itself when implementing its method
126
+ renamed_function_params = " warn"
127
+ # `0x2345 & 0xF000 >> 12` => `0x2345 & (0xF000 >> 12)`
128
+ precedence_bits = " warn"
129
+ # omitting type annotations make code easier to modify
130
+ redundant_type_annotations = " warn"
131
+ # `assert!(r.is_ok())` => `r.unwrap()`
132
+ assertions_on_result_states = " warn"
133
+ # `fs::read_to_string` requires much less steps than `File::read_to_string`
134
+ verbose_file_reads = " warn"
135
+ # `use std::io::{self}` => `use std::io`
136
+ unnecessary_self_imports = " warn"
137
+ # do not lose type information about NonZero numbers
138
+ non_zero_suggestions = " warn"
139
+ # exit obscures flow of the program
140
+ exit = " warn"
141
+ # no need for a `SAFETY:` comment on safe code
142
+ unnecessary_safety_comment = " warn"
143
+ # each `unsafe` block must contain only 1 unsafe operation
144
+ multiple_unsafe_ops_per_block = " warn"
122
145
# ---
123
146
124
147
# --- explain more things
125
148
#
126
149
# `#[allow]` => `#[allow, reason = "why"]`
127
150
allow_attributes_without_reason = " warn"
151
+ # `unsafe` blocks need a `SAFETY:` comment
152
+ undocumented_unsafe_blocks = " warn"
128
153
# `.unwrap()` => `.expect("why")`
129
154
unwrap_used = " warn"
155
+ # `arr[4]` => `arr.get(4).expect("why")`
156
+ indexing_slicing = " warn"
130
157
# `assert!(...)` => `assert!(..., "why")`
131
158
missing_assert_message = " warn"
132
159
# documentation for everything
133
160
missing_docs_in_private_items = " warn"
134
161
# `path_buf.push("foo")` => `... = PathBuf::new().join("foo")`
135
162
pathbuf_init_then_push = " warn"
136
- # mark return type as `!` for infinite loop fns
163
+ # explicitly mark return type as `!` for infinite loop fns
137
164
infinite_loop = " warn"
138
165
# ---
139
166
@@ -143,22 +170,34 @@ dbg_macro = "warn"
143
170
todo = " warn"
144
171
use_debug = " warn"
145
172
unimplemented = " warn"
146
- print_stdout = " warn" # > explicitly `#[allow]` functions to print
147
- print_stderr = " warn" # >
173
+ # explicitly `#[allow]` functions to print to stdout
174
+ print_stdout = " warn"
175
+ # explicitly `#[allow]` functions to print to stderr
176
+ print_stderr = " warn"
148
177
# ---
149
178
179
+ # --- prevent bugs
180
+ # new variants added by libraries become errors
181
+ # instead of being silently ignored
182
+ wildcard_enum_match_arm = " warn"
183
+ # if function and trait provide method of same name, it is confusing
184
+ same_name_method = " warn"
150
185
# `create_dir(...)` => `create_dir_all(...)`
151
186
# usually, failing when dir already exists is
152
187
# not what we want
153
188
create_dir = " warn"
154
- # `fs::read_to_string` requires much less steps than `File::read_to_string`
155
- verbose_file_reads = " warn"
156
- # new variants added by libraries become errors
157
- # instead of being silently ignored
158
- wildcard_enum_match_arm = " warn"
159
- # `use std::io::{self}` => `use std::io`
160
- unnecessary_self_imports = " warn"
161
- # do not lose type information about NonZero numbers
162
- non_zero_suggestions = " warn"
163
- # exit should only happen from `main`
164
- exit = " warn"
189
+ # ---
190
+
191
+ # --- allowed lints
192
+ #
193
+ # `$a * $b + $c` is slower and less precise than `$a.mul_add($b, $c)`
194
+ # but it is more readable, the gain in speed / precision
195
+ # will be negligible in most situations
196
+ suboptimal_flops = " allow"
197
+ # arbitrary limit imposes unnecessary
198
+ # restriction and can make code harder to follow
199
+ too_many_lines = " allow"
200
+ # if we need it const, make it const.
201
+ # no need to make everything that can be const, const
202
+ missing_const_for_fn = " allow"
203
+ # ---
0 commit comments