This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +43
-0
lines changed Expand file tree Collapse file tree 5 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -4441,6 +4441,7 @@ Released 2018-09-13
4441
4441
[ `chars_last_cmp` ] : https://rust-lang.github.io/rust-clippy/master/index.html#chars_last_cmp
4442
4442
[ `chars_next_cmp` ] : https://rust-lang.github.io/rust-clippy/master/index.html#chars_next_cmp
4443
4443
[ `checked_conversions` ] : https://rust-lang.github.io/rust-clippy/master/index.html#checked_conversions
4444
+ [ `clear_with_drain` ] : https://rust-lang.github.io/rust-clippy/master/index.html#clear_with_drain
4444
4445
[ `clone_double_ref` ] : https://rust-lang.github.io/rust-clippy/master/index.html#clone_double_ref
4445
4446
[ `clone_on_copy` ] : https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
4446
4447
[ `clone_on_ref_ptr` ] : https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_ref_ptr
Original file line number Diff line number Diff line change @@ -307,6 +307,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
307
307
crate :: methods:: CASE_SENSITIVE_FILE_EXTENSION_COMPARISONS_INFO ,
308
308
crate :: methods:: CHARS_LAST_CMP_INFO ,
309
309
crate :: methods:: CHARS_NEXT_CMP_INFO ,
310
+ crate :: methods:: CLEAR_WITH_DRAIN_INFO ,
310
311
crate :: methods:: CLONED_INSTEAD_OF_COPIED_INFO ,
311
312
crate :: methods:: CLONE_DOUBLE_REF_INFO ,
312
313
crate :: methods:: CLONE_ON_COPY_INFO ,
Original file line number Diff line number Diff line change
1
+ use rustc_lint:: { LateContext , LintContext } ;
2
+
3
+ use super :: CLEAR_WITH_DRAIN ;
4
+
5
+ // TODO: Adjust the parameters as necessary
6
+ pub ( super ) fn check ( cx : & LateContext ) {
7
+ todo ! ( ) ;
8
+ }
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ mod chars_last_cmp;
9
9
mod chars_last_cmp_with_unwrap;
10
10
mod chars_next_cmp;
11
11
mod chars_next_cmp_with_unwrap;
12
+ mod clear_with_drain;
12
13
mod clone_on_copy;
13
14
mod clone_on_ref_ptr;
14
15
mod cloned_instead_of_copied;
@@ -3190,6 +3191,25 @@ declare_clippy_lint! {
3190
3191
"single command line argument that looks like it should be multiple arguments"
3191
3192
}
3192
3193
3194
+ declare_clippy_lint ! {
3195
+ /// ### What it does
3196
+ ///
3197
+ /// ### Why is this bad?
3198
+ ///
3199
+ /// ### Example
3200
+ /// ```rust
3201
+ /// // example code where clippy issues a warning
3202
+ /// ```
3203
+ /// Use instead:
3204
+ /// ```rust
3205
+ /// // example code which does not raise clippy warning
3206
+ /// ```
3207
+ #[ clippy:: version = "1.69.0" ]
3208
+ pub CLEAR_WITH_DRAIN ,
3209
+ nursery,
3210
+ "default lint description"
3211
+ }
3212
+
3193
3213
pub struct Methods {
3194
3214
avoid_breaking_exported_api : bool ,
3195
3215
msrv : Msrv ,
@@ -3318,6 +3338,7 @@ impl_lint_pass!(Methods => [
3318
3338
SEEK_TO_START_INSTEAD_OF_REWIND ,
3319
3339
NEEDLESS_COLLECT ,
3320
3340
SUSPICIOUS_COMMAND_ARG_SPACE ,
3341
+ CLEAR_WITH_DRAIN ,
3321
3342
] ) ;
3322
3343
3323
3344
/// Extracts a method call name, args, and `Span` of the method name.
Original file line number Diff line number Diff line change
1
+ #![ allow( unused) ]
2
+ #![ warn( clippy:: clear_with_drain) ]
3
+
4
+ fn main ( ) {
5
+ let mut vec: Vec < i32 > = Vec :: new ( ) ;
6
+ //Lint
7
+ vec. drain ( ..) ;
8
+ vec. drain ( 0 ..vec. len ( ) ) ;
9
+
10
+ // Dont Lint
11
+ let iter = vec. drain ( ..) ;
12
+ }
You can’t perform that action at this time.
0 commit comments