Commit Graph

5667 Commits

Author SHA1 Message Date
blyxyas
54912410c7
Wildcard_imports ignore test.rs files 2023-05-08 18:24:58 +02:00
NotAPenguin
56e8e1a27d new lint: clippy::ref_patterns 2023-05-08 13:20:33 +02:00
Alex Macleod
68eb864c91 Ignore expressions from macros in default_constructed_unit_structs 2023-05-05 18:35:54 +00:00
Philipp Krones
88c7632659
Merge remote-tracking branch 'upstream/master' into rustup 2023-05-05 17:29:35 +02:00
bors
f9c1d155b4 Auto merge of #10716 - Icxolu:unitstruct_default_construction, r=Manishearth
Fixes #10609: Adds lint to detect construction of unit struct using `default`

Using `default` to construct a unit struct increases code complexity and adds a function call. This can be avoided by simply removing the call to `default` and simply construct by name.

changelog: [`default_constructed_unit_structs`]: detects construction of unit structs using `default`

fixes #10609
2023-05-03 21:43:02 +00:00
Icxolu
160371550f add rustfix annotation 2023-05-03 21:05:50 +02:00
Icxolu
4ed7fd1ecc fix failing tests 2023-05-03 20:55:14 +02:00
Icxolu
8701009860 add more test cases 2023-05-03 20:55:14 +02:00
Icxolu
4e04903631 rename to plural form 2023-05-03 19:25:25 +02:00
Dylan DPC
eac589b4e4 Rollup merge of #110955 - fee1-dead-contrib:sus-operation, r=compiler-errors
uplift `clippy::clone_double_ref` as `suspicious_double_ref_op`

Split from #109842.

r? ``@compiler-errors``
2023-05-02 11:44:52 +05:30
Icxolu
220a9db642 fixed span and corrected test output 2023-05-01 20:12:34 +02:00
y21
9613ea85c6 fix run-rustfix directive 2023-04-29 19:10:52 +02:00
y21
8d8178f931 rename lint to manual_while_let_some 2023-04-29 18:59:07 +02:00
y21
1d08325293 move lint to loops, emit proper suggestion, more tests 2023-04-29 18:59:07 +02:00
y21
bb58083ce5 new lint: while_pop_unwrap 2023-04-29 18:59:06 +02:00
bors
3594d55439 Auto merge of #10719 - blyxyas:fix-items_after_test_mod_imported_modules, r=Alexendoo
Fix `items_after_test_module`: Ignore imported modules

Fixes #10713. It does a little bit of dark magic, but intention is what really counts.
changelog:[`items_after_test_module`]: Ignore imported modules (`mod foo;`) with no body.
2023-04-28 18:42:58 +00:00
blyxyas
395b1f5bf3
Rename items + Delete imported_module.stderr 2023-04-28 20:40:47 +02:00
blyxyas
2b5820d58b
Change module import system 2023-04-28 20:23:05 +02:00
Deadbeef
81a614145f uplift clippy::clone_double_ref as suspicious_double_ref_op 2023-04-28 17:24:48 +00:00
Michael Goulet
83504fa763 Make clippy happy 2023-04-27 17:18:12 +00:00
blyxyas
273c898aef
Fix #10713 and move the tests to a subdir 2023-04-27 16:43:51 +02:00
Icxolu
9428138562 adds lint to detect construction of unit struct using default
Using `default` to construct a unit struct increases code complexity and
adds a function call. This can be avoided by simply removing the call to
`default` and simply construct by name.
2023-04-26 21:12:59 +02:00
Centri3
14a6fa4a34 use in_external_macro 2023-04-25 05:06:45 -05:00
Centri3
1ac30d3c86 make cargo test pass 2023-04-25 05:06:11 -05:00
Centri3
8efe9ff9fb run cargo dev fmt 2023-04-25 05:06:11 -05:00
Centri3
acfb2c45ba don't check if from macro invocation 2023-04-25 05:06:11 -05:00
bors
c4f2c48d9b Auto merge of #10702 - blyxyas:fix-let_underscore_untyped_help_message, r=Manishearth
Improve the help message + add a help span

This would close #10410, because it applies the general consensus achieved in that issue (that replacing `let _ = ...` to `_ = ...` doesn't present any benefits).

I also added a little help message span.

changelog:[`let_underscore_untyped`]: Fix the help message confusion + add a help message span.
2023-04-24 20:28:34 +00:00
bors
30db6edf36 Auto merge of #10707 - y21:redudant_pattern_matching_rest_pat, r=Manishearth
check for `..` pattern in `redundant_pattern_matching`

The `redundant_pattern_matching` lint currently checks for `if let Some(_) = ...`, but not for `if let Some(..) = ...`.
This PR makes sure to also check for the `..` pattern in tuple structs.
It also found one such instance in clippy itself so that shows it's worth checking for this pattern as well 😅

changelog: [`redundant_pattern_matching`]: check for `..` pattern in tuple structs
2023-04-24 19:33:53 +00:00
bors
4b6fdb4dff Auto merge of #10683 - Centri3:allow-attributes, r=Alexendoo
Fix false positive in `allow_attributes`

This would emit a warning if used in a proc-macro with the feature `lint_reasons` enabled. This is now fixed.

changelog: [`allow_attributes`]: Don't lint if in external macro
2023-04-24 17:52:17 +00:00
Centri3
3045998bcc Update allow_attributes_false_positive.rs 2023-04-24 12:01:29 -05:00
bors
5161c4ce4d Auto merge of #10697 - lochetti:fix_9757, r=dswij
Ignore `shadow` warns in code from macro expansions

This PR fixes https://github.com/rust-lang/rust-clippy/issues/9757

I am in doubt if just looking for `pat.span.from_expansion()` would be sufficient instead of looking for both `pat.span.desugaring_kind().is_some()` or `pat.span.from_expansion()`. The tests (including the new one) passes if I leave the only `if pat.span.from_expansion()`. Any feedbacks?

Also, this is my first PR here, sorry for anything and thanks for the patience!

changelog: [`shadow_same`, `shadow_reuse`, `shadow_unrelated`]: avoiding warns in macro-generated code
2023-04-24 06:25:52 +00:00
bors
96f8471d81 Auto merge of #10649 - jsoref:spelling, r=Jarcho
Spelling

This PR corrects misspellings identified by the [check-spelling action](https://github.com/marketplace/actions/check-spelling).

The misspellings have been reported at https://github.com/jsoref/rust-clippy/actions/runs/4710771873#summary-12776860721

The action reports that the changes in this PR would make it happy: https://github.com/jsoref/rust-clippy/actions/runs/4710771874#summary-12776860722

changelog: none
2023-04-23 22:30:06 +00:00
y21
e8726b20b2 also check for rest pat in redundant_pattern_matching 2023-04-23 21:34:42 +02:00
bors
7a870aef1a Auto merge of #10432 - samueltardieu:issue-10430, r=Manishearth
New lint: detect `if` expressions with simple boolean assignments to the same target

Closes #10430

changelog: [`needless_bool_assign`] new lint to detect simple boolean assignment to the same target in `if` branches
2023-04-23 15:47:00 +00:00
Josh Soref
d2061faf9e Spelling
* applying
* binding
* complex
* constituent
* demonstrate
* desugaring
* exact
* expression
* for
* functionalities
* github
* implementation
* infers
* multiple conflicting traits
* mutable
* necessarily
* nightly
* nonexistent
* optional
* parameter
* reassignments
* resources
* substitution
* suggestion
* that
* that array is
* using the

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-23 10:52:27 -04:00
bors
e1f6305ecf Auto merge of #10704 - matthiaskrgr:splitest, r=llogiq
split test into 2

changelog: none
2023-04-23 13:44:57 +00:00
bors
496c11005c Auto merge of #10679 - y21:better-const-ctx-check, r=Jarcho
use `is_inside_const_context` for `in_constant` util fn

Fixes #10452.

This PR improves the `in_constant` util function to detect more cases of const contexts. Previously this function would not detect cases like expressions in array length position or expression in an inline const block `const { .. }`.

changelog: [`bool_to_int_with_if`]: recognize array length operand as being in a const context and don't suggest `usize::from` there
2023-04-23 13:33:51 +00:00
bors
316d83a4d8 Auto merge of #10670 - lukaslueg:issue10634, r=Jarcho
Don't suggest `suboptimal_flops` unavailable in nostd

Fixes #10634

changelog: Enhancement: [`suboptimal_flops`]: Do not suggest `{f32,f64}::abs()` or `{f32,f64}::mul_add()` in a `no_std`-environment.
2023-04-23 13:23:48 +00:00
Matthias Krüger
572eecd267 split test into 2 2023-04-23 15:11:31 +02:00
Samuel Tardieu
69da902f41 Detect if expressions with boolean assignments to the same target 2023-04-23 13:44:49 +02:00
Philipp Krones
a1b75c5108 Merge commit 'a3ed905928a03b6e433d0b429190bf3a847128b3' into clippyup 2023-04-23 13:28:56 +02:00
bors
f16bfa478f Auto merge of #10703 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2023-04-23 11:07:14 +00:00
bors
a3ed905928 Auto merge of #10578 - blyxyas:items_after_test_module, r=dswij
Add `items_after_test_module` lint

Resolves task *3* of #10506, alongside *1* resolved at #10543 in an effort to help standarize a little bit more testing modules.

---

changelog:[`items_after_test_module`]: Added the lint.
2023-04-23 10:56:50 +00:00
blyxyas
acf50a7dc6
Improve the help message + add a help span 2023-04-23 12:52:45 +02:00
Philipp Krones
583c97e9bb
Merge remote-tracking branch 'upstream/master' into rustup 2023-04-23 03:39:03 -07:00
bors
419552227f Auto merge of #10701 - blyxyas:fix-fp-let_underscore_untyped, r=llogiq
Bugfix: Ignore `impl Trait`(s) @ `let_underscore_untyped`

Fixes #10411

changelog:[`let_underscore_untyped`]: Ignore `impl Trait`(s) that caused false positives.
2023-04-23 10:13:41 +00:00
blyxyas
bdd05456b1
Ignore impl Trait(s) 2023-04-23 12:09:36 +02:00
bors
6328371d24 Auto merge of #10681 - J-ZhengLi:issue10529, r=flip1995
make [`len_zero`] lint not spanning over parenthesis

sorry it should be a quick fix but I was caught up by other stuffs last couple weeks 🤦‍♂️

---

fixes: #10529

changelog: make [`len_zero`] lint not spanning over parenthesis
2023-04-23 09:50:16 +00:00
Renato Lochetti
628605e07a
Ignore shadow warns in code from macro expansions 2023-04-22 20:28:08 +01:00
blyxyas
1ac8dc51bc
Compact emmited lint 2023-04-22 21:12:55 +02:00