Commit Graph

15143 Commits

Author SHA1 Message Date
bors
a78551bb14 Auto merge of #9556 - evantypanski:et/issue-9369, r=Alexendoo
[`redundant_closure`] Fix suggestion causes error for `impl FnMut`

Fixes #9369

changelog: [`redundant_closure`] Fix suggestion causes error with `impl FnMut` types
2022-09-30 16:42:55 +00:00
Evan Typanski
dbadf37336 Add test case where FnMut used once needs &mut 2022-09-30 11:38:12 -04:00
Evan Typanski
85b8ff7f38
Fix style in if let chain
Co-authored-by: Alex Macleod <alex@macleod.io>
2022-09-30 11:36:55 -04:00
bors
5f25f7e605 Auto merge of #9557 - xxchan:xxchan/safe-anaconda, r=Manishearth
doc: make the usage of clippy.toml more clear

Added a subsection for it, and move it after `Allowing/denying lints` which is more frequently used.

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

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: none
2022-09-30 15:23:09 +00:00
xxchan
47a7d68c07 doc: make the usage of clippy.toml more clear 2022-09-30 13:43:16 +02:00
bors
68408c583e Auto merge of #9486 - kraktus:lazy_eval, r=dswij
[`unnecessary_lazy_eval`] Do not lint in external macros

fix https://github.com/rust-lang/rust-clippy/issues/9485, fix https://github.com/rust-lang/rust-clippy/issues/9439

I didn't find a way to add a test since fps occur due to an external crate.

changelog: [`unnecessary_lazy_eval`] Do not lint in external macros
2022-09-30 07:47:55 +00:00
Evan Typanski
416da1264c [redundant_closure] Add &mut to more cases 2022-09-29 19:35:04 -04:00
kraktus
6ec7759c3b [unnecessary_lazy_eval] Do not lint in external macros 2022-09-29 13:48:50 +02:00
bors
e43f5a17d4 Auto merge of #9516 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2022-09-29 10:04:13 +00:00
Philipp Krones
924c1ce97d
Update lints after sync 2022-09-29 12:02:58 +02:00
Philipp Krones
67af127f24
Fix dogfood 2022-09-29 12:02:58 +02:00
Philipp Krones
579791178d
Bump nightly version -> 2022-09-29 2022-09-29 12:02:54 +02:00
bors
5e8a4b6699 Auto merge of #9551 - kraktus:unnecessary_lazy_evaluations, r=xFrednet
[`unnecessary_lazy_evaluations`] Do not suggest switching to early evaluation when type has custom `Drop`

fix #9427

changelog: [`unnecessary_lazy_evaluations`] Do not suggest switching to early evaluation when type has custom `Drop`
2022-09-29 08:36:14 +00:00
bors
ed9c0e3030 Auto merge of #9550 - alex-semenyuk:fix_typo, r=xFrednet
Fix typo

changelog: none
2022-09-28 21:44:52 +00:00
kraktus
314d57a790 [unnecessary_lazy_evaluations] Do not suggest switching to early evaluation when type has custom Drop 2022-09-28 22:46:05 +02:00
alex-semenyuk
8ba081c597 Fix typo 2022-09-28 23:01:11 +03:00
bors
8845f82142 Auto merge of #9490 - kraktus:needless_borrow, r=Jarcho
fix [`needless_borrow`], [`explicit_auto_deref`] FPs on unions

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

changelog: fix [`needless_borrow`] false positive on unions
changelog: fix [`explicit_auto_deref`] false positive on unions

Left a couple debug derived impls on purpose I needed to debug as I don't think it's noise
2022-09-28 14:58:07 +00:00
Philipp Krones
458e83291d
Bump Clippy version -> 0.1.66 2022-09-28 14:27:50 +02:00
Philipp Krones
bbcde66685
Merge remote-tracking branch 'upstream/master' into rustup 2022-09-28 14:27:32 +02:00
bors
0f6932a1f7 Auto merge of #9546 - kraktus:default_not_default_trait, r=xFrednet
[`should_implement_trait`] Also lint `default` method

close https://github.com/rust-lang/rust-clippy/issues/8550

changelog: FP: [`should_implement_trait`]: Now also works for `default` methods
2022-09-28 11:00:37 +00:00
kraktus
7289835542 [should_implement_trait] Also lint default method 2022-09-28 08:42:01 +02:00
bors
35b7ce5ca9 Auto merge of #9545 - Alexendoo:std-instead-of-core-unstable, r=Manishearth
Don't lint unstable moves in `std_instead_of_core`

Fixes #9515

changelog: [`std_instead_of_core`]: No longer suggests unstable modules such as `core::error`
2022-09-27 20:11:34 +00:00
kraktus
14ba4fba11 fix [needless_borrow] and [explicit_auto_deref] false positive on unions 2022-09-27 21:30:32 +02:00
bors
672fb8e42e Auto merge of #9491 - kraktus:drop_copy, r=Jarcho
[`drop_copy`]: Do not lint idiomatic in match arm

close https://github.com/rust-lang/rust-clippy/issues/9482

changelog: [`drop_copy`]: Do not lint idiomatic in match arm
2022-09-27 19:18:29 +00:00
kraktus
187c27e6b0 rename and_only_expr_in_arm -> is_single_call_in_arm 2022-09-27 21:01:23 +02:00
Alex Macleod
5b0f46a9d9 Don't lint unstable moves in std_instead_of_core
Such as the currently unstable `core::error`
2022-09-27 18:21:14 +00:00
bors
9aa85dc35b Auto merge of #9511 - rust-lang:box-default, r=Alexendoo
add `box-default` lint

This adds a `box-default` lint to suggest using `Box::default()` instead of `Box::new(Default::default())`, which offers less moving parts and potentially better performance according to [the perf book](https://nnethercote.github.io/perf-book/standard-library-types.html#box).

---

changelog: add [`box_default`] lint
2022-09-27 18:14:24 +00:00
bors
257fb4b458 Auto merge of #9543 - philipcraig:fix-saturing-typo, r=giraffate
fix typo "Saturing" -> "Saturating"

---

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: fix typo "Saturing" -> "Saturating"
2022-09-27 14:38:12 +00:00
bors
47c9145bd0 Auto merge of #9497 - kraktus:needless_return2, r=llogiq
[`needless_return`] Recursively remove unneeded semicolons

fix #8336,
fix #8156,
fix https://github.com/rust-lang/rust-clippy/issues/7358,
fix #9192,
fix https://github.com/rust-lang/rust-clippy/issues/9503

changelog: [`needless_return`] Recursively remove unneeded semicolons

For now the suggestion about removing the semicolons are hidden because they would be very noisy and should be obvious if the user wants to apply the lint manually instead of using `--fix`. This could be an issue for beginner, but haven't found better way to display it.
2022-09-27 14:23:53 +00:00
bors
d31db02e47 Auto merge of #9507 - c410-f3r:arith, r=Alexendoo
[arithmetic-side-effects] Consider references

Takes into consideration integer references like `&i32::MAX` because currently things like `let _ = &1 + 0` trigger the lint.

changelog: FP: [`arithmetic_side_effects`]: Now ignores references
  [9507](https://github.com/rust-lang/rust-clippy/pull/9507)
2022-09-27 14:09:25 +00:00
bors
c153bd6237 Auto merge of #9539 - Jarcho:ice_9445, r=flip1995
Don't lint `*_interior_mutable_const` on unions due to potential ICE.

fixes #9445
cc rust-lang/rust#101113

This started ICE'ing sometime last month due to stricter UB checks. I'm not sure how we could check the value of a union as MIRI doesn't seem to store which field is currently active.

changelog: Don't ICE on const unions containing a `!Freeze` type.
2022-09-27 12:58:41 +00:00
Andre Bogus
63f441ec85 add box-default lint 2022-09-27 13:26:23 +02:00
lcnr
e5ce6d18df rustc_typeck to rustc_hir_analysis 2022-09-27 10:37:23 +02:00
Philip Craig
14abb8395c fix typo "Saturing" -> "Saturating" 2022-09-27 09:32:55 +01:00
bors
78dc616a7a Auto merge of #9487 - kraktus:question_mark, r=Jarcho
Silence [`question_mark`] in const context

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

When `const_try` is stabilised can be turned into a MSRV

changelog: Silence [`question_mark`] in const context
2022-09-27 01:12:54 +00:00
bors
cf93865a5c Auto merge of #9233 - nyurik:capture-vars, r=Alexendoo
new uninlined_format_args lint to inline explicit arguments

Implement https://github.com/rust-lang/rust-clippy/issues/8368 - a new lint to inline format arguments such as `print!("{}", var)` into `print!("{var}")`.

### Supported cases

code | suggestion | comment
---|---|---
`print!("{}", var)` | `print!("{var}")` |  simple variables
`print!("{0}", var)` | `print!("{var}")` |  positional variables
`print!("{v}", v=var)` | `print!("{var}")` |  named variables
`print!("{0} {0}", var)` | `print!("{var} {var}")` |  aliased variables
`print!("{0:1$}", var, width)` | `print!("{var:width$}")` |  width support
`print!("{0:.1$}", var, prec)` | `print!("{var:.prec$}")` |  precision support
`print!("{:.*}", prec, var)` | `print!("{var:.prec$}")` |  asterisk support

### Known Problems

* There may be a false positive if the format string is wrapped in a macro call:
```rust
# let var = 42;
macro_rules! no_param_str { () => { "{}" }; }
macro_rules! pass_through { ($expr:expr) => { $expr }; }
println!(no_param_str!(), var);
println!(pass_through!("{}"), var);
```

* Format string uses an indexed argument that cannot be inlined.
Supporting this case requires re-indexing of the format string.
Until implemented, `print!("{0}={1}", var, 1+2)` should be changed to `print!("{var}={0}", 1+2)` by hand.

changelog: [`uninlined_format_args`]: A new lint to inline format arguments, i.e. `print!("{}", var)` into `print!("{var}")`
2022-09-26 09:27:37 +00:00
Pietro Albini
06568fd6c7 remove cfg(bootstrap) 2022-09-26 10:14:45 +02:00
fee1-dead
c69edba515 Rollup merge of #102197 - Nilstrieb:const-new-🌲, r=Mark-Simulacrum
Stabilize const `BTree{Map,Set}::new`

The FCP was completed in #71835.

Since `len` and `is_empty` are not const stable yet, this also creates a new feature for them since they previously used the same `const_btree_new` feature.
2022-09-26 13:09:42 +08:00
Yuri Astrakhan
5a71bbdf3f new uninlined_format_args lint to inline explicit arguments
Implement https://github.com/rust-lang/rust-clippy/issues/8368 - a new
lint to inline format arguments such as `print!("{}", var)` into
`print!("{var}")`.

code | suggestion | comment
---|---|---
`print!("{}", var)` | `print!("{var}")` |  simple variables
`print!("{0}", var)` | `print!("{var}")` |  positional variables
`print!("{v}", v=var)` | `print!("{var}")` |  named variables
`print!("{0} {0}", var)` | `print!("{var} {var}")` |  aliased variables
`print!("{0:1$}", var, width)` | `print!("{var:width$}")` |  width
support
`print!("{0:.1$}", var, prec)` | `print!("{var:.prec$}")` |  precision
support
`print!("{:.*}", prec, var)` | `print!("{var:.prec$}")` |  asterisk
support

code | suggestion | comment
---|---|---
`print!("{0}={1}", var, 1+2)` | `print!("{var}={0}", 1+2)` | Format
string uses an indexed argument that cannot be inlined.  Supporting this
case requires re-indexing of the format string.

changelog: [`uninlined_format_args`]: A new lint to inline format
arguments, i.e. `print!("{}", var)` into `print!("{var}")`
2022-09-25 19:53:03 -04:00
Jason Newcomb
b180d954d6 Don't lint *_interior_mutable_const on unions due to potential ICE. 2022-09-25 17:37:56 -04:00
bors
57c9daa09b Auto merge of #9533 - Jarcho:integration-ice-msg, r=llogiq
Fix panic when displaying the backtrace of failing integration tests

changelog: None
2022-09-25 14:33:36 +00:00
Jason Newcomb
84933761f0 Fix panic when displaying the backtrace of failing integration tests 2022-09-25 09:15:29 -04:00
bors
00ebd8eb48 Auto merge of #9535 - alex-semenyuk:move_derive_partial_eq_without_eq_to_nursery, r=xFrednet
Moved derive_partial_eq_without_eq to nursery

changelog: Moves: Move `derive_partial_eq_without_eq` to `nursery` (now allow-by-default)
  [#9536](https://github.com/rust-lang/rust-clippy/pull/9536)

Closes: https://github.com/rust-lang/rust-clippy/issues/9530
2022-09-25 10:38:02 +00:00
alex-semenyuk
93945a54a1 Please move derive_partial_eq_without_eq to nursery 2022-09-25 13:21:25 +03:00
bors
5bd3b569dc Auto merge of #9531 - Jarcho:ice_9459, r=llogiq
Fix ICE in `needless_pass_by_value` with unsized `dyn Fn`

fixes #9459

Not really sure why a query for a type implementing `FnOnce` even works since the trait if `FnOnce<T>`, but it seems to. I would have expected it to crash like it does when passing `dyn FnOnce()` as the type.

changelog: [`needless_pass_by_value`](https://rust-lang.github.io/rust-clippy/master/#needless_pass_by_value) Fix ICE in with unsized `dyn Fn` argument
2022-09-25 08:09:02 +00:00
Jason Newcomb
1141c553d8 Fix ICE in needless_pass_by_value with unsized dyn Fn 2022-09-24 17:38:09 -04:00
Takayuki Maeda
ea75178219 separate definitions and HIR owners
fix a ui test

use `into`

fix clippy ui test

fix a run-make-fulldeps test

implement `IntoQueryParam<DefId>` for `OwnerId`

use `OwnerId` for more queries

change the type of `ParentOwnerIterator::Item` to `(OwnerId, OwnerNode)`
2022-09-24 23:21:19 +09:00
bors
8b1ad17e5c Auto merge of #9527 - nyurik:inl2, r=llogiq
fallout2: rework clippy_dev & _lints fmt inlining

Continuing #9525 -- a few more inlining, but this time with some code changes to simplify format strings:

* Inline format args where possible
* simplify a few complex macros into format str
* use formatdoc!() instead format!(indoc!(...))

changelog: none

cc: `@llogiq`
2022-09-24 06:41:17 +00:00
Yuri Astrakhan
cc6b375cd3 fallout2: rework clippy_dev & _lints fmt inlining
* Inline format args where possible
* simplify a few complex macros into format str
* use formatdoc!() instead format!(indoc!(...))
2022-09-23 23:08:12 -04:00
bors
de8a1dd7e1 Auto merge of #102068 - cjgillot:erased-lifetime-print, r=eholk
Always print '_, even for erased lifetimes.

Explicit lifetime arguments are now the recommended syntax in rust 2018 and rust 2021.  This PR applies this discipline to rustc itself.
2022-09-24 01:23:17 +00:00