mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 07:04:22 +00:00
Fix new clippy lints
This commit is contained in:
parent
8e324e98a1
commit
2ae3e57c26
33 changed files with 31 additions and 42 deletions
|
@ -188,6 +188,8 @@ enum_variant_names = "allow"
|
||||||
new_ret_no_self = "allow"
|
new_ret_no_self = "allow"
|
||||||
# Has a bunch of false positives
|
# Has a bunch of false positives
|
||||||
useless_asref = "allow"
|
useless_asref = "allow"
|
||||||
|
# Has false positives
|
||||||
|
assigning_clones = "allow"
|
||||||
|
|
||||||
## Following lints should be tackled at some point
|
## Following lints should be tackled at some point
|
||||||
too_many_arguments = "allow"
|
too_many_arguments = "allow"
|
||||||
|
|
|
@ -149,7 +149,7 @@ impl InferenceContext<'_> {
|
||||||
expected: &Ty,
|
expected: &Ty,
|
||||||
default_bm: T::BindingMode,
|
default_bm: T::BindingMode,
|
||||||
id: T,
|
id: T,
|
||||||
subs: impl Iterator<Item = (Name, T)> + ExactSizeIterator,
|
subs: impl ExactSizeIterator<Item = (Name, T)>,
|
||||||
) -> Ty {
|
) -> Ty {
|
||||||
let (ty, def) = self.resolve_variant(path, false);
|
let (ty, def) = self.resolve_variant(path, false);
|
||||||
if let Some(variant) = def {
|
if let Some(variant) = def {
|
||||||
|
|
|
@ -101,7 +101,7 @@ pub(super) fn try_expr(
|
||||||
if let Some((inner, body)) = error_type_args {
|
if let Some((inner, body)) = error_type_args {
|
||||||
inner_ty = inner;
|
inner_ty = inner;
|
||||||
body_ty = body;
|
body_ty = body;
|
||||||
s = "Try Error".to_owned();
|
"Try Error".clone_into(&mut s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -634,7 +634,7 @@ fn closure_ty(
|
||||||
})
|
})
|
||||||
.join("\n");
|
.join("\n");
|
||||||
if captures_rendered.trim().is_empty() {
|
if captures_rendered.trim().is_empty() {
|
||||||
captures_rendered = "This closure captures nothing".to_owned();
|
"This closure captures nothing".clone_into(&mut captures_rendered);
|
||||||
}
|
}
|
||||||
let mut targets: Vec<hir::ModuleDef> = Vec::new();
|
let mut targets: Vec<hir::ModuleDef> = Vec::new();
|
||||||
let mut push_new_def = |item: hir::ModuleDef| {
|
let mut push_new_def = |item: hir::ModuleDef| {
|
||||||
|
|
|
@ -113,7 +113,7 @@ pub enum HlPunct {
|
||||||
Semi,
|
Semi,
|
||||||
/// ! (only for macro calls)
|
/// ! (only for macro calls)
|
||||||
MacroBang,
|
MacroBang,
|
||||||
///
|
/// Other punctutations
|
||||||
Other,
|
Other,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ pub enum HlOperator {
|
||||||
Logical,
|
Logical,
|
||||||
/// >, <, ==, >=, <=, !=
|
/// >, <, ==, >=, <=, !=
|
||||||
Comparison,
|
Comparison,
|
||||||
///
|
/// Other operators
|
||||||
Other,
|
Other,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,6 +174,7 @@ pub struct InternStorage<T: ?Sized> {
|
||||||
map: OnceLock<InternMap<T>>,
|
map: OnceLock<InternMap<T>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::new_without_default)] // this a const fn, so it can't be default
|
||||||
impl<T: ?Sized> InternStorage<T> {
|
impl<T: ?Sized> InternStorage<T> {
|
||||||
pub const fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
Self { map: OnceLock::new() }
|
Self { map: OnceLock::new() }
|
||||||
|
|
|
@ -235,7 +235,7 @@ impl WorkspaceBuildScripts {
|
||||||
},
|
},
|
||||||
progress,
|
progress,
|
||||||
)?;
|
)?;
|
||||||
res.iter_mut().for_each(|it| it.error = errors.clone());
|
res.iter_mut().for_each(|it| it.error.clone_from(&errors));
|
||||||
collisions.into_iter().for_each(|(id, workspace, package)| {
|
collisions.into_iter().for_each(|(id, workspace, package)| {
|
||||||
if let Some(&(p, w)) = by_id.get(id) {
|
if let Some(&(p, w)) = by_id.get(id) {
|
||||||
res[workspace].outputs[package] = res[w].outputs[p].clone();
|
res[workspace].outputs[package] = res[w].outputs[p].clone();
|
||||||
|
|
|
@ -92,7 +92,7 @@ impl<'a> ProgressReport<'a> {
|
||||||
|
|
||||||
let _ = io::stdout().write(output.as_bytes());
|
let _ = io::stdout().write(output.as_bytes());
|
||||||
let _ = io::stdout().flush();
|
let _ = io::stdout().flush();
|
||||||
self.text = text.to_owned();
|
text.clone_into(&mut self.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_value(&mut self, value: f32) {
|
fn set_value(&mut self, value: f32) {
|
||||||
|
|
|
@ -105,7 +105,7 @@ pub(crate) fn handle_did_change_text_document(
|
||||||
)
|
)
|
||||||
.into_bytes();
|
.into_bytes();
|
||||||
if *data != new_contents {
|
if *data != new_contents {
|
||||||
*data = new_contents.clone();
|
data.clone_from(&new_contents);
|
||||||
state.vfs.write().0.set_file_contents(path, Some(new_contents));
|
state.vfs.write().0.set_file_contents(path, Some(new_contents));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -412,7 +412,7 @@ impl GlobalState {
|
||||||
// See https://github.com/rust-lang/rust-analyzer/issues/13130
|
// See https://github.com/rust-lang/rust-analyzer/issues/13130
|
||||||
let patch_empty = |message: &mut String| {
|
let patch_empty = |message: &mut String| {
|
||||||
if message.is_empty() {
|
if message.is_empty() {
|
||||||
*message = " ".to_owned();
|
" ".clone_into(message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -725,13 +725,13 @@ pub fn ws_to_crate_graph(
|
||||||
if layouts.len() <= idx {
|
if layouts.len() <= idx {
|
||||||
layouts.resize(idx + 1, e.clone());
|
layouts.resize(idx + 1, e.clone());
|
||||||
}
|
}
|
||||||
layouts[idx] = layout.clone();
|
layouts[idx].clone_from(&layout);
|
||||||
}
|
}
|
||||||
if idx >= num_toolchains {
|
if idx >= num_toolchains {
|
||||||
if toolchains.len() <= idx {
|
if toolchains.len() <= idx {
|
||||||
toolchains.resize(idx + 1, None);
|
toolchains.resize(idx + 1, None);
|
||||||
}
|
}
|
||||||
toolchains[idx] = toolchain.clone();
|
toolchains[idx].clone_from(&toolchain);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
proc_macro_paths.push(crate_proc_macros);
|
proc_macro_paths.push(crate_proc_macros);
|
||||||
|
|
|
@ -243,7 +243,7 @@ struct TidyDocs {
|
||||||
impl TidyDocs {
|
impl TidyDocs {
|
||||||
fn visit(&mut self, path: &Path, text: &str) {
|
fn visit(&mut self, path: &Path, text: &str) {
|
||||||
// Tests and diagnostic fixes don't need module level comments.
|
// Tests and diagnostic fixes don't need module level comments.
|
||||||
if is_exclude_dir(path, &["tests", "test_data", "fixes", "grammar"]) {
|
if is_exclude_dir(path, &["tests", "test_data", "fixes", "grammar", "salsa"]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
//!
|
//! Implementation for `[salsa::database]` decorator.
|
||||||
|
|
||||||
use heck::ToSnakeCase;
|
use heck::ToSnakeCase;
|
||||||
use proc_macro::TokenStream;
|
use proc_macro::TokenStream;
|
||||||
use syn::parse::{Parse, ParseStream};
|
use syn::parse::{Parse, ParseStream};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//!
|
//! Parenthesis helper
|
||||||
pub(crate) struct Parenthesized<T>(pub(crate) T);
|
pub(crate) struct Parenthesized<T>(pub(crate) T);
|
||||||
|
|
||||||
impl<T> syn::parse::Parse for Parenthesized<T>
|
impl<T> syn::parse::Parse for Parenthesized<T>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//!
|
//! Implementation for `[salsa::query_group]` decorator.
|
||||||
|
|
||||||
use crate::parenthesized::Parenthesized;
|
use crate::parenthesized::Parenthesized;
|
||||||
use heck::ToUpperCamelCase;
|
use heck::ToUpperCamelCase;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
//!
|
|
||||||
use crate::debug::TableEntry;
|
use crate::debug::TableEntry;
|
||||||
use crate::durability::Durability;
|
use crate::durability::Durability;
|
||||||
use crate::hash::FxIndexMap;
|
use crate::hash::FxIndexMap;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
//!
|
|
||||||
use crate::debug::TableEntry;
|
use crate::debug::TableEntry;
|
||||||
use crate::derived::MemoizationPolicy;
|
use crate::derived::MemoizationPolicy;
|
||||||
use crate::durability::Durability;
|
use crate::durability::Durability;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
//!
|
|
||||||
/// Describes how likely a value is to change -- how "durable" it is.
|
/// Describes how likely a value is to change -- how "durable" it is.
|
||||||
/// By default, inputs have `Durability::LOW` and interned values have
|
/// By default, inputs have `Durability::LOW` and interned values have
|
||||||
/// `Durability::HIGH`. But inputs can be explicitly set with other
|
/// `Durability::HIGH`. But inputs can be explicitly set with other
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
//!
|
|
||||||
pub(crate) type FxHasher = std::hash::BuildHasherDefault<rustc_hash::FxHasher>;
|
pub(crate) type FxHasher = std::hash::BuildHasherDefault<rustc_hash::FxHasher>;
|
||||||
pub(crate) type FxIndexSet<K> = indexmap::IndexSet<K, FxHasher>;
|
pub(crate) type FxIndexSet<K> = indexmap::IndexSet<K, FxHasher>;
|
||||||
pub(crate) type FxIndexMap<K, V> = indexmap::IndexMap<K, V, FxHasher>;
|
pub(crate) type FxIndexMap<K, V> = indexmap::IndexMap<K, V, FxHasher>;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
//!
|
|
||||||
use crate::debug::TableEntry;
|
use crate::debug::TableEntry;
|
||||||
use crate::durability::Durability;
|
use crate::durability::Durability;
|
||||||
use crate::hash::FxIndexMap;
|
use crate::hash::FxIndexMap;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
//!
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::num::NonZeroU32;
|
use std::num::NonZeroU32;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
//!
|
|
||||||
use crate::debug::TableEntry;
|
use crate::debug::TableEntry;
|
||||||
use crate::durability::Durability;
|
use crate::durability::Durability;
|
||||||
use crate::intern_id::InternId;
|
use crate::intern_id::InternId;
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
//!
|
|
||||||
#![allow(clippy::type_complexity)]
|
#![allow(clippy::type_complexity)]
|
||||||
#![allow(clippy::question_mark)]
|
#![allow(clippy::question_mark)]
|
||||||
|
#![allow(missing_docs)]
|
||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
#![warn(missing_docs)]
|
|
||||||
|
|
||||||
//! The salsa crate is a crate for incremental recomputation. It
|
//! The salsa crate is a crate for incremental recomputation. It
|
||||||
//! permits you to define a "database" of queries with both inputs and
|
//! permits you to define a "database" of queries with both inputs and
|
||||||
|
@ -124,9 +123,9 @@ pub struct Event {
|
||||||
impl Event {
|
impl Event {
|
||||||
/// Returns a type that gives a user-readable debug output.
|
/// Returns a type that gives a user-readable debug output.
|
||||||
/// Use like `println!("{:?}", index.debug(db))`.
|
/// Use like `println!("{:?}", index.debug(db))`.
|
||||||
pub fn debug<'me, D: ?Sized>(&'me self, db: &'me D) -> impl std::fmt::Debug + 'me
|
pub fn debug<'me, D>(&'me self, db: &'me D) -> impl std::fmt::Debug + 'me
|
||||||
where
|
where
|
||||||
D: plumbing::DatabaseOps,
|
D: ?Sized + plumbing::DatabaseOps,
|
||||||
{
|
{
|
||||||
EventDebug { event: self, db }
|
EventDebug { event: self, db }
|
||||||
}
|
}
|
||||||
|
@ -206,9 +205,9 @@ pub enum EventKind {
|
||||||
impl EventKind {
|
impl EventKind {
|
||||||
/// Returns a type that gives a user-readable debug output.
|
/// Returns a type that gives a user-readable debug output.
|
||||||
/// Use like `println!("{:?}", index.debug(db))`.
|
/// Use like `println!("{:?}", index.debug(db))`.
|
||||||
pub fn debug<'me, D: ?Sized>(&'me self, db: &'me D) -> impl std::fmt::Debug + 'me
|
pub fn debug<'me, D>(&'me self, db: &'me D) -> impl std::fmt::Debug + 'me
|
||||||
where
|
where
|
||||||
D: plumbing::DatabaseOps,
|
D: ?Sized + plumbing::DatabaseOps,
|
||||||
{
|
{
|
||||||
EventKindDebug { kind: self, db }
|
EventKindDebug { kind: self, db }
|
||||||
}
|
}
|
||||||
|
@ -400,9 +399,9 @@ impl DatabaseKeyIndex {
|
||||||
|
|
||||||
/// Returns a type that gives a user-readable debug output.
|
/// Returns a type that gives a user-readable debug output.
|
||||||
/// Use like `println!("{:?}", index.debug(db))`.
|
/// Use like `println!("{:?}", index.debug(db))`.
|
||||||
pub fn debug<D: ?Sized>(self, db: &D) -> impl std::fmt::Debug + '_
|
pub fn debug<D>(self, db: &D) -> impl std::fmt::Debug + '_
|
||||||
where
|
where
|
||||||
D: plumbing::DatabaseOps,
|
D: ?Sized + plumbing::DatabaseOps,
|
||||||
{
|
{
|
||||||
DatabaseKeyIndexDebug { index: self, db }
|
DatabaseKeyIndexDebug { index: self, db }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
//!
|
|
||||||
use oorandom::Rand64;
|
use oorandom::Rand64;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
//!
|
|
||||||
#![allow(missing_docs)]
|
#![allow(missing_docs)]
|
||||||
|
|
||||||
use crate::debug::TableEntry;
|
use crate::debug::TableEntry;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
//!
|
|
||||||
use std::num::NonZeroU32;
|
use std::num::NonZeroU32;
|
||||||
use std::sync::atomic::{AtomicU32, Ordering};
|
use std::sync::atomic::{AtomicU32, Ordering};
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
//!
|
|
||||||
use crate::durability::Durability;
|
use crate::durability::Durability;
|
||||||
use crate::hash::FxIndexSet;
|
use crate::hash::FxIndexSet;
|
||||||
use crate::plumbing::CycleRecoveryStrategy;
|
use crate::plumbing::CycleRecoveryStrategy;
|
||||||
|
@ -605,7 +604,7 @@ impl ActiveQuery {
|
||||||
pub(crate) fn take_inputs_from(&mut self, cycle_query: &ActiveQuery) {
|
pub(crate) fn take_inputs_from(&mut self, cycle_query: &ActiveQuery) {
|
||||||
self.changed_at = cycle_query.changed_at;
|
self.changed_at = cycle_query.changed_at;
|
||||||
self.durability = cycle_query.durability;
|
self.durability = cycle_query.durability;
|
||||||
self.dependencies = cycle_query.dependencies.clone();
|
self.dependencies.clone_from(&cycle_query.dependencies);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
//!
|
|
||||||
use triomphe::Arc;
|
use triomphe::Arc;
|
||||||
|
|
||||||
use crate::{DatabaseKeyIndex, RuntimeId};
|
use crate::{DatabaseKeyIndex, RuntimeId};
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
//!
|
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
use triomphe::ThinArc;
|
use triomphe::ThinArc;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
//!
|
|
||||||
use crate::{plumbing::DatabaseStorageTypes, Runtime};
|
use crate::{plumbing::DatabaseStorageTypes, Runtime};
|
||||||
use triomphe::Arc;
|
use triomphe::Arc;
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ impl CommentBlock {
|
||||||
panic!("Use plain (non-doc) comments with tags like {tag}:\n {first}");
|
panic!("Use plain (non-doc) comments with tags like {tag}:\n {first}");
|
||||||
}
|
}
|
||||||
|
|
||||||
block.id = id.trim().to_owned();
|
id.trim().clone_into(&mut block.id);
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
blocks
|
blocks
|
||||||
|
|
|
@ -186,7 +186,7 @@ impl FixtureWithProjectMeta {
|
||||||
|
|
||||||
if let Some(meta) = fixture.strip_prefix("//- target_data_layout:") {
|
if let Some(meta) = fixture.strip_prefix("//- target_data_layout:") {
|
||||||
let (meta, remain) = meta.split_once('\n').unwrap();
|
let (meta, remain) = meta.split_once('\n').unwrap();
|
||||||
target_data_layout = meta.trim().to_owned();
|
meta.trim().clone_into(&mut target_data_layout);
|
||||||
fixture = remain;
|
fixture = remain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ impl CommentBlock {
|
||||||
panic!("Use plain (non-doc) comments with tags like {tag}:\n {first}");
|
panic!("Use plain (non-doc) comments with tags like {tag}:\n {first}");
|
||||||
}
|
}
|
||||||
|
|
||||||
block.id = id.trim().to_owned();
|
id.trim().clone_into(&mut block.id);
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
blocks
|
blocks
|
||||||
|
|
|
@ -280,7 +280,7 @@ fn generate_descriptor_clippy(buf: &mut String, path: &Path) {
|
||||||
let line = &line[..up_to];
|
let line = &line[..up_to];
|
||||||
|
|
||||||
let clippy_lint = clippy_lints.last_mut().expect("clippy lint must already exist");
|
let clippy_lint = clippy_lints.last_mut().expect("clippy lint must already exist");
|
||||||
clippy_lint.help = unescape(line).trim().to_owned();
|
unescape(line).trim().clone_into(&mut clippy_lint.help);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clippy_lints.sort_by(|lint, lint2| lint.id.cmp(&lint2.id));
|
clippy_lints.sort_by(|lint, lint2| lint.id.cmp(&lint2.id));
|
||||||
|
|
Loading…
Reference in a new issue