]> git.lizzy.rs Git - rust.git/commitdiff
Documented constant expression evaluation for `repeat_once`
authorxFrednet <xFrednet@gmail.com>
Fri, 23 Jul 2021 15:02:45 +0000 (17:02 +0200)
committerxFrednet <xFrednet@gmail.com>
Fri, 23 Jul 2021 15:07:43 +0000 (17:07 +0200)
clippy_lints/src/repeat_once.rs

index b479c40bca6cd48511707d660aacb33de06055c2..17cb96bc4ebd1e7d0e0a6ef6bb0ecb35eb45ba57 100644 (file)
     /// - `.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.
     ///