]> git.lizzy.rs Git - rust.git/log
rust.git
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 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 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 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 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 #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 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 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 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 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 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 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 #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 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 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

22 months agoTypo
Caio [Thu, 15 Sep 2022 16:40:49 +0000 (13:40 -0300)]
Typo

22 months ago[arithmetic-side-effects] Finish non-overflowing ops
Caio [Thu, 15 Sep 2022 16:28:18 +0000 (13:28 -0300)]
[arithmetic-side-effects] Finish non-overflowing ops

22 months agoAuto merge of #9481 - giraffate:fix_indents, r=xFrednet
bors [Thu, 15 Sep 2022 09:03:59 +0000 (09:03 +0000)]
Auto merge of #9481 - giraffate:fix_indents, r=xFrednet

Fix indents

Markdowns are not displayed correctly.
https://github.com/rust-lang/rust-clippy/blob/master/book/src/development/common_tools_writing_lints.md#dealing-with-macros-and-expansions

changelog: none

22 months agoadded identity block test
Kartavya Vashishtha [Thu, 15 Sep 2022 04:16:01 +0000 (09:46 +0530)]
added identity block test

added binding annotations for all lines

22 months agoAdd iter_kv_map lint
Kartavya Vashishtha [Mon, 29 Aug 2022 18:39:25 +0000 (00:09 +0530)]
Add iter_kv_map lint

22 months agoFix indents
Takayuki Nakata [Thu, 15 Sep 2022 00:23:18 +0000 (09:23 +0900)]
Fix indents

22 months agoAuto merge of #9478 - Alexendoo:ra-docs, r=flip1995
bors [Wed, 14 Sep 2022 20:49:26 +0000 (20:49 +0000)]
Auto merge of #9478 - Alexendoo:ra-docs, r=flip1995

Update rust-analyzer documentation, mention linkedProjects

r-a uses the `rustc-dev` component from the rustup installed toolchain clippy specifies so it doesn't need to be manually installed. Also remove references to nightly r-a as the feature is long stable

I discovered `rust-analyzer.linkedProjects` recently and it has made working on the crates not referenced by the `clippy` crate so much nicer

changelog: none

22 months agoAuto merge of #9475 - Nemo157:mod-files-remap, r=xFrednet
bors [Wed, 14 Sep 2022 20:09:49 +0000 (20:09 +0000)]
Auto merge of #9475 - Nemo157:mod-files-remap, r=xFrednet

Make module-style lints resilient to --remap-path-prefix

changelog: [`self_named_module_files`], [`mod_module_files`]: Make module-style lints resilient to `--remap-path-prefix`

Without this if a user has configured `--remap-path-prefix` to be used for a prefix containing the current source directory the lints would silently fail to generate a warning.

22 months agoAuto merge of #9476 - Xaeroxe:bool-to-int-inverted, r=xFrednet
bors [Wed, 14 Sep 2022 19:56:12 +0000 (19:56 +0000)]
Auto merge of #9476 - Xaeroxe:bool-to-int-inverted, r=xFrednet

`bool_to_int_with_if` inverse case patch

Enhances `bool_to_int_with_if` such that it can also catch an inverse bool int conversion scenario, and makes the right suggestion for converting to int with a prefixed negation operator.

changelog: [`bool_to_int_with_if`]: Now correctly detects the inverse case, `if bool { 0 } else { 1 }`

22 months agofix: clippy_utils::Sugg should treat hir::ExprKind::DropTemps as transparent
Jacob Kiesel [Wed, 14 Sep 2022 19:29:32 +0000 (13:29 -0600)]
fix: clippy_utils::Sugg should treat hir::ExprKind::DropTemps as transparent

22 months agorefactor: use clippy_utils::Sugg instead of direct string ops
Jacob Kiesel [Wed, 14 Sep 2022 19:28:54 +0000 (13:28 -0600)]
refactor: use clippy_utils::Sugg instead of direct string ops

22 months agodogfood inverse bool_to_int_with_if
Jacob Kiesel [Wed, 14 Sep 2022 06:27:56 +0000 (00:27 -0600)]
dogfood inverse bool_to_int_with_if

22 months ago`bool_to_int_with_if` inverse case patch
Jacob Kiesel [Wed, 14 Sep 2022 05:50:47 +0000 (23:50 -0600)]
`bool_to_int_with_if` inverse case patch

22 months agoAuto merge of #8518 - Alexendoo:write-late-pass, r=flip1995
bors [Wed, 14 Sep 2022 15:58:21 +0000 (15:58 +0000)]
Auto merge of #8518 - Alexendoo:write-late-pass, r=flip1995

Migrate write.rs to a late pass

changelog: Migrates write.rs from a pre expansion pass to a late pass
changelog: [`positional_named_format_parameters`] is renamed in favour of the rustc lint `named_arguments_used_positionally`

- Macros are now identified by diagnostic items, so will no longer lint user defined macros named, e.g. a custom `print!`
- `print_literal`/`write_literal` no longer lint no longer lint literals that come from macro expansions, e.g. `env!("FOO")`
- `print_with_newline`/`write_with_newline` no longer lint strings with any internal `\r` or `\n`s

~~A false negative, `print_literal`/`write_literal` don't lint format strings that produce `FormatSpec`s, e.g. ones containing pretty print/width/align specifiers~~

Suggestion changes:
- ~~`print_literal`/`write_literal` no longer have suggestions, as the spans for the `{}`s were not easily obtainable~~
-  `print_with_newline`/`write_with_newline` has a better suggestion for a sole literal newline, but no longer has suggestions for len > 1 strings that end in a literal newline
- ~~`use_debug` spans are less precise, now point to the whole format string~~

The diff for write.rs is pretty unwieldy, other than for the `declare_clippy_lint!`s I think you'd be better off viewing it as a brand new file rather than looking at the diff, as it's mostly written from scratch

cc #6610, fixes #5721, fixes #7195, fixes #8615

22 months agoAuto merge of #9465 - Alexendoo:peekable-fp, r=flip1995
bors [Wed, 14 Sep 2022 15:03:39 +0000 (15:03 +0000)]
Auto merge of #9465 - Alexendoo:peekable-fp, r=flip1995

Fix `unused_peekable` closure and `f(&mut peekable)` false positives

changelog: Fix [`unused_peekable`] false positive when peeked in a closure or called as `f(&mut peekable)`

The `return`/`break` changes aren't part of the fix, they allow an earlier return in some cases. `break` is replaced with `return` for style purposes as they do the same thing in this case

Fixes #9456
Fixes #9462

22 months agoUpdate rust-analyzer documentation, mention linkedProjects
Alex Macleod [Wed, 14 Sep 2022 10:46:20 +0000 (10:46 +0000)]
Update rust-analyzer documentation, mention linkedProjects

22 months agoAuto merge of #9467 - pyhrr0:macro_expansion, r=giraffate
bors [Tue, 13 Sep 2022 23:45:29 +0000 (23:45 +0000)]
Auto merge of #9467 - pyhrr0:macro_expansion, r=giraffate

Fix `almost_complete_letter_range` false positive.

changelog: Fix [`almost_complete_letter_range`] false positive in an external macro

22 months agoMake module-style lints resilient to --remap-path-prefix
Wim Looman [Tue, 13 Sep 2022 19:27:01 +0000 (21:27 +0200)]
Make module-style lints resilient to --remap-path-prefix

22 months agoAuto merge of #9474 - c410-f3r:arith, r=llogiq
bors [Tue, 13 Sep 2022 19:00:24 +0000 (19:00 +0000)]
Auto merge of #9474 - c410-f3r:arith, r=llogiq

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

* Adding or Subtracting 0
* Division and Module of anything other than 0
* Multiplying 1 or 0

changelog: [arithmetic-side-effects] More non-overflowing operations

22 months ago[arithmetic-side-effects] More non-overflowing ops
Caio [Tue, 13 Sep 2022 18:50:24 +0000 (15:50 -0300)]
[arithmetic-side-effects] More non-overflowing ops

22 months agoAuto merge of #9429 - kraktus:deriv_ma, r=xFrednet
bors [Tue, 13 Sep 2022 16:43:04 +0000 (16:43 +0000)]
Auto merge of #9429 - kraktus:deriv_ma, r=xFrednet

Make `derivable_impls` machine applicable

changelog: [`derivable_impls`]: Now machine applicable

22 months agoMake `derivable_impls` machine applicable
kraktus [Mon, 5 Sep 2022 10:04:54 +0000 (12:04 +0200)]
Make `derivable_impls` machine applicable

22 months agoAuto merge of #9454 - kraktus:use_self, r=flip1995
bors [Tue, 13 Sep 2022 12:44:16 +0000 (12:44 +0000)]
Auto merge of #9454 - kraktus:use_self, r=flip1995

Do not lint `use_self` in proc macro expansion

fix https://github.com/rust-lang/rust-clippy/issues/9440
fix https://github.com/rust-lang/rust-clippy/issues/8910
fix https://github.com/rust-lang/rust-clippy/issues/6902

changelog: [`use_self`]: Do not lint in proc macro expansion

22 months agoAuto merge of #9452 - kraktus:doc, r=flip1995
bors [Tue, 13 Sep 2022 12:29:26 +0000 (12:29 +0000)]
Auto merge of #9452 - kraktus:doc, r=flip1995

Fix dev book

fix `implements_trait` and `in_external_macro` import path

Remove example using `match_trait_method` since its deprecated.

changelog: none

22 months agoOnly ignore external macros.
S. van Dijk [Tue, 13 Sep 2022 07:51:32 +0000 (09:51 +0200)]
Only ignore external macros.

22 months agoAuto merge of #9464 - lukaslueg:issue9463, r=dswij
bors [Mon, 12 Sep 2022 16:56:53 +0000 (16:56 +0000)]
Auto merge of #9464 - lukaslueg:issue9463, r=dswij

Don't panic on invalid shift while constfolding

Instead of panicking on invalid shifts while folding constants we simply give up. Fixes #9463

Notice the "attempt to shift right by `1316134912_u32`", which seems weird. AFAICS it comes from rustc itself.

changelog: none

22 months agoAuto merge of #9466 - lukaslueg:issue9460, r=dswij
bors [Mon, 12 Sep 2022 16:35:30 +0000 (16:35 +0000)]
Auto merge of #9466 - lukaslueg:issue9460, r=dswij

Don't lint `large_stack_array` inside static items

We now check if the linted `Expr` is inside an `ItemKind::Static`, which can't take the suggested `Box<[...]`. I _think_ this is the correct fix for #9460

I removed `if_chain` while I was at it.

changelog: Don't lint `large_stack_array` inside static items

22 months agoAuto merge of #9469 - Alexendoo:expr-field-visitor, r=giraffate
bors [Mon, 12 Sep 2022 13:58:53 +0000 (13:58 +0000)]
Auto merge of #9469 - Alexendoo:expr-field-visitor, r=giraffate

Fix FormatArgsExpn parsing of FormatSpec positions

Woops, forgot visitors don't walk themselves

Fixes #9468

r? `@giraffate`

changelog: none

22 months agoFix FormatArgsExpn parsing of FormatSpec positions
Alex Macleod [Mon, 12 Sep 2022 11:34:09 +0000 (11:34 +0000)]
Fix FormatArgsExpn parsing of FormatSpec positions

22 months agoAdd test.
S. van Dijk [Mon, 12 Sep 2022 08:44:44 +0000 (10:44 +0200)]
Add test.

22 months agoAuto merge of #9458 - Alexendoo:expr-field-visitor, r=giraffate
bors [Mon, 12 Sep 2022 00:21:28 +0000 (00:21 +0000)]
Auto merge of #9458 - Alexendoo:expr-field-visitor, r=giraffate

Use `visit_expr_field` for `ParamPosition`

A small change to make it a little simpler

changelog: none

22 months agoStop lint from checking code expanded from macros.
S. van Dijk [Sun, 11 Sep 2022 18:15:35 +0000 (20:15 +0200)]
Stop lint from checking code expanded from macros.

22 months agoAuto merge of #9410 - dswij:issue-9375, r=xFrednet
bors [Sun, 11 Sep 2022 15:10:00 +0000 (15:10 +0000)]
Auto merge of #9410 - dswij:issue-9375, r=xFrednet

Use macro callsite when creating `Sugg` helper

Closes #9375

changelog: Improvement: [`collapsible_if`]: Suggestions now work with macros, by taking the call site into account.

22 months agoDont lint `large_stack_array` inside static items
Lukas Lueg [Sun, 11 Sep 2022 14:24:33 +0000 (16:24 +0200)]
Dont lint `large_stack_array` inside static items

Fixes #9460

22 months agoFix `unused_peekable` closure and `f(&mut peekable)` false positives
Alex Macleod [Sun, 11 Sep 2022 12:17:51 +0000 (12:17 +0000)]
Fix `unused_peekable` closure and `f(&mut peekable)` false positives

22 months agoDon't panic on invalid shift while constfolding
Lukas Lueg [Sun, 11 Sep 2022 10:26:13 +0000 (12:26 +0200)]
Don't panic on invalid shift while constfolding

Fixes #9463

22 months agoAuto merge of #9457 - kraktus:nonminimal_bool, r=Manishearth
bors [Sat, 10 Sep 2022 19:11:08 +0000 (19:11 +0000)]
Auto merge of #9457 - kraktus:nonminimal_bool, r=Manishearth

Do not expand macro in `nonminimal_bool` suggestions

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

changelog: Do not expand macros in [`nonminimal_bool`] suggestions

22 months agoUse visit_expr_field for ParamPosition
Alex Macleod [Sat, 10 Sep 2022 18:32:05 +0000 (18:32 +0000)]
Use visit_expr_field for ParamPosition

22 months agoDo not expand macro in `nonminimal_bool` suggestions
kraktus [Sat, 10 Sep 2022 17:48:14 +0000 (19:48 +0200)]
Do not expand macro in `nonminimal_bool` suggestions

22 months agoAuto merge of #9453 - kraktus:a_on_re_state, r=Jarcho
bors [Sat, 10 Sep 2022 13:18:06 +0000 (13:18 +0000)]
Auto merge of #9453 - kraktus:a_on_re_state, r=Jarcho

[`assertions_on_result_states`]: Fix suggestion when `assert!` is not in a statement.

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

changelog: [`assertions_on_result_states`]: Fix suggestion when `assert!` is not in a statement.

22 months agoRemove duplicate context check
kraktus [Sat, 10 Sep 2022 09:47:07 +0000 (11:47 +0200)]
Remove duplicate context check

22 months agoDo not lint `use_self` in proc macro expansion
kraktus [Sat, 10 Sep 2022 09:36:31 +0000 (11:36 +0200)]
Do not lint `use_self` in proc macro expansion

22 months agorefactor: move `has_debug_impl` to `clippy_utils::ty`
kraktus [Sat, 10 Sep 2022 08:39:51 +0000 (10:39 +0200)]
refactor: move `has_debug_impl` to `clippy_utils::ty`