Skip to content

Commit 6b3ba96

Browse files
cargo clippy --fix
1 parent 6774330 commit 6b3ba96

File tree

9 files changed

+15
-15
lines changed

9 files changed

+15
-15
lines changed

crates/hir-def/src/expr_store/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub(super) fn print_body_hir(
8282
p.buf.push_str(", ");
8383
});
8484
// remove the last ", " in param list
85-
if body.params.len() > 0 {
85+
if !body.params.is_empty() {
8686
p.buf.truncate(p.buf.len() - 2);
8787
}
8888
p.buf.push(')');

crates/hir-def/src/item_tree/lower.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ impl<'a> Ctx<'a> {
939939
fn desugar_future_path(ctx: &mut LowerCtx<'_>, orig: TypeRefId) -> PathId {
940940
let path = path![core::future::Future];
941941
let mut generic_args: Vec<_> =
942-
std::iter::repeat(None).take(path.segments().len() - 1).collect();
942+
std::iter::repeat_n(None, path.segments().len() - 1).collect();
943943
let binding = AssociatedTypeBinding {
944944
name: Name::new_symbol_root(sym::Output.clone()),
945945
args: None,

crates/hir-ty/src/builder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ impl TyBuilder<()> {
263263
.as_generic_def_id(db.upcast())
264264
.map(|p| generics(db.upcast(), p).placeholder_subst(db));
265265
// These represent resume type, yield type, and return type of coroutine.
266-
let params = std::iter::repeat(ParamKind::Type).take(3).collect();
266+
let params = std::iter::repeat_n(ParamKind::Type, 3).collect();
267267
TyBuilder::new((), params, parent_subst)
268268
}
269269

@@ -340,7 +340,7 @@ impl TyBuilder<hir_def::AdtId> {
340340
pub struct Tuple(usize);
341341
impl TyBuilder<Tuple> {
342342
pub fn tuple(size: usize) -> TyBuilder<Tuple> {
343-
TyBuilder::new(Tuple(size), iter::repeat(ParamKind::Type).take(size).collect(), None)
343+
TyBuilder::new(Tuple(size), std::iter::repeat_n(ParamKind::Type, size).collect(), None)
344344
}
345345

346346
pub fn build(self) -> Ty {
@@ -356,7 +356,7 @@ impl TyBuilder<Tuple> {
356356
let elements = elements.into_iter();
357357
let len = elements.len();
358358
let mut b =
359-
TyBuilder::new(Tuple(len), iter::repeat(ParamKind::Type).take(len).collect(), None);
359+
TyBuilder::new(Tuple(len), std::iter::repeat_n(ParamKind::Type, len).collect(), None);
360360
for e in elements {
361361
b = b.push(e);
362362
}

crates/hir-ty/src/chalk_db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl chalk_solve::RustIrDatabase<Interner> for ChalkContext<'_> {
137137
let fps: &[TyFingerprint] = match binder_kind(&ty, binders) {
138138
Some(chalk_ir::TyVariableKind::Integer) => &ALL_INT_FPS,
139139
Some(chalk_ir::TyVariableKind::Float) => &ALL_FLOAT_FPS,
140-
_ => self_ty_fp.as_ref().map(std::slice::from_ref).unwrap_or(&[]),
140+
_ => self_ty_fp.as_slice(),
141141
};
142142

143143
let id_to_chalk = |id: hir_def::ImplId| id.to_chalk(self.db);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Unification and canonicalization logic.
22
3-
use std::{fmt, iter, mem};
3+
use std::{fmt, mem};
44

55
use chalk_ir::{
66
cast::Cast, fold::TypeFoldable, interner::HasInterner, zip::Zip, CanonicalVarKind, FloatTy,
@@ -386,7 +386,7 @@ impl<'a> InferenceTable<'a> {
386386
}
387387
fn extend_type_variable_table(&mut self, to_index: usize) {
388388
let count = to_index - self.type_variable_table.len() + 1;
389-
self.type_variable_table.extend(iter::repeat(TypeVariableFlags::default()).take(count));
389+
self.type_variable_table.extend(std::iter::repeat_n(TypeVariableFlags::default(), count));
390390
}
391391

392392
fn new_var(&mut self, kind: TyVariableKind, diverging: bool) -> Ty {

crates/hir-ty/src/mir/eval.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ impl Evaluator<'_> {
11191119
"Stack overflow. Tried to grow stack to {stack_size} bytes"
11201120
)));
11211121
}
1122-
self.stack.extend(iter::repeat(0).take(stack_size));
1122+
self.stack.extend(std::iter::repeat_n(0, stack_size));
11231123
Ok((locals, prev_stack_pointer))
11241124
}
11251125

@@ -2121,7 +2121,7 @@ impl Evaluator<'_> {
21212121
return Err(MirEvalError::Panic(format!("Memory allocation of {size} bytes failed")));
21222122
}
21232123
let pos = self.heap.len();
2124-
self.heap.extend(iter::repeat(0).take(size));
2124+
self.heap.extend(std::iter::repeat_n(0, size));
21252125
Ok(Address::Heap(pos))
21262126
}
21272127

crates/hir-ty/src/mir/eval/shim/simd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl Evaluator<'_> {
127127
Ordering::Greater => ["ge", "gt", "ne"].contains(&name),
128128
};
129129
let result = if result { 255 } else { 0 };
130-
destination_bytes.extend(std::iter::repeat(result).take(dest_size));
130+
destination_bytes.extend(std::iter::repeat_n(result, dest_size));
131131
}
132132

133133
destination.write_from_bytes(self, &destination_bytes)

crates/ide/src/signature_help.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ fn signature_help_for_tuple_pat_ish(
695695
}
696696
#[cfg(test)]
697697
mod tests {
698-
use std::iter;
698+
699699

700700
use expect_test::{expect, Expect};
701701
use ide_db::FilePosition;
@@ -742,11 +742,11 @@ mod tests {
742742
let gap = start.checked_sub(offset).unwrap_or_else(|| {
743743
panic!("parameter ranges out of order: {:?}", sig_help.parameter_ranges())
744744
});
745-
rendered.extend(iter::repeat(' ').take(gap as usize));
745+
rendered.extend(std::iter::repeat_n(' ', gap as usize));
746746
let param_text = &sig_help.signature[*range];
747747
let width = param_text.chars().count(); // …
748748
let marker = if is_active { '^' } else { '-' };
749-
rendered.extend(iter::repeat(marker).take(width));
749+
rendered.extend(std::iter::repeat_n(marker, width));
750750
offset += gap + u32::from(range.len());
751751
}
752752
if !sig_help.parameter_ranges().is_empty() {

crates/rust-analyzer/src/lsp/to_proto.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1549,7 +1549,7 @@ pub(crate) fn runnable(
15491549
);
15501550

15511551
let cwd = match runnable.kind {
1552-
ide::RunnableKind::Bin { .. } => workspace_root.clone(),
1552+
ide::RunnableKind::Bin => workspace_root.clone(),
15531553
_ => spec.cargo_toml.parent().to_owned(),
15541554
};
15551555

0 commit comments

Comments
 (0)