]> git.lizzy.rs Git - rust.git/log
rust.git
22 months agoAdd test case where `FnMut` used once needs `&mut`
Evan Typanski [Fri, 30 Sep 2022 15:37:50 +0000 (11:37 -0400)]
Add test case where `FnMut` used once needs `&mut`

22 months agoFix style in `if let` chain
Evan Typanski [Fri, 30 Sep 2022 15:36:55 +0000 (11:36 -0400)]
Fix style in `if let` chain

Co-authored-by: Alex Macleod <alex@macleod.io>
22 months agoAuto merge of #9557 - xxchan:xxchan/safe-anaconda, r=Manishearth
bors [Fri, 30 Sep 2022 15:23:09 +0000 (15:23 +0000)]
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

22 months agodoc: make the usage of clippy.toml more clear
xxchan [Fri, 30 Sep 2022 11:34:21 +0000 (13:34 +0200)]
doc: make the usage of clippy.toml more clear

22 months agoAuto merge of #9486 - kraktus:lazy_eval, r=dswij
bors [Fri, 30 Sep 2022 07:47:55 +0000 (07:47 +0000)]
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

22 months ago[`redundant_closure`] Add `&mut` to more cases
Evan Typanski [Thu, 29 Sep 2022 23:31:32 +0000 (19:31 -0400)]
[`redundant_closure`] Add `&mut` to more cases

22 months ago[`unnecessary_lazy_eval`] Do not lint in external macros
kraktus [Thu, 29 Sep 2022 11:45:40 +0000 (13:45 +0200)]
[`unnecessary_lazy_eval`] Do not lint in external macros

22 months agoAuto merge of #9516 - flip1995:rustup, r=flip1995
bors [Thu, 29 Sep 2022 10:04:13 +0000 (10:04 +0000)]
Auto merge of #9516 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

22 months agoUpdate lints after sync
Philipp Krones [Wed, 28 Sep 2022 12:36:56 +0000 (14:36 +0200)]
Update lints after sync

22 months agoFix dogfood
Philipp Krones [Wed, 28 Sep 2022 12:31:29 +0000 (14:31 +0200)]
Fix dogfood

22 months agoBump nightly version -> 2022-09-29
Philipp Krones [Wed, 28 Sep 2022 12:28:03 +0000 (14:28 +0200)]
Bump nightly version -> 2022-09-29

22 months agoAuto merge of #9551 - kraktus:unnecessary_lazy_evaluations, r=xFrednet
bors [Thu, 29 Sep 2022 08:36:14 +0000 (08:36 +0000)]
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`

22 months agoShrink `hir::def::Res`.
Nicholas Nethercote [Fri, 16 Sep 2022 01:45:33 +0000 (11:45 +1000)]
Shrink `hir::def::Res`.

`Res::SelfTy` currently has two `Option`s. When the second one is `Some`
the first one is never consulted. So we can split it into two variants,
`Res::SelfTyParam` and `Res::SelfTyAlias`, reducing the size of `Res`
from 24 bytes to 12. This then shrinks `hir::Path` and
`hir::PathSegment`, which are the HIR types that take up the most space.

22 months agoAuto merge of #9550 - alex-semenyuk:fix_typo, r=xFrednet
bors [Wed, 28 Sep 2022 21:44:52 +0000 (21:44 +0000)]
Auto merge of #9550 - alex-semenyuk:fix_typo, r=xFrednet

Fix typo

changelog: none

22 months ago[`unnecessary_lazy_evaluations`] Do not suggest switching to early evaluation when...
kraktus [Wed, 28 Sep 2022 20:21:52 +0000 (22:21 +0200)]
[`unnecessary_lazy_evaluations`] Do not suggest switching to early evaluation when type has custom `Drop`

22 months agoFix typo
alex-semenyuk [Wed, 28 Sep 2022 20:01:11 +0000 (23:01 +0300)]
Fix typo

22 months agoAuto merge of #9490 - kraktus:needless_borrow, r=Jarcho
bors [Wed, 28 Sep 2022 14:58:07 +0000 (14:58 +0000)]
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

22 months agoBump Clippy version -> 0.1.66
Philipp Krones [Wed, 28 Sep 2022 12:27:50 +0000 (14:27 +0200)]
Bump Clippy version -> 0.1.66

22 months agoMerge remote-tracking branch 'upstream/master' into rustup
Philipp Krones [Wed, 28 Sep 2022 12:27:32 +0000 (14:27 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

22 months agoAuto merge of #9546 - kraktus:default_not_default_trait, r=xFrednet
bors [Wed, 28 Sep 2022 11:00:37 +0000 (11:00 +0000)]
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

22 months ago[`should_implement_trait`] Also lint `default` method
kraktus [Tue, 27 Sep 2022 20:24:14 +0000 (22:24 +0200)]
[`should_implement_trait`] Also lint `default` method

22 months agoAuto merge of #9545 - Alexendoo:std-instead-of-core-unstable, r=Manishearth
bors [Tue, 27 Sep 2022 20:11:34 +0000 (20:11 +0000)]
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`

22 months agofix [`needless_borrow`] and [`explicit_auto_deref`] false positive on unions
kraktus [Sat, 17 Sep 2022 11:59:02 +0000 (13:59 +0200)]
fix [`needless_borrow`] and [`explicit_auto_deref`] false positive on unions

22 months agoAuto merge of #9491 - kraktus:drop_copy, r=Jarcho
bors [Tue, 27 Sep 2022 19:18:29 +0000 (19:18 +0000)]
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

22 months agorename `and_only_expr_in_arm` -> `is_single_call_in_arm`
kraktus [Tue, 27 Sep 2022 19:01:23 +0000 (21:01 +0200)]
rename `and_only_expr_in_arm` -> `is_single_call_in_arm`

22 months agoDon't lint unstable moves in `std_instead_of_core`
Alex Macleod [Tue, 27 Sep 2022 18:21:14 +0000 (18:21 +0000)]
Don't lint unstable moves in `std_instead_of_core`

Such as the currently unstable `core::error`

22 months agoAuto merge of #9511 - rust-lang:box-default, r=Alexendoo
bors [Tue, 27 Sep 2022 18:14:24 +0000 (18:14 +0000)]
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

22 months agoAuto merge of #9543 - philipcraig:fix-saturing-typo, r=giraffate
bors [Tue, 27 Sep 2022 14:38:12 +0000 (14:38 +0000)]
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"

22 months agoAuto merge of #9497 - kraktus:needless_return2, r=llogiq
bors [Tue, 27 Sep 2022 14:23:53 +0000 (14:23 +0000)]
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.

22 months agoAuto merge of #9507 - c410-f3r:arith, r=Alexendoo
bors [Tue, 27 Sep 2022 14:09:25 +0000 (14:09 +0000)]
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)

22 months agoAuto merge of #9539 - Jarcho:ice_9445, r=flip1995
bors [Tue, 27 Sep 2022 12:58:41 +0000 (12:58 +0000)]
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.

22 months agoadd `box-default` lint
Andre Bogus [Wed, 21 Sep 2022 21:43:49 +0000 (23:43 +0200)]
add `box-default` lint

22 months agorustc_typeck to rustc_hir_analysis
lcnr [Mon, 26 Sep 2022 11:00:29 +0000 (13:00 +0200)]
rustc_typeck to rustc_hir_analysis

22 months agofix typo "Saturing" -> "Saturating"
Philip Craig [Tue, 27 Sep 2022 08:32:55 +0000 (09:32 +0100)]
fix typo "Saturing" -> "Saturating"

22 months agoAuto merge of #9487 - kraktus:question_mark, r=Jarcho
bors [Tue, 27 Sep 2022 01:12:54 +0000 (01:12 +0000)]
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

22 months agoAuto merge of #9233 - nyurik:capture-vars, r=Alexendoo
bors [Mon, 26 Sep 2022 09:27:37 +0000 (09:27 +0000)]
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}")`

22 months agoremove cfg(bootstrap)
Pietro Albini [Tue, 20 Sep 2022 13:41:42 +0000 (15:41 +0200)]
remove cfg(bootstrap)

22 months agoRollup merge of #102197 - Nilstrieb:const-new-🌲, r=Mark-Simulacrum
fee1-dead [Mon, 26 Sep 2022 05:09:42 +0000 (13:09 +0800)]
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.

22 months agonew uninlined_format_args lint to inline explicit arguments
Yuri Astrakhan [Wed, 14 Sep 2022 16:25:48 +0000 (12:25 -0400)]
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}")`

22 months agoDon't lint `*_interior_mutable_const` on unions due to potential ICE.
Jason Newcomb [Sun, 25 Sep 2022 21:37:56 +0000 (17:37 -0400)]
Don't lint `*_interior_mutable_const` on unions due to potential ICE.

22 months agoAuto merge of #9533 - Jarcho:integration-ice-msg, r=llogiq
bors [Sun, 25 Sep 2022 14:33:36 +0000 (14:33 +0000)]
Auto merge of #9533 - Jarcho:integration-ice-msg, r=llogiq

Fix panic when displaying the backtrace of failing integration tests

changelog: None

22 months agoFix panic when displaying the backtrace of failing integration tests
Jason Newcomb [Sun, 25 Sep 2022 04:39:05 +0000 (00:39 -0400)]
Fix panic when displaying the backtrace of failing integration tests

22 months agoAuto merge of #9535 - alex-semenyuk:move_derive_partial_eq_without_eq_to_nursery...
bors [Sun, 25 Sep 2022 10:38:02 +0000 (10:38 +0000)]
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
22 months agoPlease move derive_partial_eq_without_eq to nursery
alex-semenyuk [Sun, 25 Sep 2022 10:00:25 +0000 (13:00 +0300)]
Please move derive_partial_eq_without_eq to nursery

22 months agoAuto merge of #9531 - Jarcho:ice_9459, r=llogiq
bors [Sun, 25 Sep 2022 08:09:02 +0000 (08:09 +0000)]
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

22 months agoFix ICE in `needless_pass_by_value` with unsized `dyn Fn`
Jason Newcomb [Sat, 24 Sep 2022 21:07:35 +0000 (17:07 -0400)]
Fix ICE in `needless_pass_by_value` with unsized `dyn Fn`

22 months agoseparate definitions and `HIR` owners
Takayuki Maeda [Tue, 20 Sep 2022 05:11:23 +0000 (14:11 +0900)]
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)`

22 months agoAdd `cargo lintcheck --recursive` to check dependencies of crates
Alex Macleod [Wed, 21 Sep 2022 12:29:05 +0000 (12:29 +0000)]
Add `cargo lintcheck --recursive` to check dependencies of crates

22 months agoAuto merge of #9527 - nyurik:inl2, r=llogiq
bors [Sat, 24 Sep 2022 06:41:17 +0000 (06:41 +0000)]
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`

22 months agofallout2: rework clippy_dev & _lints fmt inlining
Yuri Astrakhan [Sat, 24 Sep 2022 02:20:42 +0000 (22:20 -0400)]
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!(...))

22 months agoAuto merge of #102068 - cjgillot:erased-lifetime-print, r=eholk
bors [Sat, 24 Sep 2022 01:23:17 +0000 (01:23 +0000)]
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.

22 months agoAuto merge of #9525 - nyurik:apply-lints, r=llogiq
bors [Fri, 23 Sep 2022 21:02:02 +0000 (21:02 +0000)]
Auto merge of #9525 - nyurik:apply-lints, r=llogiq

pre-fallout: Apply uninlined_format-args lint

This change is needed for the uninlined_format-args lint to be merged. See https://github.com/rust-lang/rust-clippy/pull/9233

changelog: none

22 months agoFix clippy's const fn stability check for CURRENT_RUSTC_VERSION
Nilstrieb [Fri, 23 Sep 2022 19:04:54 +0000 (21:04 +0200)]
Fix clippy's const fn stability check for CURRENT_RUSTC_VERSION

Since clippy can use a projects MSRV for its lints, it might not want
to consider functions as const stable if they have been added lately.

Functions that have been stabilized this version use
CURRENT_RUSTC_VERSION as their version, which gets then turned into the
current version, which might be something like `1.66.0-dev`. The version
parser cannot deal with this version, so it has to be stripped off.

22 months agoStabilize const `BTree{Map,Set}::new`
Nilstrieb [Fri, 23 Sep 2022 16:03:44 +0000 (18:03 +0200)]
Stabilize const `BTree{Map,Set}::new`

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.

22 months agoand a few more from other dirs
Yuri Astrakhan [Fri, 23 Sep 2022 18:25:03 +0000 (14:25 -0400)]
and a few more from other dirs

22 months agoa few more core lint fixes
Yuri Astrakhan [Fri, 23 Sep 2022 17:55:30 +0000 (13:55 -0400)]
a few more core lint fixes

22 months agoApply uninlined_format-args to clippy_lints
Yuri Astrakhan [Fri, 23 Sep 2022 17:42:59 +0000 (13:42 -0400)]
Apply uninlined_format-args to clippy_lints

This change is needed for the uninlined_format-args lint to be merged.
See https://github.com/rust-lang/rust-clippy/pull/9233

22 months agoBless clippy.
Camille GILLOT [Thu, 22 Sep 2022 17:39:38 +0000 (19:39 +0200)]
Bless clippy.

22 months agoAuto merge of #9496 - yotamofek:never_loop_let_else, r=Jarcho
bors [Fri, 23 Sep 2022 16:06:49 +0000 (16:06 +0000)]
Auto merge of #9496 - yotamofek:never_loop_let_else, r=Jarcho

[`never_loop`]: Fix FP with let..else statements.

Fixes #9356

This has been bugging me for a while, so I thought I'd take a stab at it! I'm completely uncertain about the quality of my code, but I think it's an alright start, so opening this PR to get some feedback from more experienced clippy people :)

changelog: [`never_loop`]: Fix FP with let..else statements

22 months agoAuto merge of #9523 - smoelius:compiletest-rs, r=Alexendoo
bors [Fri, 23 Sep 2022 15:52:27 +0000 (15:52 +0000)]
Auto merge of #9523 - smoelius:compiletest-rs, r=Alexendoo

Upgrade `compiletest-rs` dependency

From `0.8` to `0.9`.

The new version includes a [fix](https://github.com/Manishearth/compiletest-rs/pull/259) for what I suspect was one cause of the recent rustup failure: https://github.com/rust-lang/rust-clippy/actions/runs/3106438892/jobs/5033324694#step:11:911

changelog: none

22 months agoAuto merge of #9519 - alessandrod:uninit-set-len-0, r=llogiq
bors [Fri, 23 Sep 2022 15:37:13 +0000 (15:37 +0000)]
Auto merge of #9519 - alessandrod:uninit-set-len-0, r=llogiq

uninit_vec: fix false positive with set_len(0)

`set_len(0)` does not create uninitialized elements. Fixes a false positive with the following pattern:

```rust
fn copy_slice_into_vec(dst: &mut Vec<u8>, src: &[u8]) {
    dst.reserve(src.len().saturating_sub(dst.len()));
    unsafe {
        dst.set_len(0);
        std::ptr::copy_nonoverlapping(src.as_ptr(), dst.as_mut_ptr(), src.len());
        dst.set_len(src.len());
    }
}
```

zulip thread: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/uninit_vec.20and.20set_len.280.29

changelog: FP: [`uninit_vec`]: No longer lints `Vec::set_len(0)`

22 months agoAuto merge of #102056 - b-naber:unevaluated, r=lcnr
bors [Fri, 23 Sep 2022 13:39:11 +0000 (13:39 +0000)]
Auto merge of #102056 - b-naber:unevaluated, r=lcnr

Introduce mir::Unevaluated

Previously the distinction between unevaluated constants in the type-system and in mir was not explicit and a little confusing. Probably better to introduce its own type for that.

r? `@lcnr`

22 months agorename Unevaluated to UnevaluatedConst
b-naber [Thu, 22 Sep 2022 10:34:23 +0000 (12:34 +0200)]
rename Unevaluated to UnevaluatedConst

22 months agoUpgrade `copiletest-rs` dependency
Samuel Moelius [Fri, 23 Sep 2022 09:53:42 +0000 (05:53 -0400)]
Upgrade `copiletest-rs` dependency

22 months agouninit_vec: special case set_len(0)
Alessandro Decina [Thu, 22 Sep 2022 23:06:13 +0000 (00:06 +0100)]
uninit_vec: special case set_len(0)

set_len(0) does not create uninitialized elements. Fixes a false positive with
the following pattern:

    fn copy_slice_into_vec(dst: &mut Vec<u8>, src: &[u8]) {
        dst.reserve(src.len().saturating_sub(dst.len()));
        unsafe {
            dst.set_len(0);
            std::ptr::copy_nonoverlapping(src.as_ptr(), dst.as_mut_ptr(), src.len());
            dst.set_len(src.len());
        }
    }

22 months agoRollup merge of #102123 - schteve:clippy-note, r=Manishearth
Matthias Krüger [Thu, 22 Sep 2022 19:34:51 +0000 (21:34 +0200)]
Rollup merge of #102123 - schteve:clippy-note, r=Manishearth

Add note to clippy::non_expressive_names doc

Addresses confusion in rust-lang/rust-clippy#9514 by updating the lint docs.

22 months agoAdd test with `unsafe` block to check #9503 is fixed too
kraktus [Thu, 22 Sep 2022 14:44:21 +0000 (16:44 +0200)]
Add test with `unsafe` block to check #9503 is fixed too

s

22 months agoMake `semicolon_span` code more refactor-tolerant
kraktus [Thu, 22 Sep 2022 14:33:14 +0000 (16:33 +0200)]
Make `semicolon_span` code more refactor-tolerant

22 months agoAuto merge of #9499 - kraktus:nonstandard_macro_braces, r=xFrednet
bors [Thu, 22 Sep 2022 14:25:27 +0000 (14:25 +0000)]
Auto merge of #9499 - kraktus:nonstandard_macro_braces, r=xFrednet

[`nonstandard_macro_braces`] Do not modify macro arguments

fix #9498

based on top of https://github.com/rust-lang/rust-clippy/pull/9471

Also simplify the lint by not caring about code format which should be `rustfmt` job, and turn the lint into machine Applicable

changelog: Suggestion: [`nonstandard_macro_braces`]: The suggestion is now machine applicable and will no longer replace brackets inside the macro argument.
  [#9499](https://github.com/rust-lang/rust-clippy/pull/9499)

22 months ago[`nonstandard_macro_braces`] Do not modify macro arguments
kraktus [Mon, 19 Sep 2022 16:08:28 +0000 (18:08 +0200)]
[`nonstandard_macro_braces`] Do not modify macro arguments

Also simplify the lint by not caring about code format which should be `rustfmt` job, and turn the lint into machine Applicable

22 months agoAuto merge of #9501 - xFrednet:changelog-1.64, r=llogiq
bors [Thu, 22 Sep 2022 12:10:53 +0000 (12:10 +0000)]
Auto merge of #9501 - xFrednet:changelog-1.64, r=llogiq

Changelog for Rust 1.64 :apple:

The normal release preparation dance. I've written the changelog like the version has already been released. The PR can be approved and then merged by anyone after the release of Rust 1.64 :upside_down_face:

---

changelog: none

22 months agointroduce mir::Unevaluated
b-naber [Mon, 19 Sep 2022 17:46:53 +0000 (19:46 +0200)]
introduce mir::Unevaluated

22 months agoAdd note to clippy::non_expressive_names doc
Steve Heindel [Wed, 21 Sep 2022 23:45:57 +0000 (19:45 -0400)]
Add note to clippy::non_expressive_names doc

22 months agoActually use the sorted vector
Michael Schubart [Wed, 21 Sep 2022 18:04:31 +0000 (19:04 +0100)]
Actually use the sorted vector

22 months ago[arithmetic-side-effects] Consider references
Caio [Wed, 21 Sep 2022 18:02:37 +0000 (15:02 -0300)]
[arithmetic-side-effects] Consider references

22 months agoMerge commit '7248d06384c6a90de58c04c1f46be88821278d8b' into sync-from-clippy
David Koloski [Wed, 21 Sep 2022 17:02:37 +0000 (13:02 -0400)]
Merge commit '7248d06384c6a90de58c04c1f46be88821278d8b' into sync-from-clippy

22 months agoAuto merge of #9471 - jplatte:patch-1, r=xFrednet
bors [Wed, 21 Sep 2022 12:56:19 +0000 (12:56 +0000)]
Auto merge of #9471 - jplatte:patch-1, r=xFrednet

Add matches! checking to nonstandard_macro_braces

changelog: Enhancement: [`nonstandard_macro_braces`]: Now includes `matches!()` in the default lint config
  [#9471](https://github.com/rust-lang/rust-clippy/pull/9471)

22 months agoAuto merge of #9505 - mikerite:fix-9504-2, r=dswij
bors [Wed, 21 Sep 2022 05:53:36 +0000 (05:53 +0000)]
Auto merge of #9505 - mikerite:fix-9504-2, r=dswij

Fix ICE in `unnecessary_to_owned`

Fixes #9504

Compiler generated call `into_future` nodes return empty substs which we need when checking it's predicates. Handle this by simply exitting when we encounter one. This change introduces false negatives in place of the ICEs.

changelog: [`unnecessary_to_owned`]: fix ICE

22 months agoFix ICE in `unnecessary_to_owned`
Michael Wright [Wed, 21 Sep 2022 05:02:52 +0000 (07:02 +0200)]
Fix ICE in `unnecessary_to_owned`

Fixes #9504

Compiler generated call `into_iter` nodes return empty substs
which we need when checking it's predicates. Handle this by
simply exitting when we encounter one. This change introduces
false negatives in place of the ICEs.

22 months agoAuto merge of #9502 - c410-f3r:arith, r=Alexendoo
bors [Tue, 20 Sep 2022 16:14:54 +0000 (16:14 +0000)]
Auto merge of #9502 - c410-f3r:arith, r=Alexendoo

[arithmetic-side-effects] Add more tests

Taken from the `integer-arithmetic` lint.

changelog: [arithmetic-side-effects] Add more tests

22 months ago[arithmetic_side_effects] Add more tests
Caio [Tue, 20 Sep 2022 15:06:49 +0000 (12:06 -0300)]
[arithmetic_side_effects] Add more tests

22 months agoChangelog for Rust 1.64 :apple:
xFrednet [Tue, 20 Sep 2022 10:14:18 +0000 (12:14 +0200)]
Changelog for Rust 1.64 :apple:

22 months agoAuto merge of #99806 - oli-obk:unconstrained_opaque_type, r=estebank
bors [Tue, 20 Sep 2022 12:09:52 +0000 (12:09 +0000)]
Auto merge of #99806 - oli-obk:unconstrained_opaque_type, r=estebank

Allow patterns to constrain the hidden type of opaque types

fixes #96572

reverts a revert as original PR was a perf regression that was fixed by reverting it: https://github.com/rust-lang/rust/pull/99368#issuecomment-1186587864)

TODO:

* check if https://github.com/rust-lang/rust/issues/99685 is avoided

22 months agoAuto merge of #9483 - c410-f3r:arith, r=Jarcho
bors [Mon, 19 Sep 2022 14:35:14 +0000 (14:35 +0000)]
Auto merge of #9483 - c410-f3r:arith, r=Jarcho

[arithmetic-side-effects] Finish non-overflowing ops

Extends https://github.com/rust-lang/rust-clippy/pull/9474 to also take into consideration "raw" binary operations. For example, `let a = b / 2` and `let a = 1 * b` won't trigger the lint.

changelog: [arithmetic-side-effects] Finish non-overflowing ops

22 months agoAdd matches! checking to nonstandard_macro_braces
Jonas Platte [Tue, 13 Sep 2022 10:08:17 +0000 (12:08 +0200)]
Add matches! checking to nonstandard_macro_braces

22 months ago[`never_loop`]: Fix FP with let..else statements.
Yotam Ofek [Mon, 19 Sep 2022 10:02:17 +0000 (10:02 +0000)]
[`never_loop`]: Fix FP with let..else statements.

22 months ago[`needless_return`] Recursively remove unneeded semicolons
kraktus [Mon, 19 Sep 2022 10:07:53 +0000 (12:07 +0200)]
[`needless_return`] Recursively remove unneeded semicolons

22 months agoremove the `Subst` trait, always use `EarlyBinder`
lcnr [Fri, 16 Sep 2022 13:31:10 +0000 (15:31 +0200)]
remove the `Subst` trait, always use `EarlyBinder`

22 months agosmall refactor
kraktus [Mon, 19 Sep 2022 05:43:16 +0000 (07:43 +0200)]
small refactor

22 months agofurther refactor
kraktus [Sun, 18 Sep 2022 19:26:23 +0000 (21:26 +0200)]
further refactor

22 months agofurther refactor of `needless_return`
kraktus [Sun, 18 Sep 2022 19:06:06 +0000 (21:06 +0200)]
further refactor of `needless_return`

22 months agorefactor `needless_return`
kraktus [Sun, 18 Sep 2022 18:41:41 +0000 (20:41 +0200)]
refactor `needless_return`

22 months ago[`drop_copy`]: Do not lint idiomatic in match arm
kraktus [Sat, 17 Sep 2022 13:33:38 +0000 (15:33 +0200)]
[`drop_copy`]: Do not lint idiomatic in match arm

22 months agoAuto merge of #9488 - Alexendoo:unused, r=llogiq
bors [Sat, 17 Sep 2022 09:29:17 +0000 (09:29 +0000)]
Auto merge of #9488 - Alexendoo:unused, r=llogiq

Add `#[allow(unused)]` to test in `cargo dev new_lint`

`rustfix` tests don't automatically apply `-Aunused` which leads to some tests having `_workarounds`, add it to new test files automatically so people don't have to worry about it

changelog: none

22 months agoAdd `#[allow(unused)]` to test in `cargo dev new_lint`
Alex Macleod [Fri, 16 Sep 2022 21:04:38 +0000 (21:04 +0000)]
Add `#[allow(unused)]` to test in `cargo dev new_lint`

22 months agoSilence [`question_mark`] in const context
kraktus [Fri, 16 Sep 2022 20:02:09 +0000 (22:02 +0200)]
Silence [`question_mark`] in const context

22 months agoChange method's name
Caio [Fri, 16 Sep 2022 20:01:29 +0000 (17:01 -0300)]
Change method's name

22 months agoRevert "Revert "Rollup merge of #98582 - oli-obk:unconstrained_opaque_type, r=estebank""
Oli Scherer [Wed, 27 Jul 2022 11:58:34 +0000 (11:58 +0000)]
Revert "Revert "Rollup merge of #98582 - oli-obk:unconstrained_opaque_type, r=estebank""

This reverts commit 4a742a691e7dd2522bad68b86fe2fd5a199d5561.

22 months agoAuto merge of #9409 - DesmondWillowbrook:iter_kv_map, r=xFrednet
bors [Fri, 16 Sep 2022 08:44:58 +0000 (08:44 +0000)]
Auto merge of #9409 - DesmondWillowbrook:iter_kv_map, r=xFrednet

Add `iter_kv_map` lint

fixes #9376

| before | after |
| -------------- | ------------------------- |
| `hmap.iter().map(\|(key, _)\| key)` | `hmap.keys()` |
| `hmap.iter().map(\|(_, v)\| v + 2)` | `hmap.values().map(\|v\| v + 2)` |
| `hmap.into_iter().map(\|(key, _)\| key)` | `hmap.into_keys()` |

Is `MachineApplicable`

changelog: [`iter_kv_map`]: added lint

22 months agoremove identity function tests
Kartavya Vashishtha [Fri, 16 Sep 2022 08:29:51 +0000 (13:59 +0530)]
remove identity function tests