Commit graph

9337 commits

Author SHA1 Message Date
y21
191a901a8d consider array initializer for large_stack_arrays 2023-05-21 15:02:51 +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
ab66a86815 Add new UNIQUE_CFG_CONDITION lint 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
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
est31
83a4b0987f Fix formatting of if let chain 2023-05-18 07:56:04 +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
cf182b9f43 Auto merge of #10789 - Centri3:patch-1, r=xFrednet
fix example heading in `string_slice`

changelog: none
2023-05-18 02:22:41 +00:00
bors
9cd483d5c9 Auto merge of #10786 - mickvangelderen:remove-unnecessary-clone-from-needless-collect-example, r=Alexendoo
Remove unnecessary `clone` from `needless_collect` example

The example for [clippy::needless_collect](https://rust-lang.github.io/rust-clippy/master/#needless_collect) is written as follows:

```rust
let len = iterator.clone().collect::<Vec<_>>().len();
// should be
let len = iterator.count();
```

With this change, the unnecessary `clone()` is removed and the the standard

    ### Example
    ```rust
    // original
    ```
    Use instead:
    ```rust
    // improved
    ```

structure is followed.

Discussion: https://github.com/rust-lang/rust-clippy/discussions/10784#discussion-5198885

changelog: [`needless_collect`]: Cleaned up the example in the lint documentation.
2023-05-18 02:11:02 +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
Dylan DPC
506b50ee39 Rollup merge of #111648 - Nilstrieb:language-items, r=WaffleLapkin
Remove `LangItems::require`

It's just a short wrapper used by `tcx.require_lang_item`. Deleting it gives us a negative diff.
2023-05-17 11:13:56 +05:30
Catherine
ae40b7f8cc
fix example heading in string_slice 2023-05-16 18:11:20 -05:00
Centri3
97467e4aa3 change clippy::version to 1.71.0 2023-05-16 16:29:31 -05:00
Nilstrieb
fc126379be Remove LangItems::require
It's just a short wrapper used by `tcx.require_lang_item`. Deleting it
gives us a negative diff.
2023-05-16 19:53:38 +02:00
Centri3
4ff1cd365d add description and rename msrv tests 2023-05-16 11:20:00 -05:00
Renato Lochetti
2d9d81fc1e
Checking for proc_macro not only when local.init is Some 2023-05-16 09:36:22 +01:00
Mick van Gelderen
79eb06c6ec
Remove unnecessary from example 2023-05-15 22:24:37 +02:00
y21
f0be0ee1aa handle nested macros and add tests for them 2023-05-15 21:45:28 +02:00
Catherine
f6a0437e74
Update clippy_lints/src/casts/ptr_cast_constness.rs
Co-authored-by: llogiq <bogusandre@gmail.com>
2023-05-15 13:14:45 -05: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
a36d9a7820 move is_ty_alias to clippy_utils 2023-05-14 12:39:08 -05: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
Caio
493b2ae8dc Rename integer_arithmetic 2023-05-14 08:37:12 -03:00
Renato Lochetti
df200aaf39
fixing fmt 2023-05-14 10:38:32 +01: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
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
blyxyas
b7a6054712
Refresh Lint Configuration's looks 2023-05-09 21:39:24 +02:00
disco07
342ce3da05 fix reviewer comments 2023-05-09 20:50:47 +02:00
bors
1407c7627e Auto merge of #10751 - blyxyas:explain_with_config, r=xFrednet
Add configuration options to `--explain`

This PR rearranges some modules, taking `metadata_collector` out of `internal_lints` and making public just the necessary functions for `explain()` to use.

The output looks something like this:
```sh
$ cargo run --bin cargo-clippy --manifest-path ../rust-clippy/Cargo.toml -- --explain cognitive_complexity
### What it does
Checks for methods with high cognitive complexity.

### Why is this bad?
Methods of high cognitive complexity tend to be hard to
both read and maintain. Also LLVM will tend to optimize small methods better.

### Known problems
Sometimes it's hard to find a way to reduce the
complexity.

### Example
You'll see it when you get the warning.

========================================
Configuration for clippy::cognitive_complexity:
- cognitive-complexity-threshold: The maximum cognitive complexity a function can have (default: 25)
```

Fixes #9990
r? `@xFrednet`

---

changelog: Docs: `cargo clippy --explain LINT` now shows possible configuration options for the explained lint
[#10751](https://github.com/rust-lang/rust-clippy/pull/10751)
<!-- changelog_checked -->
2023-05-09 18:41:30 +00:00
blyxyas
3e8fea612d
Fix config formatting, less indenting, more spacing 2023-05-09 20:35:03 +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
John Kelly
b169bdb732 Comments 2023-05-09 10:06:38 +01: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
Michael Goulet
34655dfbb7 Rollup merge of #109410 - fmease:iat-alias-kind-inherent, r=compiler-errors
Introduce `AliasKind::Inherent` for inherent associated types

Allows us to check (possibly generic) inherent associated types for well-formedness.
Type inference now also works properly.

Follow-up to #105961. Supersedes #108430.
Fixes #106722.
Fixes #108957.
Fixes #109768.
Fixes #109789.
Fixes #109790.

~Not to be merged before #108860 (`AliasKind::Weak`).~

CC `@jackh726`
r? `@compiler-errors`

`@rustbot` label T-types F-inherent_associated_types
2023-05-08 09:30:21 -07: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
5acc2993e7
Really mini minor irrelevant change for formatting 2023-05-08 18:24:59 +02:00
blyxyas
54912410c7
Wildcard_imports ignore test.rs files 2023-05-08 18:24:58 +02:00
bors
e66488a669 Auto merge of #10757 - cakebaker:add_missing_word, r=Jarcho
Add missing word "are"

changelog: none
2023-05-08 15:43:18 +00: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
John Kelly
5c8a00923b Comments 2023-05-07 10:10:44 +01:00
disco07
fb6bf1ebf6 update a func 2023-05-07 08:12:36 +02:00
Kyle Matsuda
3fc11553a8 changes from review: add FIXME to clippy and change subst_identity to skip_binder in mir subst methods 2023-05-06 23:36:04 -06:00
Kyle Matsuda
39db64e0ab make (try_)subst_and_normalize_erasing_regions take EarlyBinder 2023-05-06 22:32:39 -06:00
disco07
450a22f2dc fix error test 2023-05-07 02:56:46 +02:00
disco07
630f31ce5e fix conflict with matches macro 2023-05-07 02:45:11 +02:00
disco07
9e535f6288 fix conflict with matches macro 2023-05-07 00:59:52 +02:00
Daniel Hofstetter
f4b8cb1b28
Add missing word "are" 2023-05-06 16:21:45 +02:00
blyxyas
2a4571d959
Minimizing changes 2023-05-06 08:38:47 +02:00
bors
5889ecd14f Auto merge of #111255 - flip1995:clippyup, r=Manishearth
Update Clippy

r? `@Manishearth`
2023-05-05 21:50:14 +00: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
d2bbe76008 redundant_pattern_matching 2023-05-05 21:49:55 +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
Dylan DPC
a48c7350ab Rollup merge of #108801 - fee1-dead-contrib:c-str, r=compiler-errors
Implement RFC 3348, `c"foo"` literals

RFC: https://github.com/rust-lang/rfcs/pull/3348
Tracking issue: #105723
2023-05-05 18:40:33 +05:30
León Orell Valerian Liehr
2bc479a201 IAT: Introduce AliasKind::Inherent 2023-05-04 16:59:10 +02:00
bors
8518391e72 Auto merge of #110806 - WaffleLapkin:unmkI, r=lcnr
Replace `tcx.mk_trait_ref` with `TraitRef::new`

First step in implementing https://github.com/rust-lang/compiler-team/issues/616
r? `@lcnr`
2023-05-04 05:54:09 +00: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
48ae5a071b fix lint docs 2023-05-03 21:43:10 +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
bors
9353170dfb Auto merge of #10730 - blyxyas:no_std_mul_add, r=Jarcho
`imprecise_flops`: Globally ignore `#[no_std]` crates

Really small fix.
Fixes #10728
changelog: [`imprecise_flops`]: Fix false positives with `#[no_std]`
2023-05-03 01:47:52 +00:00
Nicholas Nethercote
431cce1540 Restrict From<S> for {D,Subd}iagnosticMessage.
Currently a `{D,Subd}iagnosticMessage` can be created from any type that
impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static,
str>`, which are reasonable. It also includes `&String`, which is pretty
weird, and results in many places making unnecessary allocations for
patterns like this:
```
self.fatal(&format!(...))
```
This creates a string with `format!`, takes a reference, passes the
reference to `fatal`, which does an `into()`, which clones the
reference, doing a second allocation. Two allocations for a single
string, bleh.

This commit changes the `From` impls so that you can only create a
`{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static,
str>`. This requires changing all the places that currently create one
from a `&String`. Most of these are of the `&format!(...)` form
described above; each one removes an unnecessary static `&`, plus an
allocation when executed. There are also a few places where the existing
use of `&String` was more reasonable; these now just use `clone()` at
the call site.

As well as making the code nicer and more efficient, this is a step
towards possibly using `Cow<'static, str>` in
`{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing
the `From<&'a str>` impls to `From<&'static str>`, which is doable, but
I'm not yet sure if it's worthwhile.
2023-05-03 08:44:39 +10:00
blyxyas
0dd2501e0d
Don't ignore check_radians 2023-05-02 20:47:18 +02:00
John Kelly
122793b494 Update trait_bounds.rs 2023-05-02 18:21:23 +01:00
John Kelly
cbd0135bd2 Update trait_bounds.rs 2023-05-02 18:15:02 +01:00
Deadbeef
f7595e0745 rm diag item, use lang item 2023-05-02 10:32:07 +00:00
Deadbeef
37127b8d70 initial step towards implementing C string literals 2023-05-02 10:30:09 +00: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
bors
824f2e701c Auto merge of #10724 - lukaslueg:largeerrdocs, r=giraffate
Clarify docs for `RESULT_LARGE_ERR`

Adds a paragraph to address https://github.com/rust-lang/rust-clippy/issues/10211#issuecomment-1521548238

changelog: [`result_large_err`]: Update the document
2023-05-02 00:41:36 +00:00
Icxolu
220a9db642 fixed span and corrected test output 2023-05-01 20:12:34 +02:00
blyxyas
5749054241
globally ignore #[no_std] crates 2023-05-01 12:39:20 +02:00
John Kelly
b9788fef29 Working 2023-04-30 14:34:46 +01:00
John Kelly
8db21e9a9c WIP 2023-04-30 14:14:47 +01:00
John Kelly
0fb3f3b256 WIP 2023-04-30 14:10:26 +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
Icxolu
032bc11fd4
fix diagnostic message style
Co-authored-by: Ruby Lazuli <general@patchmixolydic.com>
2023-04-29 21:11:34 +02:00
y21
8d8178f931 rename lint to manual_while_let_some 2023-04-29 18:59:07 +02:00
y21
f10e39fd2b make PopStmt copy+clone 2023-04-29 18:59:07 +02:00
y21
ab9b7a5ad2 remove unnecessary reference 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
bcdcc34ba9 elide lifetimes, get rid of glob import 2023-04-29 18:59:06 +02:00
y21
bb58083ce5 new lint: while_pop_unwrap 2023-04-29 18:59:06 +02:00
Lukas Lueg
2ed254e29f Clarify docs for RESULT_LARGE_ERR 2023-04-29 14:18:31 +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
f37054b396
Remove useless span magic 2023-04-28 20:19:36 +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
Maybe Waffle
95648951ea Fix uses of TraitRef::identity in clippy and rustdoc 2023-04-26 13:48:56 +00:00
bors
990bbdc2be Auto merge of #10656 - Centri3:master, r=xFrednet
Add configuration for `semicolon_block` lints

Does exactly what it says on the tin, suggests moving a block's final semicolon inside if it's multiline and outside if it's singleline.

I don't really like how this is implemented so I'm not too sure if this is ready yet. Alas, it might be ok.

---

fixes #10654

changelog: Enhancement: [`semicolon_inside_block`]: Added `semicolon-inside-block-ignore-singleline` as a new config value.
[#10656](https://github.com/rust-lang/rust-clippy/pull/10656)
changelog: Enhancement: [`semicolon_outside_block`]: Added `semicolon-outside-block-ignore-multiline` as a new config value.
[#10656](https://github.com/rust-lang/rust-clippy/pull/10656)
<!-- changelog_checked -->
2023-04-25 20:12:00 +00:00
Matthias Krüger
331c5471d7 Rollup merge of #110556 - kylematsuda:earlybinder-explicit-item-bounds, r=compiler-errors
Switch to `EarlyBinder` for `explicit_item_bounds`

Part of the work to finish https://github.com/rust-lang/rust/issues/105779.

This PR adds `EarlyBinder` to the return type of the `explicit_item_bounds` query and removes `bound_explicit_item_bounds`.

r? `@compiler-errors` (hope it's okay to request you, since you reviewed #110299 and #110498 😃)
2023-04-25 21:06:32 +02:00
Maybe Waffle
9cf96429a7 Use ty::TraitRef::new in clippy 2023-04-25 16:31:51 +00:00
Centri3
aa6c27a74e change names to not be implicitly negative 2023-04-25 11:14:52 -05:00
Centri3
14a6fa4a34 use in_external_macro 2023-04-25 05:06:45 -05:00
Centri3
acfb2c45ba don't check if from macro invocation 2023-04-25 05:06:11 -05:00
bors
5514d9f444 Auto merge of #110718 - flip1995:clippyup, r=Manishearth
Update Clippy

r? `@Manishearth`

A few days late, I was on a business trip, sorry.
2023-04-24 21:25:56 +00: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
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
4ed48698f9 Auto merge of #108118 - oli-obk:lazy_typeck, r=cjgillot
Run various queries from other queries instead of explicitly in phases

These are just legacy leftovers from when rustc didn't have a query system. While there are more cleanups of this sort that can be done here, I want to land them in smaller steps.

This phased order of query invocations was already a lie, as any query that looks at types (e.g. the wf checks run before) can invoke e.g. const eval which invokes borrowck, which invokes typeck, ...
2023-04-23 13:34:31 +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
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
blyxyas
0354cee137
Add lint items_after_test_module 2023-04-22 21:12:45 +02:00
Alex Macleod
397f36a78c Fix #[allow(clippy::enum_variant_names)] directly on variants 2023-04-22 14:53:15 +00:00
J-ZhengLi
5fc1c79019 bump up regex-syntax dependency version to 0.7.0 2023-04-22 11:17:10 +08:00
bors
86d8f1268a Auto merge of #106934 - DrMeepster:offset_of, r=WaffleLapkin
Add offset_of! macro (RFC 3308)

Implements https://github.com/rust-lang/rfcs/pull/3308 (tracking issue #106655) by adding the built in macro `core::mem::offset_of`. Two of the future possibilities are also implemented:

* Nested field accesses (without array indexing)
* DST support (for `Sized` fields)

I wrote this a few months ago, before the RFC merged. Now that it's merged, I decided to rebase and finish it.

cc `@thomcc` (RFC author)
2023-04-22 00:10:44 +00:00
Oli Scherer
7f13e6d8a5 Allow LocalDefId as the argument to def_path_str 2023-04-21 22:27:20 +00:00
Centri3
85d7de25a9 fix false positive 2023-04-21 05:12:14 -05:00
DrMeepster
68c4776b46 offset_of 2023-04-21 02:14:02 -07:00
J-ZhengLi
b8d6964bce
make [len_zero] lint not spanning over parenthesis 2023-04-21 16:56:17 +08:00
Arpad Borsos
7077bde9d2
Fix typo in significant_drop_tightening 2023-04-20 20:59:59 +02:00
Kyle Matsuda
097309c10f add EarlyBinder to output of explicit_item_bounds; replace bound_explicit_item_bounds usages; remove bound_explicit_item_bounds query 2023-04-20 12:36:50 -06:00
Kyle Matsuda
afa28e6304 change usages of explicit_item_bounds to bound_explicit_item_bounds 2023-04-20 12:36:50 -06:00
Caio
0b16f80c40 [arithmetic_side_effects] Cache symbols 2023-04-20 14:59:02 -03:00
Camille GILLOT
8ead58c67b Remove WithOptconstParam. 2023-04-20 17:48:32 +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
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
Centri3
41f6d88be5 make cargo test pass 2023-04-19 21:51:58 -05:00
Centri3
a3aeec4f75 config instead of new lint and don't panic 2023-04-19 21:46:13 -05:00
Lukas Lueg
2745c87842 Dont suggest suboptimal_flops unavailable in nostd
Fixes #10634
2023-04-19 20:04:17 +02: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
Centri3
fa1efa8b10 refactor 2023-04-17 20:57:56 -05: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
Centri3
80707aa95f improve description a bit 2023-04-17 00:37:43 -05:00
Centri3
a57445d4d6 make cargo test pass, again 2023-04-16 23:59:31 -05:00
Centri3
a7c3301b58 refactor 2023-04-16 23:56:21 -05:00
Centri3
dfccebe3e0 make cargo test pass 2023-04-16 23:36:01 -05:00
Centri3
0a81f8257e add semicolon_outside_block_if_singleline lint 2023-04-16 23:30:00 -05:00
Nilstrieb
8f53926232 Alloc hir::Lit in an arena to remove the destructor from Expr
This allows allocating `Expr`s into a dropless arena, which is useful
for using length prefixed thing slices in HIR, since these can only be
allocated in the dropless arena and not in a typed arena. This is
something I'm working on.
2023-04-16 15:35:51 +00: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
Philipp Krones
6b95029f17 Merge commit '83e42a2337dadac915c956d125f1d69132f36425' into clippyup 2023-04-11 15:31:08 +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