Skip to content

Commit 2ae3e57

Browse files
committed
Fix new clippy lints
1 parent 8e324e9 commit 2ae3e57

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
}
@@ -634,7 +634,7 @@ fn closure_ty(
634634
})
635635
.join("\n");
636636
if captures_rendered.trim().is_empty() {
637-
captures_rendered = "This closure captures nothing".to_owned();
637+
"This closure captures nothing".clone_into(&mut captures_rendered);
638638
}
639639
let mut targets: Vec<hir::ModuleDef> = Vec::new();
640640
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
@@ -235,7 +235,7 @@ impl WorkspaceBuildScripts {
235235
},
236236
progress,
237237
)?;
238-
res.iter_mut().for_each(|it| it.error = errors.clone());
238+
res.iter_mut().for_each(|it| it.error.clone_from(&errors));
239239
collisions.into_iter().for_each(|(id, workspace, package)| {
240240
if let Some(&(p, w)) = by_id.get(id) {
241241
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
@@ -412,7 +412,7 @@ impl GlobalState {
412412
// See https://github.com/rust-lang/rust-analyzer/issues/13130
413413
let patch_empty = |message: &mut String| {
414414
if message.is_empty() {
415-
*message = " ".to_owned();
415+
" ".clone_into(message);
416416
}
417417
};
418418

crates/rust-analyzer/src/reload.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,13 +725,13 @@ pub fn ws_to_crate_graph(
725725
if layouts.len() <= idx {
726726
layouts.resize(idx + 1, e.clone());
727727
}
728-
layouts[idx] = layout.clone();
728+
layouts[idx].clone_from(&layout);
729729
}
730730
if idx >= num_toolchains {
731731
if toolchains.len() <= idx {
732732
toolchains.resize(idx + 1, None);
733733
}
734-
toolchains[idx] = toolchain.clone();
734+
toolchains[idx].clone_from(&toolchain);
735735
}
736736
});
737737
proc_macro_paths.push(crate_proc_macros);

0 commit comments

Comments
 (0)