]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoLess authoritative stable_sort_primitive message
bing [Mon, 18 Apr 2022 06:42:24 +0000 (14:42 +0800)]
Less authoritative stable_sort_primitive message

2 years agoAuto merge of #8665 - InfRandomness:option_take_on_temporary, r=llogiq
bors [Sun, 17 Apr 2022 18:34:16 +0000 (18:34 +0000)]
Auto merge of #8665 - InfRandomness:option_take_on_temporary, r=llogiq

Introduce needless_option_take lint

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

Fixes #8618

changelog: Introduce [`needless_option_take`] lint

2 years agoAuto merge of #8709 - matthiaskrgr:lintcheckfix, r=llogiq
bors [Sat, 16 Apr 2022 10:22:08 +0000 (10:22 +0000)]
Auto merge of #8709 - matthiaskrgr:lintcheckfix, r=llogiq

lintcheck: fix --fix

looks like --allow-no-vcs does no longer exist(?)

changelog: none

2 years agoAuto merge of #8706 - lupd:cast-abs-to-unsigned, r=xFrednet
bors [Sat, 16 Apr 2022 09:12:15 +0000 (09:12 +0000)]
Auto merge of #8706 - lupd:cast-abs-to-unsigned, r=xFrednet

Fix formatting of `cast_abs_to_unsigned` docs

The "use instead" section of the example was not being formatted as Rust code, and the "configuration" documentation was being formatted as Rust code.

changelog: `[cast_abs_to_unsigned]` Fix example/configuration formatting

2 years agoAuto merge of #8698 - xFrednet:0000-changelog-1-61, r=flip1995
bors [Sat, 16 Apr 2022 08:26:27 +0000 (08:26 +0000)]
Auto merge of #8698 - xFrednet:0000-changelog-1-61, r=flip1995

Changelog for Rust 1.61 :octopus:

roses are red,
violets are blue,
this changelog,
is no longer a todo!

---

changelog: none

2 years agoChangelog for Rust 1.61 :octopus:
xFrednet [Wed, 13 Apr 2022 21:14:35 +0000 (23:14 +0200)]
Changelog for Rust 1.61 :octopus:

2 years agolintcheck: fix --fix
Matthias Krüger [Fri, 15 Apr 2022 22:56:28 +0000 (00:56 +0200)]
lintcheck: fix --fix

looks like --allow-no-vcs does no longer exist(?)

2 years agoAuto merge of #8705 - cpw2n5:spellcheck, r=Manishearth
bors [Fri, 15 Apr 2022 21:20:02 +0000 (21:20 +0000)]
Auto merge of #8705 - cpw2n5:spellcheck, r=Manishearth

Spellcheck

I'm brand new to this so any feedback will be helpful. I set the project up locally and ran a spellcheck on it. The code changes should only be spelling corrections. I ran the build and tests and they came back successful locally.

changelog: Various spelling corrections in comments and code.

2 years agocollapsible <> collspible
whodi [Fri, 15 Apr 2022 19:28:48 +0000 (15:28 -0400)]
collapsible <> collspible

2 years agoshound -> should
whodi [Fri, 15 Apr 2022 19:20:54 +0000 (15:20 -0400)]
shound -> should

2 years agoinitialization misspell
whodi [Fri, 15 Apr 2022 19:00:44 +0000 (15:00 -0400)]
initialization misspell

2 years agoinfallible <> infalliable in filename
whodi [Fri, 15 Apr 2022 18:33:53 +0000 (14:33 -0400)]
infallible <> infalliable in filename

2 years agoadding spell checking
whodi [Fri, 15 Apr 2022 18:25:55 +0000 (14:25 -0400)]
adding spell checking

2 years agoFix formatting of `cast_abs_to_unsigned` docs
dlup [Fri, 15 Apr 2022 20:34:44 +0000 (16:34 -0400)]
Fix formatting of `cast_abs_to_unsigned` docs

2 years agoAuto merge of #8702 - youknowone:fix-typo, r=xFrednet
bors [Fri, 15 Apr 2022 10:38:47 +0000 (10:38 +0000)]
Auto merge of #8702 - youknowone:fix-typo, r=xFrednet

Fix typo in comment

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

changelog: none

2 years agoFix typo in comment
Jeong YunWon [Fri, 15 Apr 2022 10:33:16 +0000 (19:33 +0900)]
Fix typo in comment

2 years agoAuto merge of #8563 - Jarcho:let_unit_1502, r=Jarcho
bors [Fri, 15 Apr 2022 01:57:52 +0000 (01:57 +0000)]
Auto merge of #8563 - Jarcho:let_unit_1502, r=Jarcho

Don't lint `let_unit_value` when needed for type inferenece

fixes: #1502

Pinging `@dtolnay.` I think this is enough to fix the issue. Do you have a good list crates to test this on?

changelog: Don't lint `let_unit_value` when needed for type inference

2 years agoAllow more complex expressions in `let_unit_value`
Jason Newcomb [Tue, 5 Apr 2022 01:54:34 +0000 (21:54 -0400)]
Allow more complex expressions in `let_unit_value`

2 years agoMove `let_unit_value` back into `style`
Jason Newcomb [Thu, 17 Mar 2022 23:53:28 +0000 (19:53 -0400)]
Move `let_unit_value` back into `style`

2 years agoDon't lint `let_unit_value` when needed for type inferenece
Jason Newcomb [Thu, 17 Mar 2022 23:44:12 +0000 (19:44 -0400)]
Don't lint `let_unit_value` when needed for type inferenece

2 years agoAuto merge of #8614 - pitaj:fix-7597, r=giraffate
bors [Thu, 14 Apr 2022 23:58:51 +0000 (23:58 +0000)]
Auto merge of #8614 - pitaj:fix-7597, r=giraffate

assertions_on_constants: ignore indirect `cfg!`

Fixes #7597

changelog: [`assertions_on_constants`] ignore constants indirectly based on `cfg!`

2 years agoAuto merge of #8626 - pitaj:format_add_string, r=llogiq
bors [Thu, 14 Apr 2022 14:29:22 +0000 (14:29 +0000)]
Auto merge of #8626 - pitaj:format_add_string, r=llogiq

New lint `format_add_strings`

Closes #6261

changelog: Added [`format_add_string`]: recommend using `write!` instead of appending the result of  `format!`

2 years agoAuto merge of #8677 - xFrednet:8213-manual-bits-suggestion, r=giraffate
bors [Thu, 14 Apr 2022 12:59:23 +0000 (12:59 +0000)]
Auto merge of #8677 - xFrednet:8213-manual-bits-suggestion, r=giraffate

Add `usize` cast to `clippy::manual_bits` suggestion

A fix for the suggestion from https://github.com/rust-lang/rust-clippy/pull/8213

changelog: [`manual_bits`]: The suggestion now includes a cast for proper type conversion

2 years agoAdd tests and docs
infrandomness [Tue, 12 Apr 2022 17:34:55 +0000 (19:34 +0200)]
Add tests and docs

This adds test to make sure correct behavior of lint
- The first test's option variable is not a temporary variable
- The second test does not make usage of `take()`
- The third test makes usage of `take()` and uses a temporary variable

2 years agoModify lint description
infrandomness [Mon, 11 Apr 2022 15:15:53 +0000 (17:15 +0200)]
Modify lint description

2 years agoIntroduce new lint check
infrandomness [Sun, 10 Apr 2022 21:42:33 +0000 (23:42 +0200)]
Introduce new lint check

This checks if the expression has one of `core`, `option`, `Option` or
`as_ref` in its path, this avoids false positives

2 years agoSwap type checked expression
infrandomness [Sun, 10 Apr 2022 08:59:43 +0000 (10:59 +0200)]
Swap type checked expression

Instead of type checking the entire expression (causing a false
positive), only type check for a subset of the expression (the receiver of
the matched function: `take()`)

2 years agoDelete unused variable `y` in test
infrandomness [Sat, 9 Apr 2022 16:35:18 +0000 (18:35 +0200)]
Delete unused variable `y` in test

This fixes the errors occuring while running the ui tests

2 years agoSwap the category of the lint
infrandomness [Fri, 8 Apr 2022 19:59:59 +0000 (21:59 +0200)]
Swap the category of the lint

This changes the lint from the suspicious category to the complexity category

2 years agoSwap span_lint for span_lint_and_sugg
infrandomness [Fri, 8 Apr 2022 19:54:44 +0000 (21:54 +0200)]
Swap span_lint for span_lint_and_sugg

This implements a machine applicable suggestion to any matched usage of
`.as_ref().take()``

2 years agoImplement checks to the expression
infrandomness [Fri, 8 Apr 2022 19:27:01 +0000 (21:27 +0200)]
Implement checks to the expression

The implemented checks are for checking if the expression is either of
type `Option` and isn't a syntactical place

2 years agoIntroduce option_take_on_temporary lints
infrandomness [Fri, 8 Apr 2022 18:07:19 +0000 (20:07 +0200)]
Introduce option_take_on_temporary lints

This lint checks if Option::take() is used on a temporary value (a value
that is not of type &mut Option and that is not a Place expression) to
suggest omitting take()

2 years agoUpdate lint description of `clippy::manual_bits` to include the `as usize` cast
Fridtjof Stoldt [Thu, 14 Apr 2022 05:02:59 +0000 (07:02 +0200)]
Update lint description  of `clippy::manual_bits` to include the `as usize` cast

2 years agoNew lint `format_add_strings`
Peter Jaszkowiak [Mon, 4 Apr 2022 03:40:58 +0000 (21:40 -0600)]
New lint `format_add_strings`

2 years agoassertions_on_constants: ignore indirect `cfg!`
Peter Jaszkowiak [Fri, 1 Apr 2022 04:28:59 +0000 (22:28 -0600)]
assertions_on_constants: ignore indirect `cfg!`

2 years agoAuto merge of #8676 - Alexendoo:local-used-across-loop, r=xFrednet
bors [Thu, 14 Apr 2022 04:44:33 +0000 (04:44 +0000)]
Auto merge of #8676 - Alexendoo:local-used-across-loop, r=xFrednet

Check for loops/closures in `local_used_after_expr`

Follow up to #8646, catches when a local is used multiple times because it's in a loop or a closure

changelog: none

2 years agoAdd `usize` cast to `clippy::manual_bits` suggestion
xFrednet [Sun, 10 Apr 2022 17:03:16 +0000 (19:03 +0200)]
Add `usize` cast to `clippy::manual_bits` suggestion

2 years agoAuto merge of #8670 - yoav-lavi:main, r=giraffate
bors [Wed, 13 Apr 2022 13:03:51 +0000 (13:03 +0000)]
Auto merge of #8670 - yoav-lavi:main, r=giraffate

`pub_use` restriction

[`pub_use`]

Fixes https://github.com/rust-lang/rust-clippy/issues/8545

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

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

changelog: Adds a lint called `pub_use` that restricts the usage of `pub use ...`

2 years agopub_use
Yoav Lavi [Tue, 12 Apr 2022 09:09:34 +0000 (11:09 +0200)]
pub_use

2 years agoAuto merge of #8692 - kyoto7250:fixing_unnecessary_to_owned, r=giraffate
bors [Wed, 13 Apr 2022 00:57:08 +0000 (00:57 +0000)]
Auto merge of #8692 - kyoto7250:fixing_unnecessary_to_owned, r=giraffate

fix unnecessary_to_owned about msrv

This PR fixes ``[`unnecessary_owned`]``.

## What

```rust
# sample code
fn _msrv_1_35() {
    #![clippy::msrv = "1.35"]
    let _ = &["x"][..].to_vec().into_iter();
}

fn _msrv_1_36() {
    #![clippy::msrv = "1.36"]
    let _ = &["x"][..].to_vec().into_iter();
}
```

If we will check this code using clippy, ``[`unnecessary_owned`]`` will modify the code as follows.

```rust
error: unnecessary use of `to_vec`
  --> $DIR/unnecessary_to_owned.rs:219:14
   |
LL |     let _ = &["x"][..].to_vec().into_iter();
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `["x"][..].iter().copied()`

error: unnecessary use of `to_vec`
  --> $DIR/unnecessary_to_owned.rs:224:14
   |
LL |     let _ = &["x"][..].to_vec().into_iter();
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `["x"][..].iter().copied()`
```

This is incorrect. Because `Iterator::copied` was estabilished in 1.36.

## Why

This bug was caused by not separating "copied" and "clone" by reference to msrv.

https://github.com/rust-lang/rust-clippy/blob/89ee6aa6e32df974ef9dbb3c825afbdce441e856/clippy_lints/src/methods/unnecessary_to_owned.rs#L195

So, I added a conditional branch and described the corresponding test.

Thank you in advance.

changelog: fix wrong suggestions about msrv in [`unnecessary_to_owned`]

r! `@giraffate`

2 years agoAuto merge of #8647 - Jarcho:mut_from_ref_6326, r=giraffate
bors [Wed, 13 Apr 2022 00:38:54 +0000 (00:38 +0000)]
Auto merge of #8647 - Jarcho:mut_from_ref_6326, r=giraffate

Only lint `mut_from_ref` when unsafe code is used

fixes #6326

changelog: Only lint `mut_from_ref` when unsafe code is used.

2 years agoAuto merge of #8645 - Jarcho:manual_non_exhaustive_5714, r=Jarcho
bors [Tue, 12 Apr 2022 18:38:45 +0000 (18:38 +0000)]
Auto merge of #8645 - Jarcho:manual_non_exhaustive_5714, r=Jarcho

Don't lint `manual_non_exhaustive` when the enum variant is used

fixes #5714

changelog: Don't lint `manual_non_exhaustive` when the enum variant is used

2 years agoAuto merge of #8690 - mucinoab:DoNot-rest_pat_in_fully_bound_structs-OnNonExhaustive...
bors [Tue, 12 Apr 2022 16:14:13 +0000 (16:14 +0000)]
Auto merge of #8690 - mucinoab:DoNot-rest_pat_in_fully_bound_structs-OnNonExhaustive, r=Manishearth

Do not trigger ``[`rest_pat_in_fully_bound_structs`]`` on `#[non_exhaustive]` structs

fixes #8029

Just adds an additional check to ensure that the`ty::VariantDef` is not marked as `#[non_exhaustive]`.

changelog: Do not apply ``[`rest_pat_in_fully_bound_structs`]`` on structs marked as non exhaustive.

2 years agofix unnecessary_to_owned about msrv
kyoto7250 [Tue, 12 Apr 2022 13:55:48 +0000 (22:55 +0900)]
fix unnecessary_to_owned about msrv

2 years agoAuto merge of #8691 - flip1995:infinite_recursion_only_in_recursion, r=llogiq
bors [Tue, 12 Apr 2022 13:33:54 +0000 (13:33 +0000)]
Auto merge of #8691 - flip1995:infinite_recursion_only_in_recursion, r=llogiq

Prevent infinite (exponential) recursion in only_used_in_recursion

This simplifies the visitor code a bit and prevents checking expressions
multiple times. I still think this lint should be removed for now,
because its code isn't really tested.

Fixes #8689

**NOTE:** Before merging this, we should talk about removing and revisiting this lint. See my comment in #8689

changelog: prevent infinite recursion in [`only_used_in_recursion`]

2 years agoPrevent infinite (exponential) recursion in only_used_in_recursion
flip1995 [Tue, 12 Apr 2022 13:27:28 +0000 (15:27 +0200)]
Prevent infinite (exponential) recursion in only_used_in_recursion

This simplifies the visitor code a bit and prevents checking expressions
multiple times. I still think this lint should be removed for now,
because its code isn't really tested.

2 years agoAuto merge of #8686 - Jarcho:undocumented_unsafe_blocks_8681, r=flip1995
bors [Tue, 12 Apr 2022 07:17:57 +0000 (07:17 +0000)]
Auto merge of #8686 - Jarcho:undocumented_unsafe_blocks_8681, r=flip1995

Fix ICE in `undocumented_unsafe_blocks`

fixes #8681

changelog: Fix ICE in `undocumented_unsafe_blocks`

2 years agoDo not apply `rest_pat_in_fully_bound_structs` on `#[non_exhaustive]` structs
Bruno A. Muciño [Tue, 12 Apr 2022 03:47:04 +0000 (22:47 -0500)]
Do not apply `rest_pat_in_fully_bound_structs` on `#[non_exhaustive]` structs

2 years agoAuto merge of #8688 - kyoto7250:adding_condition_for_map_clone, r=giraffate
bors [Tue, 12 Apr 2022 01:11:54 +0000 (01:11 +0000)]
Auto merge of #8688 - kyoto7250:adding_condition_for_map_clone, r=giraffate

adding condition for map_clone message

This PR fixes the message about `map_clone`.

if msrv >= 1.36, the message is correct.

```bash
$ cat main.rs
fn main() {
  let x: Vec<&i32> = vec![&1, &2];
  let y: Vec<_>  = x.iter().map(|i| *i).collect();
  println!("{:?}", y);
}

$ cargo clippy
warning: you are using an explicit closure for copying elements
 --> main.rs:3:20
  |
3 |   let y: Vec<_>  = x.iter().map(|i| *i).collect();
  |                    ^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `x.iter().copied()`
  |
  = note: `#[warn(clippy::map_clone)]` on by default
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_clone

warning: `test` (build script) generated 1 warning
warning: `test` (bin "test") generated 1 warning (1 duplicate)
    Finished dev [unoptimized + debuginfo] target(s) in 0.00s
```

but, if msrv < 1.36, the suggestion is `cloned`, but the message is `copying`.
```bash
$ cat clippy.toml
msrv = "1.35"

$ cargo clippy
warning: you are using an explicit closure for copying elements
 --> main.rs:3:20
  |
3 |   let y: Vec<_>  = x.iter().map(|i| *i).collect();
  |                    ^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `x.iter().cloned()`
```

I think  the separation of messages will make it more user-friendly.

thank you in advance.

changelog: Fixed a message in map_clone.

2 years agorefactor: Put together an if statement
kyoto7250 [Tue, 12 Apr 2022 00:49:00 +0000 (09:49 +0900)]
refactor: Put together an if statement

2 years agoadding condition for map_clone message
kyoto7250 [Mon, 11 Apr 2022 19:03:48 +0000 (04:03 +0900)]
adding condition for map_clone message

if msrv < 1.36, the message tells , but the suggestion is

2 years agoAuto merge of #8624 - pitaj:is_digit_ascii_radix, r=xFrednet
bors [Mon, 11 Apr 2022 18:56:21 +0000 (18:56 +0000)]
Auto merge of #8624 - pitaj:is_digit_ascii_radix, r=xFrednet

New lint `is_digit_ascii_radix`

Closes #6399

changelog: Added [`is_digit_ascii_radix`]: recommend `is_ascii_digit()` or `is_ascii_hexdigit()` in place of `is_digit(10)` and `is_digit(16)`

2 years agoAuto merge of #8687 - Alexendoo:cast-possible-truncation-overflow, r=xFrednet
bors [Mon, 11 Apr 2022 18:40:14 +0000 (18:40 +0000)]
Auto merge of #8687 - Alexendoo:cast-possible-truncation-overflow, r=xFrednet

Fix subtraction overflow in `cast_possible_truncation`

changelog: Fix false negative due to subtraction overflow in `cast_possible_truncation`

I *think* a false negative is the worst that can happen from this

2 years agoFix subtraction overflow in `cast_possible_truncation`
Alex Macleod [Mon, 11 Apr 2022 17:54:44 +0000 (18:54 +0100)]
Fix subtraction overflow in `cast_possible_truncation`

2 years agoFix ICE in `undocumented_unsafe_blocks`
Jason Newcomb [Mon, 11 Apr 2022 17:18:27 +0000 (13:18 -0400)]
Fix ICE in `undocumented_unsafe_blocks`

2 years agoAuto merge of #8667 - Jarcho:proc_macro_check, r=flip1995
bors [Mon, 11 Apr 2022 16:41:51 +0000 (16:41 +0000)]
Auto merge of #8667 - Jarcho:proc_macro_check, r=flip1995

Don't lint various match lints when expanded by a proc-macro

fixes #4952

As always for proc-macro output this is a hack-job of a fix. It would be really nice if more proc-macro authors would set spans correctly.

changelog: Don't lint various lints on proc-macro output.

2 years agoAuto merge of #8673 - Jarcho:same_functions_8139, r=Manishearth
bors [Mon, 11 Apr 2022 15:36:55 +0000 (15:36 +0000)]
Auto merge of #8673 - Jarcho:same_functions_8139, r=Manishearth

Fix `same_functions_in_if_condition` FP

fixes #8139

changelog: Don't consider `Foo<{ SomeConstant }>` and `Foo<{ SomeOtherConstant }>` to be the same, even if the constants have the same value.

2 years agoAuto merge of #8668 - Jarcho:iter_with_drain_8538, r=Manishearth
bors [Mon, 11 Apr 2022 15:20:01 +0000 (15:20 +0000)]
Auto merge of #8668 - Jarcho:iter_with_drain_8538, r=Manishearth

Don't lint `iter_with_drain` on references

fixes #8538
changelog: Don't lint `iter_with_drain` on references

2 years agoAuto merge of #8660 - yoav-lavi:squashed-master, r=flip1995
bors [Mon, 11 Apr 2022 11:12:33 +0000 (11:12 +0000)]
Auto merge of #8660 - yoav-lavi:squashed-master, r=flip1995

`unnecessary_owned_empty_strings`

[`unnecessary_owned_empty_strings`]

Fixes https://github.com/rust-lang/rust-clippy/issues/8650

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

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

changelog: Adds `unnecessary_owned_empty_strings`, a lint that detects passing owned empty strings to a function expecting `&str`

2 years agounnecessary_owned_empty_string -> unnecessary_owned_empty_strings
Yoav Lavi [Mon, 11 Apr 2022 11:05:42 +0000 (13:05 +0200)]
unnecessary_owned_empty_string -> unnecessary_owned_empty_strings

2 years agounnecessary_string_new
Yoav Lavi [Thu, 7 Apr 2022 18:21:47 +0000 (20:21 +0200)]
unnecessary_string_new

2 years agoAuto merge of #8671 - andy-k:fix-typo, r=flip1995
bors [Mon, 11 Apr 2022 09:22:37 +0000 (09:22 +0000)]
Auto merge of #8671 - andy-k:fix-typo, r=flip1995

fix typo

fix typo in #8630

changelog: none

2 years agoAuto merge of #8631 - Alexendoo:splitn-overlap, r=xFrednet
bors [Sun, 10 Apr 2022 17:45:19 +0000 (17:45 +0000)]
Auto merge of #8631 - Alexendoo:splitn-overlap, r=xFrednet

Remove overlap between `manual_split_once` and `needless_splitn`

changelog: Remove overlap between [`manual_split_once`] and [`needless_splitn`]. Fixes some incorrect `rsplitn` suggestions for [`manual_split_once`]

Things that can trigger `needless_splitn` no longer trigger `manual_split_once`, e.g.

```rust
s.[r]splitn(2, '=').next();
s.[r]splitn(2, '=').nth(0);
s.[r]splitn(3, '=').next_tuple();
```

Fixes some suggestions:

```rust
let s = "should not match";

s.rsplitn(2, '.').nth(1);
// old -> Some("should not match")
Some(s.rsplit_once('.').map_or(s, |x| x.0));
// new -> None
s.rsplit_once('.').map(|x| x.0);

s.rsplitn(2, '.').nth(1)?;
// old -> "should not match"
s.rsplit_once('.').map_or(s, |x| x.0);
// new -> early returns
s.rsplit_once('.')?.0;
```

2 years agoRemove overlap between `manual_split_once` and `needless_splitn`
Alex Macleod [Mon, 4 Apr 2022 15:30:38 +0000 (16:30 +0100)]
Remove overlap between `manual_split_once` and `needless_splitn`

Also fixes some incorrect suggestions for rsplitn

2 years agoCheck for loops/closures in `local_used_after_expr`
Alex Macleod [Sun, 10 Apr 2022 13:02:58 +0000 (14:02 +0100)]
Check for loops/closures in `local_used_after_expr`

2 years agoCompare inline constants by their bodies rather than value in `SpanlessEq`
Jason Newcomb [Sun, 10 Apr 2022 04:54:41 +0000 (00:54 -0400)]
Compare inline constants by their bodies rather than value in `SpanlessEq`

2 years agofix typo
Andy Kurnia [Sat, 9 Apr 2022 17:07:01 +0000 (01:07 +0800)]
fix typo

2 years agoAuto merge of #8664 - yoav-lavi:main, r=xFrednet
bors [Sat, 9 Apr 2022 14:57:06 +0000 (14:57 +0000)]
Auto merge of #8664 - yoav-lavi:main, r=xFrednet

Allow passing `--remove` to `cargo dev setup <SUBCOMMAND>`

changelog: none

Allows passing `--remove` to `cargo dev setup <SUBCOMMAND>` as an alternative to `cargo dev remove ...`

Fixes https://github.com/rust-lang/rust-clippy/issues/8663

2 years agoAllow passing --remove to `cargo dev setup <SUBCOMMAND>`
Yoav Lavi [Fri, 8 Apr 2022 13:02:49 +0000 (15:02 +0200)]
Allow passing --remove to `cargo dev setup <SUBCOMMAND>`

add missing args

unque name not needed

more descriptive help

formatting fixes

missing quote

2 years agoAuto merge of #8669 - kyoto7250:fix_comments_in_test_split_once, r=xFrednet
bors [Sat, 9 Apr 2022 11:58:18 +0000 (11:58 +0000)]
Auto merge of #8669 - kyoto7250:fix_comments_in_test_split_once, r=xFrednet

fix comments in test for split_once

This PR fixed comments in test.

`split_once` was stabilized in 1.52, so I think the comments maybe be wrong.

ref:
https://doc.rust-lang.org/std/string/struct.String.html#method.split_once

thank you in advance.

changelog: none

2 years agofix comments in test for split_once
kyoto7250 [Sat, 9 Apr 2022 11:34:43 +0000 (20:34 +0900)]
fix comments in test for split_once

split_once was stabilized in 1.52

2 years agoDon't lint `iter_with_drain` on references
Jason Newcomb [Sat, 9 Apr 2022 03:15:18 +0000 (23:15 -0400)]
Don't lint `iter_with_drain` on references

2 years agoAuto merge of #8648 - Jarcho:transmute_collection_7706, r=xFrednet
bors [Fri, 8 Apr 2022 21:43:26 +0000 (21:43 +0000)]
Auto merge of #8648 - Jarcho:transmute_collection_7706, r=xFrednet

Fix `unsound_collection_transmute`

fixes #7706

changelog: Better check size and alignment requirements in `unsound_collection_transmute`

2 years agoDon't lint various match lints when expanded by a proc-macro
Jason Newcomb [Fri, 8 Apr 2022 20:51:40 +0000 (16:51 -0400)]
Don't lint various match lints when expanded by a proc-macro

2 years agoUpdate documentation for `mut_from_ref`
Jason Newcomb [Fri, 8 Apr 2022 04:36:09 +0000 (00:36 -0400)]
Update documentation for `mut_from_ref`

2 years agoAuto merge of #8619 - pitaj:fix-6973, r=giraffate
bors [Fri, 8 Apr 2022 00:37:56 +0000 (00:37 +0000)]
Auto merge of #8619 - pitaj:fix-6973, r=giraffate

ignore `&x | &y` in unnested_or_patterns

replacing it with `&(x | y)` is actually more characters

Fixes #6973

changelog: [`unnested_or_patterns`] ignore `&x | &y`, nesting would result in more characters

2 years agoNew lint `is_digit_ascii_radix`
Peter Jaszkowiak [Sat, 2 Apr 2022 21:01:07 +0000 (15:01 -0600)]
New lint `is_digit_ascii_radix`

2 years agoAuto merge of #8657 - flip1995:raw_lint_desc, r=flip1995
bors [Thu, 7 Apr 2022 17:11:26 +0000 (17:11 +0000)]
Auto merge of #8657 - flip1995:raw_lint_desc, r=flip1995

Allow raw lint descriptions

update_lints now understands raw strings in declare_clippy_lint descriptions.

Supersedes  #8655

cc `@Alexendoo` thanks for addressing this so quickly. I build a little bit simpler version of your patch. I don't think it really matters what `Literal` we're trying to tokenize, since we assume later, that it is some sort of `str`.

changelog: none

2 years agoAllow raw lint descriptions
flip1995 [Thu, 7 Apr 2022 17:05:20 +0000 (18:05 +0100)]
Allow raw lint descriptions

update_lints now understands raw strings in declare_clippy_lint
descriptions.

Co-authored-by: Alex Macleod <alex@macleod.io>
2 years agoAuto merge of #8656 - flip1995:rustup, r=flip1995
bors [Thu, 7 Apr 2022 15:30:27 +0000 (15:30 +0000)]
Auto merge of #8656 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

2 years agoBump changelog stable version -> 1.60
flip1995 [Thu, 7 Apr 2022 15:26:43 +0000 (16:26 +0100)]
Bump changelog stable version -> 1.60

2 years agoBump nightly version -> 2022-04-07
flip1995 [Thu, 7 Apr 2022 15:24:55 +0000 (16:24 +0100)]
Bump nightly version -> 2022-04-07

2 years agoBump Clippy Version -> 0.1.62
flip1995 [Thu, 7 Apr 2022 15:24:33 +0000 (16:24 +0100)]
Bump Clippy Version -> 0.1.62

2 years agoFix internal::INVALID_PATHS lint
flip1995 [Thu, 7 Apr 2022 15:24:10 +0000 (16:24 +0100)]
Fix internal::INVALID_PATHS lint

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 7 Apr 2022 14:44:37 +0000 (15:44 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoAuto merge of #8635 - pbor:unsigned-abs, r=giraffate
bors [Thu, 7 Apr 2022 13:17:28 +0000 (13:17 +0000)]
Auto merge of #8635 - pbor:unsigned-abs, r=giraffate

Add a lint to detect cast to unsigned for abs() and suggest unsigned_…

…abs()

changelog: Add a [`cast_abs_to_unsigned`] that checks for uses of `abs()` that are cast to the corresponding unsigned integer type and suggest to replace them with `unsigned_abs()`.

2 years agoAuto merge of #8646 - Alexendoo:option-as-deref-mut, r=giraffate
bors [Thu, 7 Apr 2022 13:00:15 +0000 (13:00 +0000)]
Auto merge of #8646 - Alexendoo:option-as-deref-mut, r=giraffate

Fix `as_deref_mut` false positives in `needless_option_as_deref`

Also moves it into `methods/`

Fixes #7846
Fixes #8047

changelog: [`needless_option_as_deref`]: No longer lints for `as_deref_mut` on Options that cannot be moved

supersedes #8064

2 years agoFix `as_deref_mut` false positives in `needless_option_as_deref`
Alex Macleod [Wed, 6 Apr 2022 14:35:49 +0000 (15:35 +0100)]
Fix `as_deref_mut` false positives in `needless_option_as_deref`

Also moves the lint to the methods directory

2 years agoconf: fix lint name in comment
Paolo Borelli [Thu, 7 Apr 2022 09:29:02 +0000 (11:29 +0200)]
conf: fix lint name in comment

The lint name is ERR_EXPECT, not EXPECT_ERR

2 years agonew lint cast_abs_to_unsigned
Paolo Borelli [Mon, 4 Apr 2022 16:38:38 +0000 (18:38 +0200)]
new lint cast_abs_to_unsigned

Add a lint to detect cast to unsigned for abs() and suggest
unsigned_abs() to avoid panic when called on MIN.

2 years agoAuto merge of #8630 - Jarcho:forget_non_drop, r=Manishearth
bors [Wed, 6 Apr 2022 23:04:20 +0000 (23:04 +0000)]
Auto merge of #8630 - Jarcho:forget_non_drop, r=Manishearth

Add lints `drop_non_drop` and `forget_non_drop`

fixes #1897

changelog: Add lints `drop_non_drop` and `forget_non_drop`

2 years agoAuto merge of #8606 - InfRandomness:err()-expect()-lint, r=xFrednet
bors [Wed, 6 Apr 2022 18:07:56 +0000 (18:07 +0000)]
Auto merge of #8606 - InfRandomness:err()-expect()-lint, r=xFrednet

Add [`err_expect`] lint

[`expect_err`] lint

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

Fixes https://github.com/rust-lang/rust-clippy/issues/1435

changelog: Added a lint to detect usage of .err().expect()

2 years agoFix mistakes in documentation :
infrandomness [Wed, 6 Apr 2022 17:24:49 +0000 (19:24 +0200)]
Fix mistakes in documentation :

- err() was meant to be employed instead of ok()
- wraps comment

2 years agoAdd .err().expect() lint
InfRandomness [Tue, 29 Mar 2022 17:19:16 +0000 (19:19 +0200)]
Add .err().expect() lint

2 years agoAuto merge of #8549 - J-ZhengLi:issue8542, r=llogiq
bors [Wed, 6 Apr 2022 17:23:14 +0000 (17:23 +0000)]
Auto merge of #8549 - J-ZhengLi:issue8542, r=llogiq

fix FP in lint `[needless_match]`

fixes: #8542
fixes: #8551
fixes: #8595
fixes: #8599

---

changelog: check for more complex custom type, and ignore type coercion in [`needless_match`]

2 years agoBetter check size and alignment requirements in `unsound_collection_transmute`
Jason Newcomb [Wed, 6 Apr 2022 15:57:55 +0000 (11:57 -0400)]
Better check size and alignment requirements in `unsound_collection_transmute`

2 years agoAuto merge of #8644 - yoav-lavi:squashed-master, r=flip1995
bors [Wed, 6 Apr 2022 15:13:43 +0000 (15:13 +0000)]
Auto merge of #8644 - yoav-lavi:squashed-master, r=flip1995

update unnecessary_join documentation

changelog: none

Updates the description of `unnecessary_join` in accordance with https://github.com/rust-lang/rust-clippy/pull/8579#issuecomment-1089969859. I've also added a line regarding differences in assembly output, please let me know if it should also make it in.

2 years agoOnly lint `mut_from_ref` when unsafe code is used
Jason Newcomb [Wed, 6 Apr 2022 14:56:06 +0000 (10:56 -0400)]
Only lint `mut_from_ref` when unsafe code is used

2 years agoCleanup `manual_non_exhaustive`
Jason Newcomb [Wed, 6 Apr 2022 13:53:20 +0000 (09:53 -0400)]
Cleanup `manual_non_exhaustive`

2 years agoDon't lint `manual_non_exhaustive` when the enum variant is used
Jason Newcomb [Wed, 6 Apr 2022 13:26:59 +0000 (09:26 -0400)]
Don't lint `manual_non_exhaustive` when the enum variant is used