Skip to content

Commit c08ea17

Browse files
committed
Replace some std::iter::repeat with str::repeat
1 parent 6f5a198 commit c08ea17

File tree

4 files changed

+5
-9
lines changed

4 files changed

+5
-9
lines changed

Diff for: compiler/rustc_typeck/src/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ fn missing_items_err(
858858
// Obtain the level of indentation ending in `sugg_sp`.
859859
let indentation = tcx.sess.source_map().span_to_margin(sugg_sp).unwrap_or(0);
860860
// Make the whitespace that will make the suggestion have the right indentation.
861-
let padding: String = std::iter::repeat(" ").take(indentation).collect();
861+
let padding: String = " ".repeat(indentation);
862862

863863
for trait_item in missing_items {
864864
let snippet = suggestion_signature(&trait_item, tcx);

Diff for: src/test/ui/issues/issue-20644.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ use std::path::Path;
1919

2020
pub fn parse_summary<R: Read>(_: R, _: &Path) {
2121
let path_from_root = Path::new("");
22-
Path::new(&iter::repeat("../")
23-
.take(path_from_root.components().count() - 1)
24-
.collect::<String>());
22+
Path::new(&"../".repeat(path_from_root.components().count() - 1));
2523
}
2624

2725
fn foo() {

Diff for: src/tools/clippy/clippy_lints/src/mem_discriminant.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use rustc_errors::Applicability;
77
use rustc_hir::{BorrowKind, Expr, ExprKind};
88
use rustc_lint::{LateContext, LateLintPass};
99
use rustc_session::{declare_lint_pass, declare_tool_lint};
10-
use std::iter;
1110

1211
declare_clippy_lint! {
1312
/// **What it does:** Checks for calls of `mem::discriminant()` on a non-enum type.
@@ -67,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for MemDiscriminant {
6766
}
6867
}
6968

70-
let derefs: String = iter::repeat('*').take(derefs_needed).collect();
69+
let derefs = "*".repeat(derefs_needed);
7170
diag.span_suggestion(
7271
param.span,
7372
"try dereferencing",

Diff for: src/tools/clippy/clippy_lints/src/methods/clone_on_copy.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use rustc_hir::{BindingAnnotation, Expr, ExprKind, MatchSource, Node, PatKind};
88
use rustc_lint::LateContext;
99
use rustc_middle::ty::{self, adjustment::Adjust};
1010
use rustc_span::symbol::{sym, Symbol};
11-
use std::iter;
1211

1312
use super::CLONE_DOUBLE_REF;
1413
use super::CLONE_ON_COPY;
@@ -54,8 +53,8 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, method_name: Symbol,
5453
ty = inner;
5554
n += 1;
5655
}
57-
let refs: String = iter::repeat('&').take(n + 1).collect();
58-
let derefs: String = iter::repeat('*').take(n).collect();
56+
let refs = "&".repeat(n + 1);
57+
let derefs = "*".repeat(n);
5958
let explicit = format!("<{}{}>::clone({})", refs, ty, snip);
6059
diag.span_suggestion(
6160
expr.span,

0 commit comments

Comments
 (0)