Commit graph

5605 commits

Author SHA1 Message Date
Alex Macleod
397f36a78c Fix #[allow(clippy::enum_variant_names)] directly on variants 2023-04-22 14:53:15 +00:00
bors
06dace2920 Auto merge of #10669 - oli-obk:@, r=Alexendoo
Update to a compiletest-rs version that requires `//@` for commands

Requires https://github.com/Manishearth/compiletest-rs/pull/261 to get published

This PR is a smaller step towards https://github.com/rust-lang/rust-clippy/pull/10426

changelog: Move to a version of compiletest-rs that allows us to require `//`@`` for test suite commands.
2023-04-20 14:51:33 +00:00
Oli Scherer
def1705a27 Update to a compiletest-rs version that requires //@ for commands 2023-04-20 14:44:03 +00:00
Caio
3db7352b81 [arithmetic_side_effects] Fix #10590 2023-04-19 10:58:00 -03:00
bors
f1a552ccec Auto merge of #10203 - c410-f3r:macro-lint, r=giraffate
Suppress the triggering of some lints in derived structures

Fixes #10185
Fixes #10417

For `integer_arithmetic`, `arithmetic_side_effects` and `shadow_reuse`.

* ~~Not sure how to test these use-cases so feel free to point any method or any related PR.~~

---

changelog: FP: [`integer_arithmetic`], [`arithmetic_side_effects`]: No longer lint inside proc macros
[#10203](https://github.com/rust-lang/rust-clippy/pull/10203)
<!-- changelog_checked -->
2023-04-19 12:56:19 +00:00
bors
0c44586ff7 Auto merge of #10651 - lukaslueg:issue10641, r=xFrednet
Add size-parameter to unecessary_box_returns

Fixes #10641

This adds a configuration-knob to the `unecessary_box_returns`-lint which allows _not_ linting a `fn() -> Box<T>` if `T` is "large". The default byte size above which we no longer lint is 128 bytes (due to https://github.com/rust-lang/rust-clippy/issues/4652#issue-505670554, also used in #9373). The overall rational is given in #10641.

---

changelog: Enhancement: [`unnecessary_box_returns`]: Added new lint configuration `unnecessary-box-size` to set the maximum size of `T` in `Box<T>` to be linted
[#10651](https://github.com/rust-lang/rust-clippy/pull/10651)
<!-- changelog_checked -->
2023-04-19 12:42:33 +00:00
Lukas Lueg
4bc68f9c60 Add size-parameter to unecessary_box_returns
Fixes #10641
2023-04-19 14:32:05 +02:00
Alex Macleod
2f4f798f9b Ignore manual_slice_size_calculation in code from macro expansions 2023-04-18 17:54:26 +00:00
timvisee
b8fee8b504
Add run-rustfix marker and test file 2023-04-17 21:19:44 +02:00
timvisee
503fd56a42
Suggest applicable expression for manual slice size calculation lint 2023-04-17 20:31:25 +02:00
timvisee
4fb38cfb29
Rename std::mem::size_of_value to std::mem::size_of_val 2023-04-17 18:02:04 +02:00
Manish Goregaokar
b2edd42b24
Merge pull request #10603 from robertbastian/octal
Fix false positives and false negatives in `octal_escapes`
2023-04-13 15:50:00 -07:00
bors
0d06001449 Auto merge of #10621 - fee1-dead-contrib:bump_syn, r=flip1995
bump syn to 2.0

changelog: none
2023-04-12 08:27:12 +00:00
Deadbeef
d406f653c9 bless test error 2023-04-12 09:06:51 +08:00
Deadbeef
3813b8e10d Update ui tests auxiliary to syn 2.0 2023-04-12 08:51:11 +08:00
Michael Schubart
b85deea3f5 Test all types supported by [collection_is_never_read] 2023-04-11 12:27:25 +09:00
Michael Schubart
3d711455c2 Add test case from #10488 2023-04-11 10:37:00 +09:00
Michael Schubart
008ba7326b Ignore fake read access 2023-04-11 10:32:09 +09:00
bors
5ec2e192f5 Auto merge of #10614 - bluthej:clear-with-drain, r=Manishearth
Clear with drain

Fixes #10572: both the original intent of the issue (extending `clear_with_drain`) and the false negative for `collection_is_never_read` I found in the process are fixed by this PR.

changelog: [`clear_with_drain`]: extend to 5 other types of containers. [`collection_is_never_read`]: fix false negative for `String`s.
2023-04-11 00:29:21 +00:00
bors
e22019d0b7 Auto merge of #10593 - feniljain:fix-needless-return, r=xFrednet
fix(needless_return): do not trigger on ambiguous match arms return

If we see a case where match returns something other than `()`, we just skip `needless_return` lint in that case

Should fix #10546

Relevant Zulip Discussion: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Issue.20.2310546

---

changelog: FP: [`needless_return`]: No longer lints match statements with incompatible branches
[#10593](https://github.com/rust-lang/rust-clippy/pull/10593)
<!-- changelog_checked -->
2023-04-10 21:52:47 +00:00
bluthej
d8f0a96ba2
Merge branch 'rust-lang:master' into clear-with-drain 2023-04-09 13:40:52 +02:00
bluthej
32aa07f832 Fix false negative for Strings
`String` is not a diagnostic item and was thus not picked up by
`is_type_diagnostic_item`, leading to a false negative for
`collection_is_never_read`
2023-04-09 13:25:50 +02:00
Caio
cd0009eb30 Suppress the triggering of some lints in derived structures 2023-04-09 08:16:20 -03:00
bluthej
5b57e5cec8 Fix false negative with String and add tests
`String` is currently not a diagnostic item so it needs special
treatment
2023-04-09 12:33:20 +02:00
bluthej
9ec542873c Add 5 other container types and start testing 2023-04-07 16:07:43 +02:00
y21
5d01e6e96c new lint: suspicious_doc_comments 2023-04-07 12:04:55 +02:00
bors
b8cbce8e6a Auto merge of #10601 - schubart:manual_slice_size_calculation, r=llogiq
Add [`manual_slice_size_calculation`]

Fixes: #10518

---

changelog: new lint [`manual_slice_size_calculation`]
2023-04-07 07:39:11 +00:00
bors
9408d013e3 Auto merge of #10566 - ebobrow:iss10549, r=giraffate
fix `single_component_path_imports` FP on `self::<import>::..`

fixes #10549

I noticed that a couple functions in the file I was working on took `cx` as a parameter but didn't use them, so I removed that. Can revert if desired because it isn't related to my changes.

changelog: [`single_component_path_imports`] don't suggest removing import when it is used as `self::<import>::..`
2023-04-07 00:14:45 +00:00
Michael Schubart
b1c784d31f Fix false negatives by using expr_or_init 2023-04-07 08:00:53 +09:00
Robert Bastian
67e836d4cf fix 2023-04-06 16:31:50 +02:00
bors
de5c6d6b1e Auto merge of #10594 - J-ZhengLi:issue9824, r=Jarcho
fix [`mem_replace_option_with_none`] not considering field variables

fixes: #9824

---

changelog: fix [`mem_replace_option_with_none`] not considering field variables
2023-04-06 14:01:08 +00:00
Michael Schubart
b47a322ef1 Add tests suggested by @llogiq 2023-04-06 13:45:50 +01:00
Michael Schubart
b66aa09b95 Add [manual_slice_size_calculation] 2023-04-06 11:48:20 +01:00
Philipp Krones
04c387efe7
Merge remote-tracking branch 'upstream/master' into rustup 2023-04-06 12:32:32 +02:00
J-ZhengLi
008e07d4e8 fix [mem_replace_option_with_none] not considering field variables 2023-04-06 16:16:22 +08:00
bors
26e245d2ff Auto merge of #10554 - samueltardieu:redundant-async-block, r=Jarcho
Make redundant_async_block a more complete late pass

This lets us detect more complex situations: `async { x.await }` is simplified into `x` if:

- `x` is an expression without side-effect
- or `x` is an `async` block itself

In both cases, no part of the `async` expression can be part of a macro expansion.

Fixes #10509.
Fixes #10525.

changelog: [`redundant_async_block`] Do not lint expressions with side effects.
2023-04-05 18:31:32 +00:00
feniljain
9cf57d0a8f fix(needles_return): correct span selection for text replacement 2023-04-05 20:03:45 +05:30
feniljain
b499b7dc73 test: add test for match as stmt no triggering needless_return 2023-04-05 19:50:12 +05:30
Samuel "Sam" Tardieu
2891d8f72f Make redundant_async_block a more complete late pass
This lets us detect more complex situations: `async { x.await }` is
simplified into `x` if:

- `x` is an expression without side-effect
- or `x` is an async block itself

In both cases, no part of the `async` expression can be part of a macro
expansion.
2023-04-05 10:06:01 +02:00
bors
5d149c5dac Auto merge of #10543 - blyxyas:tests_outside_test_module, r=flip1995
Add `tests_outside_test_module` lint

Adds `tests_outside_test_module` from #10506. This PR **doesn't** close the issue, just resolves task 1.

changelog: [`tests_outside_test_module`]: The lint has been added
2023-04-04 09:46:50 +00:00
feniljain
c12748fab3 fix(needless_return): do not trigger on ambiguous match arms return 2023-04-04 09:44:49 +05:30
blyxyas
a37eb4dfc9
Fix false negative on Result<(), ()> 2023-04-03 16:07:17 +02:00
blyxyas
d602743558
only focus on double_must_use + Add Result<(), ()> test 2023-04-03 15:16:18 +02:00
blyxyas
e2742a0ea2
Fix double_must_use for async functions 2023-04-03 01:27:53 +02:00
bors
7fe83edc11 Auto merge of #10588 - blyxyas:fix-allow_nonminimal_bool, r=llogiq
Fix `nonminimal_bool` `#[allow]` attributes.

Closes #10435
changelog: [`nonminimal_bool`]: Fix false-positive where the lint ignore `#[allow]` attributes.

r? `@llogiq`
2023-04-02 22:12:46 +00:00
bors
8f0ba1f2e0 Auto merge of #10563 - nyurik:handle-all-fmt2, r=llogiq
Partial no-op refactoring of #9948

This contains some prep work for #9948 to keep that change to the minimum, and make it easier to review it.

This should be a noop, but it has some tests from that PR discussion, and should help in the future with the corner case format handling.

cc: `@Alexendoo` `@llogiq` `@xFrednet`  as the 3 people who reviewed the parent PR

----

changelog: none
2023-04-02 17:08:20 +00:00
blyxyas
36047b0216
Fix nonminimal_bool #[allow] attributes. 2023-04-02 16:18:03 +02:00
Caio
05650b7215 [arithmetic_side_effects] Fix #10583 2023-04-02 07:50:25 -03:00
blyxyas
b2856a763e
Add tests_outside_test_module lint 2023-04-02 00:35:46 +02:00
bors
ac4838c554 Auto merge of #10534 - samueltardieu:lines-filter-map-ok, r=llogiq
Flag `bufreader.lines().filter_map(Result::ok)` as suspicious

This lint detects a problem that happened recently in https://github.com/uutils/coreutils and is described in https://github.com/rust-lang/rust/issues/64144.

changelog: [`lines_filter_map_ok`]: new lint
2023-04-01 12:41:08 +00:00