]> git.lizzy.rs Git - rust.git/log
rust.git
21 months agoAuto merge of #7962 - Jarcho:fix_match_type_on_diagnostic_items, r=llogiq
bors [Sun, 2 Oct 2022 19:46:46 +0000 (19:46 +0000)]
Auto merge of #7962 - Jarcho:fix_match_type_on_diagnostic_items, r=llogiq

Fix and improve `match_type_on_diagnostic_item`

This extracts the fix for the lint out of #7647. There's still a couple of other functions to check, but at least this will get lint working again.

The two added util functions (`is_diagnostic_item` and `is_lang_item`) are needed to handle `DefId` for unit and tuple struct/variant constructors. The `rustc_diagnostic_item` and `lang` attributes are attached to the struct/variant `DefId`, but most of the time they are used through their constructors which have a different `DefId`. The two utility functions will check if the `DefId` is for a constructor and switch to the associated struct/variant `DefId`.

There does seem to be a bug on rustc's side where constructor `DefId`s from external crates seem to be returning `DefKind::Variant` instead of `DefKind::Ctor()`. There's a workaround put in right.

changelog: None

21 months agoAuto merge of #9574 - Alexendoo:unused-fixed, r=Jarcho
bors [Sun, 2 Oct 2022 19:06:58 +0000 (19:06 +0000)]
Auto merge of #9574 - Alexendoo:unused-fixed, r=Jarcho

Remove unused `.fixed` files, only run asm_syntax doctests on x86

Two small changes, removes some unused `.fixed` and makes `clippy_lints` doctests pass on non x86 arches

changelog: none

21 months agoFix and improve internal lint checking for `match_type` usages
Jason Newcomb [Thu, 11 Nov 2021 19:15:01 +0000 (14:15 -0500)]
Fix and improve internal lint checking for `match_type` usages

* Check for `const`s and `static`s from external crates
* Check for `LangItem`s
* Handle inherent functions which have the same name as a field
* Also check the following functions:
    * `match_trait_method`
    * `match_def_path`
    * `is_expr_path_def_path`
    * `is_qpath_def_path`
* Handle checking for a constructor to a diagnostic item or `LangItem`

21 months agoReplace `is_lang_ctor` with `is_res_lang_ctor`
Jason Newcomb [Wed, 29 Jun 2022 02:34:02 +0000 (22:34 -0400)]
Replace `is_lang_ctor` with `is_res_lang_ctor`

21 months agoAuto merge of #9576 - TennyZhuang:unnecessary_cast_for_non_literal_expr, r=llogiq
bors [Sun, 2 Oct 2022 15:26:45 +0000 (15:26 +0000)]
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

21 months agoAuto merge of #9479 - kraktus:manual_assert2, r=llogiq
bors [Sun, 2 Oct 2022 15:13:32 +0000 (15:13 +0000)]
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

21 months agofix some logics
TennyZhuang [Sun, 2 Oct 2022 11:04:33 +0000 (19:04 +0800)]
fix some logics

Signed-off-by: TennyZhuang <zty0826@gmail.com>
21 months agoextract common codes
TennyZhuang [Sun, 2 Oct 2022 10:41:13 +0000 (18:41 +0800)]
extract common codes

Signed-off-by: TennyZhuang <zty0826@gmail.com>
21 months agoignore the lint on some test files
TennyZhuang [Sun, 2 Oct 2022 09:53:58 +0000 (17:53 +0800)]
ignore the lint on some test files

Signed-off-by: TennyZhuang <zty0826@gmail.com>
21 months agolet unnecessary_cast work for trivial non_literal expressions
TennyZhuang [Sun, 2 Oct 2022 09:12:08 +0000 (17:12 +0800)]
let unnecessary_cast work for trivial non_literal expressions

Signed-off-by: TennyZhuang <zty0826@gmail.com>
21 months agoAuto merge of #9577 - kraktus:unnecessary_cast, r=llogiq
bors [Sun, 2 Oct 2022 14:18:41 +0000 (14:18 +0000)]
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 90fe3bea52dd6ebd0cb02785ba523f182ff761e6

changelog: [`unnecessary_cast`] add parenthesis when negative number uses a method

r? llogiq

21 months agofix tests
kraktus [Sun, 2 Oct 2022 13:25:50 +0000 (15:25 +0200)]
fix tests

21 months agoAuto merge of #9571 - rust-lang:refactor-lit-ints, r=Jarcho
bors [Sun, 2 Oct 2022 13:11:21 +0000 (13:11 +0000)]
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

21 months agofix indentation
kraktus [Sun, 2 Oct 2022 10:35:02 +0000 (12:35 +0200)]
fix indentation

21 months agorevert `manual_assert` suggestion refactor
kraktus [Fri, 16 Sep 2022 19:38:56 +0000 (21:38 +0200)]
revert `manual_assert` suggestion refactor

Because `Sugg` helper does not simplify multiple negations

21 months ago[`manual_assert`]: Preserve comments in the suggestion
kraktus [Wed, 14 Sep 2022 09:58:41 +0000 (11:58 +0200)]
[`manual_assert`]: Preserve comments in the suggestion

21 months ago[`unnecessary_cast`] add parenthesis when negative number uses a method
kraktus [Sun, 2 Oct 2022 12:30:26 +0000 (14:30 +0200)]
[`unnecessary_cast`] add parenthesis when negative number uses a method

21 months agoAuto merge of #9573 - Alexendoo:needless-borrowed-ref-slice, r=dswij
bors [Sun, 2 Oct 2022 10:39:04 +0000 (10:39 +0000)]
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

21 months agoAuto merge of #9509 - schubart:fix_sorting, r=llogiq
bors [Sun, 2 Oct 2022 07:51:45 +0000 (07:51 +0000)]
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.

21 months agolint nested patterns and slice patterns in `needless_borrowed_reference`
Alex Macleod [Sat, 1 Oct 2022 21:54:22 +0000 (21:54 +0000)]
lint nested patterns and slice patterns in `needless_borrowed_reference`

21 months agoOnly run x86 asm doctests on x86
Alex Macleod [Sat, 1 Oct 2022 22:25:01 +0000 (22:25 +0000)]
Only run x86 asm doctests on x86

21 months agoRemove unused .fixed files
Alex Macleod [Sat, 1 Oct 2022 22:24:48 +0000 (22:24 +0000)]
Remove unused .fixed files

21 months agoAuto merge of #9484 - Xaeroxe:clamping-without-clamp, r=Alexendoo
bors [Sat, 1 Oct 2022 20:55:20 +0000 (20:55 +0000)]
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

21 months agoImplement manual_clamp lint
Jacob Kiesel [Fri, 16 Sep 2022 02:50:28 +0000 (20:50 -0600)]
Implement manual_clamp lint

21 months agoAuto merge of #9569 - matthiaskrgr:rtu_from_cratesio, r=xFrednet
bors [Sat, 1 Oct 2022 16:22:58 +0000 (16:22 +0000)]
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

21 months agouse `is_integer_literal` more
Andre Bogus [Sat, 1 Oct 2022 15:55:22 +0000 (17:55 +0200)]
use `is_integer_literal` more

21 months agouse rustc_tools_util dependency from crates.io instead of this repo.
Matthias Krüger [Sat, 1 Oct 2022 14:40:10 +0000 (16:40 +0200)]
use rustc_tools_util dependency from crates.io instead of this repo.

Fixes #9553

21 months agoAuto merge of #9567 - rust-lang:doc-link-with-code, r=Alexendoo
bors [Sat, 1 Oct 2022 14:33:13 +0000 (14:33 +0000)]
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

21 months agoAuto merge of #9568 - matthiaskrgr:tools_util_bump, r=flip1995
bors [Sat, 1 Oct 2022 14:20:32 +0000 (14:20 +0000)]
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`.

21 months agorustc_tool_utils bump version in anticipation of a new release
Matthias Krüger [Fri, 30 Sep 2022 22:52:25 +0000 (00:52 +0200)]
rustc_tool_utils bump version in anticipation of a new release

cc https://github.com/rust-lang/rust-clippy/issues/9553

21 months agoavoid doc-link-with-quotes in code blocks
Andre Bogus [Sat, 1 Oct 2022 09:57:34 +0000 (11:57 +0200)]
avoid doc-link-with-quotes in code blocks

21 months agoAuto merge of #9510 - Alexendoo:lintcheck-server2, r=matthiaskrgr
bors [Fri, 30 Sep 2022 22:29:40 +0000 (22:29 +0000)]
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 =&gt; 1
clippy::needless_question_mark 0 =&gt; 3
clippy::unnecessary_cast 0 =&gt; 2
clippy::to_string_in_format_args 0 =&gt; 4
clippy::deprecated_cfg_attr 0 =&gt; 23
clippy::redundant_closure 0 =&gt; 9
clippy::drop_copy 0 =&gt; 4
clippy::double_must_use 0 =&gt; 1
clippy::transmute_num_to_bytes 0 =&gt; 9
clippy::bind_instead_of_map 0 =&gt; 14
clippy::float_cmp 0 =&gt; 16
clippy::is_digit_ascii_radix 0 =&gt; 16
clippy::manual_swap 0 =&gt; 1
clippy::needless_match 0 =&gt; 2
clippy::vec_init_then_push 0 =&gt; 1
clippy::never_loop 0 =&gt; 1
clippy::option_map_or_none 0 =&gt; 4
clippy::tabs_in_doc_comments 0 =&gt; 1
clippy::naive_bytecount 0 =&gt; 1
clippy::collapsible_if 0 =&gt; 24
clippy::copy_iterator 0 =&gt; 5
clippy::unused_io_amount 0 =&gt; 2
clippy::result_large_err 0 =&gt; 141
clippy::useless_conversion 0 =&gt; 24
clippy::flat_map_option 0 =&gt; 8
clippy::useless_format 0 =&gt; 2
clippy::module_inception 0 =&gt; 1
clippy::drop_ref 0 =&gt; 2
clippy::unnecessary_fold 0 =&gt; 2
clippy::neg_multiply 0 =&gt; 1
clippy::while_let_loop 0 =&gt; 6
clippy::missing_inline_in_public_items 0 =&gt; 37
clippy::unnecessary_mut_passed 0 =&gt; 1
unknown_lints 0 =&gt; 15
clippy::wildcard_dependencies 0 =&gt; 3
clippy::same_item_push 0 =&gt; 2
clippy::useless_asref 0 =&gt; 1
clippy::unnecessary_unwrap 0 =&gt; 4
clippy::iter_not_returning_iterator 0 =&gt; 5
clippy::comparison_to_empty 0 =&gt; 10
clippy::ref_option_ref 0 =&gt; 4
clippy::unused_peekable 0 =&gt; 1
clippy::needless_range_loop 0 =&gt; 8
clippy::absurd_extreme_comparisons 0 =&gt; 2
clippy::unnecessary_operation 0 =&gt; 2
clippy::for_kv_map 0 =&gt; 5
clippy::unnecessary_owned_empty_strings 0 =&gt; 3
clippy::transmutes_expressible_as_ptr_casts 0 =&gt; 1
clippy::toplevel_ref_arg 0 =&gt; 2
clippy::uninit_vec 0 =&gt; 3
clippy::filter_next 0 =&gt; 1
clippy::wildcard_in_or_patterns 0 =&gt; 6
clippy::cast_ptr_alignment 0 =&gt; 48
clippy::manual_memcpy 0 =&gt; 1
clippy::assign_op_pattern 0 =&gt; 313
clippy::unnecessary_lazy_evaluations 0 =&gt; 14
clippy::println_empty_string 0 =&gt; 2
clippy::redundant_pattern 0 =&gt; 2
clippy::declare_interior_mutable_const 0 =&gt; 8
clippy::large_stack_arrays 0 =&gt; 4
clippy::match_bool 0 =&gt; 4
clippy::unicode_not_nfc 0 =&gt; 2075
clippy::inconsistent_digit_grouping 0 =&gt; 4
clippy::no_effect_underscore_binding 0 =&gt; 2
clippy::let_and_return 0 =&gt; 5
clippy::transmute_ptr_to_ref 0 =&gt; 12
clippy::op_ref 0 =&gt; 13
clippy::unnecessary_join 0 =&gt; 4
clippy::into_iter_on_ref 0 =&gt; 13
clippy::from_str_radix_10 0 =&gt; 7
clippy::ptr_offset_with_cast 0 =&gt; 48
clippy::erasing_op 0 =&gt; 1
clippy::swap_ptr_to_ref 0 =&gt; 3
clippy::needless_bitwise_bool 0 =&gt; 2
clippy::extend_with_drain 0 =&gt; 19
clippy::only_used_in_recursion 0 =&gt; 4
clippy::needless_late_init 0 =&gt; 8
clippy::excessive_precision 0 =&gt; 1959
clippy::match_ref_pats 0 =&gt; 10
clippy::unit_arg 0 =&gt; 20
clippy::bool_comparison 0 =&gt; 4
clippy::bool_assert_comparison 0 =&gt; 1
clippy::eq_op 0 =&gt; 6
clippy::cast_abs_to_unsigned 0 =&gt; 6
clippy::format_in_format_args 0 =&gt; 1
clippy::iter_cloned_collect 0 =&gt; 4
clippy::ptr_eq 0 =&gt; 3
clippy::needless_bool 0 =&gt; 5
clippy::transmute_ptr_to_ptr 0 =&gt; 16
clippy::needless_option_take 0 =&gt; 2
clippy::flat_map_identity 0 =&gt; 1
clippy::needless_splitn 0 =&gt; 2
clippy::blocks_in_if_conditions 0 =&gt; 1
clippy::write_literal 0 =&gt; 1
clippy::manual_split_once 0 =&gt; 1
clippy::result_unit_err 0 =&gt; 36
clippy::unused_unit 0 =&gt; 11
clippy::single_match 0 =&gt; 22
clippy::manual_find 0 =&gt; 3
clippy::derive_ord_xor_partial_ord 0 =&gt; 6
clippy::char_lit_as_u8 0 =&gt; 2
clippy::let_unit_value 0 =&gt; 2
clippy::needless_continue 0 =&gt; 19
clippy::zero_sized_map_values 0 =&gt; 4
clippy::needless_arbitrary_self_type 0 =&gt; 6
clippy::partialeq_to_none 0 =&gt; 11
clippy::partialeq_ne_impl 0 =&gt; 1
clippy::invalid_upcast_comparisons 0 =&gt; 1
clippy::mut_range_bound 0 =&gt; 4
clippy::match_result_ok 0 =&gt; 2
clippy::ptr_arg 0 =&gt; 8
clippy::iter_nth_zero 0 =&gt; 18
clippy::needless_for_each 0 =&gt; 1
clippy::manual_unwrap_or 0 =&gt; 1
clippy::transmute_int_to_float 0 =&gt; 6
clippy::cast_slice_from_raw_parts 0 =&gt; 1
clippy::match_wild_err_arm 0 =&gt; 2
clippy::match_like_matches_macro 4 =&gt; 116
clippy::enum_glob_use 50 =&gt; 380
clippy::get_first 3 =&gt; 33
clippy::needless_doctest_main 10 =&gt; 26
clippy::struct_excessive_bools 19 =&gt; 51
clippy::cast_possible_wrap 46 =&gt; 538
clippy::manual_string_new 10 =&gt; 27
clippy::match_same_arms 53 =&gt; 1039
clippy::manual_non_exhaustive 1 =&gt; 33
clippy::redundant_pattern_matching 2 =&gt; 13
clippy::new_without_default 5 =&gt; 73
clippy::option_as_ref_deref 2 =&gt; 9
clippy::unwrap_or_else_default 2 =&gt; 4
clippy::case_sensitive_file_extension_comparisons 6 =&gt; 9
clippy::cast_precision_loss 45 =&gt; 110
clippy::needless_pass_by_value 26 =&gt; 187
clippy::redundant_closure_for_method_calls 170 =&gt; 539
clippy::let_underscore_drop 33 =&gt; 133
clippy::single_match_else 51 =&gt; 138
clippy::needless_borrow 24 =&gt; 382
clippy::redundant_else 37 =&gt; 151
clippy::type_complexity 2 =&gt; 22
clippy::ptr_as_ptr 93 =&gt; 1135
clippy::needless_lifetimes 7 =&gt; 100
clippy::single_char_add_str 2 =&gt; 22
clippy::similar_names 99 =&gt; 352
clippy::cargo_common_metadata 25 =&gt; 276
clippy::int_plus_one 1 =&gt; 2
clippy::missing_safety_doc 9 =&gt; 152
clippy::redundant_slicing 2 =&gt; 13
clippy::mut_mut 2 =&gt; 17
clippy::derive_partial_eq_without_eq 8 =&gt; 141
clippy::derive_hash_xor_eq 2 =&gt; 20
clippy::from_iter_instead_of_collect 2 =&gt; 17
clippy::verbose_bit_mask 1 =&gt; 8
clippy::too_many_lines 58 =&gt; 162
clippy::module_name_repetitions 178 =&gt; 1104
clippy::explicit_into_iter_loop 12 =&gt; 32
clippy::cast_lossless 45 =&gt; 478
clippy::many_single_char_names 9 =&gt; 23
clippy::unnested_or_patterns 27 =&gt; 127
clippy::upper_case_acronyms 5 =&gt; 29
clippy::needless_return 5 =&gt; 97
clippy::precedence 1 =&gt; 11
clippy::len_zero 2 =&gt; 70
clippy::manual_strip 2 =&gt; 30
clippy::derivable_impls 2 =&gt; 12
clippy::unused_self 20 =&gt; 187
clippy::enum_variant_names 1 =&gt; 6
clippy::self_named_constructors 1 =&gt; 3
clippy::explicit_auto_deref 19 =&gt; 314
clippy::semicolon_if_nothing_returned 137 =&gt; 1861
clippy::should_implement_trait 1 =&gt; 7
clippy::expl_impl_clone_on_copy 159 =&gt; 1318
clippy::stable_sort_primitive 4 =&gt; 12
clippy::mem_replace_with_default 7 =&gt; 46
clippy::borrow_deref_ref 5 =&gt; 140
clippy::large_enum_variant 1 =&gt; 4
clippy::map_unwrap_or 30 =&gt; 203
clippy::zero_ptr 3 =&gt; 25
clippy::filter_map_next 2 =&gt; 6
clippy::identity_op 5 =&gt; 76
clippy::checked_conversions 1 =&gt; 8
clippy::len_without_is_empty 9 =&gt; 47
clippy::missing_errors_doc 372 =&gt; 2333
clippy::fn_params_excessive_bools 3 =&gt; 7
clippy::single_component_path_imports 6 =&gt; 28
clippy::unreadable_literal 366 =&gt; 9814
clippy::field_reassign_with_default 1 =&gt; 5
clippy::redundant_clone 1 =&gt; 8
clippy::cloned_instead_of_copied 36 =&gt; 78
clippy::too_many_arguments 4 =&gt; 22
clippy::option_map_unit_fn 7 =&gt; 9
clippy::extra_unused_lifetimes 1 =&gt; 24
clippy::unnecessary_wraps 26 =&gt; 128
clippy::used_underscore_binding 1 =&gt; 50
clippy::inconsistent_struct_constructor 2 =&gt; 7
clippy::manual_range_contains 9 =&gt; 120
clippy::map_clone 7 =&gt; 46
clippy::cast_slice_different_sizes 1 =&gt; 4
clippy::missing_panics_doc 114 =&gt; 603
renamed_and_removed_lints 3 =&gt; 9
clippy::items_after_statements 155 =&gt; 309
clippy::inefficient_to_string 5 =&gt; 6
clippy::comparison_chain 1 =&gt; 19
clippy::crate_in_macro_def 3 =&gt; 6
clippy::write_with_newline 2 =&gt; 36
clippy::manual_saturating_arithmetic 1 =&gt; 2
clippy::clone_on_copy 1 =&gt; 86
clippy::negative_feature_names 3 =&gt; 16
clippy::redundant_field_names 112 =&gt; 1013
clippy::from_over_into 2 =&gt; 28
clippy::wildcard_imports 178 =&gt; 376
clippy::unusual_byte_groupings 19 =&gt; 65
clippy::option_option 2 =&gt; 10
clippy::nonminimal_bool 1 =&gt; 17
clippy::borrow_as_ptr 2 =&gt; 172
clippy::redundant_static_lifetimes 24 =&gt; 1701
clippy::or_fun_call 1 =&gt; 63
clippy::single_char_pattern 3 =&gt; 79
clippy::explicit_iter_loop 72 =&gt; 148
clippy::collapsible_else_if 2 =&gt; 27
clippy::manual_str_repeat 1 =&gt; 6
clippy::if_same_then_else 3 =&gt; 31
clippy::while_let_on_iterator 4 =&gt; 28
clippy::multiple_crate_versions 5 =&gt; 19
clippy::cast_possible_truncation 115 =&gt; 1172
clippy::explicit_deref_methods 1 =&gt; 38
clippy::default_trait_access 48 =&gt; 130
clippy::question_mark 2 =&gt; 28
clippy::must_use_candidate 612 =&gt; 5369
clippy::manual_map 1 =&gt; 12
clippy::bool_to_int_with_if 2 =&gt; 15
clippy::doc_markdown 202 =&gt; 1709
clippy::cast_sign_loss 60 =&gt; 477
clippy::wrong_self_convention 11 =&gt; 45
clippy::transmute_float_to_int 6 =&gt; 18
clippy::return_self_not_must_use 66 =&gt; 736
clippy::range_plus_one 1 =&gt; 36
clippy::manual_assert 11 =&gt; 62
clippy::trivially_copy_pass_by_ref 40 =&gt; 189
clippy::match_on_vec_items 2 =&gt; 7
clippy::inline_always 59 =&gt; 1079
clippy::if_not_else 31 =&gt; 205
clippy::implicit_clone 10 =&gt; 32
clippy::match_wildcard_for_single_variants 16 =&gt; 101
clippy::doc_link_with_quotes 7 =&gt; 35
clippy::redundant_feature_names 4 =&gt; 41
</code></pre></details>

changelog: none

21 months agoAuto merge of #9556 - evantypanski:et/issue-9369, r=Alexendoo
bors [Fri, 30 Sep 2022 16:42:55 +0000 (16:42 +0000)]
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

21 months agoAdd test case where `FnMut` used once needs `&mut`
Evan Typanski [Fri, 30 Sep 2022 15:37:50 +0000 (11:37 -0400)]
Add test case where `FnMut` used once needs `&mut`

21 months agoFix style in `if let` chain
Evan Typanski [Fri, 30 Sep 2022 15:36:55 +0000 (11:36 -0400)]
Fix style in `if let` chain

Co-authored-by: Alex Macleod <alex@macleod.io>
21 months agoAuto merge of #9557 - xxchan:xxchan/safe-anaconda, r=Manishearth
bors [Fri, 30 Sep 2022 15:23:09 +0000 (15:23 +0000)]
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

21 months agodoc: make the usage of clippy.toml more clear
xxchan [Fri, 30 Sep 2022 11:34:21 +0000 (13:34 +0200)]
doc: make the usage of clippy.toml more clear

21 months agoAuto merge of #9486 - kraktus:lazy_eval, r=dswij
bors [Fri, 30 Sep 2022 07:47:55 +0000 (07:47 +0000)]
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

21 months ago[`redundant_closure`] Add `&mut` to more cases
Evan Typanski [Thu, 29 Sep 2022 23:31:32 +0000 (19:31 -0400)]
[`redundant_closure`] Add `&mut` to more cases

21 months ago[`unnecessary_lazy_eval`] Do not lint in external macros
kraktus [Thu, 29 Sep 2022 11:45:40 +0000 (13:45 +0200)]
[`unnecessary_lazy_eval`] Do not lint in external macros

21 months agoAuto merge of #9516 - flip1995:rustup, r=flip1995
bors [Thu, 29 Sep 2022 10:04:13 +0000 (10:04 +0000)]
Auto merge of #9516 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

21 months agoUpdate lints after sync
Philipp Krones [Wed, 28 Sep 2022 12:36:56 +0000 (14:36 +0200)]
Update lints after sync

21 months agoFix dogfood
Philipp Krones [Wed, 28 Sep 2022 12:31:29 +0000 (14:31 +0200)]
Fix dogfood

21 months agoBump nightly version -> 2022-09-29
Philipp Krones [Wed, 28 Sep 2022 12:28:03 +0000 (14:28 +0200)]
Bump nightly version -> 2022-09-29

21 months agoAuto merge of #9551 - kraktus:unnecessary_lazy_evaluations, r=xFrednet
bors [Thu, 29 Sep 2022 08:36:14 +0000 (08:36 +0000)]
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`

21 months agoAuto merge of #9550 - alex-semenyuk:fix_typo, r=xFrednet
bors [Wed, 28 Sep 2022 21:44:52 +0000 (21:44 +0000)]
Auto merge of #9550 - alex-semenyuk:fix_typo, r=xFrednet

Fix typo

changelog: none

21 months ago[`unnecessary_lazy_evaluations`] Do not suggest switching to early evaluation when...
kraktus [Wed, 28 Sep 2022 20:21:52 +0000 (22:21 +0200)]
[`unnecessary_lazy_evaluations`] Do not suggest switching to early evaluation when type has custom `Drop`

21 months agoFix typo
alex-semenyuk [Wed, 28 Sep 2022 20:01:11 +0000 (23:01 +0300)]
Fix typo

21 months agoAuto merge of #9490 - kraktus:needless_borrow, r=Jarcho
bors [Wed, 28 Sep 2022 14:58:07 +0000 (14:58 +0000)]
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

21 months agoBump Clippy version -> 0.1.66
Philipp Krones [Wed, 28 Sep 2022 12:27:50 +0000 (14:27 +0200)]
Bump Clippy version -> 0.1.66

21 months agoMerge remote-tracking branch 'upstream/master' into rustup
Philipp Krones [Wed, 28 Sep 2022 12:27:32 +0000 (14:27 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

21 months agoAuto merge of #9546 - kraktus:default_not_default_trait, r=xFrednet
bors [Wed, 28 Sep 2022 11:00:37 +0000 (11:00 +0000)]
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

21 months ago[`should_implement_trait`] Also lint `default` method
kraktus [Tue, 27 Sep 2022 20:24:14 +0000 (22:24 +0200)]
[`should_implement_trait`] Also lint `default` method

22 months agoAuto merge of #9545 - Alexendoo:std-instead-of-core-unstable, r=Manishearth
bors [Tue, 27 Sep 2022 20:11:34 +0000 (20:11 +0000)]
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`

22 months agofix [`needless_borrow`] and [`explicit_auto_deref`] false positive on unions
kraktus [Sat, 17 Sep 2022 11:59:02 +0000 (13:59 +0200)]
fix [`needless_borrow`] and [`explicit_auto_deref`] false positive on unions

22 months agoAuto merge of #9491 - kraktus:drop_copy, r=Jarcho
bors [Tue, 27 Sep 2022 19:18:29 +0000 (19:18 +0000)]
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

22 months agorename `and_only_expr_in_arm` -> `is_single_call_in_arm`
kraktus [Tue, 27 Sep 2022 19:01:23 +0000 (21:01 +0200)]
rename `and_only_expr_in_arm` -> `is_single_call_in_arm`

22 months agoDon't lint unstable moves in `std_instead_of_core`
Alex Macleod [Tue, 27 Sep 2022 18:21:14 +0000 (18:21 +0000)]
Don't lint unstable moves in `std_instead_of_core`

Such as the currently unstable `core::error`

22 months agoAuto merge of #9511 - rust-lang:box-default, r=Alexendoo
bors [Tue, 27 Sep 2022 18:14:24 +0000 (18:14 +0000)]
Auto merge of #9511 - rust-lang:box-default, r=Alexendoo

add `box-default` lint

This adds a `box-default` lint to suggest using `Box::default()` instead of `Box::new(Default::default())`, which offers less moving parts and potentially better performance according to [the perf book](https://nnethercote.github.io/perf-book/standard-library-types.html#box).

---

changelog: add [`box_default`] lint

22 months agoAuto merge of #9543 - philipcraig:fix-saturing-typo, r=giraffate
bors [Tue, 27 Sep 2022 14:38:12 +0000 (14:38 +0000)]
Auto merge of #9543 - philipcraig:fix-saturing-typo, r=giraffate

fix typo "Saturing" -> "Saturating"

---

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: fix typo "Saturing" -> "Saturating"

22 months agoAuto merge of #9497 - kraktus:needless_return2, r=llogiq
bors [Tue, 27 Sep 2022 14:23:53 +0000 (14:23 +0000)]
Auto merge of #9497 - kraktus:needless_return2, r=llogiq

[`needless_return`] Recursively remove unneeded semicolons

fix #8336,
fix #8156,
fix https://github.com/rust-lang/rust-clippy/issues/7358,
fix #9192,
fix https://github.com/rust-lang/rust-clippy/issues/9503

changelog: [`needless_return`] Recursively remove unneeded semicolons

For now the suggestion about removing the semicolons are hidden because they would be very noisy and should be obvious if the user wants to apply the lint manually instead of using `--fix`. This could be an issue for beginner, but haven't found better way to display it.

22 months agoAuto merge of #9507 - c410-f3r:arith, r=Alexendoo
bors [Tue, 27 Sep 2022 14:09:25 +0000 (14:09 +0000)]
Auto merge of #9507 - c410-f3r:arith, r=Alexendoo

[arithmetic-side-effects] Consider references

Takes into consideration integer references like `&i32::MAX` because currently things like `let _ = &1 + 0` trigger the lint.

changelog: FP: [`arithmetic_side_effects`]: Now ignores references
  [9507](https://github.com/rust-lang/rust-clippy/pull/9507)

22 months agoAuto merge of #9539 - Jarcho:ice_9445, r=flip1995
bors [Tue, 27 Sep 2022 12:58:41 +0000 (12:58 +0000)]
Auto merge of #9539 - Jarcho:ice_9445, r=flip1995

Don't lint `*_interior_mutable_const` on unions due to potential ICE.

fixes #9445
cc rust-lang/rust#101113

This started ICE'ing sometime last month due to stricter UB checks. I'm not sure how we could check the value of a union as MIRI doesn't seem to store which field is currently active.

changelog: Don't ICE on const unions containing a `!Freeze` type.

22 months agoadd `box-default` lint
Andre Bogus [Wed, 21 Sep 2022 21:43:49 +0000 (23:43 +0200)]
add `box-default` lint

22 months agorustc_typeck to rustc_hir_analysis
lcnr [Mon, 26 Sep 2022 11:00:29 +0000 (13:00 +0200)]
rustc_typeck to rustc_hir_analysis

22 months agofix typo "Saturing" -> "Saturating"
Philip Craig [Tue, 27 Sep 2022 08:32:55 +0000 (09:32 +0100)]
fix typo "Saturing" -> "Saturating"

22 months agoAuto merge of #9487 - kraktus:question_mark, r=Jarcho
bors [Tue, 27 Sep 2022 01:12:54 +0000 (01:12 +0000)]
Auto merge of #9487 - kraktus:question_mark, r=Jarcho

Silence [`question_mark`] in const context

fix https://github.com/rust-lang/rust-clippy/issues/9175

When `const_try` is stabilised can be turned into a MSRV

changelog: Silence [`question_mark`] in const context

22 months agoAuto merge of #9233 - nyurik:capture-vars, r=Alexendoo
bors [Mon, 26 Sep 2022 09:27:37 +0000 (09:27 +0000)]
Auto merge of #9233 - nyurik:capture-vars, r=Alexendoo

new uninlined_format_args lint to inline explicit arguments

Implement https://github.com/rust-lang/rust-clippy/issues/8368 - a new lint to inline format arguments such as `print!("{}", var)` into `print!("{var}")`.

### Supported cases

code | suggestion | comment
---|---|---
`print!("{}", var)` | `print!("{var}")` |  simple variables
`print!("{0}", var)` | `print!("{var}")` |  positional variables
`print!("{v}", v=var)` | `print!("{var}")` |  named variables
`print!("{0} {0}", var)` | `print!("{var} {var}")` |  aliased variables
`print!("{0:1$}", var, width)` | `print!("{var:width$}")` |  width support
`print!("{0:.1$}", var, prec)` | `print!("{var:.prec$}")` |  precision support
`print!("{:.*}", prec, var)` | `print!("{var:.prec$}")` |  asterisk support

### Known Problems

* There may be a false positive if the format string is wrapped in a macro call:
```rust
# let var = 42;
macro_rules! no_param_str { () => { "{}" }; }
macro_rules! pass_through { ($expr:expr) => { $expr }; }
println!(no_param_str!(), var);
println!(pass_through!("{}"), var);
```

* Format string uses an indexed argument that cannot be inlined.
Supporting this case requires re-indexing of the format string.
Until implemented, `print!("{0}={1}", var, 1+2)` should be changed to `print!("{var}={0}", 1+2)` by hand.

changelog: [`uninlined_format_args`]: A new lint to inline format arguments, i.e. `print!("{}", var)` into `print!("{var}")`

22 months agoremove cfg(bootstrap)
Pietro Albini [Tue, 20 Sep 2022 13:41:42 +0000 (15:41 +0200)]
remove cfg(bootstrap)

22 months agoRollup merge of #102197 - Nilstrieb:const-new-🌲, r=Mark-Simulacrum
fee1-dead [Mon, 26 Sep 2022 05:09:42 +0000 (13:09 +0800)]
Rollup merge of #102197 - Nilstrieb:const-new-🌲, r=Mark-Simulacrum

Stabilize const `BTree{Map,Set}::new`

The FCP was completed in #71835.

Since `len` and `is_empty` are not const stable yet, this also creates a new feature for them since they previously used the same `const_btree_new` feature.

22 months agonew uninlined_format_args lint to inline explicit arguments
Yuri Astrakhan [Wed, 14 Sep 2022 16:25:48 +0000 (12:25 -0400)]
new uninlined_format_args lint to inline explicit arguments

Implement https://github.com/rust-lang/rust-clippy/issues/8368 - a new
lint to inline format arguments such as `print!("{}", var)` into
`print!("{var}")`.

code | suggestion | comment
---|---|---
`print!("{}", var)` | `print!("{var}")` |  simple variables
`print!("{0}", var)` | `print!("{var}")` |  positional variables
`print!("{v}", v=var)` | `print!("{var}")` |  named variables
`print!("{0} {0}", var)` | `print!("{var} {var}")` |  aliased variables
`print!("{0:1$}", var, width)` | `print!("{var:width$}")` |  width
support
`print!("{0:.1$}", var, prec)` | `print!("{var:.prec$}")` |  precision
support
`print!("{:.*}", prec, var)` | `print!("{var:.prec$}")` |  asterisk
support

code | suggestion | comment
---|---|---
`print!("{0}={1}", var, 1+2)` | `print!("{var}={0}", 1+2)` | Format
string uses an indexed argument that cannot be inlined.  Supporting this
case requires re-indexing of the format string.

changelog: [`uninlined_format_args`]: A new lint to inline format
arguments, i.e. `print!("{}", var)` into `print!("{var}")`

22 months agoDon't lint `*_interior_mutable_const` on unions due to potential ICE.
Jason Newcomb [Sun, 25 Sep 2022 21:37:56 +0000 (17:37 -0400)]
Don't lint `*_interior_mutable_const` on unions due to potential ICE.

22 months agoAuto merge of #9533 - Jarcho:integration-ice-msg, r=llogiq
bors [Sun, 25 Sep 2022 14:33:36 +0000 (14:33 +0000)]
Auto merge of #9533 - Jarcho:integration-ice-msg, r=llogiq

Fix panic when displaying the backtrace of failing integration tests

changelog: None

22 months agoFix panic when displaying the backtrace of failing integration tests
Jason Newcomb [Sun, 25 Sep 2022 04:39:05 +0000 (00:39 -0400)]
Fix panic when displaying the backtrace of failing integration tests

22 months agoAuto merge of #9535 - alex-semenyuk:move_derive_partial_eq_without_eq_to_nursery...
bors [Sun, 25 Sep 2022 10:38:02 +0000 (10:38 +0000)]
Auto merge of #9535 - alex-semenyuk:move_derive_partial_eq_without_eq_to_nursery, r=xFrednet

Moved derive_partial_eq_without_eq to nursery

changelog: Moves: Move `derive_partial_eq_without_eq` to `nursery` (now allow-by-default)
  [#9536](https://github.com/rust-lang/rust-clippy/pull/9536)

Closes: https://github.com/rust-lang/rust-clippy/issues/9530
22 months agoPlease move derive_partial_eq_without_eq to nursery
alex-semenyuk [Sun, 25 Sep 2022 10:00:25 +0000 (13:00 +0300)]
Please move derive_partial_eq_without_eq to nursery

22 months agoAuto merge of #9531 - Jarcho:ice_9459, r=llogiq
bors [Sun, 25 Sep 2022 08:09:02 +0000 (08:09 +0000)]
Auto merge of #9531 - Jarcho:ice_9459, r=llogiq

Fix ICE in `needless_pass_by_value` with unsized `dyn Fn`

fixes #9459

Not really sure why a query for a type implementing `FnOnce` even works since the trait if `FnOnce<T>`, but it seems to. I would have expected it to crash like it does when passing `dyn FnOnce()` as the type.

changelog: [`needless_pass_by_value`](https://rust-lang.github.io/rust-clippy/master/#needless_pass_by_value) Fix ICE in with unsized `dyn Fn` argument

22 months agoFix ICE in `needless_pass_by_value` with unsized `dyn Fn`
Jason Newcomb [Sat, 24 Sep 2022 21:07:35 +0000 (17:07 -0400)]
Fix ICE in `needless_pass_by_value` with unsized `dyn Fn`

22 months agoseparate definitions and `HIR` owners
Takayuki Maeda [Tue, 20 Sep 2022 05:11:23 +0000 (14:11 +0900)]
separate definitions and `HIR` owners

fix a ui test

use `into`

fix clippy ui test

fix a run-make-fulldeps test

implement `IntoQueryParam<DefId>` for `OwnerId`

use `OwnerId` for more queries

change the type of `ParentOwnerIterator::Item` to `(OwnerId, OwnerNode)`

22 months agoAdd `cargo lintcheck --recursive` to check dependencies of crates
Alex Macleod [Wed, 21 Sep 2022 12:29:05 +0000 (12:29 +0000)]
Add `cargo lintcheck --recursive` to check dependencies of crates

22 months agoAuto merge of #9527 - nyurik:inl2, r=llogiq
bors [Sat, 24 Sep 2022 06:41:17 +0000 (06:41 +0000)]
Auto merge of #9527 - nyurik:inl2, r=llogiq

fallout2: rework clippy_dev & _lints fmt inlining

Continuing #9525 -- a few more inlining, but this time with some code changes to simplify format strings:

* Inline format args where possible
* simplify a few complex macros into format str
* use formatdoc!() instead format!(indoc!(...))

changelog: none

cc: `@llogiq`

22 months agofallout2: rework clippy_dev & _lints fmt inlining
Yuri Astrakhan [Sat, 24 Sep 2022 02:20:42 +0000 (22:20 -0400)]
fallout2: rework clippy_dev & _lints fmt inlining

* Inline format args where possible
* simplify a few complex macros into format str
* use formatdoc!() instead format!(indoc!(...))

22 months agoAuto merge of #102068 - cjgillot:erased-lifetime-print, r=eholk
bors [Sat, 24 Sep 2022 01:23:17 +0000 (01:23 +0000)]
Auto merge of #102068 - cjgillot:erased-lifetime-print, r=eholk

Always print '_, even for erased lifetimes.

Explicit lifetime arguments are now the recommended syntax in rust 2018 and rust 2021.  This PR applies this discipline to rustc itself.

22 months agoAuto merge of #9525 - nyurik:apply-lints, r=llogiq
bors [Fri, 23 Sep 2022 21:02:02 +0000 (21:02 +0000)]
Auto merge of #9525 - nyurik:apply-lints, r=llogiq

pre-fallout: Apply uninlined_format-args lint

This change is needed for the uninlined_format-args lint to be merged. See https://github.com/rust-lang/rust-clippy/pull/9233

changelog: none

22 months agoFix clippy's const fn stability check for CURRENT_RUSTC_VERSION
Nilstrieb [Fri, 23 Sep 2022 19:04:54 +0000 (21:04 +0200)]
Fix clippy's const fn stability check for CURRENT_RUSTC_VERSION

Since clippy can use a projects MSRV for its lints, it might not want
to consider functions as const stable if they have been added lately.

Functions that have been stabilized this version use
CURRENT_RUSTC_VERSION as their version, which gets then turned into the
current version, which might be something like `1.66.0-dev`. The version
parser cannot deal with this version, so it has to be stripped off.

22 months agoStabilize const `BTree{Map,Set}::new`
Nilstrieb [Fri, 23 Sep 2022 16:03:44 +0000 (18:03 +0200)]
Stabilize const `BTree{Map,Set}::new`

Since `len` and `is_empty` are not const stable yet, this also
creates a new feature for them since they previously used the same
`const_btree_new` feature.

22 months agoand a few more from other dirs
Yuri Astrakhan [Fri, 23 Sep 2022 18:25:03 +0000 (14:25 -0400)]
and a few more from other dirs

22 months agoa few more core lint fixes
Yuri Astrakhan [Fri, 23 Sep 2022 17:55:30 +0000 (13:55 -0400)]
a few more core lint fixes

22 months agoApply uninlined_format-args to clippy_lints
Yuri Astrakhan [Fri, 23 Sep 2022 17:42:59 +0000 (13:42 -0400)]
Apply uninlined_format-args to clippy_lints

This change is needed for the uninlined_format-args lint to be merged.
See https://github.com/rust-lang/rust-clippy/pull/9233

22 months agoBless clippy.
Camille GILLOT [Thu, 22 Sep 2022 17:39:38 +0000 (19:39 +0200)]
Bless clippy.

22 months agoAuto merge of #9496 - yotamofek:never_loop_let_else, r=Jarcho
bors [Fri, 23 Sep 2022 16:06:49 +0000 (16:06 +0000)]
Auto merge of #9496 - yotamofek:never_loop_let_else, r=Jarcho

[`never_loop`]: Fix FP with let..else statements.

Fixes #9356

This has been bugging me for a while, so I thought I'd take a stab at it! I'm completely uncertain about the quality of my code, but I think it's an alright start, so opening this PR to get some feedback from more experienced clippy people :)

changelog: [`never_loop`]: Fix FP with let..else statements

22 months agoAuto merge of #9523 - smoelius:compiletest-rs, r=Alexendoo
bors [Fri, 23 Sep 2022 15:52:27 +0000 (15:52 +0000)]
Auto merge of #9523 - smoelius:compiletest-rs, r=Alexendoo

Upgrade `compiletest-rs` dependency

From `0.8` to `0.9`.

The new version includes a [fix](https://github.com/Manishearth/compiletest-rs/pull/259) for what I suspect was one cause of the recent rustup failure: https://github.com/rust-lang/rust-clippy/actions/runs/3106438892/jobs/5033324694#step:11:911

changelog: none

22 months agoAuto merge of #9519 - alessandrod:uninit-set-len-0, r=llogiq
bors [Fri, 23 Sep 2022 15:37:13 +0000 (15:37 +0000)]
Auto merge of #9519 - alessandrod:uninit-set-len-0, r=llogiq

uninit_vec: fix false positive with set_len(0)

`set_len(0)` does not create uninitialized elements. Fixes a false positive with the following pattern:

```rust
fn copy_slice_into_vec(dst: &mut Vec<u8>, src: &[u8]) {
    dst.reserve(src.len().saturating_sub(dst.len()));
    unsafe {
        dst.set_len(0);
        std::ptr::copy_nonoverlapping(src.as_ptr(), dst.as_mut_ptr(), src.len());
        dst.set_len(src.len());
    }
}
```

zulip thread: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/uninit_vec.20and.20set_len.280.29

changelog: FP: [`uninit_vec`]: No longer lints `Vec::set_len(0)`

22 months agoAuto merge of #102056 - b-naber:unevaluated, r=lcnr
bors [Fri, 23 Sep 2022 13:39:11 +0000 (13:39 +0000)]
Auto merge of #102056 - b-naber:unevaluated, r=lcnr

Introduce mir::Unevaluated

Previously the distinction between unevaluated constants in the type-system and in mir was not explicit and a little confusing. Probably better to introduce its own type for that.

r? `@lcnr`

22 months agorename Unevaluated to UnevaluatedConst
b-naber [Thu, 22 Sep 2022 10:34:23 +0000 (12:34 +0200)]
rename Unevaluated to UnevaluatedConst

22 months agoUpgrade `copiletest-rs` dependency
Samuel Moelius [Fri, 23 Sep 2022 09:53:42 +0000 (05:53 -0400)]
Upgrade `copiletest-rs` dependency

22 months agouninit_vec: special case set_len(0)
Alessandro Decina [Thu, 22 Sep 2022 23:06:13 +0000 (00:06 +0100)]
uninit_vec: special case set_len(0)

set_len(0) does not create uninitialized elements. Fixes a false positive with
the following pattern:

    fn copy_slice_into_vec(dst: &mut Vec<u8>, src: &[u8]) {
        dst.reserve(src.len().saturating_sub(dst.len()));
        unsafe {
            dst.set_len(0);
            std::ptr::copy_nonoverlapping(src.as_ptr(), dst.as_mut_ptr(), src.len());
            dst.set_len(src.len());
        }
    }

22 months agoRollup merge of #102123 - schteve:clippy-note, r=Manishearth
Matthias Krüger [Thu, 22 Sep 2022 19:34:51 +0000 (21:34 +0200)]
Rollup merge of #102123 - schteve:clippy-note, r=Manishearth

Add note to clippy::non_expressive_names doc

Addresses confusion in rust-lang/rust-clippy#9514 by updating the lint docs.

22 months agoAdd test with `unsafe` block to check #9503 is fixed too
kraktus [Thu, 22 Sep 2022 14:44:21 +0000 (16:44 +0200)]
Add test with `unsafe` block to check #9503 is fixed too

s

22 months agoMake `semicolon_span` code more refactor-tolerant
kraktus [Thu, 22 Sep 2022 14:33:14 +0000 (16:33 +0200)]
Make `semicolon_span` code more refactor-tolerant