Skip to content

Commit 2a239b9

Browse files
committed
Auto merge of rust-lang#16401 - Urhengulas:lint-table, r=Veykril
Expand lint tables && make clippy happy 🎉 This PR expands the lint tables on `./Cargo.toml` and thereby makes `cargo clippy` exit successfully! 🎉 Fixes rust-lang#15918 ## How? In the beginning there are some warnings for rustc. Next, and most importantly, there is the clippy lint table. There are a few sections in there. First there are the lint groups. Second there are all lints which are permanently allowed with the reasoning why they are allowed. Third there is a huge list of temporarily allowed lints. They should be removed in the mid-term, but incur a substantial amount of work, therefore they are allowed for now and can be worked on bit by bit. Fourth there are all lints which should warn. Additionally there are a few allow statements in the code for lints which should be permanently allowed in this specific place, but not in the whole code base. ## Follow up work - [ ] Run clippy in CI - [ ] Remove tidy test (at least `@Veykril` wrote this in rust-lang#15017) - [ ] Work on temporarily allowed lints
2 parents 04edfa1 + 4087dcf commit 2a239b9

File tree

9 files changed

+103
-4
lines changed

9 files changed

+103
-4
lines changed

Cargo.toml

+93-4
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ dissimilar = "1.0.7"
105105
either = "1.9.0"
106106
expect-test = "1.4.0"
107107
hashbrown = { version = "0.14", features = [
108-
"inline-more",
108+
"inline-more",
109109
], default-features = false }
110110
indexmap = "2.1.0"
111111
itertools = "0.12.0"
@@ -118,9 +118,9 @@ semver = "1.0.14"
118118
serde = { version = "1.0.192", features = ["derive"] }
119119
serde_json = "1.0.108"
120120
smallvec = { version = "1.10.0", features = [
121-
"const_new",
122-
"union",
123-
"const_generics",
121+
"const_new",
122+
"union",
123+
"const_generics",
124124
] }
125125
smol_str = "0.2.1"
126126
text-size = "1.1.1"
@@ -138,8 +138,97 @@ xshell = "0.2.5"
138138
# We need to freeze the version of the crate, as the raw-api feature is considered unstable
139139
dashmap = { version = "=5.5.3", features = ["raw-api"] }
140140

141+
[workspace.lints.rust]
142+
rust_2018_idioms = "warn"
143+
unused_lifetimes = "warn"
144+
semicolon_in_expressions_from_macros = "warn"
145+
141146
[workspace.lints.clippy]
147+
# FIXME Remove the tidy test once the lint table is stable
148+
149+
## lint groups
150+
complexity = { level = "warn", priority = -1 }
151+
correctness = { level = "deny", priority = -1 }
152+
perf = { level = "deny", priority = -1 }
153+
restriction = { level = "allow", priority = -1 }
154+
style = { level = "warn", priority = -1 }
155+
suspicious = { level = "warn", priority = -1 }
156+
157+
## allow following lints
158+
# () makes a fine error in most cases
159+
result_unit_err = "allow"
160+
# We don't expose public APIs that matter like this
161+
len_without_is_empty = "allow"
162+
# We currently prefer explicit control flow return over `...?;` statements whose result is unused
163+
question_mark = "allow"
164+
# We have macros that rely on this currently
165+
enum_variant_names = "allow"
166+
# Builder pattern disagrees
167+
new_ret_no_self = "allow"
168+
169+
## Following lints should be tackled at some point
170+
bind_instead_of_map = "allow"
171+
borrowed_box = "allow"
172+
borrow_deref_ref = "allow"
142173
collapsible_if = "allow"
174+
collapsible_match = "allow"
175+
clone_on_copy = "allow"
176+
derivable_impls = "allow"
177+
derived_hash_with_manual_eq = "allow"
178+
double_parens = "allow"
179+
explicit_auto_deref = "allow"
180+
field_reassign_with_default = "allow"
181+
forget_non_drop = "allow"
182+
format_collect = "allow"
183+
for_kv_map = "allow"
184+
filter_map_bool_then = "allow"
185+
from_str_radix_10 = "allow"
186+
get_first = "allow"
187+
if_same_then_else = "allow"
188+
large_enum_variant = "allow"
189+
let_and_return = "allow"
190+
manual_find = "allow"
191+
manual_map = "allow"
192+
map_clone = "allow"
193+
match_like_matches_macro = "allow"
194+
match_single_binding = "allow"
195+
needless_borrow = "allow"
196+
needless_doctest_main = "allow"
197+
needless_lifetimes = "allow"
143198
needless_pass_by_value = "allow"
199+
needless_return = "allow"
200+
new_without_default = "allow"
144201
nonminimal_bool = "allow"
202+
non_canonical_clone_impl = "allow"
203+
non_canonical_partial_ord_impl = "allow"
204+
non_minimal_cfg = "allow"
205+
only_used_in_recursion = "allow"
206+
op_ref = "allow"
207+
option_map_unit_fn = "allow"
208+
partialeq_to_none = "allow"
209+
ptr_arg = "allow"
210+
redundant_closure = "allow"
145211
redundant_pattern_matching = "allow"
212+
search_is_some = "allow"
213+
self_named_constructors = "allow"
214+
single_match = "allow"
215+
skip_while_next = "allow"
216+
too_many_arguments = "allow"
217+
toplevel_ref_arg = "allow"
218+
type_complexity = "allow"
219+
unnecessary_cast = "allow"
220+
unnecessary_filter_map = "allow"
221+
unnecessary_lazy_evaluations = "allow"
222+
unnecessary_mut_passed = "allow"
223+
useless_conversion = "allow"
224+
useless_format = "allow"
225+
wildcard_in_or_patterns = "allow"
226+
wrong_self_convention = "allow"
227+
228+
## warn at following lints
229+
dbg_macro = "warn"
230+
todo = "warn"
231+
unimplemented = "allow"
232+
rc_buffer = "warn"
233+
# FIXME enable this, we use this pattern a lot so its annoying work ...
234+
# str_to_string = "warn"

crates/base-db/src/input.rs

+1
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ impl ReleaseChannel {
261261
}
262262
}
263263

264+
#[allow(clippy::should_implement_trait)]
264265
pub fn from_str(str: &str) -> Option<Self> {
265266
Some(match str {
266267
"" | "stable" => ReleaseChannel::Stable,

crates/hir-def/src/lang_item.rs

+1
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ macro_rules! language_item_table {
260260
}
261261

262262
/// Opposite of [`LangItem::name`]
263+
#[allow(clippy::should_implement_trait)]
263264
pub fn from_str(name: &str) -> Option<Self> {
264265
match name {
265266
$( stringify!($name) => Some(LangItem::$variant), )*

crates/hir-expand/src/builtin_fn_macro.rs

+1
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ fn unreachable_expand(
392392
ExpandResult::ok(call)
393393
}
394394

395+
#[allow(clippy::never_loop)]
395396
fn use_panic_2021(db: &dyn ExpandDatabase, span: Span) -> bool {
396397
// To determine the edition, we check the first span up the expansion
397398
// stack that does not have #[allow_internal_unstable(edition_panic)].

crates/hir-expand/src/quote.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! A simplified version of quote-crate like quasi quote macro
2+
#![allow(clippy::crate_in_macro_def)]
23

34
use span::Span;
45
use syntax::format_smolstr;

crates/ide/src/syntax_tree.rs

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ fn syntax_tree_for_string(token: &SyntaxToken, text_range: TextRange) -> Option<
5252
}
5353
}
5454

55+
#[allow(clippy::redundant_locals)]
5556
fn syntax_tree_for_token(node: &SyntaxToken, text_range: TextRange) -> Option<String> {
5657
// Range of the full node
5758
let node_range = node.text_range();

crates/rust-analyzer/src/cli/rustc_tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ const SUPPORTED_DIAGNOSTICS: &[DiagnosticCode] = &[
226226
];
227227

228228
impl flags::RustcTests {
229+
#[allow(clippy::redundant_locals)]
229230
pub fn run(self) -> Result<()> {
230231
let mut tester = Tester::new()?;
231232
let walk_dir = WalkDir::new(self.rustc_repo.join("tests/ui"));

crates/span/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ impl fmt::Debug for HirFileIdRepr {
225225
}
226226

227227
impl From<FileId> for HirFileId {
228+
#[allow(clippy::let_unit_value)]
228229
fn from(id: FileId) -> Self {
229230
_ = Self::ASSERT_MAX_FILE_ID_IS_SAME;
230231
assert!(id.index() <= Self::MAX_HIR_FILE_ID, "FileId index {} is too large", id.index());
@@ -233,6 +234,7 @@ impl From<FileId> for HirFileId {
233234
}
234235

235236
impl From<MacroFileId> for HirFileId {
237+
#[allow(clippy::let_unit_value)]
236238
fn from(MacroFileId { macro_call_id: MacroCallId(id) }: MacroFileId) -> Self {
237239
_ = Self::ASSERT_MAX_FILE_ID_IS_SAME;
238240
let id = id.as_u32();

lib/la-arena/src/map.rs

+2
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ where
252252
{
253253
/// Ensures a value is in the entry by inserting the default value if empty, and returns a mutable reference
254254
/// to the value in the entry.
255+
// BUG this clippy lint is a false positive
256+
#[allow(clippy::unwrap_or_default)]
255257
pub fn or_default(self) -> &'a mut V {
256258
self.or_insert_with(Default::default)
257259
}

0 commit comments

Comments
 (0)