Commit graph

8276 commits

Author SHA1 Message Date
Alex Macleod
9226066bcb FormatArgsExpn: Find comma spans and ignore weird proc macro spans 2022-10-05 16:10:52 +00:00
Caio
a44914fcd3 Dogfood 2022-10-03 20:10:00 -03:00
Caio
2a6a98f95b [arithmetic-side-effects] Do not ignore literal references 2022-10-03 19:49:03 -03:00
bors
e8c1b5478c Auto merge of #9559 - c410-f3r:arith, r=Alexendoo
Fix #9544

Fix #9544

r? `@Alexendoo`

changelog: [`arithmetic_side_effects`]: Fix false negative for `CustomType / usize`, `CustomType * float` and similar
2022-10-03 21:54:08 +00:00
Caio
99363fef65 Address comments 2022-10-03 18:36:12 -03:00
bors
5825ae7bd4 Auto merge of #9581 - ebobrow:mul-add-negative, r=Manishearth
`suboptimal_flops` lint for multiply and subtract

fixes #9526

changelog: [`suboptimal_flops`] lint for multiply and subtract
2022-10-03 17:12:10 +00:00
royrustdev
f1c831ad17 add implicit_saturating_add lint 2022-10-03 16:46:38 +05:30
Elliot Bobrow
15431b36bb
Merge branch 'master' into mul-add-negative 2022-10-02 21:27:57 -07:00
Elliot Bobrow
7747032b77 suboptimal_flops lint for multiply and subtract 2022-10-02 21:00:51 -07:00
TennyZhuang
bf18768219 let upper_case_acronyms check the enum name
Signed-off-by: TennyZhuang <zty0826@gmail.com>
2022-10-03 10:11:57 +08:00
Jason Newcomb
38236a7135 Use for_each_expr in place of some visitors 2022-10-02 17:15:19 -04:00
Jason Newcomb
649d443646 Replace expr_visitor with for_each_expr 2022-10-02 17:04:22 -04:00
bors
bef93d3b14 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
2022-10-02 19:46:46 +00:00
bors
0341198ba1 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
2022-10-02 19:06:58 +00:00
Jason Newcomb
162aa19793 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`
2022-10-02 15:02:55 -04:00
Jason Newcomb
8e7af6b429 Replace is_lang_ctor with is_res_lang_ctor 2022-10-02 14:50:37 -04:00
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
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
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
Alex Macleod
52a68dc097 lint nested patterns and slice patterns in needless_borrowed_reference 2022-10-01 22:31:10 +00:00
Alex Macleod
a834ac9800 Only run x86 asm doctests on x86 2022-10-01 22:27:38 +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
Andre Bogus
eef5d477b5 use is_integer_literal more 2022-10-01 17:55:22 +02:00
Andre Bogus
3757a0e903 avoid doc-link-with-quotes in code blocks 2022-10-01 15:25:37 +02:00
Caio
4876882b29 Fix #9544 2022-09-30 15:30:40 -03: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
85b8ff7f38
Fix style in if let chain
Co-authored-by: Alex Macleod <alex@macleod.io>
2022-09-30 11:36:55 -04: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
67af127f24
Fix dogfood 2022-09-29 12:02:58 +02: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
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