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
44414441[ `chars_last_cmp` ] : https://rust-lang.github.io/rust-clippy/master/index.html#chars_last_cmp
44424442[ `chars_next_cmp` ] : https://rust-lang.github.io/rust-clippy/master/index.html#chars_next_cmp
44434443[ `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
44444445[ `clone_double_ref` ] : https://rust-lang.github.io/rust-clippy/master/index.html#clone_double_ref
44454446[ `clone_on_copy` ] : https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
44464447[ `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] = &[
307307 crate :: methods:: CASE_SENSITIVE_FILE_EXTENSION_COMPARISONS_INFO ,
308308 crate :: methods:: CHARS_LAST_CMP_INFO ,
309309 crate :: methods:: CHARS_NEXT_CMP_INFO ,
310+ crate :: methods:: CLEAR_WITH_DRAIN_INFO ,
310311 crate :: methods:: CLONED_INSTEAD_OF_COPIED_INFO ,
311312 crate :: methods:: CLONE_DOUBLE_REF_INFO ,
312313 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;
99mod chars_last_cmp_with_unwrap;
1010mod chars_next_cmp;
1111mod chars_next_cmp_with_unwrap;
12+ mod clear_with_drain;
1213mod clone_on_copy;
1314mod clone_on_ref_ptr;
1415mod cloned_instead_of_copied;
@@ -3190,6 +3191,25 @@ declare_clippy_lint! {
31903191 "single command line argument that looks like it should be multiple arguments"
31913192}
31923193
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+
31933213pub struct Methods {
31943214 avoid_breaking_exported_api : bool ,
31953215 msrv : Msrv ,
@@ -3318,6 +3338,7 @@ impl_lint_pass!(Methods => [
33183338 SEEK_TO_START_INSTEAD_OF_REWIND ,
33193339 NEEDLESS_COLLECT ,
33203340 SUSPICIOUS_COMMAND_ARG_SPACE ,
3341+ CLEAR_WITH_DRAIN ,
33213342] ) ;
33223343
33233344/// 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