Commit graph

5883 commits

Author SHA1 Message Date
y21
a239c8b52b [unnecessary_lazy_eval]: don't lint on types with deref impl 2023-06-02 00:06:34 +02:00
Centri3
eed466281c ignore Foo::deref altogether 2023-06-01 14:29:56 -05:00
est31
0a7366897d manual_let_else: only add () around PatKind::Or at the top level
At the top level, () are required, but on the levels below they are not.
2023-06-01 18:55:24 +02:00
MarcusGrass
b2c85b31bb
Move bail into lint to prevent no-linting, move to unfixable 2023-06-01 16:02:42 +02:00
MarcusGrass
16f1cf8fd4
Ignore from_over_into if it contains Self 2023-06-01 10:46:29 +02:00
Centri3
8188da3614 Fix suggestion on fully qualified syntax 2023-05-31 23:33:30 -05:00
Centri3
04b7cae37e refine output 2023-05-31 17:30:23 -05:00
Centri3
97a0ccc1d3 implement host_endian_bytes and the other two 2023-05-31 17:30:23 -05:00
Centri3
3ab6aeefb1 to_xx_bytes implemented, from_xx_bytes todo
Mentioned in #10765
2023-05-31 17:30:23 -05:00
y21
a859b0e6df don't lint enums, update note in lint description 2023-05-31 23:52:02 +02:00
y21
f74ec6b1b8 new lint: missing_field_in_debug
move some strings into consts, more tests

s/missing_field_in_debug/missing_fields_in_debug

dont trigger in macro expansions

make dogfood tests happy

minor cleanups

replace HashSet with FxHashSet

replace match_def_path with match_type

if_chain -> let chains, fix markdown, allow newtype pattern

fmt

consider string literal in `.field()` calls as used

don't intern defined symbol, remove mentions of 'debug_tuple'

special-case PD, account for field access through `Deref`
2023-05-31 23:52:02 +02:00
MarcusGrass
d4b388eb43
Add from_over_into replace for type in Self reference 2023-05-31 17:46:05 +02:00
bors
e85869578d Auto merge of #10845 - disco07:master, r=giraffate
nonminimal_bool fix double not

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

changelog: Fix [`nonminimal_bool`] false positive when `!!x`, `x` isn't boolean and implements `Not`
2023-05-31 13:36:09 +00:00
Urgau
1a5db18b11 Drop uplifted clippy::cast_ref_to_mut 2023-05-31 13:42:53 +02:00
disco07
e4927f98fa change booleans file and update tests 2023-05-31 00:17:26 +02:00
y21
d816eba09d fix new failing proc macro tests 2023-05-30 22:32:47 +02:00
y21
de1f410018 merge explicit_into_iter_fn_arg into useless_conversion 2023-05-30 22:32:26 +02:00
Charalampos Mitrodimas
288312463e [wildcard_imports] Modules that contain prelude are also allowed
This commit fixes #10846 by checking if the path segment contains the
word "prelude".

Signed-off-by: Charalampos Mitrodimas <charmitro@gmail.com>
2023-05-30 21:29:04 +03:00
disco07
d3534a6521 fix issues 10836 2023-05-30 07:43:10 +02:00
Renato Lochetti
ffc2bc83b0
Fixing invalid_regex with invalid UTF8. Also, adding more test cases 2023-05-28 12:53:03 +01:00
bors
dc17e7317b Auto merge of #10797 - est31:manual_let_else_pattern, r=llogiq
Improve pattern printing for manual_let_else

* Address a formatting issue pointed out in https://github.com/rust-lang/rust-clippy/pull/10175/files#r1137091002
* Replace variables inside | patterns in the if let: `let v = if let V::A(v) | V::B(v) = v { v } else ...`
* Support nested patterns: `let v = if let Ok(Ok(Ok(v))) = v { v } else ...`
* Support tuple structs with more than one arg: `let v = V::W(v, _) = v { v } else ...`; note that more than one *capture* is still not supported, so it bails for `let (v, w) = if let E::F(vi, wi) = x { (vi, wi)}`
* Correctly handle .. in tuple struct patterns: `let v = V::X(v, ..) = v { v } else ...`

- \[ ] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[ ] Executed `cargo dev update_lints`
- \[ ] Added lint documentation
- \[x] Run `cargo dev fmt`

[lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints

---

changelog: [`manual_let_else`]: improve variable name in suggestions

Closes #10431 as this PR is adding a test for the `mut` case.
2023-05-27 10:22:40 +00:00
bors
c9ddcf0d06 Auto merge of #10822 - Alexendoo:needless-else-cfg, r=llogiq
Ignore `#[cfg]`'d out code in `needless_else`

changelog: none (same release as #10810)

`#[cfg]` making things fun once more

This lead me to think about macro calls that expand to nothing as well, but apparently they produce an empty stmt in the AST so are already handled, added a test for that

r? `@llogiq`
2023-05-27 10:09:51 +00:00
Urgau
5a2094319b Drop uplifted clippy::invalid_utf8_in_unchecked 2023-05-27 00:16:47 +02:00
bors
f1fd4673bc Auto merge of #10813 - y21:issue10755, r=xFrednet
[`default_constructed_unit_structs`]: do not lint on type alias paths

Fixes #10755.

Type aliases cannot be used as a constructor, so this lint should not trigger in those cases.
I also changed `clippy_utils::is_ty_alias` to also consider associated types since [they kinda are type aliases too](48ec50ae39/compiler/rustc_resolve/src/late/diagnostics.rs (L1520)).

changelog: [`default_constructed_unit_structs`]: do not lint on type alias paths
2023-05-26 15:20:21 +00:00
disco07
0b507c6f04
redundant pattern matches! result 2023-05-26 15:38:38 +02:00
bors
05740adf6e Auto merge of #10807 - y21:issue10800, r=Jarcho
[`unused_async`]: do not consider `await` in nested `async` blocks as used

Fixes #10800.
This PR makes sure that `await` expressions inside of inner `async` blocks don't prevent the lint from triggering.
For example
```rs
async fn foo() {
  async {
    std::future::ready(()).await;
  }
}
```
Even though there *is* a `.await` expression in this function, it's contained in an async block, which means that the enclosing function doesn't need to be `async` too.

changelog: [`unused_async`]: do not consider `await` in nested `async` blocks as used
2023-05-26 00:30:24 +00:00
Centri3
d7a98f507a also ensure generics with the same type are linted 2023-05-25 04:17:36 -05:00
Centri3
d2de5769a1 add generics in test 2023-05-25 04:05:13 -05:00
Alex Macleod
021b7398e1 Ignore #[cfg]'d out code in needless_else 2023-05-24 21:45:46 +00:00
Centri3
94e586e85d actually appease CI
I should always run cargo test before committing 😅
2023-05-24 11:06:56 -05:00
Centri3
5adb270c8d ok 2023-05-24 11:02:35 -05:00
Centri3
7f7979f80b emit unnecessary_cast on raw pointers as well 2023-05-24 10:53:31 -05:00
y21
6a76101d3a update docs, simplify arg->param map, dont lint on chain 2023-05-24 15:59:12 +02:00
y21
516f4f6aef new lint: explicit_into_iter_fn_arg 2023-05-24 15:59:12 +02:00
Alex Macleod
47a024e81d Display the needless_return suggestion 2023-05-23 23:47:04 +00:00
bors
a0fd17d3f0 Auto merge of #10779 - Centri3:ptr_cast_constness, r=llogiq
Add new lint `ptr_cast_constness`

This adds a new lint which functions as the opposite side of the coin to `ptr_as_ptr`. Rather than linting only as casts that don't change constness, this lints only constness; suggesting to use `pointer::cast_const` or `pointer::cast_mut` instead.

changelog: new lint [`ptr_cast_constness`]
2023-05-23 21:40:50 +00:00
bors
97598e9e8f Auto merge of #10810 - samueltardieu:needless-else, r=llogiq
needless_else: new lint to check for empty `else` clauses

Empty `else` clauses are useless. They happen in the wild and are not linted yet: https://github.com/uutils/coreutils/pull/4880/files

`else` clauses containing or preceded by comments are not linted as the comments might be important.

changelog: [`needless_else`]: new lint
2023-05-23 21:28:40 +00:00
y21
8ef6240afb point to await expr in note 2023-05-23 17:22:23 +02:00
Centri3
5825b9e3e2 actually fix it 2023-05-23 00:35:00 -05:00
Centri3
f4b02aa374 fix #10776 2023-05-23 00:35:00 -05:00
bors
fe792d9f7d Auto merge of #10809 - nyurik:match-unsafe, r=Jarcho
Fix missing block for unsafe code

If a block is declared as unsafe, it needs an extra layer of curly braces around it.

Fixes #10808

This code adds handling for `UnsafeSource::UserProvided` block, i.e. `unsafe { ... }`. Note that we do not handle the `UnsafeSource::CompilerGenerated` as it seems to not be possible to generate that with the user code (?), or at least doesn't seem to be needed to be handled explicitly.

There is an issue with this code: it does not add an extra indentation for the unsafe blocks. I think this is a relatively minor concern for such an edge case, and should probably be done by a separate PR (fixing compile bug is more important than getting styling perfect especially when `rustfmt` will fix it anyway)

```rust
// original code
unsafe {
  ...
}

// code that is now generated by this PR
{ unsafe {
  ...
} }

// what we would ideally like to get
{
  unsafe {
    ...
  }
}
```

changelog: [`single_match`](https://rust-lang.github.io/rust-clippy/master/#single_match): Fix suggestion for `unsafe` blocks
2023-05-23 04:45:14 +00:00
Yuri Astrakhan
ed935de087 Run-rustfix 2023-05-22 23:00:28 -04:00
bors
ec2f2d5e47 Auto merge of #10806 - y21:issue10741, r=giraffate
[`large_stack_arrays`]: check array initializer expressions

Fixes #10741.
Prior to this PR, the lint only checked array repeat expressions (ie. `[T; n]`). Now it also checks array initializer expressions.

changelog: [`large_stack_arrays`]: check array initializer expressions
2023-05-23 00:14:01 +00:00
Yuri Astrakhan
9fd34e0c75 Use #[rustfmt::skip] 2023-05-22 20:02:45 -04:00
y21
8c82486ea9 [default_constructed_unit_structs]: do not lint type aliases 2023-05-22 16:13:23 +02:00
y21
3e1302fa0c [match_wild_err_arm]: do not lint in const contexts 2023-05-22 14:04:13 +02:00
Samuel "Sam" Tardieu
e6646eb5fd needless_else: new lint to check for empty else clauses 2023-05-22 11:52:26 +02:00
Yuri Astrakhan
e926148188 Fix unsafe blocks 2023-05-22 04:07:17 -04:00
Yuri Astrakhan
1c277d1be8 Unit tests highlighting unsafe match issue
These unit tests generate non-compilable code.  I did NOT `bless` them on purpose because the stderr output is not good.

I'm surprised we don't auto-compile the suggestions here - is this something that can be easily enabled?

See #10808
2023-05-22 02:48:14 -04:00
y21
1e73a9eb4b do not consider await in nested async blocks 2023-05-21 23:07:30 +02:00
y21
e9a98d925f add test case for #10741 2023-05-21 15:07:53 +02:00
Urgau
915ff71b7c Rename forget_ref lint to forgetting_references 2023-05-21 14:28:09 +02:00
Urgau
fdbfe0e249 Rename drop_ref lint to dropping_references 2023-05-21 14:16:41 +02:00
Urgau
234f2b67cb Rename forget_copy lint to forgetting_copy_types 2023-05-21 14:09:03 +02:00
Urgau
9b97ae98f8 Rename drop_copy lint to dropping_copy_types 2023-05-21 13:37:32 +02:00
Philipp Krones
b76b0aeb63 Merge commit '435a8ad86c7a33bd7ffb91c59039943408d3b6aa' into clippyup 2023-05-20 15:39:26 +02:00
Philipp Krones
96b32b1cb8
Merge remote-tracking branch 'upstream/master' into rustup 2023-05-20 15:32:20 +02:00
Guillaume Gomez
dbc76a7663 Add check for empty cfg all condition 2023-05-20 00:37:08 +02:00
Guillaume Gomez
fcf19481aa Add UI test for UNIQUE_CFG_CONDITION 2023-05-19 16:16:37 +02:00
bors
2a1dbbaec5 Auto merge of #10777 - Icxolu:unnecessary_collect, r=xFrednet
Enhance `needless_collect`: lint in method/function arguments that take an `IntoIterator`

Updates `needless_collect` to also lint `collect` calls in method/function arguments that take an `IntoIterator` (for example `Extend::extend`). Every `Iterator` trivially implements `IntoIterator` and collecting it only causes an unnecessary allocation.

---

changelog: Enhancement: [`needless_collect`]: Now also detects function arguments, taking a generic `IntoIterator`
[#10777](https://github.com/rust-lang/rust-clippy/pull/10777)
<!-- changelog_checked -->

fixes #10762
2023-05-19 12:26:43 +00:00
Jason Newcomb
58132cb3b0 Improve SpanlessEq
* Don't consider expansions of different macros to be the same, even if they expand to the same tokens
* Don't consider `cfg!` expansions to be equal if they check different configs.
2023-05-18 16:42:13 -04:00
Jason Newcomb
5351170744 Slightly refactor constant evaluation and add detection for empty macro expansion and cfged statements. 2023-05-18 15:43:33 -04:00
Jason Newcomb
0b3c2ed811 Search for inactive cfg attributes and empty macro expansion through
the entire block
2023-05-18 15:43:23 -04:00
Alex Macleod
cfa5aa2aad Don't suggest unnameable types in box_default, let_underscore_untyped 2023-05-18 18:51:27 +00:00
bors
22b319606f Auto merge of #10753 - disco07:master, r=xFrednet
redundant_pattern_matching

This PR try to solve this issue https://github.com/rust-lang/rust-clippy/pull/10726,
but it enter in conflict with another test.

changelog: none

Try to test this:
```
let _w = match x {
     Some(_) => true,
     _ => false,
};
```

this happen:
```
 error: match expression looks like `matches!` macro
   --> $DIR/match_expr_like_matches_macro.rs:21:14
    |
 LL |       let _w = match x {
    |  ______________^
 LL | |         Some(_) => true,
 LL | |         _ => false,
 LL | |     };
    | |_____^ help: try this: `matches!(x, Some(_))`

+error: redundant pattern matching, consider using `is_some()`
+  --> $DIR/match_expr_like_matches_macro.rs:21:14
+   |
+LL |       let _w = match x {
+   |  ______________^
+LL | |         Some(_) => true,
+LL | |         _ => false,
+LL | |     };
+   | |_____^ help: try this: `x.is_some()`
+   |
+   = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings`
+
```
I need some help to fix this. Thanks
2023-05-18 09:52:27 +00:00
est31
ef38662d04 Some improvements to the manual_let_else lint suggestions
* Replace variables inside | patterns in the if let: let v = if let V::A(v) | V::B(v) = v { v } else ...
* Support nested patterns: let v = if let Ok(Ok(Ok(v))) = v { v } else ...
* Support tuple structs with more than one arg: let v = V::W(v, _) = v { v } else ...
* Correctly handle .. in tuple struct patterns: let v = V::X(v, ..) = v { v } else ...
2023-05-18 11:16:57 +02:00
bors
270cbeb735 Auto merge of #10674 - c410-f3r:macro-lint, r=Jarcho
Rename `integer_arithmetic`

The lack of official feedback in #10200 made me give up on pursuing the matter but after yet another use-case that is not handled by `integer_arithmetic` (#10615), I think it is worth trying again.

---

changelog: Move/Deprecation: Rename `integer_arithmetic` to `arithmetic_side_effects`
[#10674](https://github.com/rust-lang/rust-clippy/pull/10674)
<!-- changelog_checked -->
2023-05-18 05:26:33 +00:00
bors
815a07e667 Auto merge of #10725 - y21:issue9914, r=Jarcho
don't remove `dbg!` in arbitrary expressions

Fixes #9914

The `dbg_macro` lint replaces empty `dbg!` invocations with the empty string in its suggestion, which is not always valid code in certain contexts (e.g. `let _ = dbg!();` becomes `let _ = ;`). This PR changes it to `()`, which should always be valid where `dbg!()` is valid (`dbg!()` with no arguments evaluates to `()`).

It also special-cases "standalone" `dbg!();` expression statements, where it will suggest removing the whole statement entirely like it did before.

changelog: [`dbg_macro`]: don't remove `dbg!()` in arbitrary expressions as it sometimes results in syntax errors
2023-05-18 05:11:52 +00:00
bors
f3f6fd8920 Auto merge of #10775 - lochetti:fix_10723, r=xFrednet
Ignoring `let_underscore_untyped` warnings in code from proc macros

Don't linting let_underscore_untyped if code was generated by procedural macro.

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

---

closes: https://github.com/rust-lang/rust-clippy/issues/10723

changelog: Fix: [`let_underscore_untyped`]: No longer lints inside proc macros
[#10775](https://github.com/rust-lang/rust-clippy/pull/10775)
<!-- changelog_checked -->
2023-05-18 01:59:38 +00:00
bors
223f5184ba Auto merge of #10682 - J-ZhengLi:issue10680, r=dswij
fix [`invalid_regex`] not recognizing new syntax introduced after regex-1.8.0

fixes: #10680

---

changelog: fix [`invalid_regex`] not recognizing new syntax introduced after regex-1.8.0

bump up `regex-syntax` dependency version to 0.7.0
2023-05-18 01:46:01 +00:00
bors
407c352688 Auto merge of #10337 - EliasHolzmann:fix/10335, r=dswij
Fix: Some suggestions generated by the option_if_let_else lint did not compile

This addresses a bug in Clippy where the fix suggestend by the `option_if_let_else` lint would not compile for `Result`s which have an impure expression in the `else` branch.

---

changelog: [`option_if_let_else`]: Fixed incorrect suggestion for `Result`s
[#10337](https://github.com/rust-lang/rust-clippy/pull/10337)
<!-- changelog_checked -->

Fixes #10335.
2023-05-18 01:34:19 +00:00
bors
7e18451633 Auto merge of #10175 - koka831:fix/10171, r=giraffate
Use original variable name in the suggestion

Fix https://github.com/rust-lang/rust-clippy/issues/10171

---

changelog: Sugg: [`manual_let_else`]: Now suggest the correct variable name
[#10175](https://github.com/rust-lang/rust-clippy/pull/10175)
<!-- changelog_checked -->
2023-05-18 01:21:27 +00:00
León Orell Valerian Liehr
0eb364b8d6 Exclude inherent projections from some alias ty matches 2023-05-17 23:53:58 +02:00
Centri3
4ff1cd365d add description and rename msrv tests 2023-05-16 11:20:00 -05:00
y21
f0be0ee1aa handle nested macros and add tests for them 2023-05-15 21:45:28 +02:00
disco07
79a8867add update test option 2023-05-15 19:43:22 +02:00
Centri3
c5a914b181 check msrv 2023-05-14 19:31:12 -05:00
Centri3
8c191add87 the implementation!! 2023-05-14 19:25:23 -05:00
bors
590c9fc108 Auto merge of #10778 - Centri3:type-alias-fix, r=llogiq
Don't emit clippy::useless_conversion on type aliases

Fixes #10773

changelog: Enhancement: [`useless_conversion`]: Don't lint on type aliases
2023-05-14 20:24:27 +00:00
Centri3
1190c02bb8 fix #10773 2023-05-14 12:21:23 -05:00
Icxolu
84f89f30eb enhance needless_collect
Updates `needless_collect` to lint for collecting into a method or
function argument thats taking an `IntoIterator` (for example `extend`).
Every `Iterator` trivially implements `IntoIterator` and colleting it
only causes an unnecessary allocation.
2023-05-14 18:47:16 +02:00
David Tolnay
fcb132765c Exposes false negative in clippy's diverging_sub_expression 2023-05-14 07:58:45 -07:00
Caio
493b2ae8dc Rename integer_arithmetic 2023-05-14 08:37:12 -03:00
Renato Lochetti
e234dfa63e
Ignoring let_underscore_untyped warnings in code from proc macros 2023-05-14 10:26:48 +01:00
bors
a167973e81 Auto merge of #10768 - c410-f3r:arith-3, r=Jarcho
[arithmetic_side_effects] Consider referenced allowed or hard-coded types

Fix #10767

```
changelog: [`arithmetic_side_effects`]: Do not fire when dealing with allowed or hard-coded types that are referenced.
```
2023-05-14 04:41:41 +00:00
Caio
891fffef0c Consider referenced allowed or hard-coded types 2023-05-13 23:24:33 -03:00
bors
fff790b659 Auto merge of #10691 - jdswensen:jds/fix-doc-empty-line, r=Jarcho
fix: warn on empty line outer AttrKind::DocComment

changelog: [`empty_line_after_doc_comments`]: add lint for checking empty lines after rustdoc comments.

Fixes: #10395
2023-05-12 16:39:02 +00:00
Icxolu
a8834bc46a add lint manual_next_back
checks for manual reverse iteration (`.rev().next()`) of a
`DoubleEndedIterator`
2023-05-11 22:25:14 +02:00
disco07
c53ceba56f update tests 2023-05-11 07:20:02 +02:00
disco07
3991dd10b5 fix reviewer comments: tests results 2023-05-11 07:07:10 +02:00
Jake Swensen
0a4cfbf1f8 fix: warn on empty line outer AttrKind::DocComment
changelog: [`empty_line_after_doc_comments`]: add lint for checking
empty lines after rustdoc comments.

Fixes: #10395
2023-05-10 20:41:23 -05:00
Samuel "Sam" Tardieu
c5d4b04dd5 needless_bool: do not simplify code if it loses comments 2023-05-10 21:19:24 +02:00
Urgau
35e5aac5c8 Drop uplifted clippy::forget_copy 2023-05-10 19:36:02 +02:00
Urgau
22688fc91f Drop uplifted clippy::forget_ref 2023-05-10 19:36:01 +02:00
Urgau
551f6e6154 Drop uplifted clippy::drop_copy 2023-05-10 19:36:01 +02:00
Urgau
6af0359f2a Drop uplifted clippy::drop_ref 2023-05-10 19:36:01 +02:00
disco07
342ce3da05 fix reviewer comments 2023-05-09 20:50:47 +02:00
bors
77e4d7a839 Auto merge of #10727 - john-h-k:lint/dup-auto-traits, r=Manishearth
Extend `trait_duplication_in_bounds` to cover trait objects

This PR extends `trait_duplication_in_bounds` to cover trait objects.

Currently,
```rs
fn foo(_a: &(dyn Any + Send + Send)) {}
```

generates no warnings. With this PR, it will complain about a duplicate trait and can remove it

Moved from rust-lang/rust#110991

changelog: [`trait_duplication_in_bounds`]: warn on duplicate trait object constraints
2023-05-09 13:46:18 +00:00
bors
d696f3b652 Auto merge of #10584 - blyxyas:fix-wildcard_imports_testsrs, r=flip1995
fix: `wildcard_imports` ignore `test.rs` files

Adds a check to see if the building crate is a test one, if so, ignore it

---

Closes #10580
changelog:[`wildcard_imports`]: Add a check to ignore files named `test.rs` and `tests.rs`
2023-05-08 16:46:23 +00:00
blyxyas
4c3e2ff2a4
Fix header 2023-05-08 18:38:41 +02:00
bors
90ce1a2e7c Auto merge of #10761 - lochetti:fix_9871, r=Manishearth
Ignore `borrow_deref_ref` warnings in code from procedural macros.

Don't linting `borrow_deref_ref` if code was generated by procedural macro.

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

changelog: [`borrow_deref_ref`] avoiding warnings in macro-generated code
2023-05-08 16:29:02 +00:00
blyxyas
ba0e7e88cb
Now the lint ignores any crates with --cfg test 2023-05-08 18:24:59 +02:00
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
Renato Lochetti
394b4c1906
Ignore borrow_deref_ref warnings in code from procedural macros. 2023-05-07 12:35:17 +01:00
disco07
9e535f6288 fix conflict with matches macro 2023-05-07 00:59:52 +02:00
Elias Holzmann
d80ca09f5e Fix: Some suggestions generated by the option_if_let_else lint did not compile 2023-05-05 22:20:04 +02:00
disco07
afa2741e6a redundant_pattern_matching 2023-05-05 21:33:16 +02:00
Alex Macleod
68eb864c91 Ignore expressions from macros in default_constructed_unit_structs 2023-05-05 18:35:54 +00:00
Philipp Krones
7e9abb311d Merge commit '371120bdbf58a331db5dcfb2d9cddc040f486de8' into clippyup 2023-05-05 17:45:49 +02: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
John Kelly
b9788fef29 Working 2023-04-30 14:34:46 +01:00
John Kelly
1eff408ca4 WIP 2023-04-30 13:45:45 +01:00
John Kelly
478555d468 wip 2023-04-30 13:16:04 +01:00
y21
cc607fe32e don't remove dbg! in arbitrary expressions 2023-04-30 01:30:15 +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
Alex Macleod
b4067660f6 Add a test that checks for old style test headers 2023-04-23 14:20:55 +00: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