Commit Graph

15209 Commits

Author SHA1 Message Date
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
Alex Macleod
fc77d91469 Add cargo lintcheck --recursive to check dependencies of crates 2022-09-24 12:01:08 +00: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
bors
c2d426650b 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
2022-09-23 21:02:02 +00:00
Nilstrieb
e30b37b84b 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.
2022-09-23 21:04:54 +02:00
Nilstrieb
334f4535bd 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.
2022-09-23 20:55:37 +02:00
Yuri Astrakhan
59d0e8caba and a few more from other dirs 2022-09-23 14:25:03 -04:00
Yuri Astrakhan
cb6d1267c4 a few more core lint fixes 2022-09-23 13:55:30 -04:00
Yuri Astrakhan
e67b2bf732 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
2022-09-23 13:42:59 -04:00
Camille GILLOT
781e45c224 Bless clippy. 2022-09-23 18:42:14 +02:00
bors
ff65eec801 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
2022-09-23 16:06:49 +00:00
bors
c8f2f383b5 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
2022-09-23 15:52:27 +00:00
bors
dc14531fe9 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)`
2022-09-23 15:37:13 +00:00
bors
d9277c6aa8 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`
2022-09-23 13:39:11 +00:00
b-naber
26861fbd7f rename Unevaluated to UnevaluatedConst 2022-09-23 14:27:34 +02:00
Samuel Moelius
628a854ae2 Upgrade copiletest-rs dependency 2022-09-23 05:53:42 -04:00
Alessandro Decina
49319b4206 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());
        }
    }
2022-09-23 09:35:47 +01:00
Matthias Krüger
2063b8f137 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.
2022-09-22 21:34:51 +02:00
kraktus
b333645971 Add test with unsafe block to check #9503 is fixed too
s
2022-09-22 16:52:25 +02:00
kraktus
cda7547394 Make semicolon_span code more refactor-tolerant 2022-09-22 16:33:14 +02:00
bors
61fd2a8c6f 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)
2022-09-22 14:25:27 +00:00
kraktus
a390115c6f [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
2022-09-22 16:24:23 +02:00
bors
c2c170adbe Auto merge of #9501 - xFrednet:changelog-1.64, r=llogiq
Changelog for Rust 1.64 🍎

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 🙃

---

changelog: none
2022-09-22 12:10:53 +00:00
b-naber
adc7e3e679 introduce mir::Unevaluated 2022-09-22 12:35:28 +02:00
Steve Heindel
09b1e8ff34 Add note to clippy::non_expressive_names doc 2022-09-21 19:45:57 -04:00
Michael Schubart
033dae9ecc Actually use the sorted vector 2022-09-21 19:04:31 +01:00
Caio
4c5f23082a [arithmetic-side-effects] Consider references 2022-09-21 15:02:37 -03:00
David Koloski
4d015293d1 Merge commit '7248d06384c6a90de58c04c1f46be88821278d8b' into sync-from-clippy 2022-09-21 13:13:27 -04:00
bors
7248d06384 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)
2022-09-21 12:56:19 +00:00
bors
3956c9d3fe 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
2022-09-21 05:53:36 +00:00
Michael Wright
a783d54207 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.
2022-09-21 07:14:04 +02:00
bors
1f66a3e8d0 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
2022-09-20 16:14:54 +00:00
Caio
736d88b549 [arithmetic_side_effects] Add more tests 2022-09-20 12:06:49 -03:00
xFrednet
e279f22a91
Changelog for Rust 1.64 🍎 2022-09-20 15:23:48 +02:00
bors
0dc24ca376 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
2022-09-20 12:09:52 +00:00
bors
5c3c6a2de6 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
2022-09-19 14:35:14 +00:00
Jonas Platte
25584c0c67
Add matches! checking to nonstandard_macro_braces 2022-09-19 14:16:59 +02:00
Yotam Ofek
d63aeceaa1 [never_loop]: Fix FP with let..else statements. 2022-09-19 10:57:29 +00:00