mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-09-21 23:12:02 +00:00
Auto merge of #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 #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 #15017) - [ ] Work on temporarily allowed lints
This commit is contained in:
commit
2a239b9833
9 changed files with 103 additions and 4 deletions
97
Cargo.toml
97
Cargo.toml
|
@ -105,7 +105,7 @@ dissimilar = "1.0.7"
|
||||||
either = "1.9.0"
|
either = "1.9.0"
|
||||||
expect-test = "1.4.0"
|
expect-test = "1.4.0"
|
||||||
hashbrown = { version = "0.14", features = [
|
hashbrown = { version = "0.14", features = [
|
||||||
"inline-more",
|
"inline-more",
|
||||||
], default-features = false }
|
], default-features = false }
|
||||||
indexmap = "2.1.0"
|
indexmap = "2.1.0"
|
||||||
itertools = "0.12.0"
|
itertools = "0.12.0"
|
||||||
|
@ -118,9 +118,9 @@ semver = "1.0.14"
|
||||||
serde = { version = "1.0.192", features = ["derive"] }
|
serde = { version = "1.0.192", features = ["derive"] }
|
||||||
serde_json = "1.0.108"
|
serde_json = "1.0.108"
|
||||||
smallvec = { version = "1.10.0", features = [
|
smallvec = { version = "1.10.0", features = [
|
||||||
"const_new",
|
"const_new",
|
||||||
"union",
|
"union",
|
||||||
"const_generics",
|
"const_generics",
|
||||||
] }
|
] }
|
||||||
smol_str = "0.2.1"
|
smol_str = "0.2.1"
|
||||||
text-size = "1.1.1"
|
text-size = "1.1.1"
|
||||||
|
@ -138,8 +138,97 @@ xshell = "0.2.5"
|
||||||
# We need to freeze the version of the crate, as the raw-api feature is considered unstable
|
# We need to freeze the version of the crate, as the raw-api feature is considered unstable
|
||||||
dashmap = { version = "=5.5.3", features = ["raw-api"] }
|
dashmap = { version = "=5.5.3", features = ["raw-api"] }
|
||||||
|
|
||||||
|
[workspace.lints.rust]
|
||||||
|
rust_2018_idioms = "warn"
|
||||||
|
unused_lifetimes = "warn"
|
||||||
|
semicolon_in_expressions_from_macros = "warn"
|
||||||
|
|
||||||
[workspace.lints.clippy]
|
[workspace.lints.clippy]
|
||||||
|
# FIXME Remove the tidy test once the lint table is stable
|
||||||
|
|
||||||
|
## lint groups
|
||||||
|
complexity = { level = "warn", priority = -1 }
|
||||||
|
correctness = { level = "deny", priority = -1 }
|
||||||
|
perf = { level = "deny", priority = -1 }
|
||||||
|
restriction = { level = "allow", priority = -1 }
|
||||||
|
style = { level = "warn", priority = -1 }
|
||||||
|
suspicious = { level = "warn", priority = -1 }
|
||||||
|
|
||||||
|
## allow following lints
|
||||||
|
# () makes a fine error in most cases
|
||||||
|
result_unit_err = "allow"
|
||||||
|
# We don't expose public APIs that matter like this
|
||||||
|
len_without_is_empty = "allow"
|
||||||
|
# We currently prefer explicit control flow return over `...?;` statements whose result is unused
|
||||||
|
question_mark = "allow"
|
||||||
|
# We have macros that rely on this currently
|
||||||
|
enum_variant_names = "allow"
|
||||||
|
# Builder pattern disagrees
|
||||||
|
new_ret_no_self = "allow"
|
||||||
|
|
||||||
|
## Following lints should be tackled at some point
|
||||||
|
bind_instead_of_map = "allow"
|
||||||
|
borrowed_box = "allow"
|
||||||
|
borrow_deref_ref = "allow"
|
||||||
collapsible_if = "allow"
|
collapsible_if = "allow"
|
||||||
|
collapsible_match = "allow"
|
||||||
|
clone_on_copy = "allow"
|
||||||
|
derivable_impls = "allow"
|
||||||
|
derived_hash_with_manual_eq = "allow"
|
||||||
|
double_parens = "allow"
|
||||||
|
explicit_auto_deref = "allow"
|
||||||
|
field_reassign_with_default = "allow"
|
||||||
|
forget_non_drop = "allow"
|
||||||
|
format_collect = "allow"
|
||||||
|
for_kv_map = "allow"
|
||||||
|
filter_map_bool_then = "allow"
|
||||||
|
from_str_radix_10 = "allow"
|
||||||
|
get_first = "allow"
|
||||||
|
if_same_then_else = "allow"
|
||||||
|
large_enum_variant = "allow"
|
||||||
|
let_and_return = "allow"
|
||||||
|
manual_find = "allow"
|
||||||
|
manual_map = "allow"
|
||||||
|
map_clone = "allow"
|
||||||
|
match_like_matches_macro = "allow"
|
||||||
|
match_single_binding = "allow"
|
||||||
|
needless_borrow = "allow"
|
||||||
|
needless_doctest_main = "allow"
|
||||||
|
needless_lifetimes = "allow"
|
||||||
needless_pass_by_value = "allow"
|
needless_pass_by_value = "allow"
|
||||||
|
needless_return = "allow"
|
||||||
|
new_without_default = "allow"
|
||||||
nonminimal_bool = "allow"
|
nonminimal_bool = "allow"
|
||||||
|
non_canonical_clone_impl = "allow"
|
||||||
|
non_canonical_partial_ord_impl = "allow"
|
||||||
|
non_minimal_cfg = "allow"
|
||||||
|
only_used_in_recursion = "allow"
|
||||||
|
op_ref = "allow"
|
||||||
|
option_map_unit_fn = "allow"
|
||||||
|
partialeq_to_none = "allow"
|
||||||
|
ptr_arg = "allow"
|
||||||
|
redundant_closure = "allow"
|
||||||
redundant_pattern_matching = "allow"
|
redundant_pattern_matching = "allow"
|
||||||
|
search_is_some = "allow"
|
||||||
|
self_named_constructors = "allow"
|
||||||
|
single_match = "allow"
|
||||||
|
skip_while_next = "allow"
|
||||||
|
too_many_arguments = "allow"
|
||||||
|
toplevel_ref_arg = "allow"
|
||||||
|
type_complexity = "allow"
|
||||||
|
unnecessary_cast = "allow"
|
||||||
|
unnecessary_filter_map = "allow"
|
||||||
|
unnecessary_lazy_evaluations = "allow"
|
||||||
|
unnecessary_mut_passed = "allow"
|
||||||
|
useless_conversion = "allow"
|
||||||
|
useless_format = "allow"
|
||||||
|
wildcard_in_or_patterns = "allow"
|
||||||
|
wrong_self_convention = "allow"
|
||||||
|
|
||||||
|
## warn at following lints
|
||||||
|
dbg_macro = "warn"
|
||||||
|
todo = "warn"
|
||||||
|
unimplemented = "allow"
|
||||||
|
rc_buffer = "warn"
|
||||||
|
# FIXME enable this, we use this pattern a lot so its annoying work ...
|
||||||
|
# str_to_string = "warn"
|
||||||
|
|
|
@ -261,6 +261,7 @@ impl ReleaseChannel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::should_implement_trait)]
|
||||||
pub fn from_str(str: &str) -> Option<Self> {
|
pub fn from_str(str: &str) -> Option<Self> {
|
||||||
Some(match str {
|
Some(match str {
|
||||||
"" | "stable" => ReleaseChannel::Stable,
|
"" | "stable" => ReleaseChannel::Stable,
|
||||||
|
|
|
@ -260,6 +260,7 @@ macro_rules! language_item_table {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Opposite of [`LangItem::name`]
|
/// Opposite of [`LangItem::name`]
|
||||||
|
#[allow(clippy::should_implement_trait)]
|
||||||
pub fn from_str(name: &str) -> Option<Self> {
|
pub fn from_str(name: &str) -> Option<Self> {
|
||||||
match name {
|
match name {
|
||||||
$( stringify!($name) => Some(LangItem::$variant), )*
|
$( stringify!($name) => Some(LangItem::$variant), )*
|
||||||
|
|
|
@ -392,6 +392,7 @@ fn unreachable_expand(
|
||||||
ExpandResult::ok(call)
|
ExpandResult::ok(call)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::never_loop)]
|
||||||
fn use_panic_2021(db: &dyn ExpandDatabase, span: Span) -> bool {
|
fn use_panic_2021(db: &dyn ExpandDatabase, span: Span) -> bool {
|
||||||
// To determine the edition, we check the first span up the expansion
|
// To determine the edition, we check the first span up the expansion
|
||||||
// stack that does not have #[allow_internal_unstable(edition_panic)].
|
// stack that does not have #[allow_internal_unstable(edition_panic)].
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
//! A simplified version of quote-crate like quasi quote macro
|
//! A simplified version of quote-crate like quasi quote macro
|
||||||
|
#![allow(clippy::crate_in_macro_def)]
|
||||||
|
|
||||||
use span::Span;
|
use span::Span;
|
||||||
use syntax::format_smolstr;
|
use syntax::format_smolstr;
|
||||||
|
|
|
@ -52,6 +52,7 @@ fn syntax_tree_for_string(token: &SyntaxToken, text_range: TextRange) -> Option<
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::redundant_locals)]
|
||||||
fn syntax_tree_for_token(node: &SyntaxToken, text_range: TextRange) -> Option<String> {
|
fn syntax_tree_for_token(node: &SyntaxToken, text_range: TextRange) -> Option<String> {
|
||||||
// Range of the full node
|
// Range of the full node
|
||||||
let node_range = node.text_range();
|
let node_range = node.text_range();
|
||||||
|
|
|
@ -226,6 +226,7 @@ const SUPPORTED_DIAGNOSTICS: &[DiagnosticCode] = &[
|
||||||
];
|
];
|
||||||
|
|
||||||
impl flags::RustcTests {
|
impl flags::RustcTests {
|
||||||
|
#[allow(clippy::redundant_locals)]
|
||||||
pub fn run(self) -> Result<()> {
|
pub fn run(self) -> Result<()> {
|
||||||
let mut tester = Tester::new()?;
|
let mut tester = Tester::new()?;
|
||||||
let walk_dir = WalkDir::new(self.rustc_repo.join("tests/ui"));
|
let walk_dir = WalkDir::new(self.rustc_repo.join("tests/ui"));
|
||||||
|
|
|
@ -225,6 +225,7 @@ impl fmt::Debug for HirFileIdRepr {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<FileId> for HirFileId {
|
impl From<FileId> for HirFileId {
|
||||||
|
#[allow(clippy::let_unit_value)]
|
||||||
fn from(id: FileId) -> Self {
|
fn from(id: FileId) -> Self {
|
||||||
_ = Self::ASSERT_MAX_FILE_ID_IS_SAME;
|
_ = Self::ASSERT_MAX_FILE_ID_IS_SAME;
|
||||||
assert!(id.index() <= Self::MAX_HIR_FILE_ID, "FileId index {} is too large", id.index());
|
assert!(id.index() <= Self::MAX_HIR_FILE_ID, "FileId index {} is too large", id.index());
|
||||||
|
@ -233,6 +234,7 @@ impl From<FileId> for HirFileId {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<MacroFileId> for HirFileId {
|
impl From<MacroFileId> for HirFileId {
|
||||||
|
#[allow(clippy::let_unit_value)]
|
||||||
fn from(MacroFileId { macro_call_id: MacroCallId(id) }: MacroFileId) -> Self {
|
fn from(MacroFileId { macro_call_id: MacroCallId(id) }: MacroFileId) -> Self {
|
||||||
_ = Self::ASSERT_MAX_FILE_ID_IS_SAME;
|
_ = Self::ASSERT_MAX_FILE_ID_IS_SAME;
|
||||||
let id = id.as_u32();
|
let id = id.as_u32();
|
||||||
|
|
|
@ -252,6 +252,8 @@ where
|
||||||
{
|
{
|
||||||
/// Ensures a value is in the entry by inserting the default value if empty, and returns a mutable reference
|
/// Ensures a value is in the entry by inserting the default value if empty, and returns a mutable reference
|
||||||
/// to the value in the entry.
|
/// to the value in the entry.
|
||||||
|
// BUG this clippy lint is a false positive
|
||||||
|
#[allow(clippy::unwrap_or_default)]
|
||||||
pub fn or_default(self) -> &'a mut V {
|
pub fn or_default(self) -> &'a mut V {
|
||||||
self.or_insert_with(Default::default)
|
self.or_insert_with(Default::default)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue