Skip to content

Commit 25a77cf

Browse files
committed
remove clippy::double_neg
1 parent 6180622 commit 25a77cf

File tree

12 files changed

+93
-146
lines changed

12 files changed

+93
-146
lines changed

.github/driver.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ unset CARGO_MANIFEST_DIR
4747

4848
# Run a lint and make sure it produces the expected output. It's also expected to exit with code 1
4949
# FIXME: How to match the clippy invocation in compile-test.rs?
50-
./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/double_neg.rs 2>double_neg.stderr && exit 1
51-
sed -e "/= help: for/d" double_neg.stderr > normalized.stderr
52-
diff -u normalized.stderr tests/ui/double_neg.stderr
50+
./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/box_default.rs 2>box_default.stderr && exit 1
51+
sed -e "/= help: for/d" box_default.stderr > normalized.stderr
52+
diff -u normalized.stderr tests/ui/box_default.stderr
5353

5454
# make sure "clippy-driver --rustc --arg" and "rustc --arg" behave the same
5555
SYSROOT=$(rustc --print sysroot)

book/src/usage.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ You can configure lint levels on the command line by adding
3333
`-A/W/D clippy::lint_name` like this:
3434

3535
```bash
36-
cargo clippy -- -Aclippy::style -Wclippy::double_neg -Dclippy::perf
36+
cargo clippy -- -Aclippy::style -Wclippy::box_default -Dclippy::perf
3737
```
3838

3939
For [CI] all warnings can be elevated to errors which will in turn fail
@@ -101,11 +101,10 @@ You can configure lint levels in source code the same way you can configure
101101
```rust,ignore
102102
#![allow(clippy::style)]
103103
104-
#[warn(clippy::double_neg)]
104+
#[warn(clippy::box_default)]
105105
fn main() {
106-
let x = 1;
107-
let y = --x;
108-
// ^^ warning: double negation
106+
let _ = Box::<String>::new(Default::default());
107+
// ^ warning: `Box::new(_)` of default value
109108
}
110109
```
111110

clippy_dev/src/new_lint.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ fn setup_mod_file(path: &Path, lint: &LintData<'_>) -> io::Result<&'static str>
455455
});
456456

457457
// Find both the last lint declaration (declare_clippy_lint!) and the lint pass impl
458-
while let Some(LintDeclSearchResult { content, .. }) = iter.find(|result| result.token == TokenKind::Ident) {
458+
while let Some(LintDeclSearchResult { content, .. }) = iter.find(|result| result.token_kind == TokenKind::Ident) {
459459
let mut iter = iter
460460
.by_ref()
461461
.filter(|t| !matches!(t.token_kind, TokenKind::Whitespace | TokenKind::LineComment { .. }));
@@ -465,7 +465,7 @@ fn setup_mod_file(path: &Path, lint: &LintData<'_>) -> io::Result<&'static str>
465465
// matches `!{`
466466
match_tokens!(iter, Bang OpenBrace);
467467
if let Some(LintDeclSearchResult { range, .. }) =
468-
iter.find(|result| result.token == TokenKind::CloseBrace)
468+
iter.find(|result| result.token_kind == TokenKind::CloseBrace)
469469
{
470470
last_decl_curly_offset = Some(range.end);
471471
}

clippy_lints/src/declared_lints.rs

-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,6 @@ pub static LINTS: &[&crate::LintInfo] = &[
507507
crate::misc::USED_UNDERSCORE_BINDING_INFO,
508508
crate::misc::USED_UNDERSCORE_ITEMS_INFO,
509509
crate::misc_early::BUILTIN_TYPE_SHADOW_INFO,
510-
crate::misc_early::DOUBLE_NEG_INFO,
511510
crate::misc_early::DUPLICATE_UNDERSCORE_ARGUMENT_INFO,
512511
crate::misc_early::MIXED_CASE_HEX_LITERALS_INFO,
513512
crate::misc_early::REDUNDANT_AT_REST_PATTERN_INFO,

clippy_lints/src/deprecated_lints.rs

+2
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ declare_with_version! { RENAMED(RENAMED_VERSION): &[(&str, &str)] = &[
129129
("clippy::clone_double_ref", "suspicious_double_ref_op"),
130130
#[clippy::version = ""]
131131
("clippy::cmp_nan", "invalid_nan_comparisons"),
132+
#[clippy::version = "1.86.0"]
133+
("clippy::double_neg", "double_negations"),
132134
#[clippy::version = ""]
133135
("clippy::drop_bounds", "drop_bounds"),
134136
#[clippy::version = ""]

clippy_lints/src/misc_early/double_neg.rs

-18
This file was deleted.

clippy_lints/src/misc_early/mod.rs

-22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
mod builtin_type_shadow;
2-
mod double_neg;
32
mod literal_suffix;
43
mod mixed_case_hex_literals;
54
mod redundant_at_rest_pattern;
@@ -85,25 +84,6 @@ declare_clippy_lint! {
8584
"function arguments having names which only differ by an underscore"
8685
}
8786

88-
declare_clippy_lint! {
89-
/// ### What it does
90-
/// Detects expressions of the form `--x`.
91-
///
92-
/// ### Why is this bad?
93-
/// It can mislead C/C++ programmers to think `x` was
94-
/// decremented.
95-
///
96-
/// ### Example
97-
/// ```no_run
98-
/// let mut x = 3;
99-
/// --x;
100-
/// ```
101-
#[clippy::version = "pre 1.29.0"]
102-
pub DOUBLE_NEG,
103-
style,
104-
"`--x`, which is a double negation of `x` and not a pre-decrement as in C/C++"
105-
}
106-
10787
declare_clippy_lint! {
10888
/// ### What it does
10989
/// Warns on hexadecimal literals with mixed-case letter
@@ -352,7 +332,6 @@ declare_clippy_lint! {
352332
declare_lint_pass!(MiscEarlyLints => [
353333
UNNEEDED_FIELD_PATTERN,
354334
DUPLICATE_UNDERSCORE_ARGUMENT,
355-
DOUBLE_NEG,
356335
MIXED_CASE_HEX_LITERALS,
357336
UNSEPARATED_LITERAL_SUFFIX,
358337
SEPARATED_LITERAL_SUFFIX,
@@ -415,7 +394,6 @@ impl EarlyLintPass for MiscEarlyLints {
415394
if let ExprKind::Lit(lit) = expr.kind {
416395
MiscEarlyLints::check_lit(cx, lit, expr.span);
417396
}
418-
double_neg::check(cx, expr);
419397
}
420398
}
421399

tests/ui/double_neg.rs

-10
This file was deleted.

tests/ui/double_neg.stderr

-11
This file was deleted.

tests/ui/rename.fixed

+8-7
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
#![allow(clippy::disallowed_methods)]
1414
#![allow(clippy::disallowed_types)]
1515
#![allow(clippy::mixed_read_write_in_expression)]
16-
#![allow(clippy::manual_find_map)]
1716
#![allow(clippy::manual_filter_map)]
18-
#![allow(unpredictable_function_pointer_comparisons)]
17+
#![allow(clippy::manual_find_map)]
1918
#![allow(clippy::useless_conversion)]
2019
#![allow(clippy::redundant_pattern_matching)]
2120
#![allow(clippy::match_result_ok)]
@@ -30,6 +29,7 @@
3029
#![allow(clippy::unwrap_used)]
3130
#![allow(clippy::panicking_overflow_checks)]
3231
#![allow(clippy::needless_borrow)]
32+
#![allow(clippy::reversed_empty_ranges)]
3333
#![allow(clippy::single_char_add_str)]
3434
#![allow(clippy::module_name_repetitions)]
3535
#![allow(clippy::missing_const_for_thread_local)]
@@ -39,9 +39,11 @@
3939
#![allow(invalid_reference_casting)]
4040
#![allow(suspicious_double_ref_op)]
4141
#![allow(invalid_nan_comparisons)]
42+
#![allow(double_negations)]
4243
#![allow(drop_bounds)]
4344
#![allow(dropping_copy_types)]
4445
#![allow(dropping_references)]
46+
#![allow(unpredictable_function_pointer_comparisons)]
4547
#![allow(useless_ptr_null_checks)]
4648
#![allow(for_loops_over_fallibles)]
4749
#![allow(forgetting_copy_types)]
@@ -60,8 +62,6 @@
6062
#![allow(unknown_lints)]
6163
#![allow(unused_labels)]
6264
#![allow(ambiguous_wide_pointer_comparisons)]
63-
#![allow(unpredictable_function_pointer_comparisons)]
64-
#![allow(clippy::reversed_empty_ranges)]
6565
#![warn(clippy::almost_complete_range)] //~ ERROR: lint `clippy::almost_complete_letter_range`
6666
#![warn(clippy::disallowed_names)] //~ ERROR: lint `clippy::blacklisted_name`
6767
#![warn(clippy::blocks_in_conditions)] //~ ERROR: lint `clippy::block_in_if_condition_expr`
@@ -74,9 +74,8 @@
7474
#![warn(clippy::disallowed_methods)] //~ ERROR: lint `clippy::disallowed_method`
7575
#![warn(clippy::disallowed_types)] //~ ERROR: lint `clippy::disallowed_type`
7676
#![warn(clippy::mixed_read_write_in_expression)] //~ ERROR: lint `clippy::eval_order_dependence`
77-
#![warn(clippy::manual_find_map)] //~ ERROR: lint `clippy::find_map`
7877
#![warn(clippy::manual_filter_map)] //~ ERROR: lint `clippy::filter_map`
79-
#![warn(unpredictable_function_pointer_comparisons)] //~ ERROR: lint `clippy::fn_address_comparisons`
78+
#![warn(clippy::manual_find_map)] //~ ERROR: lint `clippy::find_map`
8079
#![warn(clippy::useless_conversion)] //~ ERROR: lint `clippy::identity_conversion`
8180
#![warn(clippy::redundant_pattern_matching)] //~ ERROR: lint `clippy::if_let_redundant_pattern_matching`
8281
#![warn(clippy::match_result_ok)] //~ ERROR: lint `clippy::if_let_some_result`
@@ -95,6 +94,7 @@
9594
#![warn(clippy::expect_used)] //~ ERROR: lint `clippy::result_expect_used`
9695
#![warn(clippy::map_unwrap_or)] //~ ERROR: lint `clippy::result_map_unwrap_or_else`
9796
#![warn(clippy::unwrap_used)] //~ ERROR: lint `clippy::result_unwrap_used`
97+
#![warn(clippy::reversed_empty_ranges)] //~ ERROR: lint `clippy::reverse_range_loop`
9898
#![warn(clippy::single_char_add_str)] //~ ERROR: lint `clippy::single_char_push_str`
9999
#![warn(clippy::module_name_repetitions)] //~ ERROR: lint `clippy::stutter`
100100
#![warn(clippy::missing_const_for_thread_local)] //~ ERROR: lint `clippy::thread_local_initializer_can_be_made_const`
@@ -104,9 +104,11 @@
104104
#![warn(invalid_reference_casting)] //~ ERROR: lint `clippy::cast_ref_to_mut`
105105
#![warn(suspicious_double_ref_op)] //~ ERROR: lint `clippy::clone_double_ref`
106106
#![warn(invalid_nan_comparisons)] //~ ERROR: lint `clippy::cmp_nan`
107+
#![warn(double_negations)] //~ ERROR: lint `clippy::double_neg`
107108
#![warn(drop_bounds)] //~ ERROR: lint `clippy::drop_bounds`
108109
#![warn(dropping_copy_types)] //~ ERROR: lint `clippy::drop_copy`
109110
#![warn(dropping_references)] //~ ERROR: lint `clippy::drop_ref`
111+
#![warn(unpredictable_function_pointer_comparisons)] //~ ERROR: lint `clippy::fn_address_comparisons`
110112
#![warn(useless_ptr_null_checks)] //~ ERROR: lint `clippy::fn_null_check`
111113
#![warn(for_loops_over_fallibles)] //~ ERROR: lint `clippy::for_loop_over_option`
112114
#![warn(for_loops_over_fallibles)] //~ ERROR: lint `clippy::for_loop_over_result`
@@ -128,6 +130,5 @@
128130
#![warn(unknown_lints)] //~ ERROR: lint `clippy::unknown_clippy_lints`
129131
#![warn(unused_labels)] //~ ERROR: lint `clippy::unused_label`
130132
#![warn(ambiguous_wide_pointer_comparisons)] //~ ERROR: lint `clippy::vtable_address_comparisons`
131-
#![warn(clippy::reversed_empty_ranges)] //~ ERROR: lint `clippy::reverse_range_loop`
132133

133134
fn main() {}

tests/ui/rename.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
#![allow(clippy::disallowed_methods)]
1414
#![allow(clippy::disallowed_types)]
1515
#![allow(clippy::mixed_read_write_in_expression)]
16-
#![allow(clippy::manual_find_map)]
1716
#![allow(clippy::manual_filter_map)]
18-
#![allow(unpredictable_function_pointer_comparisons)]
17+
#![allow(clippy::manual_find_map)]
1918
#![allow(clippy::useless_conversion)]
2019
#![allow(clippy::redundant_pattern_matching)]
2120
#![allow(clippy::match_result_ok)]
@@ -30,6 +29,7 @@
3029
#![allow(clippy::unwrap_used)]
3130
#![allow(clippy::panicking_overflow_checks)]
3231
#![allow(clippy::needless_borrow)]
32+
#![allow(clippy::reversed_empty_ranges)]
3333
#![allow(clippy::single_char_add_str)]
3434
#![allow(clippy::module_name_repetitions)]
3535
#![allow(clippy::missing_const_for_thread_local)]
@@ -39,9 +39,11 @@
3939
#![allow(invalid_reference_casting)]
4040
#![allow(suspicious_double_ref_op)]
4141
#![allow(invalid_nan_comparisons)]
42+
#![allow(double_negations)]
4243
#![allow(drop_bounds)]
4344
#![allow(dropping_copy_types)]
4445
#![allow(dropping_references)]
46+
#![allow(unpredictable_function_pointer_comparisons)]
4547
#![allow(useless_ptr_null_checks)]
4648
#![allow(for_loops_over_fallibles)]
4749
#![allow(forgetting_copy_types)]
@@ -60,8 +62,6 @@
6062
#![allow(unknown_lints)]
6163
#![allow(unused_labels)]
6264
#![allow(ambiguous_wide_pointer_comparisons)]
63-
#![allow(unpredictable_function_pointer_comparisons)]
64-
#![allow(clippy::reversed_empty_ranges)]
6565
#![warn(clippy::almost_complete_letter_range)] //~ ERROR: lint `clippy::almost_complete_letter_range`
6666
#![warn(clippy::blacklisted_name)] //~ ERROR: lint `clippy::blacklisted_name`
6767
#![warn(clippy::block_in_if_condition_expr)] //~ ERROR: lint `clippy::block_in_if_condition_expr`
@@ -74,9 +74,8 @@
7474
#![warn(clippy::disallowed_method)] //~ ERROR: lint `clippy::disallowed_method`
7575
#![warn(clippy::disallowed_type)] //~ ERROR: lint `clippy::disallowed_type`
7676
#![warn(clippy::eval_order_dependence)] //~ ERROR: lint `clippy::eval_order_dependence`
77-
#![warn(clippy::find_map)] //~ ERROR: lint `clippy::find_map`
7877
#![warn(clippy::filter_map)] //~ ERROR: lint `clippy::filter_map`
79-
#![warn(clippy::fn_address_comparisons)] //~ ERROR: lint `clippy::fn_address_comparisons`
78+
#![warn(clippy::find_map)] //~ ERROR: lint `clippy::find_map`
8079
#![warn(clippy::identity_conversion)] //~ ERROR: lint `clippy::identity_conversion`
8180
#![warn(clippy::if_let_redundant_pattern_matching)] //~ ERROR: lint `clippy::if_let_redundant_pattern_matching`
8281
#![warn(clippy::if_let_some_result)] //~ ERROR: lint `clippy::if_let_some_result`
@@ -95,6 +94,7 @@
9594
#![warn(clippy::result_expect_used)] //~ ERROR: lint `clippy::result_expect_used`
9695
#![warn(clippy::result_map_unwrap_or_else)] //~ ERROR: lint `clippy::result_map_unwrap_or_else`
9796
#![warn(clippy::result_unwrap_used)] //~ ERROR: lint `clippy::result_unwrap_used`
97+
#![warn(clippy::reverse_range_loop)] //~ ERROR: lint `clippy::reverse_range_loop`
9898
#![warn(clippy::single_char_push_str)] //~ ERROR: lint `clippy::single_char_push_str`
9999
#![warn(clippy::stutter)] //~ ERROR: lint `clippy::stutter`
100100
#![warn(clippy::thread_local_initializer_can_be_made_const)] //~ ERROR: lint `clippy::thread_local_initializer_can_be_made_const`
@@ -104,9 +104,11 @@
104104
#![warn(clippy::cast_ref_to_mut)] //~ ERROR: lint `clippy::cast_ref_to_mut`
105105
#![warn(clippy::clone_double_ref)] //~ ERROR: lint `clippy::clone_double_ref`
106106
#![warn(clippy::cmp_nan)] //~ ERROR: lint `clippy::cmp_nan`
107+
#![warn(clippy::double_neg)] //~ ERROR: lint `clippy::double_neg`
107108
#![warn(clippy::drop_bounds)] //~ ERROR: lint `clippy::drop_bounds`
108109
#![warn(clippy::drop_copy)] //~ ERROR: lint `clippy::drop_copy`
109110
#![warn(clippy::drop_ref)] //~ ERROR: lint `clippy::drop_ref`
111+
#![warn(clippy::fn_address_comparisons)] //~ ERROR: lint `clippy::fn_address_comparisons`
110112
#![warn(clippy::fn_null_check)] //~ ERROR: lint `clippy::fn_null_check`
111113
#![warn(clippy::for_loop_over_option)] //~ ERROR: lint `clippy::for_loop_over_option`
112114
#![warn(clippy::for_loop_over_result)] //~ ERROR: lint `clippy::for_loop_over_result`
@@ -128,6 +130,5 @@
128130
#![warn(clippy::unknown_clippy_lints)] //~ ERROR: lint `clippy::unknown_clippy_lints`
129131
#![warn(clippy::unused_label)] //~ ERROR: lint `clippy::unused_label`
130132
#![warn(clippy::vtable_address_comparisons)] //~ ERROR: lint `clippy::vtable_address_comparisons`
131-
#![warn(clippy::reverse_range_loop)] //~ ERROR: lint `clippy::reverse_range_loop`
132133

133134
fn main() {}

0 commit comments

Comments
 (0)