From 544c462d255e23c99d99c5ed67a7b16bf61eb563 Mon Sep 17 00:00:00 2001 From: xFrednet Date: Fri, 23 Jul 2021 17:02:45 +0200 Subject: [PATCH 1/1] Documented constant expression evaluation for `repeat_once` --- clippy_lints/src/repeat_once.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/repeat_once.rs b/clippy_lints/src/repeat_once.rs index b479c40bca6..17cb96bc4eb 100644 --- a/clippy_lints/src/repeat_once.rs +++ b/clippy_lints/src/repeat_once.rs @@ -16,7 +16,11 @@ /// - `.clone()` for `String` /// - `.to_vec()` for `slice` /// - /// **Why is this bad?** For example, `String.repeat(1)` is equivalent to `.clone()`. If cloning the string is the intention behind this, `clone()` should be used. + /// The lint will evaluate constant expressions and values as arguments of `.repeat(..)` and emit a message if + /// they are equivalent to `1`. (Related discussion in [rust-clippy#7306](https://github.com/rust-lang/rust-clippy/issues/7306)) + /// + /// **Why is this bad?** For example, `String.repeat(1)` is equivalent to `.clone()`. If cloning + /// the string is the intention behind this, `clone()` should be used. /// /// **Known problems:** None. /// -- 2.44.0