Skip to content

Commit

Permalink
use repeat_n() where available
Browse files Browse the repository at this point in the history
  • Loading branch information
lapla-cogito committed Dec 20, 2024
1 parent 7290ea6 commit 87082a2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/doc/lazy_continuation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub(super) fn check(
diag.span_suggestion_verbose(
span.shrink_to_hi(),
"indent this line",
std::iter::repeat(" ").take(indent).join(""),
std::iter::repeat_n(" ", indent).join(""),
Applicability::MaybeIncorrect,
);
diag.help("if this is supposed to be its own paragraph, add a blank line");
Expand Down
5 changes: 2 additions & 3 deletions clippy_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
clippy::missing_errors_doc,
clippy::missing_panics_doc,
clippy::must_use_candidate,
clippy::manual_repeat_n,
rustc::diagnostic_outside_of_impl,
rustc::untranslatable_diagnostic
)]
Expand Down Expand Up @@ -89,7 +88,7 @@ use core::mem;
use core::ops::ControlFlow;
use std::collections::hash_map::Entry;
use std::hash::BuildHasherDefault;
use std::iter::{once, repeat};
use std::iter::{once, repeat_n};
use std::sync::{Mutex, MutexGuard, OnceLock};

use itertools::Itertools;
Expand Down Expand Up @@ -3415,7 +3414,7 @@ fn maybe_get_relative_path(from: &DefPath, to: &DefPath, max_super: usize) -> St
}))
.join("::")
} else {
repeat(String::from("super")).take(go_up_by).chain(path).join("::")
repeat_n(String::from("super"), go_up_by).chain(path).join("::")
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/manual_repeat_n.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ mod foo_lib {
fn foo() {
let _ = match 1 {
1 => foo_lib::iter(),
2 => std::iter::repeat([1, 2].as_slice()).take(2), /* Shouldn't lint because `external_lib::iter` doesn't
* return `std::iter::RepeatN`. */
2 => std::iter::repeat([1, 2].as_slice()).take(2), /* Shouldn't lint because `external_lib::iter` doesn't */
// return `std::iter::RepeatN`.
_ => todo!(),
};
}

0 comments on commit 87082a2

Please sign in to comment.