Skip to content

Commit 3691380

Browse files
committed
Auto merge of #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);

0 commit comments

Comments
 (0)