diff options
| author | bluthej <joffrey.bluthe@e.email> | 2023-03-20 18:46:18 +0100 |
|---|---|---|
| committer | bluthej <joffrey.bluthe@e.email> | 2023-03-22 11:01:57 +0100 |
| commit | 484c82e0418325df5d25e8d0e11e10a5d1371502 (patch) | |
| tree | d2f187e5c1bf852bd8efbf53073ea64fb1a0474e | |
| parent | 589d7e1ab40af9950d33715ef6cf866efa04f9a2 (diff) | |
| download | rust-484c82e0418325df5d25e8d0e11e10a5d1371502.tar.gz rust-484c82e0418325df5d25e8d0e11e10a5d1371502.zip | |
Update lint declaration
| -rw-r--r-- | clippy_lints/src/methods/mod.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index 859284b6a5c..4e74ac6af2b 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -3193,21 +3193,27 @@ declare_clippy_lint! { declare_clippy_lint! { /// ### What it does + /// Checks for usage of `.drain(..)` for the sole purpose of clearing a `Vec`. /// /// ### Why is this bad? + /// This creates an unnecessary iterator that is dropped immediately. + /// + /// Calling `.clear()` also makes the intent clearer. /// /// ### Example /// ```rust - /// // example code where clippy issues a warning + /// let mut v = vec![1, 2, 3]; + /// v.drain(..); /// ``` /// Use instead: /// ```rust - /// // example code which does not raise clippy warning + /// let mut v = vec![1, 2, 3]; + /// v.clear(); /// ``` #[clippy::version = "1.69.0"] pub CLEAR_WITH_DRAIN, nursery, - "default lint description" + "calling `drain` in order to `clear` a `Vec`" } pub struct Methods { |
