]> git.lizzy.rs Git - rust.git/log
rust.git
22 months agoAuto merge of #9365 - c410-f3r:arith, r=Alexendoo
bors [Wed, 7 Sep 2022 19:55:34 +0000 (19:55 +0000)]
Auto merge of #9365 - c410-f3r:arith, r=Alexendoo

[Arithmetic] Consider literals

Fixes https://github.com/rust-lang/rust-clippy/issues/9307 and makes the `arithmetic` lint behave like `integer_arithmetic`.

It is worth noting that literal integers of a binary operation (`1 + 1`, `i32::MAX + 1`), **regardless if they are in a constant environment**, won't trigger the lint. Assign operations also have similar reasoning.

changelog: Consider literals in the arithmetic lint

22 months agoAuto merge of #9441 - Jarcho:hang_9433, r=Alexendoo
bors [Wed, 7 Sep 2022 19:43:00 +0000 (19:43 +0000)]
Auto merge of #9441 - Jarcho:hang_9433, r=Alexendoo

Fix hang in `vec_init_then_push`

fixes #9433
changelog: Fix infinite loop in `vec_init_then_push`

22 months agoFix hang in `vec_init_then_push`
Jason Newcomb [Wed, 7 Sep 2022 19:26:44 +0000 (15:26 -0400)]
Fix hang in `vec_init_then_push`

22 months ago[Arithmetic] Consider literals
Caio [Wed, 7 Sep 2022 13:00:45 +0000 (10:00 -0300)]
[Arithmetic] Consider literals

22 months agoAuto merge of #9421 - xphoniex:fix-#9420, r=giraffate
bors [Tue, 6 Sep 2022 23:44:38 +0000 (23:44 +0000)]
Auto merge of #9421 - xphoniex:fix-#9420, r=giraffate

Suggest `unwrap_or_default` when closure returns `"".to_string`

Closes https://github.com/rust-lang/rust-clippy/issues/9420

changelog: [`unwrap_or_else_default`]: suggest `unwrap_or_default()` instead of `unwrap_or_else` with a closure that returns an empty `to_string`.

22 months agoSuggest `unwrap_or_default` when closure returns `"".to_string`
xphoniex [Tue, 6 Sep 2022 04:38:29 +0000 (04:38 +0000)]
Suggest `unwrap_or_default` when closure returns `"".to_string`

Signed-off-by: xphoniex <xphoniex@users.noreply.github.com>
22 months agoAuto merge of #9342 - relrelb:or_default, r=dswij
bors [Mon, 5 Sep 2022 04:54:31 +0000 (04:54 +0000)]
Auto merge of #9342 - relrelb:or_default, r=dswij

Suggest `Entry::or_default` for `Entry::or_insert(Default::default())`

Unlike past similar work done in #6228, expand the existing `or_fun_call`
lint to detect `or_insert` calls with a `T::new()` or `T::default()`
argument, much like currently done for `unwrap_or` calls. In that case,
suggest the use of `or_default`, which is more idiomatic.

Note that even with this change, `or_insert_with(T::default)` calls
aren't detected as candidates for `or_default()`, in the same manner
that currently `unwrap_or_else(T::default)` calls aren't detected as
candidates for `unwrap_or_default()`.

Also, as a nearby cleanup, change `KNOW_TYPES` from `static` to `const`,
since as far as I understand it's preferred (should Clippy have a lint
for that?).

Addresses #3812.

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

changelog: [`or_fun_call`]: Suggest `Entry::or_default` for `Entry::or_insert(Default::default())`

22 months agoSuggest `Entry::or_default` for `Entry::or_insert(Default::default())`
relrelb [Tue, 16 Aug 2022 20:26:03 +0000 (23:26 +0300)]
Suggest `Entry::or_default` for `Entry::or_insert(Default::default())`

Unlike past similar work done in #6228, expand the existing `or_fun_call`
lint to detect `or_insert` calls with a `T::new()` or `T::default()`
argument, much like currently done for `unwrap_or` calls. In that case,
suggest the use of `or_default`, which is more idiomatic.

Note that even with this change, `or_insert_with(T::default)` calls
aren't detected as candidates for `or_default()`, in the same manner
that currently `unwrap_or_else(T::default)` calls aren't detected as
candidates for `unwrap_or_default()`.

Also, as a nearby cleanup, change `KNOW_TYPES` from `static` to `const`,
since as far as I understand it's preferred (should Clippy have a lint
for that?).

Fixes #3812.

22 months agoAuto merge of #9425 - kraktus:patch-1, r=xFrednet
bors [Sun, 4 Sep 2022 15:32:09 +0000 (15:32 +0000)]
Auto merge of #9425 - kraktus:patch-1, r=xFrednet

fix wording for `derivable_impls`

While looking at the explanation as to why this lint was not automatically applicable, found the explanation a bit clunky grammatically.

 Feel free to close if you consider the wording was correct in the first place.

changelog: none

22 months agofix wording for `derivable_impls`
kraktus [Sun, 4 Sep 2022 14:29:30 +0000 (16:29 +0200)]
fix wording for `derivable_impls`

22 months agoAuto merge of #9424 - mikerite:fix-9351-4, r=xFrednet
bors [Sun, 4 Sep 2022 15:14:58 +0000 (15:14 +0000)]
Auto merge of #9424 - mikerite:fix-9351-4, r=xFrednet

Fix `unnecessary_to_owned` false positive

Fixes #9351.

Note that this commit reworks that fix for #9317. The change
is to check that the type implements `AsRef<str>` before regarding
`to_string` as an equivalent of `to_owned`. This was suggested
by Jarcho in the #9317 issue comments.

The benefit of this is that it moves some complexity out of
`check_other_call_arg` and simplifies the module as a whole.

changelog: FP: [`unnecessary_to_owned`]: No longer lints, if type change would cause errors in the caller function

22 months agoFix `unnecessary_to_owned` false positive
Michael Wright [Sat, 3 Sep 2022 15:00:44 +0000 (17:00 +0200)]
Fix `unnecessary_to_owned` false positive

Fixes #9351.

Note that this commit reworks that fix for #9317. The change
is to check that the type implements `AsRef<str>` before regarding
`to_string` as an equivalent of `to_owned`. This was suggested
by Jarcho in the #9317 issue comments.

The benefit of this is that it moves some complexity out of
`check_other_call_arg` and simplifies the module as a whole.

22 months agoAuto merge of #9400 - lukaslueg:approx_large_enum, r=llogiq
bors [Sat, 3 Sep 2022 07:34:42 +0000 (07:34 +0000)]
Auto merge of #9400 - lukaslueg:approx_large_enum, r=llogiq

Use `approx_ty_size` for `large_enum_variant`

This builds upon #9373 to use the approximate size of each variant for `large_enum_variant`. This allows us to lint in situations where an `enum` contains generics but is still guaranteed to have a large variant on an at-least basis, e.g. with `(T, [u8; 512])`.

* I've changed the wording from "is ... bytes" to "contains at least" because
  * the size is now an approximate lower bound (e.g. `512` in the example above). The actual size is larger due to `T`, including due to `T`'s memory layout.
  * the discriminant is not taken into account in the message. This comes up with variants like `A(T)`, which are "is at least 0 bytes" otherwise, which may be misleading.
* If the second-largest variant has no fields, there is a special case "carries no data" instead of "is at least 0 bytes".
* A variant like `A(T)` is "at least 0 bytes", which is technically true, yet we don't distinguish between "indeterminate" and truly "ZST".
* The generics-tests that were there before now lint while they didn't lint before. AFAICS this is correct.

I guess the above is correct-ish. However, I use the `SubstsRef` that I got via `cx.tcx.type_of(item.def_id)` to solve for generics in the variants. Is this even applicable, since we start from an - [ ] `ItemKind`?

changelog: none

22 months agoUse `approx_ty_size` for `large_enum_variant`
Lukas Lueg [Tue, 30 Aug 2022 20:27:21 +0000 (22:27 +0200)]
Use `approx_ty_size` for `large_enum_variant`

22 months agoAuto merge of #8952 - rust-lang:explain, r=xFredNet
bors [Fri, 2 Sep 2022 20:27:42 +0000 (20:27 +0000)]
Auto merge of #8952 - rust-lang:explain, r=xFredNet

add `--explain` subcommand

This closes #8291.

---

changelog: add `cargo clippy -- --explain <lintname>` subcommand

22 months agoadd `--explain` subcommand
Andre Bogus [Sun, 5 Jun 2022 08:44:14 +0000 (10:44 +0200)]
add `--explain` subcommand

22 months agoAuto merge of #9418 - lukaslueg:issue9415, r=llogiq
bors [Fri, 2 Sep 2022 18:54:06 +0000 (18:54 +0000)]
Auto merge of #9418 - lukaslueg:issue9415, r=llogiq

Fix `mut_mutex_lock` when Mutex is behind immutable deref

I *think* the problem here is the `if let ty::Ref(_, _, Mutability::Mut) = cx.typeck_results().expr_ty(recv).kind()` line tries to check if the `Mutex` can be mutably borrowed (there already is a test for `Arc<Mutex<_>>`), but gets bamboozled by the `&mut Arc` indirection. And I *think* checking the deref-adjustment to filter immutable-adjust (the deref through the `Arc`, starting from `&mut Arc`) is the correct fix.

Fixes #9415

changelog: Fix `mut_mutex_lock` when Mutex is behind immutable deref

22 months agoFix `mut_mutex_lock` for Mutex behind imm deref
Lukas Lueg [Fri, 2 Sep 2022 18:28:00 +0000 (20:28 +0200)]
Fix `mut_mutex_lock` for Mutex behind imm deref

Fixes #9415

22 months agoAuto merge of #9417 - Jarcho:ice_9414, r=Alexendoo
bors [Fri, 2 Sep 2022 18:07:38 +0000 (18:07 +0000)]
Auto merge of #9417 - Jarcho:ice_9414, r=Alexendoo

Don't use `hir_ty_to_ty` in `result_large_err`

fixes #9414

This occurs starting with 2022-09-01. I checked that this does fix the ICE on rust-lang/rust@9353538. Not sure which pr caused the late-bound region to leak through `hir_ty_to_ty`.

changelog: None

22 months agoDon't use `hir_ty_to_ty` in `result_large_err` as it sometimes leaves late-bound...
Jason Newcomb [Fri, 2 Sep 2022 17:40:35 +0000 (13:40 -0400)]
Don't use `hir_ty_to_ty` in `result_large_err` as it sometimes leaves late-bound lifetimes.

22 months agoAuto merge of #9412 - xFrednet:jst-r-bool-to-int-lint, r=xFrednet
bors [Thu, 1 Sep 2022 21:39:06 +0000 (21:39 +0000)]
Auto merge of #9412 - xFrednet:jst-r-bool-to-int-lint, r=xFrednet

New lint `bool_to_int_with_if`

This is a rebased version of https://github.com/rust-lang/rust-clippy/pull/9086 I could sadly not push directly push to the PR branch as it's protected.

The lint implementation comes from `@jst-r.` Thank you for the work you put into this :)

---

Closes: https://github.com/rust-lang/rust-clippy/issues/8131
Closes: https://github.com/rust-lang/rust-clippy/pull/9086
changelog: Add lint [`bool_to_int_with_if`]

r? `@ghost`

22 months agoNew lint `bool_to_int_with_if`
Dmitrii Lavrov [Thu, 30 Jun 2022 13:57:15 +0000 (16:57 +0300)]
New lint `bool_to_int_with_if`

22 months agoAuto merge of #9404 - lukaslueg:issue9402, r=giraffate
bors [Thu, 1 Sep 2022 13:18:17 +0000 (13:18 +0000)]
Auto merge of #9404 - lukaslueg:issue9402, r=giraffate

Fix `suboptimal_float` not linting on `{const}.powf({const})`

There used to be an early return if the receiver was an effective const but the method was not linted, not taking into account later cases where the receiver and the arguments are both effective consts for different methods. Removed the early return.

Fixes #9402
Fixes #9201

changelog: Fix `suboptimal_flops`, `imprecise_flops` not linting on `{const}.powf({const})` et al

22 months agoFix {subopt,imprec}_float not lint const.*(const)
Lukas Lueg [Wed, 31 Aug 2022 19:08:33 +0000 (21:08 +0200)]
Fix {subopt,imprec}_float not lint const.*(const)

Fixes #9402
Fixes #9201

22 months agoAuto merge of #9406 - Jarcho:unescape_ice, r=Manishearth
bors [Thu, 1 Sep 2022 04:12:00 +0000 (04:12 +0000)]
Auto merge of #9406 - Jarcho:unescape_ice, r=Manishearth

Correctly handle unescape warnings

fixes #9405

changelog: Fix ICE when format literals raise compiler warnings

22 months agoCorrectly handle unescape warnings
Jason Newcomb [Thu, 1 Sep 2022 03:24:29 +0000 (23:24 -0400)]
Correctly handle unescape warnings

22 months agoAuto merge of #9403 - softmoth:wild_err_expect, r=Alexendoo
bors [Wed, 31 Aug 2022 13:53:39 +0000 (13:53 +0000)]
Auto merge of #9403 - softmoth:wild_err_expect, r=Alexendoo

match_wild_err_arm: Fix typo in note text

changelog: [`match_wild_err_arm`]: fix typo in note text

22 months agomatch_wild_err_arm: Fix typo in note text
Tim Siegel [Wed, 31 Aug 2022 13:09:11 +0000 (09:09 -0400)]
match_wild_err_arm: Fix typo in note text

22 months agoAuto merge of #9397 - Jarcho:trait_dup_order, r=dswij
bors [Wed, 31 Aug 2022 08:07:33 +0000 (08:07 +0000)]
Auto merge of #9397 - Jarcho:trait_dup_order, r=dswij

Fix the emission order of `trait_duplication_in_bounds`

Makes the lint emit in source order rather than whatever order the hash map happens to be in. This is currently blocking the sync into rustc.

changelog: None

22 months agoAuto merge of #9373 - lukaslueg:result_large_err, r=Alexendoo
bors [Tue, 30 Aug 2022 18:20:45 +0000 (18:20 +0000)]
Auto merge of #9373 - lukaslueg:result_large_err, r=Alexendoo

Initial implementation `result_large_err`

This is a shot at #6560, #4652, and #3884. The lint checks for `Result` being returned from functions/methods where the `Err` variant is larger than a configurable threshold (the default of which is 128 bytes). There has been some discussion around this, which I'll try to quickly summarize:

* A large `Err`-variant may force an equally large `Result` if `Err` is actually bigger than `Ok`.
* There is a cost involved in large `Result`, as LLVM may choose to `memcpy` them around above a certain size.
* We usually expect the `Err` variant to be seldomly used, but pay the cost every time.
* `Result` returned from library code has a high chance of bubbling up the call stack, getting stuffed into `MyLibError { IoError(std::io::Error), ParseError(parselib::Error), ...}`, exacerbating the problem.

This PR deliberately does not take into account comparing the `Ok` to the `Err` variant (e.g. a ratio, or one being larger than the other). Rather we choose an absolute threshold for `Err`'s size, above which we warn. The reason for this is that `Err`s probably get `map_err`'ed further up the call stack, and we can't draw conclusions from the ratio at the point where the `Result` is returned. A relative threshold would also be less predictable, while not accounting for the cost of LLVM being forced to generate less efficient code if the `Err`-variant is _large_ in absolute terms.

We lint private functions as well as public functions, as the perf-cost applies to in-crate code as well.

In order to account for type-parameters, I conjured up `fn approx_ty_size`. The function relies on `LateContext::layout_of` to compute the actual size, and in case of failure (e.g. due to generics) tries to come up with an "at least size". In the latter case, the size of obviously wrong, but the inspected size certainly can't be smaller than that. Please give the approach a heavy dose of review, as I'm not actually familiar with the type-system at all (read: I have no idea what I'm doing).

The approach does, however flimsy it is, allow us to successfully lint situations like

```rust
pub union UnionError<T: Copy> {
    _maybe: T,
    _or_perhaps_even: (T, [u8; 512]),
}

// We know `UnionError<T>` will be at least 512 bytes, no matter what `T` is
pub fn param_large_union<T: Copy>() -> Result<(), UnionError<T>> {
    Ok(())
}
```

I've given some refactoring to `functions/result_unit_err.rs` to re-use some bits. This is also the groundwork for #6409

The default threshold is 128 because of https://github.com/rust-lang/rust-clippy/issues/4652#issue-505670554

`lintcheck` does not trigger this lint for a threshold of 128. It does warn for 64, though.

The suggestion currently is the following, which is just a placeholder for discussion to be had. I did have the computed size in a `span_label`. However, that might cause both ui-tests here and lints elsewhere to become flaky wrt to their output (as the size is platform dependent).

```
error: the `Err`-variant returned via this `Result` is very large
  --> $DIR/result_large_err.rs:36:34
   |
LL | pub fn param_large_error<R>() -> Result<(), (u128, R, FullyDefinedLargeError)> {
   |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The `Err` variant is unusually large, at least 128 bytes
```

changelog: Add [`result_large_err`] lint

22 months agoInitial implementation of `result_large_err`
Lukas Lueg [Wed, 24 Aug 2022 21:11:19 +0000 (23:11 +0200)]
Initial implementation of `result_large_err`

22 months agoFix the order of `trait_duplication_in_bounds`
Jason Newcomb [Tue, 30 Aug 2022 04:33:56 +0000 (00:33 -0400)]
Fix the order of `trait_duplication_in_bounds`
* Emit the lint in source order
* Make suggestions with multiple traits be in source order rather than alphabetical

22 months agoAuto merge of #9394 - lukaslueg:issue9391, r=Jarcho
bors [Tue, 30 Aug 2022 00:37:45 +0000 (00:37 +0000)]
Auto merge of #9394 - lukaslueg:issue9391, r=Jarcho

Fix missing parens in `suboptimal_flops` suggestion

Fixes #9391. The problem is simple enough, I didn't check if the same problem occurs elsewhere, though.

changelog: fix missing parenthesis in `suboptimal_flops` suggestion

22 months agoFix more parens for `suboptimal_flops` suggs
Lukas Lueg [Mon, 29 Aug 2022 20:36:11 +0000 (22:36 +0200)]
Fix more parens for `suboptimal_flops` suggs

22 months agoAuto merge of #9395 - Alexendoo:suspicious-to-owned-test, r=Manishearth
bors [Mon, 29 Aug 2022 19:26:22 +0000 (19:26 +0000)]
Auto merge of #9395 - Alexendoo:suspicious-to-owned-test, r=Manishearth

Fix `suspicious_to_owned` test when `c_char` is `u8`

e.g. on aarch64 linux

changelog: none

22 months agoAuto merge of #9247 - clubby789:raw_slice_pointer_cast, r=Alexendoo
bors [Mon, 29 Aug 2022 18:07:50 +0000 (18:07 +0000)]
Auto merge of #9247 - clubby789:raw_slice_pointer_cast, r=Alexendoo

New lint: Raw slice pointer cast

Adds a lint to check for a raw slice being created and cast back to a pointer, suggesting `ptr::slice_from_raw_parts`, to identify UB such as https://github.com/SimonSapin/rust-typed-arena/pull/54.
```
changelog: [`cast_slice_from_raw_parts`]: Add lint to check for `slice::from_raw_parts(.., ..) as *const _`
```

22 months agoUpdate clippy_lints/src/casts/mod.rs
clubby789 [Mon, 29 Aug 2022 14:17:23 +0000 (15:17 +0100)]
Update clippy_lints/src/casts/mod.rs

Co-authored-by: Alex Macleod <alex@macleod.io>
22 months agoAdd lint `cast_slice_from_raw_parts`
clubby789 [Tue, 26 Jul 2022 18:17:21 +0000 (19:17 +0100)]
Add lint `cast_slice_from_raw_parts`

22 months agoFix `suspicious_to_owned` test when `c_char` is `u8`
Alex Macleod [Mon, 29 Aug 2022 12:07:59 +0000 (12:07 +0000)]
Fix `suspicious_to_owned` test when `c_char` is `u8`

22 months agoFix missing parens in `suboptimal_flops` sugg
Lukas Lueg [Mon, 29 Aug 2022 11:56:03 +0000 (13:56 +0200)]
Fix missing parens in `suboptimal_flops` sugg

Fixes #9391

22 months agoAuto merge of #9385 - rust-lang:unnecessary-cast-remove-parens, r=Alexendoo
bors [Mon, 29 Aug 2022 11:49:08 +0000 (11:49 +0000)]
Auto merge of #9385 - rust-lang:unnecessary-cast-remove-parens, r=Alexendoo

remove parenthesis from `unnecessary_cast` suggestion

This fixes #9380.

---

changelog: none

22 months agoAuto merge of #9388 - Jarcho:rustup, r=Jarcho
bors [Mon, 29 Aug 2022 01:51:23 +0000 (01:51 +0000)]
Auto merge of #9388 - Jarcho:rustup, r=Jarcho

Rustup

Hopefully this is done right.

changelog: None

22 months agoDisable incremental compilation on CI
Jason Newcomb [Sun, 28 Aug 2022 23:22:46 +0000 (19:22 -0400)]
Disable incremental compilation on CI

22 months agoAuto merge of #9389 - lukaslueg:penmacro, r=llogiq
bors [Sun, 28 Aug 2022 10:59:16 +0000 (10:59 +0000)]
Auto merge of #9389 - lukaslueg:penmacro, r=llogiq

Don't lint literal `None` from expansion

This addresses https://github.com/rust-lang/rust-clippy/pull/9288#issuecomment-1229398524: If the literal `None` is from expansion, we never lint. This is correct because e.g. replacing the call to `option_env!` with whatever that macro expanded to at the time of linting is certainly wrong.

changelog: Don't lint [`partialeq_to_none`] for macro-expansions

22 months agoFixes for latest nightly
Jason Newcomb [Sun, 28 Aug 2022 10:22:08 +0000 (06:22 -0400)]
Fixes for latest nightly

22 months agoBump nightly version -> 2022-08-27
Jason Newcomb [Sun, 28 Aug 2022 10:03:24 +0000 (06:03 -0400)]
Bump nightly version -> 2022-08-27

22 months agoMerge branch 'master' into rustup
Jason Newcomb [Sun, 28 Aug 2022 10:02:19 +0000 (06:02 -0400)]
Merge branch 'master' into rustup

22 months agoDon't lint literal None from expansion
Lukas Lueg [Sun, 28 Aug 2022 10:18:50 +0000 (12:18 +0200)]
Don't lint literal None from expansion

22 months agoAuto merge of #9276 - dswij:9164, r=flip1995
bors [Sun, 28 Aug 2022 07:08:18 +0000 (07:08 +0000)]
Auto merge of #9276 - dswij:9164, r=flip1995

Ignore `match_like_matches_macro` when there is comment

Closes #9164

changelog: [`match_like_matches_macro`] is ignored when there is some comment inside the match block.

Also add `span_contains_comment` util to check if given span contains comments.

22 months agoAuto merge of #8984 - xanathar:pr/suspicious_to_owned, r=llogiq
bors [Sat, 27 Aug 2022 17:38:40 +0000 (17:38 +0000)]
Auto merge of #8984 - xanathar:pr/suspicious_to_owned, r=llogiq

Implemented `suspicious_to_owned` lint to check if `to_owned` is called on a `Cow`

changelog: Add lint ``[`suspicious_to_owned`]``

-----------------
Hi,
posting this unsolicited PR as I've been burned by this issue :)
Being unsolicited, feel free to reject it or reassign a different lint level etc.

This lint checks whether `to_owned` is called on `Cow<'_, _>`. This is done because `to_owned` is very similarly named to `into_owned`, but the effect of calling those two methods is completely different (one makes the `Cow::Borrowed` into a `Cow::Owned`, the other just clones the `Cow`). If the cow is then passed to code for which the type is not checked (e.g. generics, closures, etc.) it might slip through and if the cow data is coming from an unsafe context there is the potential for accidentally cause undefined behavior.
Even if not falling into this painful case, there's really no reason to call `to_owned` on a `Cow` other than confusing people reading the code: either `into_owned` or `clone` should be called.

Note that this overlaps perfectly with `implicit_clone` as a warning, but `implicit_clone` is classified pedantic (while the consequences for `Cow` might be of a wider blast radius than just pedantry); given the overlap, I set-up the lint so that if `suspicious_to_owned` triggers `implicit_clone` will not trigger. I'm not 100% sure this is done in the correct way (I tried to copy what other lints were doing) so please provide feedback on it if it isn't.

### Checklist

- \[x] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[x] Executed `cargo dev update_lints`
- \[x] Added lint documentation
- \[x] Run `cargo dev fmt`

22 months agoIgnore when there is comment
dswij [Sat, 27 Aug 2022 16:06:30 +0000 (00:06 +0800)]
Ignore  when there is comment

22 months agoAdd `span_contains_comments` util
dswij [Mon, 1 Aug 2022 12:31:23 +0000 (20:31 +0800)]
Add `span_contains_comments` util

22 months agoremove parenthesis from unnecessary_cast suggestion
Andre Bogus [Sat, 27 Aug 2022 10:04:19 +0000 (12:04 +0200)]
remove parenthesis from unnecessary_cast suggestion

22 months agoAuto merge of #9381 - lukaslueg:issue9361, r=dswij
bors [Sat, 27 Aug 2022 08:37:29 +0000 (08:37 +0000)]
Auto merge of #9381 - lukaslueg:issue9361, r=dswij

Don't lint `needless_return` if `return` has attrs

Fixes #9361

The lint used to have a mechanic to allow `cfg`-attrs on naked `return`-statements. This was well-intentioned, yet we can have any kind of attribute, e.g. `allow`, `expect` or even custom `derive`. So the mechanic was simply removed. We now never lint on a naked `return`-statement that has attributes on it.

Turns out that the ui-test had a Catch22 in it: In `check_expect()` the `#[expect(clippy::needless_return)]` is an attribute on the `return` statement that can and will be rustfixed away without side effects. But any other attribute would also have been removed, which is what #9361 is about. The test proved the wrong thing. Removed the test, the body is tested elsewhere as well.

changelog: Ignore [`needless_return`] on `return`s with attrs

22 months agoImplemented suspicious_to_owned lint to check if `to_owned` is called on a `Cow`.
Marco Mastropaolo [Fri, 10 Jun 2022 16:28:31 +0000 (18:28 +0200)]
Implemented suspicious_to_owned lint to check if `to_owned` is called on a `Cow`.

This is done because `to_owned` is very similarly named to `into_owned`, but the
effect of calling those two methods is completely different. This creates
confusion (stemming from the ambiguity of the 'owned' term in the context of
`Cow`s) and might not be what the writer intended.

22 months agoDon't lint `needless_return` if `return` has attrs
Lukas Lueg [Fri, 26 Aug 2022 17:06:07 +0000 (19:06 +0200)]
Don't lint `needless_return` if `return` has attrs

Fixes #9361

22 months agoAuto merge of #9374 - sk1p:patch-1, r=Jarcho
bors [Fri, 26 Aug 2022 13:15:58 +0000 (13:15 +0000)]
Auto merge of #9374 - sk1p:patch-1, r=Jarcho

uninit_vec: Vec::spare_capacity_mut is stable

Quick documentation fix: `Vec::spare_capacity_mut` no longer needs nightly.

changelog: none

22 months agoAuto merge of #9379 - royrustdev:multi_assignments, r=llogiq
bors [Fri, 26 Aug 2022 12:05:57 +0000 (12:05 +0000)]
Auto merge of #9379 - royrustdev:multi_assignments, r=llogiq

new lint

This fixes #6576

If you added a new lint, here's a checklist for things that will be
checked during review or continuous integration.

- \[x] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[x] Executed `cargo dev update_lints`
- \[x] Added lint documentation
- \[x] Run `cargo dev fmt`

---

changelog: add [`multi_assignments`] lint

22 months agoadd `multi_assignments` lint
royrustdev [Fri, 26 Aug 2022 07:16:41 +0000 (12:46 +0530)]
add `multi_assignments` lint

22 months agouninit_vec: Vec::spare_capacity_mut is stable
Alexander Clausen [Thu, 25 Aug 2022 12:10:55 +0000 (14:10 +0200)]
uninit_vec: Vec::spare_capacity_mut is stable

Quick documentation fix: `Vec::spare_capacity_mut` no longer needs nightly.

22 months agoRollup merge of #99332 - jyn514:stabilize-label-break-value, r=petrochenkov
Yuki Okushi [Wed, 24 Aug 2022 23:50:54 +0000 (08:50 +0900)]
Rollup merge of #99332 - jyn514:stabilize-label-break-value, r=petrochenkov

Stabilize `#![feature(label_break_value)]`

See the stabilization report in https://github.com/rust-lang/rust/issues/48594#issuecomment-1186213313.

22 months agoAuto merge of #9370 - mikerite:20220824_ty_contains, r=Jarcho
bors [Wed, 24 Aug 2022 13:34:32 +0000 (13:34 +0000)]
Auto merge of #9370 - mikerite:20220824_ty_contains, r=Jarcho

Replace `contains_ty(..)` with `Ty::contains(..)`

This removes some code we don't need and the method syntax is
also more readable IMO.

changelog: none

22 months agoReplace `contains_ty(..)` with `Ty::contains(..)`
Michael Wright [Wed, 24 Aug 2022 06:11:29 +0000 (08:11 +0200)]
Replace `contains_ty(..)` with `Ty::contains(..)`

This removes some code we don't need and the method syntax is
also more readable IMO.

22 months agoStabilize `#![feature(label_break_value)]`
Joshua Nelson [Thu, 14 Jul 2022 13:30:38 +0000 (08:30 -0500)]
Stabilize `#![feature(label_break_value)]`

 # Stabilization proposal

The feature was implemented in https://github.com/rust-lang/rust/pull/50045 by est31 and has been in nightly since 2018-05-16 (over 4 years now).
There are [no open issues][issue-label] other than the tracking issue. There is a strong consensus that `break` is the right keyword and we should not use `return`.

There have been several concerns raised about this feature on the tracking issue (other than the one about tests, which has been fixed, and an interaction with try blocks, which has been fixed).
1. nrc's original comment about cost-benefit analysis: https://github.com/rust-lang/rust/issues/48594#issuecomment-422235234
2. joshtriplett's comments about seeing use cases: https://github.com/rust-lang/rust/issues/48594#issuecomment-422281176
3. withoutboats's comments that Rust does not need more control flow constructs: https://github.com/rust-lang/rust/issues/48594#issuecomment-450050630

Many different examples of code that's simpler using this feature have been provided:
- A lexer by rpjohnst which must repeat code without label-break-value: https://github.com/rust-lang/rust/issues/48594#issuecomment-422502014
- A snippet by SergioBenitez which avoids using a new function and adding several new return points to a function: https://github.com/rust-lang/rust/issues/48594#issuecomment-427628251. This particular case would also work if `try` blocks were stabilized (at the cost of making the code harder to optimize).
- Several examples by JohnBSmith: https://github.com/rust-lang/rust/issues/48594#issuecomment-434651395
- Several examples by Centril: https://github.com/rust-lang/rust/issues/48594#issuecomment-440154733
- An example by petrochenkov where this is used in the compiler itself to avoid duplicating error checking code: https://github.com/rust-lang/rust/issues/48594#issuecomment-443557569
- Amanieu recently provided another example related to complex conditions, where try blocks would not have helped: https://github.com/rust-lang/rust/issues/48594#issuecomment-1184213006

Additionally, petrochenkov notes that this is strictly more powerful than labelled loops due to macros which accidentally exit a loop instead of being consumed by the macro matchers: https://github.com/rust-lang/rust/issues/48594#issuecomment-450246249

nrc later resolved their concern, mostly because of the aforementioned macro problems.
joshtriplett suggested that macros could be able to generate IR directly
(https://github.com/rust-lang/rust/issues/48594#issuecomment-451685983) but there are no open RFCs,
and the design space seems rather speculative.

joshtriplett later resolved his concerns, due to a symmetry between this feature and existing labelled break: https://github.com/rust-lang/rust/issues/48594#issuecomment-632960804

withoutboats has regrettably left the language team.

joshtriplett later posted that the lang team would consider starting an FCP given a stabilization report: https://github.com/rust-lang/rust/issues/48594#issuecomment-1111269353

[issue-label]: https://github.com/rust-lang/rust/issues?q=is%3Aissue+is%3Aopen+label%3AF-label_break_value+

 ## Report

+ Feature gate:
    - https://github.com/rust-lang/rust/blob/d695a497bbf4b20d2580b75075faa80230d41667/src/test/ui/feature-gates/feature-gate-label_break_value.rs
+ Diagnostics:
    - https://github.com/rust-lang/rust/blob/6b2d3d5f3cd1e553d87b5496632132565b6779d3/compiler/rustc_parse/src/parser/diagnostics.rs#L2629
    - https://github.com/rust-lang/rust/blob/f65bf0b2bb1a99f73095c01a118f3c37d3ee614c/compiler/rustc_resolve/src/diagnostics.rs#L749
    - https://github.com/rust-lang/rust/blob/f65bf0b2bb1a99f73095c01a118f3c37d3ee614c/compiler/rustc_resolve/src/diagnostics.rs#L1001
    - https://github.com/rust-lang/rust/blob/111df9e6eda1d752233482c1309d00d20a4bbf98/compiler/rustc_passes/src/loops.rs#L254
    - https://github.com/rust-lang/rust/blob/d695a497bbf4b20d2580b75075faa80230d41667/compiler/rustc_parse/src/parser/expr.rs#L2079
    - https://github.com/rust-lang/rust/blob/d695a497bbf4b20d2580b75075faa80230d41667/compiler/rustc_parse/src/parser/expr.rs#L1569
+ Tests:
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_continue.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_unlabeled_break.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_illegal_uses.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/lint/unused_labels.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/run-pass/for-loop-while/label_break_value.rs

 ## Interactions with other features

Labels follow the hygiene of local variables.

label-break-value is permitted within `try` blocks:
```rust
let _: Result<(), ()> = try {
    'foo: {
        Err(())?;
        break 'foo;
    }
};
```

label-break-value is disallowed within closures, generators, and async blocks:
```rust
'a: {
    || break 'a
    //~^ ERROR use of unreachable label `'a`
    //~| ERROR `break` inside of a closure
}
```

label-break-value is disallowed on [_BlockExpression_]; it can only occur as a [_LoopExpression_]:
```rust
fn labeled_match() {
    match false 'b: { //~ ERROR block label not supported here
        _ => {}
    }
}

macro_rules! m {
    ($b:block) => {
        'lab: $b; //~ ERROR cannot use a `block` macro fragment here
        unsafe $b; //~ ERROR cannot use a `block` macro fragment here
        |x: u8| -> () $b; //~ ERROR cannot use a `block` macro fragment here
    }
}

fn foo() {
    m!({});
}
```

[_BlockExpression_]: https://doc.rust-lang.org/nightly/reference/expressions/block-expr.html
[_LoopExpression_]: https://doc.rust-lang.org/nightly/reference/expressions/loop-expr.html

22 months agoAuto merge of #9366 - Alexendoo:manual_string_new, r=xFrednet
bors [Tue, 23 Aug 2022 21:00:03 +0000 (21:00 +0000)]
Auto merge of #9366 - Alexendoo:manual_string_new, r=xFrednet

Rename `manual_empty_string_creation` and move to pedantic

Renames it to `manual_string_new` and moves it to the pedantic category

Pedantic because it's a fairly minor style change but could be very noisy

changelog: *doesn't need its own entry, but remember to s/manual_empty_string_creation/manual_string_new/ the changelog entry for #9295*

r? `@xFrednet` to get it in before the upcoming sync as this isn't a `cargo dev rename_lint` style rename

22 months agoRename `manual_empty_string_creation` and move to pedantic
Alex Macleod [Tue, 23 Aug 2022 14:17:30 +0000 (14:17 +0000)]
Rename `manual_empty_string_creation` and move to pedantic

22 months agoRemove the symbol from `ast::LitKind::Err`.
Nicholas Nethercote [Mon, 22 Aug 2022 03:27:52 +0000 (13:27 +1000)]
Remove the symbol from `ast::LitKind::Err`.

Because it's never used meaningfully.

22 months agoAuto merge of #9259 - smoelius:fix-9256, r=llogiq
bors [Mon, 22 Aug 2022 10:44:41 +0000 (10:44 +0000)]
Auto merge of #9259 - smoelius:fix-9256, r=llogiq

Fix `to_string_in_format_args` false positive

Fix #9256

changelog: none

22 months ago`needed_ref` -> `needs_ref`
Samuel E. Moelius III [Fri, 29 Jul 2022 21:46:09 +0000 (17:46 -0400)]
`needed_ref` -> `needs_ref`

22 months agoFix `to_string_in_format_args` false positive
Samuel E. Moelius III [Fri, 29 Jul 2022 09:34:49 +0000 (05:34 -0400)]
Fix `to_string_in_format_args` false positive

22 months agoAuto merge of #9092 - tamaroning:fix-needless-match, r=llogiq
bors [Sun, 21 Aug 2022 13:22:21 +0000 (13:22 +0000)]
Auto merge of #9092 - tamaroning:fix-needless-match, r=llogiq

Fix false positives of needless_match

closes: #9084
made needless_match take into account arm in the form of `_ if => ...`

changelog: none

22 months agoAuto merge of #8992 - kyoto7250:fix_8753, r=flip1995
bors [Sun, 21 Aug 2022 09:58:24 +0000 (09:58 +0000)]
Auto merge of #8992 - kyoto7250:fix_8753, r=flip1995

feat(fix): Do not lint if the target code is inside a loop

close #8753

we consider the following code.

```rust
fn main() {
    let vec = vec![1];
    let w: Vec<usize> = vec.iter().map(|i| i * i).collect();  // <- once.

    for i in 0..2 {
        let _ = w.contains(&i);
    }
}
```

and the clippy will issue the following warning.

```rust
warning: avoid using `collect()` when not needed
 --> src/main.rs:3:51
  |
3 |     let w: Vec<usize> = vec.iter().map(|i| i * i).collect();
  |                                                   ^^^^^^^
...
6 |         let _ = w.contains(&i);
  |                 -------------- the iterator could be used here instead
  |
  = note: `#[warn(clippy::needless_collect)]` on by default
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_collect
help: check if the original Iterator contains an element instead of collecting then checking
  |
3 ~
4 |
5 |     for i in 0..2 {
6 ~         let _ = vec.iter().map(|i| i * i).any(|x| x == i);
```

Rewrite the code as indicated.

```rust
fn main() {
    let vec = vec![1];

    for i in 0..2 {
        let _ = vec.iter().map(|i| i * i).any(|x| x == i);  // <- execute `map` every loop.
    }
}
```

this code is valid in the compiler, but, it is different from the code before the rewrite.
So, we should not lint, If `collect` is outside of a loop.

Thank you in advance.

---

changelog: Do not lint if the target code is inside a loop in `needless_collect`

22 months agoImprove error if rustfix coverage test spuriously fails
Philipp Krones [Sun, 21 Aug 2022 09:36:30 +0000 (11:36 +0200)]
Improve error if rustfix coverage test spuriously fails

22 months agoReduce code duplication
Philipp Krones [Sun, 21 Aug 2022 09:03:54 +0000 (11:03 +0200)]
Reduce code duplication

Only check for the kind of loop once instead of re-desugaring it.

22 months agofeat(fix): Do not lint if the target code is inside a loop
kyoto7250 [Mon, 13 Jun 2022 14:27:26 +0000 (23:27 +0900)]
feat(fix): Do not lint if the target code is inside a loop

22 months agoAuto merge of #8696 - J-ZhengLi:issue8492, r=flip1995
bors [Sun, 21 Aug 2022 08:32:44 +0000 (08:32 +0000)]
Auto merge of #8696 - J-ZhengLi:issue8492, r=flip1995

check for if-some-or-ok-else-none-or-err

fixes: #8492

---

changelog: make [`option_if_let_else`] to check for match expression with both Option and Result; **TODO: Change lint name? Add new lint with similar functionality?**

22 months agoReduce indentation and add comment about lint name
Philipp Krones [Sun, 21 Aug 2022 08:29:07 +0000 (10:29 +0200)]
Reduce indentation and add comment about lint name

22 months agoUpdate needless_match.stderr
tamaron [Sun, 21 Aug 2022 08:26:39 +0000 (17:26 +0900)]
Update needless_match.stderr

22 months agoand check for `Result`
J-ZhengLi [Sat, 16 Apr 2022 09:40:28 +0000 (17:40 +0800)]
and check for `Result`

22 months agoallow check for `match` in lint [`option_if_let_else`]
J-ZhengLi [Sat, 16 Apr 2022 08:57:06 +0000 (16:57 +0800)]
allow check for `match` in lint [`option_if_let_else`]
and add test case for `Result`

22 months agoAuto merge of #8857 - smoelius:fix-8855, r=flip1995
bors [Sat, 20 Aug 2022 18:02:34 +0000 (18:02 +0000)]
Auto merge of #8857 - smoelius:fix-8855, r=flip1995

Add test for #8855

Fix #8855

Here is what I think is going on.

First, the expression `format!("{:>6} {:>6}", a, b.to_string())` expands to:
```rust
{
    let res =
        ::alloc::fmt::format(::core::fmt::Arguments::new_v1_formatted(&["",
                            " "],
                &[::core::fmt::ArgumentV1::new_display(&a),
                            ::core::fmt::ArgumentV1::new_display(&b.to_string())],
                &[::core::fmt::rt::v1::Argument {
                                position: 0usize,
                                format: ::core::fmt::rt::v1::FormatSpec {
                                    fill: ' ',
                                    align: ::core::fmt::rt::v1::Alignment::Right,
                                    flags: 0u32,
                                    precision: ::core::fmt::rt::v1::Count::Implied,
                                    width: ::core::fmt::rt::v1::Count::Is(6usize),
                                },
                            },
                            ::core::fmt::rt::v1::Argument {
                                position: 1usize,
                                format: ::core::fmt::rt::v1::FormatSpec {
                                    fill: ' ',
                                    align: ::core::fmt::rt::v1::Alignment::Right,
                                    flags: 0u32,
                                    precision: ::core::fmt::rt::v1::Count::Implied,
                                    width: ::core::fmt::rt::v1::Count::Is(6usize),
                                },
                            }], unsafe { ::core::fmt::UnsafeArg::new() }));
    res
}
```
When I dump the expressions that get past the call to `has_string_formatting` [here](https://github.com/rust-lang/rust-clippy/blob/b312ad7d0cf0f30be2bd4658b71a3520a2e76709/clippy_lints/src/format_args.rs#L83), I see more than I would expect.

In particular, I see this subexpression of the above:
```
                &[::core::fmt::ArgumentV1::new_display(&a),
                            ::core::fmt::ArgumentV1::new_display(&b.to_string())],
```

This suggests to me that more expressions are getting past [this call](https://github.com/rust-lang/rust-clippy/blob/b312ad7d0cf0f30be2bd4658b71a3520a2e76709/clippy_lints/src/format_args.rs#L71) to `FormatArgsExpn::parse` than should.

Those expressions are then visited, but no `::core::fmt::rt::v1::Argument`s are found and pushed [here](https://github.com/rust-lang/rust-clippy/blob/b312ad7d0cf0f30be2bd4658b71a3520a2e76709/clippy_utils/src/macros.rs#L407).

As a result, the expressions appear unformatted, hence, the false positive.

My proposed fix is to restrict `FormatArgsExpn::parse` so that it only matches `Call` expressions.

cc: `@akanalytics`

changelog: none

22 months agoAdd test for #8855
Samuel E. Moelius III [Fri, 20 May 2022 21:53:03 +0000 (17:53 -0400)]
Add test for #8855

22 months agoAuto merge of #9269 - nahuakang:collapsible_str_replace, r=flip1995
bors [Sat, 20 Aug 2022 13:44:35 +0000 (13:44 +0000)]
Auto merge of #9269 - nahuakang:collapsible_str_replace, r=flip1995

Lint `collapsible_str_replace`

fixes #6651

```
changelog: [`collapsible_str_replace`]: create new lint `collapsible_str_replace`
```

If you added a new lint, here's a checklist for things that will be
checked during review or continuous integration.

- \[x] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[ ] Executed `cargo dev update_lints`
- \[x] Added lint documentation
- \[x] Run `cargo dev fmt`

22 months agoAuto merge of #9355 - alex-semenyuk:fixed_typos, r=giraffate
bors [Sat, 20 Aug 2022 12:49:00 +0000 (12:49 +0000)]
Auto merge of #9355 - alex-semenyuk:fixed_typos, r=giraffate

Fix typos

changelog: none

22 months agoSimplify lint logic and address code review comments
Nahua Kang [Sun, 14 Aug 2022 16:33:55 +0000 (18:33 +0200)]
Simplify lint logic and address code review comments

22 months agoFix typos
alex-semenyuk [Sat, 20 Aug 2022 09:31:29 +0000 (12:31 +0300)]
Fix typos

22 months agoAuto merge of #9258 - Serial-ATA:unused-peekable, r=Alexendoo
bors [Fri, 19 Aug 2022 18:30:13 +0000 (18:30 +0000)]
Auto merge of #9258 - Serial-ATA:unused-peekable, r=Alexendoo

Add [`unused_peekable`] lint

changelog: Add [`unused_peekable`] lint
closes: #854

22 months agoAdjust test cases; run cargo dev bless
Nahua Kang [Mon, 8 Aug 2022 20:31:53 +0000 (22:31 +0200)]
Adjust test cases; run cargo dev bless

22 months agoRemove checks on char slice; improve lint suggestion
Nahua Kang [Mon, 8 Aug 2022 20:02:26 +0000 (22:02 +0200)]
Remove checks on char slice; improve lint suggestion

22 months agoHandle repeated str::replace calls with single char kind to str
Nahua Kang [Sun, 7 Aug 2022 12:08:09 +0000 (14:08 +0200)]
Handle repeated str::replace calls with single char kind to str

22 months agoHandle replace calls with char slices
Nahua Kang [Fri, 5 Aug 2022 19:08:43 +0000 (21:08 +0200)]
Handle replace calls with char slices

22 months agoExtend and improve initial test cases for collapsible_str_replace
Nahua Kang [Thu, 4 Aug 2022 21:46:41 +0000 (23:46 +0200)]
Extend and improve initial test cases for collapsible_str_replace

22 months agoRegister new lint collapsible_str_replace to methods
Nahua Kang [Tue, 2 Aug 2022 20:37:40 +0000 (22:37 +0200)]
Register new lint collapsible_str_replace to methods

22 months agoAuto merge of #8804 - Jarcho:in_recursion, r=Alexendoo
bors [Fri, 19 Aug 2022 16:11:48 +0000 (16:11 +0000)]
Auto merge of #8804 - Jarcho:in_recursion, r=Alexendoo

Rework `only_used_in_recursion`

fixes #8782
fixes #8629
fixes #8560
fixes #8556

This is a complete rewrite of the lint. This loses some capabilities of the old implementation. Namely the ability to track through tuple and slice patterns, as well as the ability to trace through assignments.

The two reported bugs are fixed with this. One was caused by using the name of the method rather than resolving to the `DefId` of the called method. The second was cause by using the existence of a cycle in the dependency graph to determine whether the parameter was used in recursion even though there were other ways to create a cycle in the graph.

Implementation wise this switches from using a visitor to walking up the tree from every use of each parameter until it has been determined the parameter is used for something other than recursion. This is likely to perform better as it avoids walking the entire function a second time, and it is unlikely to walk up the HIR tree very much. Some cases would perform worse though.

cc `@buttercrab`

changelog: Scale back `only_used_in_recursion` to fix false positives
changelog: Move `only_used_in_recursion` back to `complexity`

22 months agoAuto merge of #9349 - Alexendoo:format-args-expn, r=flip1995
bors [Fri, 19 Aug 2022 15:55:05 +0000 (15:55 +0000)]
Auto merge of #9349 - Alexendoo:format-args-expn, r=flip1995

Refactor `FormatArgsExpn`

It now for each format argument `{..}` has:
- The `Expr` it points to, and how it does so (named/named inline/numbered/implicit)
- The parsed `FormatSpec` (format trait/fill/align/etc., the precision/width and any value they point to)
- Many spans

The caller no longer needs to pair up arguments to their value, or separately interpret the `specs` `Expr`s when it isn't `None`

The gist is that it combines the result of [`rustc_parse_format::Parser`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse_format/struct.Parser.html) with the macro expansion itself

This unfortunately makes the code a bit longer, however we need to use both as neither have all the information we're after. `rustc_parse_format` doesn't have the information to resolve named arguments to their values. The macro expansion doesn't contain whether the positions are implicit/numbered/named, or the spans for format arguments

Wanted by #9233 and #8518 to be able to port the changes from #9040

Also fixes #8643, previously the format args seem to have been paired up with the wrong values somehow

changelog: [`format_in_format_args`]: Fix false positive due to misattributed arguments

r? `@flip1995`
cc `@nyurik`

22 months agoMove `only_used_in_recursion` back into `complexity`
Jason Newcomb [Mon, 16 May 2022 00:06:17 +0000 (20:06 -0400)]
Move `only_used_in_recursion` back into `complexity`

22 months agoRework `only_used_in_recursion`
Jason Newcomb [Sun, 8 May 2022 17:11:53 +0000 (13:11 -0400)]
Rework `only_used_in_recursion`

22 months agoRefactor `FormatArgsExpn`
Alex Macleod [Thu, 18 Aug 2022 17:25:02 +0000 (17:25 +0000)]
Refactor `FormatArgsExpn`

22 months agoAuto merge of #8957 - Jarcho:more_pass_merges, r=flip1995
bors [Fri, 19 Aug 2022 15:08:49 +0000 (15:08 +0000)]
Auto merge of #8957 - Jarcho:more_pass_merges, r=flip1995

More lint pass merges

changelog: None

22 months agoMove `VerboseFileReads` into `Methods` lint pass
Jason Newcomb [Mon, 6 Jun 2022 15:58:30 +0000 (11:58 -0400)]
Move `VerboseFileReads` into `Methods` lint pass