Skip to content

Commit 0c33372

Browse files
committed
remove clippy::double_neg
1 parent db80bdd commit 0c33372

File tree

12 files changed

+108
-165
lines changed

12 files changed

+108
-165
lines changed

src/tools/clippy/.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)

src/tools/clippy/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

src/tools/clippy/clippy_dev/src/new_lint.rs

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

472472
// Find both the last lint declaration (declare_clippy_lint!) and the lint pass impl
473-
while let Some(LintDeclSearchResult { content, .. }) = iter.find(|result| result.token == TokenKind::Ident) {
473+
while let Some(LintDeclSearchResult { content, .. }) = iter.find(|result| result.token_kind == TokenKind::Ident) {
474474
let mut iter = iter
475475
.by_ref()
476476
.filter(|t| !matches!(t.token_kind, TokenKind::Whitespace | TokenKind::LineComment { .. }));
@@ -480,7 +480,7 @@ fn setup_mod_file(path: &Path, lint: &LintData<'_>) -> io::Result<&'static str>
480480
// matches `!{`
481481
match_tokens!(iter, Bang OpenBrace);
482482
if let Some(LintDeclSearchResult { range, .. }) =
483-
iter.find(|result| result.token == TokenKind::CloseBrace)
483+
iter.find(|result| result.token_kind == TokenKind::CloseBrace)
484484
{
485485
last_decl_curly_offset = Some(range.end);
486486
}

src/tools/clippy/clippy_lints/src/declared_lints.rs

-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,6 @@ pub static LINTS: &[&crate::LintInfo] = &[
494494
crate::misc::USED_UNDERSCORE_BINDING_INFO,
495495
crate::misc::USED_UNDERSCORE_ITEMS_INFO,
496496
crate::misc_early::BUILTIN_TYPE_SHADOW_INFO,
497-
crate::misc_early::DOUBLE_NEG_INFO,
498497
crate::misc_early::DUPLICATE_UNDERSCORE_ARGUMENT_INFO,
499498
crate::misc_early::MIXED_CASE_HEX_LITERALS_INFO,
500499
crate::misc_early::REDUNDANT_AT_REST_PATTERN_INFO,

src/tools/clippy/clippy_lints/src/deprecated_lints.rs

+2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ declare_with_version! { RENAMED(RENAMED_VERSION): &[(&str, &str)] = &[
127127
("clippy::clone_double_ref", "suspicious_double_ref_op"),
128128
#[clippy::version = ""]
129129
("clippy::cmp_nan", "invalid_nan_comparisons"),
130+
#[clippy::version = "1.84.0"]
131+
("clippy::double_neg", "double_negations"),
130132
#[clippy::version = ""]
131133
("clippy::drop_bounds", "drop_bounds"),
132134
#[clippy::version = ""]

src/tools/clippy/clippy_lints/src/misc_early/double_neg.rs

-18
This file was deleted.

src/tools/clippy/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

src/tools/clippy/tests/ui/double_neg.rs

-10
This file was deleted.

src/tools/clippy/tests/ui/double_neg.stderr

-11
This file was deleted.

src/tools/clippy/tests/ui/rename.fixed

+6-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +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)]
17+
#![allow(clippy::manual_find_map)]
1818
#![allow(clippy::useless_conversion)]
1919
#![allow(clippy::redundant_pattern_matching)]
2020
#![allow(clippy::match_result_ok)]
@@ -29,6 +29,7 @@
2929
#![allow(clippy::unwrap_used)]
3030
#![allow(clippy::panicking_overflow_checks)]
3131
#![allow(clippy::needless_borrow)]
32+
#![allow(clippy::reversed_empty_ranges)]
3233
#![allow(clippy::single_char_add_str)]
3334
#![allow(clippy::module_name_repetitions)]
3435
#![allow(clippy::missing_const_for_thread_local)]
@@ -38,6 +39,7 @@
3839
#![allow(invalid_reference_casting)]
3940
#![allow(suspicious_double_ref_op)]
4041
#![allow(invalid_nan_comparisons)]
42+
#![allow(double_negations)]
4143
#![allow(drop_bounds)]
4244
#![allow(dropping_copy_types)]
4345
#![allow(dropping_references)]
@@ -59,7 +61,6 @@
5961
#![allow(unknown_lints)]
6062
#![allow(unused_labels)]
6163
#![allow(ambiguous_wide_pointer_comparisons)]
62-
#![allow(clippy::reversed_empty_ranges)]
6364
#![warn(clippy::almost_complete_range)] //~ ERROR: lint `clippy::almost_complete_letter_range`
6465
#![warn(clippy::disallowed_names)] //~ ERROR: lint `clippy::blacklisted_name`
6566
#![warn(clippy::blocks_in_conditions)] //~ ERROR: lint `clippy::block_in_if_condition_expr`
@@ -72,8 +73,8 @@
7273
#![warn(clippy::disallowed_methods)] //~ ERROR: lint `clippy::disallowed_method`
7374
#![warn(clippy::disallowed_types)] //~ ERROR: lint `clippy::disallowed_type`
7475
#![warn(clippy::mixed_read_write_in_expression)] //~ ERROR: lint `clippy::eval_order_dependence`
75-
#![warn(clippy::manual_find_map)] //~ ERROR: lint `clippy::find_map`
7676
#![warn(clippy::manual_filter_map)] //~ ERROR: lint `clippy::filter_map`
77+
#![warn(clippy::manual_find_map)] //~ ERROR: lint `clippy::find_map`
7778
#![warn(clippy::useless_conversion)] //~ ERROR: lint `clippy::identity_conversion`
7879
#![warn(clippy::redundant_pattern_matching)] //~ ERROR: lint `clippy::if_let_redundant_pattern_matching`
7980
#![warn(clippy::match_result_ok)] //~ ERROR: lint `clippy::if_let_some_result`
@@ -92,6 +93,7 @@
9293
#![warn(clippy::expect_used)] //~ ERROR: lint `clippy::result_expect_used`
9394
#![warn(clippy::map_unwrap_or)] //~ ERROR: lint `clippy::result_map_unwrap_or_else`
9495
#![warn(clippy::unwrap_used)] //~ ERROR: lint `clippy::result_unwrap_used`
96+
#![warn(clippy::reversed_empty_ranges)] //~ ERROR: lint `clippy::reverse_range_loop`
9597
#![warn(clippy::single_char_add_str)] //~ ERROR: lint `clippy::single_char_push_str`
9698
#![warn(clippy::module_name_repetitions)] //~ ERROR: lint `clippy::stutter`
9799
#![warn(clippy::missing_const_for_thread_local)] //~ ERROR: lint `clippy::thread_local_initializer_can_be_made_const`
@@ -101,6 +103,7 @@
101103
#![warn(invalid_reference_casting)] //~ ERROR: lint `clippy::cast_ref_to_mut`
102104
#![warn(suspicious_double_ref_op)] //~ ERROR: lint `clippy::clone_double_ref`
103105
#![warn(invalid_nan_comparisons)] //~ ERROR: lint `clippy::cmp_nan`
106+
#![warn(double_negations)] //~ ERROR: lint `clippy::double_neg`
104107
#![warn(drop_bounds)] //~ ERROR: lint `clippy::drop_bounds`
105108
#![warn(dropping_copy_types)] //~ ERROR: lint `clippy::drop_copy`
106109
#![warn(dropping_references)] //~ ERROR: lint `clippy::drop_ref`
@@ -125,6 +128,5 @@
125128
#![warn(unknown_lints)] //~ ERROR: lint `clippy::unknown_clippy_lints`
126129
#![warn(unused_labels)] //~ ERROR: lint `clippy::unused_label`
127130
#![warn(ambiguous_wide_pointer_comparisons)] //~ ERROR: lint `clippy::vtable_address_comparisons`
128-
#![warn(clippy::reversed_empty_ranges)] //~ ERROR: lint `clippy::reverse_range_loop`
129131

130132
fn main() {}

src/tools/clippy/tests/ui/rename.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -13,8 +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)]
17+
#![allow(clippy::manual_find_map)]
1818
#![allow(clippy::useless_conversion)]
1919
#![allow(clippy::redundant_pattern_matching)]
2020
#![allow(clippy::match_result_ok)]
@@ -29,6 +29,7 @@
2929
#![allow(clippy::unwrap_used)]
3030
#![allow(clippy::panicking_overflow_checks)]
3131
#![allow(clippy::needless_borrow)]
32+
#![allow(clippy::reversed_empty_ranges)]
3233
#![allow(clippy::single_char_add_str)]
3334
#![allow(clippy::module_name_repetitions)]
3435
#![allow(clippy::missing_const_for_thread_local)]
@@ -38,6 +39,7 @@
3839
#![allow(invalid_reference_casting)]
3940
#![allow(suspicious_double_ref_op)]
4041
#![allow(invalid_nan_comparisons)]
42+
#![allow(double_negations)]
4143
#![allow(drop_bounds)]
4244
#![allow(dropping_copy_types)]
4345
#![allow(dropping_references)]
@@ -54,12 +56,11 @@
5456
#![allow(enum_intrinsics_non_enums)]
5557
#![allow(non_fmt_panics)]
5658
#![allow(named_arguments_used_positionally)]
57-
#![allow(temporary_cstring_as_ptr)]
59+
#![allow(dangling_pointers_from_temporaries)]
5860
#![allow(undropped_manually_drops)]
5961
#![allow(unknown_lints)]
6062
#![allow(unused_labels)]
6163
#![allow(ambiguous_wide_pointer_comparisons)]
62-
#![allow(clippy::reversed_empty_ranges)]
6364
#![warn(clippy::almost_complete_letter_range)] //~ ERROR: lint `clippy::almost_complete_letter_range`
6465
#![warn(clippy::blacklisted_name)] //~ ERROR: lint `clippy::blacklisted_name`
6566
#![warn(clippy::block_in_if_condition_expr)] //~ ERROR: lint `clippy::block_in_if_condition_expr`
@@ -72,8 +73,8 @@
7273
#![warn(clippy::disallowed_method)] //~ ERROR: lint `clippy::disallowed_method`
7374
#![warn(clippy::disallowed_type)] //~ ERROR: lint `clippy::disallowed_type`
7475
#![warn(clippy::eval_order_dependence)] //~ ERROR: lint `clippy::eval_order_dependence`
75-
#![warn(clippy::find_map)] //~ ERROR: lint `clippy::find_map`
7676
#![warn(clippy::filter_map)] //~ ERROR: lint `clippy::filter_map`
77+
#![warn(clippy::find_map)] //~ ERROR: lint `clippy::find_map`
7778
#![warn(clippy::identity_conversion)] //~ ERROR: lint `clippy::identity_conversion`
7879
#![warn(clippy::if_let_redundant_pattern_matching)] //~ ERROR: lint `clippy::if_let_redundant_pattern_matching`
7980
#![warn(clippy::if_let_some_result)] //~ ERROR: lint `clippy::if_let_some_result`
@@ -92,6 +93,7 @@
9293
#![warn(clippy::result_expect_used)] //~ ERROR: lint `clippy::result_expect_used`
9394
#![warn(clippy::result_map_unwrap_or_else)] //~ ERROR: lint `clippy::result_map_unwrap_or_else`
9495
#![warn(clippy::result_unwrap_used)] //~ ERROR: lint `clippy::result_unwrap_used`
96+
#![warn(clippy::reverse_range_loop)] //~ ERROR: lint `clippy::reverse_range_loop`
9597
#![warn(clippy::single_char_push_str)] //~ ERROR: lint `clippy::single_char_push_str`
9698
#![warn(clippy::stutter)] //~ ERROR: lint `clippy::stutter`
9799
#![warn(clippy::thread_local_initializer_can_be_made_const)] //~ ERROR: lint `clippy::thread_local_initializer_can_be_made_const`
@@ -101,6 +103,7 @@
101103
#![warn(clippy::cast_ref_to_mut)] //~ ERROR: lint `clippy::cast_ref_to_mut`
102104
#![warn(clippy::clone_double_ref)] //~ ERROR: lint `clippy::clone_double_ref`
103105
#![warn(clippy::cmp_nan)] //~ ERROR: lint `clippy::cmp_nan`
106+
#![warn(clippy::double_neg)] //~ ERROR: lint `clippy::double_neg`
104107
#![warn(clippy::drop_bounds)] //~ ERROR: lint `clippy::drop_bounds`
105108
#![warn(clippy::drop_copy)] //~ ERROR: lint `clippy::drop_copy`
106109
#![warn(clippy::drop_ref)] //~ ERROR: lint `clippy::drop_ref`
@@ -125,6 +128,5 @@
125128
#![warn(clippy::unknown_clippy_lints)] //~ ERROR: lint `clippy::unknown_clippy_lints`
126129
#![warn(clippy::unused_label)] //~ ERROR: lint `clippy::unused_label`
127130
#![warn(clippy::vtable_address_comparisons)] //~ ERROR: lint `clippy::vtable_address_comparisons`
128-
#![warn(clippy::reverse_range_loop)] //~ ERROR: lint `clippy::reverse_range_loop`
129131

130132
fn main() {}

0 commit comments

Comments
 (0)