Auto merge of #16920 - Veykril:clippy-lints, r=Veykril

internal: Fix new nightly clippy lints
This commit is contained in:
bors 2024-04-01 16:00:18 +00:00
commit 3691380c35
33 changed files with 31 additions and 42 deletions

View File

@ -188,6 +188,8 @@ enum_variant_names = "allow"
new_ret_no_self = "allow"
# Has a bunch of false positives
useless_asref = "allow"
# Has false positives
assigning_clones = "allow"
## Following lints should be tackled at some point
too_many_arguments = "allow"

View File

@ -149,7 +149,7 @@ pub(super) fn infer_record_pat_like<T: PatLike>(
expected: &Ty,
default_bm: T::BindingMode,
id: T,
subs: impl Iterator<Item = (Name, T)> + ExactSizeIterator,
subs: impl ExactSizeIterator<Item = (Name, T)>,
) -> Ty {
let (ty, def) = self.resolve_variant(path, false);
if let Some(variant) = def {

View File

@ -101,7 +101,7 @@ pub(super) fn try_expr(
if let Some((inner, body)) = error_type_args {
inner_ty = inner;
body_ty = body;
s = "Try Error".to_owned();
"Try Error".clone_into(&mut s);
}
}
}
@ -637,7 +637,7 @@ fn closure_ty(
})
.join("\n");
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 push_new_def = |item: hir::ModuleDef| {

View File

@ -113,7 +113,7 @@ pub enum HlPunct {
Semi,
/// ! (only for macro calls)
MacroBang,
///
/// Other punctutations
Other,
}
@ -127,7 +127,7 @@ pub enum HlOperator {
Logical,
/// >, <, ==, >=, <=, !=
Comparison,
///
/// Other operators
Other,
}

View File

@ -174,6 +174,7 @@ pub struct InternStorage<T: ?Sized> {
map: OnceLock<InternMap<T>>,
}
#[allow(clippy::new_without_default)] // this a const fn, so it can't be default
impl<T: ?Sized> InternStorage<T> {
pub const fn new() -> Self {
Self { map: OnceLock::new() }

View File

@ -237,7 +237,7 @@ pub(crate) fn run_once(
},
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)| {
if let Some(&(p, w)) = by_id.get(id) {
res[workspace].outputs[package] = res[w].outputs[p].clone();

View File

@ -92,7 +92,7 @@ fn update_text(&mut self, text: &str) {
let _ = io::stdout().write(output.as_bytes());
let _ = io::stdout().flush();
self.text = text.to_owned();
text.clone_into(&mut self.text);
}
fn set_value(&mut self, value: f32) {

View File

@ -105,7 +105,7 @@ pub(crate) fn handle_did_change_text_document(
)
.into_bytes();
if *data != new_contents {
*data = new_contents.clone();
data.clone_from(&new_contents);
state.vfs.write().0.set_file_contents(path, Some(new_contents));
}
}

View File

@ -411,7 +411,7 @@ fn handle_event(&mut self, event: Event) -> anyhow::Result<()> {
// See https://github.com/rust-lang/rust-analyzer/issues/13130
let patch_empty = |message: &mut String| {
if message.is_empty() {
*message = " ".to_owned();
" ".clone_into(message);
}
};

View File

@ -741,13 +741,13 @@ pub fn ws_to_crate_graph(
if layouts.len() <= idx {
layouts.resize(idx + 1, e.clone());
}
layouts[idx] = layout.clone();
layouts[idx].clone_from(&layout);
}
if idx >= num_toolchains {
if toolchains.len() <= idx {
toolchains.resize(idx + 1, None);
}
toolchains[idx] = toolchain.clone();
toolchains[idx].clone_from(&toolchain);
}
});
proc_macro_paths.push(crate_proc_macros);

View File

@ -243,7 +243,7 @@ struct TidyDocs {
impl TidyDocs {
fn visit(&mut self, path: &Path, text: &str) {
// 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;
}

View File

@ -1,4 +1,5 @@
//!
//! Implementation for `[salsa::database]` decorator.
use heck::ToSnakeCase;
use proc_macro::TokenStream;
use syn::parse::{Parse, ParseStream};

View File

@ -1,4 +1,4 @@
//!
//! Parenthesis helper
pub(crate) struct Parenthesized<T>(pub(crate) T);
impl<T> syn::parse::Parse for Parenthesized<T>

View File

@ -1,4 +1,4 @@
//!
//! Implementation for `[salsa::query_group]` decorator.
use crate::parenthesized::Parenthesized;
use heck::ToUpperCamelCase;

View File

@ -1,4 +1,3 @@
//!
use crate::debug::TableEntry;
use crate::durability::Durability;
use crate::hash::FxIndexMap;

View File

@ -1,4 +1,3 @@
//!
use crate::debug::TableEntry;
use crate::derived::MemoizationPolicy;
use crate::durability::Durability;

View File

@ -1,4 +1,3 @@
//!
/// Describes how likely a value is to change -- how "durable" it is.
/// By default, inputs have `Durability::LOW` and interned values have
/// `Durability::HIGH`. But inputs can be explicitly set with other

View File

@ -1,4 +1,3 @@
//!
pub(crate) type FxHasher = std::hash::BuildHasherDefault<rustc_hash::FxHasher>;
pub(crate) type FxIndexSet<K> = indexmap::IndexSet<K, FxHasher>;
pub(crate) type FxIndexMap<K, V> = indexmap::IndexMap<K, V, FxHasher>;

View File

@ -1,4 +1,3 @@
//!
use crate::debug::TableEntry;
use crate::durability::Durability;
use crate::hash::FxIndexMap;

View File

@ -1,4 +1,3 @@
//!
use std::fmt;
use std::num::NonZeroU32;

View File

@ -1,4 +1,3 @@
//!
use crate::debug::TableEntry;
use crate::durability::Durability;
use crate::intern_id::InternId;

View File

@ -1,8 +1,7 @@
//!
#![allow(clippy::type_complexity)]
#![allow(clippy::question_mark)]
#![allow(missing_docs)]
#![warn(rust_2018_idioms)]
#![warn(missing_docs)]
//! The salsa crate is a crate for incremental recomputation. It
//! permits you to define a "database" of queries with both inputs and
@ -124,9 +123,9 @@ pub struct Event {
impl Event {
/// Returns a type that gives a user-readable debug output.
/// 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
D: plumbing::DatabaseOps,
D: ?Sized + plumbing::DatabaseOps,
{
EventDebug { event: self, db }
}
@ -206,9 +205,9 @@ pub enum EventKind {
impl EventKind {
/// Returns a type that gives a user-readable debug output.
/// 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
D: plumbing::DatabaseOps,
D: ?Sized + plumbing::DatabaseOps,
{
EventKindDebug { kind: self, db }
}
@ -400,9 +399,9 @@ pub fn key_index(self) -> u32 {
/// Returns a type that gives a user-readable debug output.
/// 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
D: plumbing::DatabaseOps,
D: ?Sized + plumbing::DatabaseOps,
{
DatabaseKeyIndexDebug { index: self, db }
}

View File

@ -1,4 +1,3 @@
//!
use oorandom::Rand64;
use parking_lot::Mutex;
use std::fmt::Debug;

View File

@ -1,4 +1,3 @@
//!
#![allow(missing_docs)]
use crate::debug::TableEntry;

View File

@ -1,4 +1,3 @@
//!
use std::num::NonZeroU32;
use std::sync::atomic::{AtomicU32, Ordering};

View File

@ -1,4 +1,3 @@
//!
use crate::durability::Durability;
use crate::hash::FxIndexSet;
use crate::plumbing::CycleRecoveryStrategy;
@ -605,7 +604,7 @@ fn remove_cycle_participants(&mut self, cycle: &Cycle) {
pub(crate) fn take_inputs_from(&mut self, cycle_query: &ActiveQuery) {
self.changed_at = cycle_query.changed_at;
self.durability = cycle_query.durability;
self.dependencies = cycle_query.dependencies.clone();
self.dependencies.clone_from(&cycle_query.dependencies);
}
}

View File

@ -1,4 +1,3 @@
//!
use triomphe::Arc;
use crate::{DatabaseKeyIndex, RuntimeId};

View File

@ -1,4 +1,3 @@
//!
use tracing::debug;
use triomphe::ThinArc;

View File

@ -1,4 +1,3 @@
//!
use crate::{plumbing::DatabaseStorageTypes, Runtime};
use triomphe::Arc;

View File

@ -69,7 +69,7 @@ pub fn extract(tag: &str, text: &str) -> Vec<CommentBlock> {
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
});
blocks

View File

@ -186,7 +186,7 @@ pub fn parse(ra_fixture: &str) -> Self {
if let Some(meta) = fixture.strip_prefix("//- target_data_layout:") {
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;
}

View File

@ -84,7 +84,7 @@ fn extract(tag: &str, text: &str) -> Vec<CommentBlock> {
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
});
blocks

View File

@ -280,7 +280,7 @@ fn generate_descriptor_clippy(buf: &mut String, path: &Path) {
let line = &line[..up_to];
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));