Commit Graph

9219 Commits

Author SHA1 Message Date
Samuel Tardieu
69da902f41 Detect if expressions with boolean assignments to the same target 2023-04-23 13:44:49 +02:00
Arpad Borsos
7077bde9d2
Fix typo in significant_drop_tightening 2023-04-20 20:59:59 +02:00
Caio
0b16f80c40 [arithmetic_side_effects] Cache symbols 2023-04-20 14:59:02 -03: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
bors
523c8fa2ed Auto merge of #10615 - c410-f3r:bbbbbbbbbbb, r=giraffate
[arithmetic_side_effects] Fix #10590

Fix #10590

changelog: [`arithmetic_side_effects`]: Detect integer methods that can introduce side effects
2023-04-20 13:27:22 +00:00
bors
4d35b5e27b Auto merge of #10668 - xFrednet:changelog-1-69, r=flip1995
Changelog for Rust 1.69 🌸

Roses are blue,
Violets are red,
Something is wrong,
We still commit!

---

changelog: none
2023-04-19 17:24:44 +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
xFrednet
747ff0656b
Update version attribute for 1.69 lints 2023-04-19 14:55:18 +02: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
a2580db642
Use clippy_utils::std_or_core in manual slice size calculation lint 2023-04-17 21:19:49 +02: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
Caio
d6390625dc Address comments 2023-04-15 16:05:46 -03: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
d9c2957221 Auto merge of #10629 - Alexendoo:as-ptr-cast-mut-docs-ub, r=Jarcho
Fix UB in `as_ptr_cast_mut` documentation

changelog: none

Fixes #10628

There's no `String::as_mut_ptr` surprisingly, so the example is actually calling `str::as_mut_ptr` on an empty `str`
2023-04-12 16:47:34 +00:00
bluthej
6409556926 Standardize lint formulation 2023-04-12 13:48:03 +02:00
Alex Macleod
8f979af3d1 Fix UB in as_ptr_cast_mut documentation 2023-04-11 11:17:18 +00:00
Michael Schubart
008ba7326b Ignore fake read access 2023-04-11 10:32:09 +09:00
Michael Schubart
63030acf4f Refactor 2023-04-11 10:27:32 +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
bors
4904d754e0 Auto merge of #10624 - the8472:remove-drain-filter-feature, r=xFrednet
remove unusued `#![feature(drain_filter)]`

The unstable feature does not appear to be used and its presence blocks work in https://github.com/rust-lang/rust/pull/104455

changelog: none
2023-04-10 12:55:50 +00:00
The 8472
d6fe73db3f remove unusued feature 2023-04-10 13:13:09 +02:00
Kisaragi
ba1f19ee30
apply code review suggestion
Co-authored-by: llogiq <bogusandre@gmail.com>
2023-04-10 01:31:30 +09:00
Kisaragi
5109a8a840
[missing_const_for_fn] fix #7121 2023-04-10 00:55:32 +09:00
bluthej
d8f0a96ba2
Merge branch 'rust-lang:master' into clear-with-drain 2023-04-09 13:40:52 +02:00
bluthej
7852962820 Change format! style to please dogfood test 2023-04-09 13:37:02 +02:00
bluthej
423b54ac12 Update documentation for clear_with_drain
The specific type `Vec` is replaced with the generic term 'container'
2023-04-09 13:29:27 +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
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
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
Oli Scherer
e9c7fb10b9 Rename ast::Static to ast::StaticItem to match ast::ConstItem 2023-04-04 15:34:40 +00:00