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

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

23 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

23 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.

23 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

23 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

23 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

23 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`

23 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

23 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

23 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`

23 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

23 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.

23 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

23 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?**

23 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

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

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

23 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`

23 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

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

23 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`

23 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

23 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

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

23 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

23 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

23 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

23 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

23 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

23 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

23 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

23 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`

23 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`

23 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`

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

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

23 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

23 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

23 months agoMove `VecResizeToZero` into `Methods` lint pass
Jason Newcomb [Mon, 6 Jun 2022 15:17:38 +0000 (11:17 -0400)]
Move `VecResizeToZero` into `Methods` lint pass

23 months agoMove `UnnecessarySortBy` into `Methods` lint pass
Jason Newcomb [Mon, 6 Jun 2022 03:22:58 +0000 (23:22 -0400)]
Move `UnnecessarySortBy` into `Methods` lint pass

23 months agoMove `UnitHash` into `Methods` lint pass
Jason Newcomb [Mon, 6 Jun 2022 01:41:33 +0000 (21:41 -0400)]
Move `UnitHash` into `Methods` lint pass

23 months agoMove `TransmutingNull` into `Transmute` lint pass
Jason Newcomb [Mon, 6 Jun 2022 01:36:40 +0000 (21:36 -0400)]
Move `TransmutingNull` into `Transmute` lint pass

23 months agoMove `StableSortPrimitive` to `Methods` lint pass
Jason Newcomb [Mon, 6 Jun 2022 01:07:29 +0000 (21:07 -0400)]
Move `StableSortPrimitive` to `Methods` lint pass

23 months agoMove `RepeatOnce` into `Methods` lint pass
Jason Newcomb [Mon, 6 Jun 2022 00:49:03 +0000 (20:49 -0400)]
Move `RepeatOnce` into `Methods` lint pass

23 months agoMove `range_zip_with_len` into `Methods` lint pass
Jason Newcomb [Mon, 6 Jun 2022 00:39:57 +0000 (20:39 -0400)]
Move `range_zip_with_len` into `Methods` lint pass

23 months agoMove `PathBufPushOverwrite` into `Methods` lint group
Jason Newcomb [Mon, 6 Jun 2022 00:27:36 +0000 (20:27 -0400)]
Move `PathBufPushOverwrite` into `Methods` lint group

23 months agoMove `OpenOptions` into `Methods` lint pass
Jason Newcomb [Mon, 6 Jun 2022 00:09:55 +0000 (20:09 -0400)]
Move `OpenOptions` into `Methods` lint pass

23 months agoMove `MutMutexLock` into `Methods` lint pass
Jason Newcomb [Sun, 5 Jun 2022 23:57:58 +0000 (19:57 -0400)]
Move `MutMutexLock` into `Methods` lint pass

23 months agoMove `MapErrIgnore` into `Methods` lint pass
Jason Newcomb [Sun, 5 Jun 2022 19:59:24 +0000 (15:59 -0400)]
Move `MapErrIgnore` into `Methods` lint pass

23 months agoMove `MapClone` into `Methods` lint pass
Jason Newcomb [Sun, 5 Jun 2022 19:45:04 +0000 (15:45 -0400)]
Move `MapClone` into `Methods` lint pass

23 months agoMove `ManualOkOr` into `Methods` lint pass
Jason Newcomb [Sun, 5 Jun 2022 19:20:47 +0000 (15:20 -0400)]
Move `ManualOkOr` into `Methods` lint pass

23 months agoMove `GetFirst` into `Methods` lint pass
Jason Newcomb [Sun, 5 Jun 2022 17:44:09 +0000 (13:44 -0400)]
Move `GetFirst` into `Methods` lint pass

23 months agoMove `CaseSensitiveFileExtensionComparisons` into `Methods` lint pass
Jason Newcomb [Sun, 5 Jun 2022 17:21:04 +0000 (13:21 -0400)]
Move `CaseSensitiveFileExtensionComparisons` into `Methods` lint pass

23 months agoMove `BytesCountToLen` into `Methods` lint pass
Jason Newcomb [Sun, 5 Jun 2022 17:05:11 +0000 (13:05 -0400)]
Move `BytesCountToLen` into `Methods` lint pass

23 months agoMove `ByteCount` into `Methods` lint pass
Jason Newcomb [Sun, 5 Jun 2022 15:39:36 +0000 (11:39 -0400)]
Move `ByteCount` into `Methods` lint pass

23 months agoMove `BorrowAsPtr` into `Casts` lint pass
Jason Newcomb [Sun, 5 Jun 2022 13:33:15 +0000 (09:33 -0400)]
Move `BorrowAsPtr` into `Casts` lint pass

23 months agoMove `AsUnderscore` into `Casts` lint pass
Jason Newcomb [Sun, 5 Jun 2022 13:13:13 +0000 (09:13 -0400)]
Move `AsUnderscore` into `Casts` lint pass

23 months agoBetter handle method/function calls
Serial [Fri, 5 Aug 2022 17:49:43 +0000 (13:49 -0400)]
Better handle method/function calls

23 months agoAdd [`unused_peekable`] lint
Serial [Fri, 29 Jul 2022 00:50:43 +0000 (20:50 -0400)]
Add [`unused_peekable`] lint

23 months agoAuto merge of #9295 - Guilherme-Vasconcelos:manual-empty-string-creation, r=dswij
bors [Fri, 19 Aug 2022 11:19:06 +0000 (11:19 +0000)]
Auto merge of #9295 - Guilherme-Vasconcelos:manual-empty-string-creation, r=dswij

Add `manual_empty_string_creations` lint

Closes #2972

- [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: [`manual_empty_string_creations`]: Add lint for empty String not being created with `String::new()`

23 months agoAuto merge of #9348 - lukaslueg:issue9347, r=Alexendoo
bors [Thu, 18 Aug 2022 18:13:39 +0000 (18:13 +0000)]
Auto merge of #9348 - lukaslueg:issue9347, r=Alexendoo

Don't lint on match pattern-binding in ´question_mark`

Fixes #9347

Technically it is possible to have a blank match-pattern that does nothing, and we fail to lint. But it's easier to be safe than sorry here.

changelog: [`question_mark`]: don't lint `if let`s with subpatterns

23 months agoDont lint on match pattern-binding
Lukas Lueg [Thu, 18 Aug 2022 17:30:56 +0000 (19:30 +0200)]
Dont lint on match pattern-binding

Fixes #9347

Technically it is possible to have a blank match-pattern that does
nothing, and we fail to lint. But its easier to be safe than sorry here.

23 months agoAuto merge of #9136 - smoelius:enhance-needless-borrow, r=Jarcho
bors [Thu, 18 Aug 2022 15:57:37 +0000 (15:57 +0000)]
Auto merge of #9136 - smoelius:enhance-needless-borrow, r=Jarcho

Enhance `needless_borrow` to consider trait implementations

The proposed enhancement causes `needless_borrow` to suggest removing `&` from `&e` when `&e` is an argument position requiring trait implementations, and `e` implements the required traits. Example:
```
error: the borrowed expression implements the required traits
  --> $DIR/needless_borrow.rs:131:51
   |
LL |     let _ = std::process::Command::new("ls").args(&["-a", "-l"]).status().unwrap();
   |                                                   ^^^^^^^^^^^^^ help: change this to: `["-a", "-l"]`
```

r? `@Jarcho`

changelog: Enhance `needless_borrow` to consider trait implementations

23 months agoAuto merge of #9338 - sgued:9331-unwrap-err-used, r=giraffate
bors [Wed, 17 Aug 2022 23:35:44 +0000 (23:35 +0000)]
Auto merge of #9338 - sgued:9331-unwrap-err-used, r=giraffate

unwrap_used and expect_used: trigger on uses of their _err variants

changelog: [`unwrap_used`]: lint uses of `unwrap_err`
changelog: [`expect_used`]: lint uses of `expect_err`

fixes #9331

23 months agounwrap_used: Fix error message for unwrap_err when expect_used is allowed
Sosthène Guédon [Wed, 17 Aug 2022 16:58:17 +0000 (18:58 +0200)]
unwrap_used: Fix error message for unwrap_err when expect_used is allowed

23 months agoAuto merge of #9287 - Jarcho:trans_undefined, r=xFrednet
bors [Wed, 17 Aug 2022 13:14:55 +0000 (13:14 +0000)]
Auto merge of #9287 - Jarcho:trans_undefined, r=xFrednet

`transmute_undefined_repr` fix

changelog: Don't lint `transmute_undefined_repr` when the the first field of a `repr(C)` type is compatible with the other type

23 months agoAuto merge of #9345 - cherryblossom000:patch-1, r=flip1995
bors [Wed, 17 Aug 2022 09:18:14 +0000 (09:18 +0000)]
Auto merge of #9345 - cherryblossom000:patch-1, r=flip1995

Fix typo in as_undescore docs

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

changelog: none

23 months agoAuto merge of #9344 - Jarcho:opt_target_dir, r=flip1995
bors [Wed, 17 Aug 2022 08:56:35 +0000 (08:56 +0000)]
Auto merge of #9344 - Jarcho:opt_target_dir, r=flip1995

Handle `CARGO_TARGET_DIR` not being set in compile-test

changelog: None

23 months agoFix typo in as_undescore docs
cherryblossom [Wed, 17 Aug 2022 08:56:06 +0000 (18:56 +1000)]
Fix typo in as_undescore docs

du -> due

23 months agoHandle `CARGO_TARGET_DIR` not being set in compile-test
Jason Newcomb [Wed, 17 Aug 2022 01:22:29 +0000 (21:22 -0400)]
Handle `CARGO_TARGET_DIR` not being set in compile-test

23 months agoAuto merge of #9341 - bmc-msft:suggest-map_or-instead-of-unwrap_or, r=giraffate
bors [Wed, 17 Aug 2022 00:30:41 +0000 (00:30 +0000)]
Auto merge of #9341 - bmc-msft:suggest-map_or-instead-of-unwrap_or, r=giraffate

suggest map_or in case_sensitive_file_extension_comparisons

changelog: [`case_sensitive_file_extension_comparisons `]: updated suggestion in the example to use `map_or`

Currently, case_sensitive_file_extension_comparisons suggests using `map(..).unwrap_or(..)` which trips up the `map_unwrap_or` lint.  This updates the suggestion to use `map_or`.

23 months agoFix adjacent code
Samuel E. Moelius III [Fri, 8 Jul 2022 09:30:17 +0000 (05:30 -0400)]
Fix adjacent code

23 months agoEnhance `needless_borrow` to consider trait implementations
Samuel E. Moelius III [Fri, 8 Jul 2022 09:29:10 +0000 (05:29 -0400)]
Enhance `needless_borrow` to consider trait implementations

23 months agoAuto merge of #9343 - Serial-ATA:compiletest-target-env, r=Manishearth
bors [Tue, 16 Aug 2022 21:39:45 +0000 (21:39 +0000)]
Auto merge of #9343 - Serial-ATA:compiletest-target-env, r=Manishearth

Use `CARGO_TARGET_DIR` in compile-test

changelog: none

I have a global `CARGO_TARGET_DIR` set, but forgot to delete the old target dir. `compile-test` was getting tripped up on an outdated `rustfix_missing_coverage.txt` I had in there, keeping me from running tests :smile:.

23 months agoUse `CARGO_TARGET_DIR` in compile-test
Serial [Tue, 16 Aug 2022 21:17:21 +0000 (17:17 -0400)]
Use `CARGO_TARGET_DIR` in compile-test

23 months agoAuto merge of #9327 - Serial-ATA:non_ascii_literal_macro, r=Alexendoo
bors [Tue, 16 Aug 2022 20:22:39 +0000 (20:22 +0000)]
Auto merge of #9327 - Serial-ATA:non_ascii_literal_macro, r=Alexendoo

Fix [`non_ascii_literal`] in tests

changelog: Don't lint [`non_ascii_literal`] when using non-ascii comments in tests
changelog: Don't lint [`non_ascii_literal`] when `allow`ed on tests

closes: #7739
closes: #8263

23 months agosuggest map_or in case_sensitive_file_extension_comparisons
Brian Caswell [Tue, 16 Aug 2022 20:03:23 +0000 (16:03 -0400)]
suggest map_or in case_sensitive_file_extension_comparisons

Currently, case_sensitive_file_extension_comparisons suggests using
`map(..).unwrap_or(..)` which trips up `map_unwrap_or`.  This updates
the suggestion to use map_or.

23 months agoFix [`non_ascii_literal`] in tests
Serial [Sat, 13 Aug 2022 00:02:57 +0000 (20:02 -0400)]
Fix [`non_ascii_literal`] in tests

23 months agounwrap_used and expect_used: trigger on uses of their _err variants
Sosthène Guédon [Mon, 15 Aug 2022 18:30:30 +0000 (20:30 +0200)]
unwrap_used and expect_used: trigger on uses of their _err variants

23 months agoAuto merge of #9340 - alex-semenyuk:box_t, r=dswij
bors [Tue, 16 Aug 2022 13:27:10 +0000 (13:27 +0000)]
Auto merge of #9340 - alex-semenyuk:box_t, r=dswij

Fix example

The example didn't show the actual problem [playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=9d0e0727ca5bbd854767f50da693ca0f)
changelog: none

23 months agoAuto merge of #9040 - miam-miam100:unused_named_parameter, r=dswij
bors [Tue, 16 Aug 2022 13:11:27 +0000 (13:11 +0000)]
Auto merge of #9040 - miam-miam100:unused_named_parameter, r=dswij

Add new lint [`positional_named_format_parameters`]

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

changelog: Add new lint [`positional_named_format_parameters`] to warn when named parameters in format strings are used as positional arguments.

23 months agoFix example
alexey semenyuk [Tue, 16 Aug 2022 09:50:53 +0000 (12:50 +0300)]
Fix example

23 months agoAuto merge of #9328 - stanislav-tkach:borrow_deref_ref-remove-extra-deref-from-exampl...
bors [Tue, 16 Aug 2022 00:19:21 +0000 (00:19 +0000)]
Auto merge of #9328 - stanislav-tkach:borrow_deref_ref-remove-extra-deref-from-example, r=giraffate

Remove extra dereference from the borrow_deref_ref lint example

I don't think such minor change should be mentioned in the changelog.

changelog: none

23 months agoAuto merge of #9318 - lukaslueg:ifletmutexref, r=xFrednet
bors [Mon, 15 Aug 2022 21:31:37 +0000 (21:31 +0000)]
Auto merge of #9318 - lukaslueg:ifletmutexref, r=xFrednet

Fix if_let_mutex not checking Mutexes behind refs

Fixes #9193

We can always peel references because we are looking for a method-call, for which autoderef applies.

---

changelog: [`if_let_mutex`]: detect calls to `Mutex::lock()` if mutex is behind a ref
changelog: [`if_let_mutex`]: Add labels to the two instances of the same Mutex that will deadlock

23 months agoSimplify the borrow_deref_ref lint example
Stanislav Tkach [Sat, 13 Aug 2022 14:04:30 +0000 (16:04 +0200)]
Simplify the borrow_deref_ref lint example

23 months agoFix label not starting with lcase-letter
lukaslueg [Mon, 15 Aug 2022 18:13:31 +0000 (20:13 +0200)]
Fix label not starting with lcase-letter

Co-authored-by: Fridtjof Stoldt <xFrednet@gmail.com>
23 months agoAuto merge of #9329 - xphoniex:fix-#9317, r=flip1995
bors [Mon, 15 Aug 2022 10:01:20 +0000 (10:01 +0000)]
Auto merge of #9329 - xphoniex:fix-#9317, r=flip1995

Skip `unnecessary_to_owned` when `t != t.to_string()`

Fixes #9317

changelog: [`unnecessary_to_owned`]: none

23 months agoSkip `unnecessary_to_owned` when `t != t.to_string()`
xphoniex [Sun, 14 Aug 2022 16:29:26 +0000 (16:29 +0000)]
Skip `unnecessary_to_owned` when `t != t.to_string()`

Signed-off-by: xphoniex <dj.2dixx@gmail.com>
23 months agoUpdate all tests to comply with clippy::manual_empty_string_creations
Guilherme-Vasconcelos [Fri, 5 Aug 2022 23:59:50 +0000 (20:59 -0300)]
Update all tests to comply with clippy::manual_empty_string_creations

23 months agoImplement clippy::manual_empty_string_creations lint
Guilherme-Vasconcelos [Mon, 18 Jul 2022 00:20:51 +0000 (21:20 -0300)]
Implement clippy::manual_empty_string_creations lint

23 months agoAuto merge of #9187 - sgued:iter-once, r=flip1995
bors [Sun, 14 Aug 2022 15:45:17 +0000 (15:45 +0000)]
Auto merge of #9187 - sgued:iter-once, r=flip1995

Add lint recommending using `std::iter::once` and `std::iter::empty`

```
changelog: [`iter_once`]: add new lint
changelog: [`iter_empty`]: add new lint
```

fixes #9186

- \[ ] 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`

[lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints

The lint doesn't really follow the naming conventions. I don't have any better idea so I'm open to suggestions.

23 months agoAuto merge of #9167 - aldhsu:fix-trait-duplication-false-pos, r=flip1995
bors [Sun, 14 Aug 2022 14:46:26 +0000 (14:46 +0000)]
Auto merge of #9167 - aldhsu:fix-trait-duplication-false-pos, r=flip1995

Fixes [`trait_duplication_in_bounds`] false positives

Fixes #9076 #9151 #8757.
Partially fixes #8771.

changelog: [`trait_duplication_in_bounds`]: Reduce number of false positives.

23 months agoAuto merge of #9326 - flip1995:version-update, r=xFrednet
bors [Sat, 13 Aug 2022 10:02:57 +0000 (10:02 +0000)]
Auto merge of #9326 - flip1995:version-update, r=xFrednet

Update lint versions for 1.63 release

r? `@xFrednet`

changelog: none

23 months agoUpdate lint versions for 1.63 release
flip1995 [Fri, 12 Aug 2022 21:19:53 +0000 (23:19 +0200)]
Update lint versions for 1.63 release

23 months agoAuto merge of #9324 - flip1995:changelog, r=xFrednet
bors [Fri, 12 Aug 2022 21:11:33 +0000 (21:11 +0000)]
Auto merge of #9324 - flip1995:changelog, r=xFrednet

1.63 Changelog

r? `@xFrednet`

changelog: none

[Rendered](https://github.com/flip1995/rust-clippy/blob/changelog/CHANGELOG.md)

23 months agoUpdate Changelog to 1.63
flip1995 [Mon, 8 Aug 2022 19:42:27 +0000 (21:42 +0200)]
Update Changelog to 1.63

23 months agoAuto merge of #9289 - mkrasnitski:9094, r=xFrednet
bors [Fri, 12 Aug 2022 06:25:59 +0000 (06:25 +0000)]
Auto merge of #9289 - mkrasnitski:9094, r=xFrednet

Extend `if_then_some_else_none` to also suggest `bool::then_some`

Closes #9094.

changelog: Extend `if_then_some_else_none` to also suggest `bool::then_some`

23 months agoLint trait duplication in one pass.
Allen Hsu [Fri, 12 Aug 2022 02:51:58 +0000 (12:51 +1000)]
Lint trait duplication in one pass.

23 months agoAdjust lint description for better clarity
Michael Krasnitski [Fri, 12 Aug 2022 02:41:25 +0000 (22:41 -0400)]
Adjust lint description for better clarity