bors
f8ba19287d
Auto merge of #9576 - TennyZhuang:unnecessary_cast_for_non_literal_expr, r=llogiq
...
let unnecessary_cast work for trivial non_literal expressions
Signed-off-by: TennyZhuang <zty0826@gmail.com>
---
changelog: [`unnecessary_cast`]: fix for trivial non_literal expressions
Fixes #9562
2022-10-02 15:26:45 +00:00
bors
11a6d19c59
Auto merge of #9479 - kraktus:manual_assert2, r=llogiq
...
[`manual_assert`]: Preserve comments in the suggestion
close https://github.com/rust-lang/rust-clippy/issues/7730
changelog: [`manual_assert`]: Preserve comments in the suggestion
2022-10-02 15:13:32 +00:00
TennyZhuang
c9b93143d5
fix some logics
...
Signed-off-by: TennyZhuang <zty0826@gmail.com>
2022-10-02 23:02:13 +08:00
TennyZhuang
bff811bfdf
extract common codes
...
Signed-off-by: TennyZhuang <zty0826@gmail.com>
2022-10-02 23:02:13 +08:00
TennyZhuang
f2043989ca
ignore the lint on some test files
...
Signed-off-by: TennyZhuang <zty0826@gmail.com>
2022-10-02 23:02:13 +08:00
TennyZhuang
081f73954b
let unnecessary_cast work for trivial non_literal expressions
...
Signed-off-by: TennyZhuang <zty0826@gmail.com>
2022-10-02 23:02:11 +08:00
bors
ac12011315
Auto merge of #9577 - kraktus:unnecessary_cast, r=llogiq
...
[`unnecessary_cast`] add parenthesis when negative number uses a method
fix #9563
The issue was probably introduced by 90fe3bea52
changelog: [`unnecessary_cast`] add parenthesis when negative number uses a method
r? llogiq
2022-10-02 14:18:41 +00:00
kraktus
3ab02aa359
fix tests
2022-10-02 15:25:50 +02:00
bors
d6d5ecd625
Auto merge of #9571 - rust-lang:refactor-lit-ints, r=Jarcho
...
use `is_integer_literal` more
I noticed that we have the `is_integer_literal` function in our `clippy_utils`, yet almost everywhere people still match int literal expressions manually. So I searched for instances to replace and shorten the code a bit.
---
changelog: none
2022-10-02 13:11:21 +00:00
kraktus
22be60b4f0
fix indentation
2022-10-02 15:03:48 +02:00
kraktus
a35734c172
revert manual_assert
suggestion refactor
...
Because `Sugg` helper does not simplify multiple negations
2022-10-02 15:03:48 +02:00
kraktus
2c04c1a188
[manual_assert
]: Preserve comments in the suggestion
2022-10-02 15:03:48 +02:00
kraktus
90b446fd38
[unnecessary_cast
] add parenthesis when negative number uses a method
2022-10-02 14:35:38 +02:00
bors
5d837b58f7
Auto merge of #9573 - Alexendoo:needless-borrowed-ref-slice, r=dswij
...
lint nested patterns and slice patterns in `needless_borrowed_reference`
Now lints in positions other than top level, e.g. `Some(&ref a)`. Or patterns are excluded as that can cause issues
Slice patterns of `ref`s are now linted, e.g. `&[ref a, ref b]`. An easy one to walk into as you might expect that to match against a slice you should use `&[]`, then to get around a `cannot move out of type [T]` error you apply a `ref`
changelog: [`needless_borrowed_reference`]: lint nested patterns and slice patterns
2022-10-02 10:39:04 +00:00
bors
cb8da67194
Auto merge of #9509 - schubart:fix_sorting, r=llogiq
...
Fix sorting in ` cargo dev update_lints` script
changelog: none
The old code cloned and sorted `usable_lints` into `sorted_usable_lints`, but then failed to do anything with `sorted_usable_lints`.
This was discovered by my new `collection_is_never_read` lint (#9267 ) that I'm working on!
Fix: I renamed the sorted vector to `usable_lints`. Therefore it now gets used where the unsorted one was used previously.
2022-10-02 07:51:45 +00:00
Alex Macleod
52a68dc097
lint nested patterns and slice patterns in needless_borrowed_reference
2022-10-01 22:31:10 +00:00
bors
64243c6f99
Auto merge of #9484 - Xaeroxe:clamping-without-clamp, r=Alexendoo
...
Implement `manual_clamp` lint
Fixes #9477
Fixes #6751
Identifies common patterns where usage of the `clamp` function would be more succinct and clear, and suggests using the `clamp` function instead.
changelog: [`manual_clamp`]: Implement manual_clamp lint
2022-10-01 20:55:20 +00:00
Jacob Kiesel
b221184572
Implement manual_clamp lint
2022-10-01 13:58:41 -06:00
bors
9b6b452cff
Auto merge of #9569 - matthiaskrgr:rtu_from_cratesio, r=xFrednet
...
use rustc_tools_util dependency from crates.io instead of this repo.
Fixes #9553
changelog: none
2022-10-01 16:22:58 +00:00
Andre Bogus
eef5d477b5
use is_integer_literal
more
2022-10-01 17:55:22 +02:00
Matthias Krüger
ce609c661b
use rustc_tools_util dependency from crates.io instead of this repo.
...
Fixes #9553
2022-10-01 16:40:10 +02:00
bors
8da24295c6
Auto merge of #9567 - rust-lang:doc-link-with-code, r=Alexendoo
...
avoid doc-link-with-quotes in code blocks
This fixes #8961 by moving the lint into the docs code, thus being able to re-use the pulldown-cmark parser and simplifying the code.
---
changelog: none
2022-10-01 14:33:13 +00:00
bors
8030ee9ae7
Auto merge of #9568 - matthiaskrgr:tools_util_bump, r=flip1995
...
rustc_tool_utils: bump version in anticipation of a new release
cc https://github.com/rust-lang/rust-clippy/issues/9553
After this is merged, I will publish the 0.2.1 version to crates.io, and make another PR that switches clippy to use the dependency from crates.io.
The source can still be kept in the clippy repo though imo.
This will allow miri and clippy to "share" the crate in the rustc repo once they both depend on it.
reopen of #9561
changelog: release `rustc_tools_util` on `Crates.io`.
2022-10-01 14:20:32 +00:00
Matthias Krüger
418b30b499
rustc_tool_utils bump version in anticipation of a new release
...
cc https://github.com/rust-lang/rust-clippy/issues/9553
2022-10-01 16:13:48 +02:00
Andre Bogus
3757a0e903
avoid doc-link-with-quotes in code blocks
2022-10-01 15:25:37 +02:00
bors
31b17411a6
Auto merge of #9510 - Alexendoo:lintcheck-server2, r=matthiaskrgr
...
Add `cargo lintcheck --recursive` to check dependencies of crates
r? `@matthiaskrgr`
This just adds the mode without changing how a regular run works
Takes a fair bit longer to run than a `-j4` or regular run
```
cargo lintcheck -j4 468.33s user 43.78s system 290% cpu 2:56.42 total
cargo lintcheck 428.81s user 41.85s system 199% cpu 3:55.37 total
cargo lintcheck --recursive 679.83s user 45.01s system 210% cpu 5:43.72 total
```
But finds more results:
<details>
<summary>Stats</summary>
<pre><code>clippy::explicit_counter_loop 0 => 1
clippy::needless_question_mark 0 => 3
clippy::unnecessary_cast 0 => 2
clippy::to_string_in_format_args 0 => 4
clippy::deprecated_cfg_attr 0 => 23
clippy::redundant_closure 0 => 9
clippy::drop_copy 0 => 4
clippy::double_must_use 0 => 1
clippy::transmute_num_to_bytes 0 => 9
clippy::bind_instead_of_map 0 => 14
clippy::float_cmp 0 => 16
clippy::is_digit_ascii_radix 0 => 16
clippy::manual_swap 0 => 1
clippy::needless_match 0 => 2
clippy::vec_init_then_push 0 => 1
clippy::never_loop 0 => 1
clippy::option_map_or_none 0 => 4
clippy::tabs_in_doc_comments 0 => 1
clippy::naive_bytecount 0 => 1
clippy::collapsible_if 0 => 24
clippy::copy_iterator 0 => 5
clippy::unused_io_amount 0 => 2
clippy::result_large_err 0 => 141
clippy::useless_conversion 0 => 24
clippy::flat_map_option 0 => 8
clippy::useless_format 0 => 2
clippy::module_inception 0 => 1
clippy::drop_ref 0 => 2
clippy::unnecessary_fold 0 => 2
clippy::neg_multiply 0 => 1
clippy::while_let_loop 0 => 6
clippy::missing_inline_in_public_items 0 => 37
clippy::unnecessary_mut_passed 0 => 1
unknown_lints 0 => 15
clippy::wildcard_dependencies 0 => 3
clippy::same_item_push 0 => 2
clippy::useless_asref 0 => 1
clippy::unnecessary_unwrap 0 => 4
clippy::iter_not_returning_iterator 0 => 5
clippy::comparison_to_empty 0 => 10
clippy::ref_option_ref 0 => 4
clippy::unused_peekable 0 => 1
clippy::needless_range_loop 0 => 8
clippy::absurd_extreme_comparisons 0 => 2
clippy::unnecessary_operation 0 => 2
clippy::for_kv_map 0 => 5
clippy::unnecessary_owned_empty_strings 0 => 3
clippy::transmutes_expressible_as_ptr_casts 0 => 1
clippy::toplevel_ref_arg 0 => 2
clippy::uninit_vec 0 => 3
clippy::filter_next 0 => 1
clippy::wildcard_in_or_patterns 0 => 6
clippy::cast_ptr_alignment 0 => 48
clippy::manual_memcpy 0 => 1
clippy::assign_op_pattern 0 => 313
clippy::unnecessary_lazy_evaluations 0 => 14
clippy::println_empty_string 0 => 2
clippy::redundant_pattern 0 => 2
clippy::declare_interior_mutable_const 0 => 8
clippy::large_stack_arrays 0 => 4
clippy::match_bool 0 => 4
clippy::unicode_not_nfc 0 => 2075
clippy::inconsistent_digit_grouping 0 => 4
clippy::no_effect_underscore_binding 0 => 2
clippy::let_and_return 0 => 5
clippy::transmute_ptr_to_ref 0 => 12
clippy::op_ref 0 => 13
clippy::unnecessary_join 0 => 4
clippy::into_iter_on_ref 0 => 13
clippy::from_str_radix_10 0 => 7
clippy::ptr_offset_with_cast 0 => 48
clippy::erasing_op 0 => 1
clippy::swap_ptr_to_ref 0 => 3
clippy::needless_bitwise_bool 0 => 2
clippy::extend_with_drain 0 => 19
clippy::only_used_in_recursion 0 => 4
clippy::needless_late_init 0 => 8
clippy::excessive_precision 0 => 1959
clippy::match_ref_pats 0 => 10
clippy::unit_arg 0 => 20
clippy::bool_comparison 0 => 4
clippy::bool_assert_comparison 0 => 1
clippy::eq_op 0 => 6
clippy::cast_abs_to_unsigned 0 => 6
clippy::format_in_format_args 0 => 1
clippy::iter_cloned_collect 0 => 4
clippy::ptr_eq 0 => 3
clippy::needless_bool 0 => 5
clippy::transmute_ptr_to_ptr 0 => 16
clippy::needless_option_take 0 => 2
clippy::flat_map_identity 0 => 1
clippy::needless_splitn 0 => 2
clippy::blocks_in_if_conditions 0 => 1
clippy::write_literal 0 => 1
clippy::manual_split_once 0 => 1
clippy::result_unit_err 0 => 36
clippy::unused_unit 0 => 11
clippy::single_match 0 => 22
clippy::manual_find 0 => 3
clippy::derive_ord_xor_partial_ord 0 => 6
clippy::char_lit_as_u8 0 => 2
clippy::let_unit_value 0 => 2
clippy::needless_continue 0 => 19
clippy::zero_sized_map_values 0 => 4
clippy::needless_arbitrary_self_type 0 => 6
clippy::partialeq_to_none 0 => 11
clippy::partialeq_ne_impl 0 => 1
clippy::invalid_upcast_comparisons 0 => 1
clippy::mut_range_bound 0 => 4
clippy::match_result_ok 0 => 2
clippy::ptr_arg 0 => 8
clippy::iter_nth_zero 0 => 18
clippy::needless_for_each 0 => 1
clippy::manual_unwrap_or 0 => 1
clippy::transmute_int_to_float 0 => 6
clippy::cast_slice_from_raw_parts 0 => 1
clippy::match_wild_err_arm 0 => 2
clippy::match_like_matches_macro 4 => 116
clippy::enum_glob_use 50 => 380
clippy::get_first 3 => 33
clippy::needless_doctest_main 10 => 26
clippy::struct_excessive_bools 19 => 51
clippy::cast_possible_wrap 46 => 538
clippy::manual_string_new 10 => 27
clippy::match_same_arms 53 => 1039
clippy::manual_non_exhaustive 1 => 33
clippy::redundant_pattern_matching 2 => 13
clippy::new_without_default 5 => 73
clippy::option_as_ref_deref 2 => 9
clippy::unwrap_or_else_default 2 => 4
clippy::case_sensitive_file_extension_comparisons 6 => 9
clippy::cast_precision_loss 45 => 110
clippy::needless_pass_by_value 26 => 187
clippy::redundant_closure_for_method_calls 170 => 539
clippy::let_underscore_drop 33 => 133
clippy::single_match_else 51 => 138
clippy::needless_borrow 24 => 382
clippy::redundant_else 37 => 151
clippy::type_complexity 2 => 22
clippy::ptr_as_ptr 93 => 1135
clippy::needless_lifetimes 7 => 100
clippy::single_char_add_str 2 => 22
clippy::similar_names 99 => 352
clippy::cargo_common_metadata 25 => 276
clippy::int_plus_one 1 => 2
clippy::missing_safety_doc 9 => 152
clippy::redundant_slicing 2 => 13
clippy::mut_mut 2 => 17
clippy::derive_partial_eq_without_eq 8 => 141
clippy::derive_hash_xor_eq 2 => 20
clippy::from_iter_instead_of_collect 2 => 17
clippy::verbose_bit_mask 1 => 8
clippy::too_many_lines 58 => 162
clippy::module_name_repetitions 178 => 1104
clippy::explicit_into_iter_loop 12 => 32
clippy::cast_lossless 45 => 478
clippy::many_single_char_names 9 => 23
clippy::unnested_or_patterns 27 => 127
clippy::upper_case_acronyms 5 => 29
clippy::needless_return 5 => 97
clippy::precedence 1 => 11
clippy::len_zero 2 => 70
clippy::manual_strip 2 => 30
clippy::derivable_impls 2 => 12
clippy::unused_self 20 => 187
clippy::enum_variant_names 1 => 6
clippy::self_named_constructors 1 => 3
clippy::explicit_auto_deref 19 => 314
clippy::semicolon_if_nothing_returned 137 => 1861
clippy::should_implement_trait 1 => 7
clippy::expl_impl_clone_on_copy 159 => 1318
clippy::stable_sort_primitive 4 => 12
clippy::mem_replace_with_default 7 => 46
clippy::borrow_deref_ref 5 => 140
clippy::large_enum_variant 1 => 4
clippy::map_unwrap_or 30 => 203
clippy::zero_ptr 3 => 25
clippy::filter_map_next 2 => 6
clippy::identity_op 5 => 76
clippy::checked_conversions 1 => 8
clippy::len_without_is_empty 9 => 47
clippy::missing_errors_doc 372 => 2333
clippy::fn_params_excessive_bools 3 => 7
clippy::single_component_path_imports 6 => 28
clippy::unreadable_literal 366 => 9814
clippy::field_reassign_with_default 1 => 5
clippy::redundant_clone 1 => 8
clippy::cloned_instead_of_copied 36 => 78
clippy::too_many_arguments 4 => 22
clippy::option_map_unit_fn 7 => 9
clippy::extra_unused_lifetimes 1 => 24
clippy::unnecessary_wraps 26 => 128
clippy::used_underscore_binding 1 => 50
clippy::inconsistent_struct_constructor 2 => 7
clippy::manual_range_contains 9 => 120
clippy::map_clone 7 => 46
clippy::cast_slice_different_sizes 1 => 4
clippy::missing_panics_doc 114 => 603
renamed_and_removed_lints 3 => 9
clippy::items_after_statements 155 => 309
clippy::inefficient_to_string 5 => 6
clippy::comparison_chain 1 => 19
clippy::crate_in_macro_def 3 => 6
clippy::write_with_newline 2 => 36
clippy::manual_saturating_arithmetic 1 => 2
clippy::clone_on_copy 1 => 86
clippy::negative_feature_names 3 => 16
clippy::redundant_field_names 112 => 1013
clippy::from_over_into 2 => 28
clippy::wildcard_imports 178 => 376
clippy::unusual_byte_groupings 19 => 65
clippy::option_option 2 => 10
clippy::nonminimal_bool 1 => 17
clippy::borrow_as_ptr 2 => 172
clippy::redundant_static_lifetimes 24 => 1701
clippy::or_fun_call 1 => 63
clippy::single_char_pattern 3 => 79
clippy::explicit_iter_loop 72 => 148
clippy::collapsible_else_if 2 => 27
clippy::manual_str_repeat 1 => 6
clippy::if_same_then_else 3 => 31
clippy::while_let_on_iterator 4 => 28
clippy::multiple_crate_versions 5 => 19
clippy::cast_possible_truncation 115 => 1172
clippy::explicit_deref_methods 1 => 38
clippy::default_trait_access 48 => 130
clippy::question_mark 2 => 28
clippy::must_use_candidate 612 => 5369
clippy::manual_map 1 => 12
clippy::bool_to_int_with_if 2 => 15
clippy::doc_markdown 202 => 1709
clippy::cast_sign_loss 60 => 477
clippy::wrong_self_convention 11 => 45
clippy::transmute_float_to_int 6 => 18
clippy::return_self_not_must_use 66 => 736
clippy::range_plus_one 1 => 36
clippy::manual_assert 11 => 62
clippy::trivially_copy_pass_by_ref 40 => 189
clippy::match_on_vec_items 2 => 7
clippy::inline_always 59 => 1079
clippy::if_not_else 31 => 205
clippy::implicit_clone 10 => 32
clippy::match_wildcard_for_single_variants 16 => 101
clippy::doc_link_with_quotes 7 => 35
clippy::redundant_feature_names 4 => 41
</code></pre></details>
changelog: none
2022-09-30 22:29:40 +00:00
bors
a78551bb14
Auto merge of #9556 - evantypanski:et/issue-9369, r=Alexendoo
...
[`redundant_closure`] Fix suggestion causes error for `impl FnMut`
Fixes #9369
changelog: [`redundant_closure`] Fix suggestion causes error with `impl FnMut` types
2022-09-30 16:42:55 +00:00
Evan Typanski
dbadf37336
Add test case where FnMut
used once needs &mut
2022-09-30 11:38:12 -04:00
Evan Typanski
85b8ff7f38
Fix style in if let
chain
...
Co-authored-by: Alex Macleod <alex@macleod.io>
2022-09-30 11:36:55 -04:00
bors
5f25f7e605
Auto merge of #9557 - xxchan:xxchan/safe-anaconda, r=Manishearth
...
doc: make the usage of clippy.toml more clear
Added a subsection for it, and move it after `Allowing/denying lints` which is more frequently used.
fix https://github.com/rust-lang/rust-clippy/issues/9265
*Please write a short comment explaining your change (or "none" for internal only changes)*
changelog: none
2022-09-30 15:23:09 +00:00
xxchan
47a7d68c07
doc: make the usage of clippy.toml more clear
2022-09-30 13:43:16 +02:00
bors
68408c583e
Auto merge of #9486 - kraktus:lazy_eval, r=dswij
...
[`unnecessary_lazy_eval`] Do not lint in external macros
fix https://github.com/rust-lang/rust-clippy/issues/9485 , fix https://github.com/rust-lang/rust-clippy/issues/9439
I didn't find a way to add a test since fps occur due to an external crate.
changelog: [`unnecessary_lazy_eval`] Do not lint in external macros
2022-09-30 07:47:55 +00:00
Evan Typanski
416da1264c
[redundant_closure
] Add &mut
to more cases
2022-09-29 19:35:04 -04:00
kraktus
6ec7759c3b
[unnecessary_lazy_eval
] Do not lint in external macros
2022-09-29 13:48:50 +02:00
bors
e43f5a17d4
Auto merge of #9516 - flip1995:rustup, r=flip1995
...
Rustup
r? `@ghost`
changelog: none
2022-09-29 10:04:13 +00:00
Philipp Krones
924c1ce97d
Update lints after sync
2022-09-29 12:02:58 +02:00
Philipp Krones
67af127f24
Fix dogfood
2022-09-29 12:02:58 +02:00
Philipp Krones
579791178d
Bump nightly version -> 2022-09-29
2022-09-29 12:02:54 +02:00
bors
5e8a4b6699
Auto merge of #9551 - kraktus:unnecessary_lazy_evaluations, r=xFrednet
...
[`unnecessary_lazy_evaluations`] Do not suggest switching to early evaluation when type has custom `Drop`
fix #9427
changelog: [`unnecessary_lazy_evaluations`] Do not suggest switching to early evaluation when type has custom `Drop`
2022-09-29 08:36:14 +00:00
bors
ed9c0e3030
Auto merge of #9550 - alex-semenyuk:fix_typo, r=xFrednet
...
Fix typo
changelog: none
2022-09-28 21:44:52 +00:00
kraktus
314d57a790
[unnecessary_lazy_evaluations
] Do not suggest switching to early evaluation when type has custom Drop
2022-09-28 22:46:05 +02:00
alex-semenyuk
8ba081c597
Fix typo
2022-09-28 23:01:11 +03:00
bors
8845f82142
Auto merge of #9490 - kraktus:needless_borrow, r=Jarcho
...
fix [`needless_borrow`], [`explicit_auto_deref`] FPs on unions
fix https://github.com/rust-lang/rust-clippy/issues/9383
changelog: fix [`needless_borrow`] false positive on unions
changelog: fix [`explicit_auto_deref`] false positive on unions
Left a couple debug derived impls on purpose I needed to debug as I don't think it's noise
2022-09-28 14:58:07 +00:00
Philipp Krones
458e83291d
Bump Clippy version -> 0.1.66
2022-09-28 14:27:50 +02:00
Philipp Krones
bbcde66685
Merge remote-tracking branch 'upstream/master' into rustup
2022-09-28 14:27:32 +02:00
bors
0f6932a1f7
Auto merge of #9546 - kraktus:default_not_default_trait, r=xFrednet
...
[`should_implement_trait`] Also lint `default` method
close https://github.com/rust-lang/rust-clippy/issues/8550
changelog: FP: [`should_implement_trait`]: Now also works for `default` methods
2022-09-28 11:00:37 +00:00
kraktus
7289835542
[should_implement_trait
] Also lint default
method
2022-09-28 08:42:01 +02:00
bors
35b7ce5ca9
Auto merge of #9545 - Alexendoo:std-instead-of-core-unstable, r=Manishearth
...
Don't lint unstable moves in `std_instead_of_core`
Fixes #9515
changelog: [`std_instead_of_core`]: No longer suggests unstable modules such as `core::error`
2022-09-27 20:11:34 +00:00
kraktus
14ba4fba11
fix [needless_borrow
] and [explicit_auto_deref
] false positive on unions
2022-09-27 21:30:32 +02:00
bors
672fb8e42e
Auto merge of #9491 - kraktus:drop_copy, r=Jarcho
...
[`drop_copy`]: Do not lint idiomatic in match arm
close https://github.com/rust-lang/rust-clippy/issues/9482
changelog: [`drop_copy`]: Do not lint idiomatic in match arm
2022-09-27 19:18:29 +00:00