Skip to content

Commit 3691380

Browse files
committed
Auto merge of rust-lang#16920 - Veykril:clippy-lints, r=Veykril
internal: Fix new nightly clippy lints
2 parents ff8a24a + 2ae3e57 commit 3691380

File tree

33 files changed

+31
-42
lines changed

33 files changed

+31
-42
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ enum_variant_names = "allow"
188188
new_ret_no_self = "allow"
189189
# Has a bunch of false positives
190190
useless_asref = "allow"
191+
# Has false positives
192+
assigning_clones = "allow"
191193

192194
## Following lints should be tackled at some point
193195
too_many_arguments = "allow"

crates/hir-ty/src/infer/pat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl InferenceContext<'_> {
149149
expected: &Ty,
150150
default_bm: T::BindingMode,
151151
id: T,
152-
subs: impl Iterator<Item = (Name, T)> + ExactSizeIterator,
152+
subs: impl ExactSizeIterator<Item = (Name, T)>,
153153
) -> Ty {
154154
let (ty, def) = self.resolve_variant(path, false);
155155
if let Some(variant) = def {

crates/ide/src/hover/render.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ pub(super) fn try_expr(
101101
if let Some((inner, body)) = error_type_args {
102102
inner_ty = inner;
103103
body_ty = body;
104-
s = "Try Error".to_owned();
104+
"Try Error".clone_into(&mut s);
105105
}
106106
}
107107
}
@@ -637,7 +637,7 @@ fn closure_ty(
637637
})
638638
.join("\n");
639639
if captures_rendered.trim().is_empty() {
640-
captures_rendered = "This closure captures nothing".to_owned();
640+
"This closure captures nothing".clone_into(&mut captures_rendered);
641641
}
642642
let mut targets: Vec<hir::ModuleDef> = Vec::new();
643643
let mut push_new_def = |item: hir::ModuleDef| {

crates/ide/src/syntax_highlighting/tags.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ pub enum HlPunct {
113113
Semi,
114114
/// ! (only for macro calls)
115115
MacroBang,
116-
///
116+
/// Other punctutations
117117
Other,
118118
}
119119

@@ -127,7 +127,7 @@ pub enum HlOperator {
127127
Logical,
128128
/// >, <, ==, >=, <=, !=
129129
Comparison,
130-
///
130+
/// Other operators
131131
Other,
132132
}
133133

crates/intern/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ pub struct InternStorage<T: ?Sized> {
174174
map: OnceLock<InternMap<T>>,
175175
}
176176

177+
#[allow(clippy::new_without_default)] // this a const fn, so it can't be default
177178
impl<T: ?Sized> InternStorage<T> {
178179
pub const fn new() -> Self {
179180
Self { map: OnceLock::new() }

crates/project-model/src/build_scripts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ impl WorkspaceBuildScripts {
237237
},
238238
progress,
239239
)?;
240-
res.iter_mut().for_each(|it| it.error = errors.clone());
240+
res.iter_mut().for_each(|it| it.error.clone_from(&errors));
241241
collisions.into_iter().for_each(|(id, workspace, package)| {
242242
if let Some(&(p, w)) = by_id.get(id) {
243243
res[workspace].outputs[package] = res[w].outputs[p].clone();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl<'a> ProgressReport<'a> {
9292

9393
let _ = io::stdout().write(output.as_bytes());
9494
let _ = io::stdout().flush();
95-
self.text = text.to_owned();
95+
text.clone_into(&mut self.text);
9696
}
9797

9898
fn set_value(&mut self, value: f32) {

crates/rust-analyzer/src/handlers/notification.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ pub(crate) fn handle_did_change_text_document(
105105
)
106106
.into_bytes();
107107
if *data != new_contents {
108-
*data = new_contents.clone();
108+
data.clone_from(&new_contents);
109109
state.vfs.write().0.set_file_contents(path, Some(new_contents));
110110
}
111111
}

crates/rust-analyzer/src/main_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ impl GlobalState {
411411
// See https://github.com/rust-lang/rust-analyzer/issues/13130
412412
let patch_empty = |message: &mut String| {
413413
if message.is_empty() {
414-
*message = " ".to_owned();
414+
" ".clone_into(message);
415415
}
416416
};
417417

crates/rust-analyzer/src/reload.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,13 +741,13 @@ pub fn ws_to_crate_graph(
741741
if layouts.len() <= idx {
742742
layouts.resize(idx + 1, e.clone());
743743
}
744-
layouts[idx] = layout.clone();
744+
layouts[idx].clone_from(&layout);
745745
}
746746
if idx >= num_toolchains {
747747
if toolchains.len() <= idx {
748748
toolchains.resize(idx + 1, None);
749749
}
750-
toolchains[idx] = toolchain.clone();
750+
toolchains[idx].clone_from(&toolchain);
751751
}
752752
});
753753
proc_macro_paths.push(crate_proc_macros);

crates/rust-analyzer/tests/slow-tests/tidy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ struct TidyDocs {
243243
impl TidyDocs {
244244
fn visit(&mut self, path: &Path, text: &str) {
245245
// Tests and diagnostic fixes don't need module level comments.
246-
if is_exclude_dir(path, &["tests", "test_data", "fixes", "grammar"]) {
246+
if is_exclude_dir(path, &["tests", "test_data", "fixes", "grammar", "salsa"]) {
247247
return;
248248
}
249249

crates/salsa/salsa-macros/src/database_storage.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//!
1+
//! Implementation for `[salsa::database]` decorator.
2+
23
use heck::ToSnakeCase;
34
use proc_macro::TokenStream;
45
use syn::parse::{Parse, ParseStream};

crates/salsa/salsa-macros/src/parenthesized.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//!
1+
//! Parenthesis helper
22
pub(crate) struct Parenthesized<T>(pub(crate) T);
33

44
impl<T> syn::parse::Parse for Parenthesized<T>

crates/salsa/salsa-macros/src/query_group.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//!
1+
//! Implementation for `[salsa::query_group]` decorator.
22
33
use crate::parenthesized::Parenthesized;
44
use heck::ToUpperCamelCase;

crates/salsa/src/derived.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//!
21
use crate::debug::TableEntry;
32
use crate::durability::Durability;
43
use crate::hash::FxIndexMap;

crates/salsa/src/derived/slot.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//!
21
use crate::debug::TableEntry;
32
use crate::derived::MemoizationPolicy;
43
use crate::durability::Durability;

crates/salsa/src/durability.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//!
21
/// Describes how likely a value is to change -- how "durable" it is.
32
/// By default, inputs have `Durability::LOW` and interned values have
43
/// `Durability::HIGH`. But inputs can be explicitly set with other

crates/salsa/src/hash.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//!
21
pub(crate) type FxHasher = std::hash::BuildHasherDefault<rustc_hash::FxHasher>;
32
pub(crate) type FxIndexSet<K> = indexmap::IndexSet<K, FxHasher>;
43
pub(crate) type FxIndexMap<K, V> = indexmap::IndexMap<K, V, FxHasher>;

crates/salsa/src/input.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//!
21
use crate::debug::TableEntry;
32
use crate::durability::Durability;
43
use crate::hash::FxIndexMap;

crates/salsa/src/intern_id.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//!
21
use std::fmt;
32
use std::num::NonZeroU32;
43

crates/salsa/src/interned.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//!
21
use crate::debug::TableEntry;
32
use crate::durability::Durability;
43
use crate::intern_id::InternId;

crates/salsa/src/lib.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
//!
21
#![allow(clippy::type_complexity)]
32
#![allow(clippy::question_mark)]
3+
#![allow(missing_docs)]
44
#![warn(rust_2018_idioms)]
5-
#![warn(missing_docs)]
65

76
//! The salsa crate is a crate for incremental recomputation. It
87
//! permits you to define a "database" of queries with both inputs and
@@ -124,9 +123,9 @@ pub struct Event {
124123
impl Event {
125124
/// Returns a type that gives a user-readable debug output.
126125
/// Use like `println!("{:?}", index.debug(db))`.
127-
pub fn debug<'me, D: ?Sized>(&'me self, db: &'me D) -> impl std::fmt::Debug + 'me
126+
pub fn debug<'me, D>(&'me self, db: &'me D) -> impl std::fmt::Debug + 'me
128127
where
129-
D: plumbing::DatabaseOps,
128+
D: ?Sized + plumbing::DatabaseOps,
130129
{
131130
EventDebug { event: self, db }
132131
}
@@ -206,9 +205,9 @@ pub enum EventKind {
206205
impl EventKind {
207206
/// Returns a type that gives a user-readable debug output.
208207
/// Use like `println!("{:?}", index.debug(db))`.
209-
pub fn debug<'me, D: ?Sized>(&'me self, db: &'me D) -> impl std::fmt::Debug + 'me
208+
pub fn debug<'me, D>(&'me self, db: &'me D) -> impl std::fmt::Debug + 'me
210209
where
211-
D: plumbing::DatabaseOps,
210+
D: ?Sized + plumbing::DatabaseOps,
212211
{
213212
EventKindDebug { kind: self, db }
214213
}
@@ -400,9 +399,9 @@ impl DatabaseKeyIndex {
400399

401400
/// Returns a type that gives a user-readable debug output.
402401
/// Use like `println!("{:?}", index.debug(db))`.
403-
pub fn debug<D: ?Sized>(self, db: &D) -> impl std::fmt::Debug + '_
402+
pub fn debug<D>(self, db: &D) -> impl std::fmt::Debug + '_
404403
where
405-
D: plumbing::DatabaseOps,
404+
D: ?Sized + plumbing::DatabaseOps,
406405
{
407406
DatabaseKeyIndexDebug { index: self, db }
408407
}

crates/salsa/src/lru.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//!
21
use oorandom::Rand64;
32
use parking_lot::Mutex;
43
use std::fmt::Debug;

crates/salsa/src/plumbing.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//!
21
#![allow(missing_docs)]
32

43
use crate::debug::TableEntry;

crates/salsa/src/revision.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//!
21
use std::num::NonZeroU32;
32
use std::sync::atomic::{AtomicU32, Ordering};
43

crates/salsa/src/runtime.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//!
21
use crate::durability::Durability;
32
use crate::hash::FxIndexSet;
43
use crate::plumbing::CycleRecoveryStrategy;
@@ -605,7 +604,7 @@ impl ActiveQuery {
605604
pub(crate) fn take_inputs_from(&mut self, cycle_query: &ActiveQuery) {
606605
self.changed_at = cycle_query.changed_at;
607606
self.durability = cycle_query.durability;
608-
self.dependencies = cycle_query.dependencies.clone();
607+
self.dependencies.clone_from(&cycle_query.dependencies);
609608
}
610609
}
611610

crates/salsa/src/runtime/dependency_graph.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//!
21
use triomphe::Arc;
32

43
use crate::{DatabaseKeyIndex, RuntimeId};

crates/salsa/src/runtime/local_state.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//!
21
use tracing::debug;
32
use triomphe::ThinArc;
43

crates/salsa/src/storage.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//!
21
use crate::{plumbing::DatabaseStorageTypes, Runtime};
32
use triomphe::Arc;
43

crates/sourcegen/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl CommentBlock {
6969
panic!("Use plain (non-doc) comments with tags like {tag}:\n {first}");
7070
}
7171

72-
block.id = id.trim().to_owned();
72+
id.trim().clone_into(&mut block.id);
7373
true
7474
});
7575
blocks

crates/test-utils/src/fixture.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ impl FixtureWithProjectMeta {
186186

187187
if let Some(meta) = fixture.strip_prefix("//- target_data_layout:") {
188188
let (meta, remain) = meta.split_once('\n').unwrap();
189-
target_data_layout = meta.trim().to_owned();
189+
meta.trim().clone_into(&mut target_data_layout);
190190
fixture = remain;
191191
}
192192

xtask/src/codegen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl CommentBlock {
8484
panic!("Use plain (non-doc) comments with tags like {tag}:\n {first}");
8585
}
8686

87-
block.id = id.trim().to_owned();
87+
id.trim().clone_into(&mut block.id);
8888
true
8989
});
9090
blocks

xtask/src/codegen/lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ fn generate_descriptor_clippy(buf: &mut String, path: &Path) {
280280
let line = &line[..up_to];
281281

282282
let clippy_lint = clippy_lints.last_mut().expect("clippy lint must already exist");
283-
clippy_lint.help = unescape(line).trim().to_owned();
283+
unescape(line).trim().clone_into(&mut clippy_lint.help);
284284
}
285285
}
286286
clippy_lints.sort_by(|lint, lint2| lint.id.cmp(&lint2.id));

0 commit comments

Comments
 (0)