]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoEasier readability for needless_late_init
binggh [Tue, 3 May 2022 09:51:23 +0000 (17:51 +0800)]
Easier readability for needless_late_init

2 years agoAuto merge of #8730 - tamaroning:fix8724, r=Alexendoo
bors [Tue, 3 May 2022 07:05:51 +0000 (07:05 +0000)]
Auto merge of #8730 - tamaroning:fix8724, r=Alexendoo

[FP] identity_op in front of if

fix #8724

changelog: FP: [`identity_op`]: is now allowed in front of if statements, blocks and other expressions where the suggestion would be invalid.

Resolved simular problems with blocks, mathces, and loops.
identity_op always does NOT suggest reducing `0 + if b { 1 } else { 2 } + 3` into  `if b { 1 } else { 2 } + 3` even in the case that the expression is in `f(expr)` or `let x = expr;` for now.

2 years agoimprove identity_op
tamaron [Fri, 22 Apr 2022 01:39:38 +0000 (10:39 +0900)]
improve identity_op

fix

Update identity_op.rs

ok

update without_loop_counters test

chore

fix

chore

remove visitor and leftmost

fix

add document

2 years agoAuto merge of #8767 - xFrednet:8765-fix-doc-example, r=camsteffen
bors [Sat, 30 Apr 2022 17:37:00 +0000 (17:37 +0000)]
Auto merge of #8767 - xFrednet:8765-fix-doc-example, r=camsteffen

Add missing quite in `large_include_file` example

Roses are red,
violets are blue,
this fix,
was simple to do

Closes: https://github.com/rust-lang/rust-clippy/issues/8765
changelog: None

2 years agoAuto merge of #8625 - Jarcho:rename_lint, r=xFrednet
bors [Sat, 30 Apr 2022 17:22:34 +0000 (17:22 +0000)]
Auto merge of #8625 - Jarcho:rename_lint, r=xFrednet

Add `cargo dev rename_lint`

fixes #7799

changelog: None

2 years agoAdd missing quite in `large_include_file` example
xFrednet [Sat, 30 Apr 2022 17:16:19 +0000 (19:16 +0200)]
Add missing quite in `large_include_file` example

2 years agoAuto merge of #8720 - asquared31415:ptr-cast-ice-fix, r=Alexendoo,xFrednet
bors [Sat, 30 Apr 2022 16:51:01 +0000 (16:51 +0000)]
Auto merge of #8720 - asquared31415:ptr-cast-ice-fix, r=Alexendoo,xFrednet

fix ICE in `cast_slice_different_sizes`

fixes #8708

changelog: fixes an ICE introduced in #8445

2 years agoAuto merge of #8764 - dtolnay-contrib:checkoutv3, r=llogiq
bors [Sat, 30 Apr 2022 14:54:45 +0000 (14:54 +0000)]
Auto merge of #8764 - dtolnay-contrib:checkoutv3, r=llogiq

Update GitHub Actions actions/checkout@v2 to v3

The v2 implementation uses Node 12, which is end-of-life on April 30, 2022. See https://nodejs.org/en/about/releases/. Update to v3, which is based on Node 16 whose support lasts until April 30, 2024.

---

changelog: none

2 years agoUpdate GitHub Actions actions/checkout@v2 to v3
David Tolnay [Sat, 30 Apr 2022 02:28:03 +0000 (19:28 -0700)]
Update GitHub Actions actions/checkout@v2 to v3

The v2 implementation uses Node 12, which is end-of-life on April 30, 2022.
See https://nodejs.org/en/about/releases/. Update to v3, which is based on
Node 16 whose support lasts until April 30, 2024.

2 years agouse non-panicking snippet, use struct update syntax and add comment
asquared31415 [Fri, 29 Apr 2022 01:27:32 +0000 (21:27 -0400)]
use non-panicking snippet, use struct update syntax and add comment

2 years agoAuto merge of #8431 - dswij:8416, r=xFrednet
bors [Wed, 27 Apr 2022 09:47:08 +0000 (09:47 +0000)]
Auto merge of #8431 - dswij:8416, r=xFrednet

`redundant_closure` fix FP on coerced closure

Closes https://github.com/rust-lang/rust-clippy/issues/8416,
Closes https://github.com/rust-lang/rust-clippy/issues/7812
Closes https://github.com/rust-lang/rust-clippy/issues/8091

~~Seems like this is fixed in #817 and regressed.~~

Ignore coerced closure false positives, but this will lead to some false negatives on resolvable generics. IMO, this is still an overall improvement

changelog: [`redundant_closure`] ignores coerced closure

2 years agoAuto merge of #8743 - Alexendoo:useless-attribute-redundant-pub-crate, r=llogiq
bors [Wed, 27 Apr 2022 05:43:13 +0000 (05:43 +0000)]
Auto merge of #8743 - Alexendoo:useless-attribute-redundant-pub-crate, r=llogiq

ignore `redundant_pub_crate` in `useless_attribute`

changelog: [`useless_attribute`] no longer lints [`redundant_pub_crate`]

As mentioned in https://github.com/rust-lang/rust-clippy/issues/8732#issuecomment-1106489634

> And it turns out I can't even explicitly allow it at the usage site, because then `clippy::useless_attribute` fires (which would also be a FP?), which is deny-by-default.
>
> Though it does work if I then allow `clippy::useless_attribute`. ðŸ˜‚
>
> ```rust
> #[allow(clippy::useless_attribute)]
> #[allow(clippy::redundant_pub_crate)]
> pub(crate) use bit;
> ```
>
> The originally-reported warning now no longer occurs.

2 years ago`redundant_closure` ignore coerced closure
dswij [Wed, 23 Feb 2022 15:04:06 +0000 (23:04 +0800)]
`redundant_closure` ignore coerced closure

2 years agoAuto merge of #8617 - Alexendoo:relax-needless-late-init, r=giraffate
bors [Wed, 27 Apr 2022 00:11:17 +0000 (00:11 +0000)]
Auto merge of #8617 - Alexendoo:relax-needless-late-init, r=giraffate

`needless_late_init`: ignore `if let`, `let mut` and significant drops

No longer lints `if let`, personal taste on this one is pretty split, so it probably shouldn't be warning by default. Fixes #8613

```rust
let x = if let Some(n) = y {
    n
} else {
    1
}
```

No longer lints `let mut`, things like the following are not uncommon and look fine as they are

https://github.com/shepmaster/twox-hash/blob/b169c16d86eb8ea4a296b0acb9d00ca7e3c3005f/src/sixty_four.rs#L88-L93

Avoids changing the drop order in an observable way, where the type of `x` has a drop with side effects and something between `x` and the first use also does, e.g.

https://github.com/denoland/rusty_v8/blob/48cc6cb791cac57d22fab1a2feaa92da8ddc9a68/tests/test_api.rs#L159-L167

The implementation of `type_needs_ordered_drop_inner` was changed a bit, it now uses `Ty::has_significant_drop` and reordered the ifs to check diagnostic name before checking the implicit drop impl

changelog: [`needless_late_init`]: No longer lints `if let` statements, `let mut` bindings and no longer significantly changes drop order

2 years ago`needless_late_init`: ignore `if let`, `let mut` and significant drops
Alex Macleod [Fri, 1 Apr 2022 17:23:47 +0000 (18:23 +0100)]
`needless_late_init`: ignore `if let`, `let mut` and significant drops

2 years agoAuto merge of #8737 - smoelius:extra-impl-lifetimes, r=giraffate
bors [Tue, 26 Apr 2022 00:06:53 +0000 (00:06 +0000)]
Auto merge of #8737 - smoelius:extra-impl-lifetimes, r=giraffate

Extend `extra_unused_lifetimes` to handle impl lifetimes

Fixes #6437 (cc: `@carols10cents)`

changelog: fix #6437

2 years agoAuto merge of #8727 - Serial-ATA:lint-large-includes, r=xFrednet
bors [Mon, 25 Apr 2022 17:29:27 +0000 (17:29 +0000)]
Auto merge of #8727 - Serial-ATA:lint-large-includes, r=xFrednet

Add `large_include_file` lint

changelog: Add [`large_include_file`] lint
closes #7005

2 years agoFix naming
Samuel E. Moelius III [Mon, 25 Apr 2022 13:23:59 +0000 (09:23 -0400)]
Fix naming

2 years agoFix false positives
Samuel E. Moelius III [Mon, 25 Apr 2022 09:20:08 +0000 (05:20 -0400)]
Fix false positives

2 years agoremove extra lifetime
asquared31415 [Sun, 24 Apr 2022 23:41:43 +0000 (19:41 -0400)]
remove extra lifetime

2 years agoAuto merge of #8742 - goth-turtle:mistyped-literal-suffix, r=llogiq
bors [Sun, 24 Apr 2022 20:16:40 +0000 (20:16 +0000)]
Auto merge of #8742 - goth-turtle:mistyped-literal-suffix, r=llogiq

mistyped_literal_suffix: improve integer suggestions, avoid wrong float suggestions

This PR fixes 2 things:
- The known problem that integer types are always suggested as signed, by suggesting an unsigned suffix for literals that wouldnt fit in the signed type, and ignores any literals too big for the corresponding unsigned type too.
- The lint would only look at the integer part of any floating point literals without an exponent, this causing #6129. This just ignores those literals.

Examples:
```rust
let _ = 2_32; // still 2_i32
let _ = 234_8; // would now suggest 234_u8

// these are now ignored
let _ = 500_8;
let _ = 123_32.123;
```

changelog: suggest correct integer types in [`mistyped_literal_suffix`], ignore float literals without an exponent
fixes #6129

2 years agoAdd `large_include_file` lint
Serial [Thu, 21 Apr 2022 15:01:18 +0000 (11:01 -0400)]
Add `large_include_file` lint

2 years agomistyped_literal_suffixes: ignore floats without exponent
goth-turtle [Sun, 24 Apr 2022 13:06:48 +0000 (15:06 +0200)]
mistyped_literal_suffixes: ignore floats without exponent

Previously this lint would only look at the integer part of floating
point literals without an exponent, giving wrong suggestions like:

```
  |
8 |     let _ = 123_32.123;
  |             ^^^^^^^^^^ help: did you mean to write: `123.123_f32`
  |
```

Instead, it now ignores these literals.
Fixes #6129

2 years agomistyped_literal_suffixes: improve suggestions for integer types
goth-turtle [Sat, 23 Apr 2022 20:20:50 +0000 (22:20 +0200)]
mistyped_literal_suffixes: improve suggestions for integer types

Instead of just always suggesting signed suffixes regardless of size
of the value, it now suggests an unsigned suffix when the value wouldn't
fit into the corresponding signed type, and ignores the literal entirely
if it is too big for the unsigned type as well.

2 years agoAdd `rename_lint` command
Jason Newcomb [Mon, 4 Apr 2022 00:28:47 +0000 (20:28 -0400)]
Add `rename_lint` command

2 years agoAuto merge of #8738 - tamaroning:fix_wrong_self_convention, r=xFrednet
bors [Sun, 24 Apr 2022 12:40:15 +0000 (12:40 +0000)]
Auto merge of #8738 - tamaroning:fix_wrong_self_convention, r=xFrednet

wrong_self_convention allows `is_*` to take `&mut self`

fix #8480 and #8513
Allowing `is_*` to take `&self` or none is too restrictive.

changelog: FPs: [`wrong_self_convention`] now allows `&mut self` and no self as arguments for `is_*` methods

2 years agoAuto merge of #8736 - Serial-ATA:issue-8732, r=xFrednet
bors [Sun, 24 Apr 2022 12:06:08 +0000 (12:06 +0000)]
Auto merge of #8736 - Serial-ATA:issue-8732, r=xFrednet

Add macro export exemption to `redundant_pub_crate`

changelog: Add macro export exemption to `redundant_pub_crate`
closes #8732

2 years agofix ICE by using a type to return the info we want and also fix some bugs in displayi...
asquared31415 [Sat, 23 Apr 2022 16:49:40 +0000 (12:49 -0400)]
fix ICE by using a type to return the info we want and also fix some bugs in displaying an extra mut when a TypeAndMut was wrong

2 years agofix
tamaron [Sat, 23 Apr 2022 13:45:26 +0000 (22:45 +0900)]
fix

2 years agoignore `redundant_pub_crate` in `useless_attribute`
Alex Macleod [Sat, 23 Apr 2022 11:23:18 +0000 (12:23 +0100)]
ignore `redundant_pub_crate` in `useless_attribute`

2 years agoExtend `extra_unused_lifetimes` to handle impl lifetimes
Samuel E. Moelius III [Sat, 23 Apr 2022 00:05:18 +0000 (20:05 -0400)]
Extend `extra_unused_lifetimes` to handle impl lifetimes

2 years agoAdd macro export exemption to `redundant_pub_crate`
Serial [Fri, 22 Apr 2022 22:03:23 +0000 (18:03 -0400)]
Add macro export exemption to `redundant_pub_crate`

2 years agoAuto merge of #8731 - Alexendoo:dogfood-allow-unknown-lints, r=xFrednet
bors [Fri, 22 Apr 2022 17:11:53 +0000 (17:11 +0000)]
Auto merge of #8731 - Alexendoo:dogfood-allow-unknown-lints, r=xFrednet

dogfood: allow unknown lints when not running with `internal` feature

changelog: none

https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/unknown.20lint.20in.20test.20dogfood_clippy

It's only a warning so this wasn't causing the test to fail, but if you had another error somewhere or used `--nocapture` the extra warnings would be shown

2 years agodogfood: allow unknown lints when not running with `internal` feature
Alex Macleod [Fri, 22 Apr 2022 12:05:53 +0000 (13:05 +0100)]
dogfood: allow unknown lints when not running with `internal` feature

2 years agoAuto merge of #8717 - Alexendoo:manual-split-once-manual-iter, r=dswij,xFrednet
bors [Fri, 22 Apr 2022 09:57:00 +0000 (09:57 +0000)]
Auto merge of #8717 - Alexendoo:manual-split-once-manual-iter, r=dswij,xFrednet

`manual_split_once`: lint manual iteration of `SplitN`

changelog: `manual_split_once`: lint manual iteration of `SplitN`

Now lints:

```rust
let mut iter = "a.b.c".splitn(2, '.');
let first = iter.next().unwrap();
let second = iter.next().unwrap();

let mut iter = "a.b.c".splitn(2, '.');
let first = iter.next()?;
let second = iter.next()?;

let mut iter = "a.b.c".rsplitn(2, '.');
let first = iter.next().unwrap();
let second = iter.next().unwrap();

let mut iter = "a.b.c".rsplitn(2, '.');
let first = iter.next()?;
let second = iter.next()?;
```

It suggests (minus leftover whitespace):

```rust
let (first, second) = "a.b.c".split_once('.').unwrap();

let (first, second) = "a.b.c".split_once('.')?;

let (second, first) = "a.b.c".rsplit_once('.').unwrap();

let (second, first) = "a.b.c".rsplit_once('.')?;
```

Currently only lints if the statements are next to each other, as detecting the various kinds of shadowing was tricky, so the following won't lint

```rust
let mut iter = "a.b.c".splitn(2, '.');
let something_else = 1;
let first = iter.next()?;
let second = iter.next()?;
```

2 years agoAuto merge of #8729 - Serial-ATA:issue-7318, r=Manishearth
bors [Thu, 21 Apr 2022 18:05:14 +0000 (18:05 +0000)]
Auto merge of #8729 - Serial-ATA:issue-7318, r=Manishearth

Fix missing whitespace in `collapsible_else_if` suggestion

changelog: Fix missing whitespace in [`collapsible_else_if`] suggestion
closes #7318

2 years agoFix missing whitespace in `collapsible_else_if` suggestion
Serial [Thu, 21 Apr 2022 17:42:55 +0000 (13:42 -0400)]
Fix missing whitespace in `collapsible_else_if` suggestion

2 years ago`manual_split_once`: lint manual iteration of `SplitN`
Alex Macleod [Mon, 18 Apr 2022 12:28:23 +0000 (13:28 +0100)]
`manual_split_once`: lint manual iteration of `SplitN`

2 years agoAuto merge of #8571 - PyroTechniac:empty-drop, r=flip1995
bors [Thu, 21 Apr 2022 08:03:31 +0000 (08:03 +0000)]
Auto merge of #8571 - PyroTechniac:empty-drop, r=flip1995

add `empty_drop`

Closes #8352

changelog: New lint [`empty_drop`]

2 years agoAdd empty_drop lint
Gryffon Bellish [Fri, 25 Mar 2022 19:31:52 +0000 (15:31 -0400)]
Add empty_drop lint

2 years agoAuto merge of #8716 - binggh:stable-sort-message-update, r=giraffate
bors [Thu, 21 Apr 2022 00:27:13 +0000 (00:27 +0000)]
Auto merge of #8716 - binggh:stable-sort-message-update, r=giraffate

Less authoritative stable_sort_primitive message

fixes #8241

Hey all - first contribution here so I'm deciding to start with something small.

Updated the linked message to be less authoritative as well as moved the lint grouping from `perf` to `pedantic` as suggested by `@camsteffen` under the issue.

changelog: [`stable_sort_primitive`]: emit less authoritative message and move to `pedantic`

2 years agoAuto merge of #8700 - youknowone:needless_match-false-positive, r=xFrednet
bors [Wed, 20 Apr 2022 17:16:39 +0000 (17:16 +0000)]
Auto merge of #8700 - youknowone:needless_match-false-positive, r=xFrednet

Fix needless_match false positive for if-let when the else block doesn't match to given expr

<!--

Thank you for making Clippy better!

We're collecting our changelog from pull request descriptions.
If your PR only includes internal changes, you can just write
`changelog: none`. Otherwise, please write a short comment
explaining your change. Also, it's helpful for us that
the lint name is put into brackets `[]` and backticks `` ` ` ``,
e.g. ``[`lint_name`]``.

If your PR fixes an issue, you can add "fixes #issue_number" into this
PR description. This way the issue will be automatically closed when
your PR is merged.

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

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

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

Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.

Delete this line and everything above before opening your PR.

--->

fix #8695

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

changelog: Fixed ``[`needless_match`]`` false positive when else block expression differs.

2 years agoBetter documentation wording and add known problems section
bing [Wed, 20 Apr 2022 15:11:54 +0000 (23:11 +0800)]
Better documentation wording and add known problems section

2 years agoAuto merge of #8711 - kyoto7250:new-lint-bytes-count-to-len, r=giraffate
bors [Tue, 19 Apr 2022 12:44:07 +0000 (12:44 +0000)]
Auto merge of #8711 - kyoto7250:new-lint-bytes-count-to-len, r=giraffate

Take over: New lint bytes count to len

take over #8375
close #8083

This PR adds new lint about  considering replacing `.bytes().count()` with `.len()`.

Thank you in advance.

---

r! `@Manishearth`

changelog: adds new lint [`bytes_count_to_len`] to consider replacing `.bytes().count()` with `.len()`

2 years agofix ICE
asquared31415 [Tue, 19 Apr 2022 02:19:34 +0000 (22:19 -0400)]
fix ICE

2 years agoadd checking type
kyoto7250 [Sat, 16 Apr 2022 08:53:22 +0000 (17:53 +0900)]
add checking type

adding test patterns

cargo dev bless

fix comment

add ;

delete :

fix suggestion code

and update stderr in tests.

use match_def_path when checking method name

2 years agoadds lint logic and test for bytes_count_to_len
Chase Ruskin [Mon, 31 Jan 2022 00:16:10 +0000 (19:16 -0500)]
adds lint logic and test for bytes_count_to_len

formats code with

fixes single match clippy error to replace with if let

swaps ident.name.as_str to ident.name == sym for count fn

2 years agoAuto merge of #8707 - OneSignal:await-invalid-types, r=llogiq
bors [Mon, 18 Apr 2022 18:36:50 +0000 (18:36 +0000)]
Auto merge of #8707 - OneSignal:await-invalid-types, r=llogiq

Add `await_holding_invalid_type` lint

changelog: [`await_holding_invalid_type`]

This lint allows users to create a denylist of types which are not allowed to be
held across await points. This is essentially a re-implementation of the
language-level [`must_not_suspend`
lint](https://github.com/rust-lang/rust/issues/83310). That lint has a lot of
work still to be done before it will reach Rust stable, and in the meantime
there are a lot of types which can trip up developers if they are used
improperly.

I originally implemented this specifically for `tracing::span::Entered`, until I discovered #8434 and read the commentary on that PR. Given this implementation is fully user configurable, doesn't tie clippy to any one particular crate, and introduces no additional dependencies, it seems more appropriate.

2 years agofixup! Add `await_holding_invalid_type` lint
Lily Mara [Mon, 18 Apr 2022 18:32:28 +0000 (11:32 -0700)]
fixup! Add `await_holding_invalid_type` lint

2 years agofixup! Add `await_holding_invalid_type` lint
Lily Mara [Mon, 18 Apr 2022 18:30:59 +0000 (11:30 -0700)]
fixup! Add `await_holding_invalid_type` lint

2 years agofixup! Add `await_holding_invalid_type` lint
Lily Mara [Mon, 18 Apr 2022 18:16:35 +0000 (11:16 -0700)]
fixup! Add `await_holding_invalid_type` lint

2 years agofixup! Add `await_holding_invalid_type` lint
Lily Mara [Mon, 18 Apr 2022 17:34:17 +0000 (10:34 -0700)]
fixup! Add `await_holding_invalid_type` lint

2 years agoUpdate clippy_lints/src/await_holding_invalid.rs
Lily Mara [Mon, 18 Apr 2022 17:32:11 +0000 (10:32 -0700)]
Update clippy_lints/src/await_holding_invalid.rs

Co-authored-by: llogiq <bogusandre@gmail.com>
2 years agoUpdate clippy_lints/src/await_holding_invalid.rs
Lily Mara [Mon, 18 Apr 2022 17:32:03 +0000 (10:32 -0700)]
Update clippy_lints/src/await_holding_invalid.rs

Co-authored-by: llogiq <bogusandre@gmail.com>
2 years agoUpdate clippy_lints/src/await_holding_invalid.rs
Lily Mara [Mon, 18 Apr 2022 17:31:57 +0000 (10:31 -0700)]
Update clippy_lints/src/await_holding_invalid.rs

Co-authored-by: llogiq <bogusandre@gmail.com>
2 years agoAuto merge of #8701 - xFrednet:0000-clippy-print-hir-attr, r=flip1995
bors [Mon, 18 Apr 2022 13:06:03 +0000 (13:06 +0000)]
Auto merge of #8701 - xFrednet:0000-clippy-print-hir-attr, r=flip1995

Rework `#[clippy::dump]` attribute for debugging

Hey `@rust-lang/clippy,` this adds a new `#[clippy::print_hir]` attribute that prints the node to the console using `{:#?}`. Personally, I use print debugging quite a lot while working on Clippy, and this is a simple shortcut that also works in the playground (Once this has been synced). The question is now, if we want to have this attribute. Are there any concerns? I think it's similar to our `#[clippy::author]` attribute.

I haven't added a test, as the `.stdout` file would require updates with every HIR change inside rustc. Here are some examples, for the current implementation

<details>
<summary>`do_something(&map);`</summary>

```rs
Expr {
    hir_id: HirId {
        owner: DefId(0:7 ~ aaa[995b]::main),
        local_id: 21,
    },
    kind: Call(
        Expr {
            hir_id: HirId {
                owner: DefId(0:7 ~ aaa[995b]::main),
                local_id: 17,
            },
            kind: Path(
                Resolved(
                    None,
                    Path {
                        span: tests/ui/aaa.rs:23:5: 23:17 (#0),
                        res: Def(
                            Fn,
                            DefId(0:6 ~ aaa[995b]::do_something),
                        ),
                        segments: [
                            PathSegment {
                                ident: do_something#0,
                                hir_id: Some(
                                    HirId {
                                        owner: DefId(0:7 ~ aaa[995b]::main),
                                        local_id: 16,
                                    },
                                ),
                                res: Some(
                                    Err,
                                ),
                                args: None,
                                infer_args: true,
                            },
                        ],
                    },
                ),
            ),
            span: tests/ui/aaa.rs:23:5: 23:17 (#0),
        },
        [
            Expr {
                hir_id: HirId {
                    owner: DefId(0:7 ~ aaa[995b]::main),
                    local_id: 20,
                },
                kind: AddrOf(
                    Ref,
                    Not,
                    Expr {
                        hir_id: HirId {
                            owner: DefId(0:7 ~ aaa[995b]::main),
                            local_id: 19,
                        },
                        kind: Path(
                            Resolved(
                                None,
                                Path {
                                    span: tests/ui/aaa.rs:23:19: 23:22 (#0),
                                    res: Local(
                                        HirId {
                                            owner: DefId(0:7 ~ aaa[995b]::main),
                                            local_id: 15,
                                        },
                                    ),
                                    segments: [
                                        PathSegment {
                                            ident: map#0,
                                            hir_id: Some(
                                                HirId {
                                                    owner: DefId(0:7 ~ aaa[995b]::main),
                                                    local_id: 18,
                                                },
                                            ),
                                            res: Some(
                                                Local(
                                                    HirId {
                                                        owner: DefId(0:7 ~ aaa[995b]::main),
                                                        local_id: 15,
                                                    },
                                                ),
                                            ),
                                            args: None,
                                            infer_args: true,
                                        },
                                    ],
                                },
                            ),
                        ),
                        span: tests/ui/aaa.rs:23:19: 23:22 (#0),
                    },
                ),
                span: tests/ui/aaa.rs:23:18: 23:22 (#0),
            },
        ],
    ),
    span: tests/ui/aaa.rs:23:5: 23:23 (#0),
}
```
</details>

<details>
<summary>`use std::collections::HashMap;`</summary>

```rs
Item {
    ident: HashMap#0,
    def_id: DefId(0:5 ~ aaa[995b]::{misc#1}),
    kind: Use(
        Path {
            span: tests/ui/aaa.rs:8:5: 8:30 (#0),
            res: Def(
                Struct,
                DefId(1:1294 ~ std[928b]::collections::hash::map::HashMap),
            ),
            segments: [
                PathSegment {
                    ident: std#0,
                    hir_id: Some(
                        HirId {
                            owner: DefId(0:5 ~ aaa[995b]::{misc#1}),
                            local_id: 1,
                        },
                    ),
                    res: Some(
                        Def(
                            Mod,
                            DefId(1:0 ~ std[928b]),
                        ),
                    ),
                    args: None,
                    infer_args: false,
                },
                PathSegment {
                    ident: collections#0,
                    hir_id: Some(
                        HirId {
                            owner: DefId(0:5 ~ aaa[995b]::{misc#1}),
                            local_id: 2,
                        },
                    ),
                    res: Some(
                        Def(
                            Mod,
                            DefId(1:1193 ~ std[928b]::collections),
                        ),
                    ),
                    args: None,
                    infer_args: false,
                },
                PathSegment {
                    ident: HashMap#0,
                    hir_id: Some(
                        HirId {
                            owner: DefId(0:5 ~ aaa[995b]::{misc#1}),
                            local_id: 3,
                        },
                    ),
                    res: Some(
                        Err,
                    ),
                    args: None,
                    infer_args: false,
                },
            ],
        },
        Single,
    ),
    vis: Spanned {
        node: Inherited,
        span: tests/ui/aaa.rs:8:1: 8:1 (#0),
    },
    span: tests/ui/aaa.rs:8:1: 8:31 (#0),
}
```

</details>

<details>
<summary>`"100"`</summary>

```rs
Expr {
    hir_id: HirId {
        owner: DefId(0:7 ~ aaa[995b]::main),
        local_id: 27,
    },
    kind: Lit(
        Spanned {
            node: Str(
                "100",
                Cooked,
            ),
            span: tests/ui/aaa.rs:28:9: 28:14 (#0),
        },
    ),
    span: tests/ui/aaa.rs:28:9: 28:14 (#0),
}
```
</details>

---

changelog: Added `[clippy::print_hir]` to inspect rustc's internal representation

2 years agoUpdate lints
bing [Mon, 18 Apr 2022 06:48:34 +0000 (14:48 +0800)]
Update lints

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 agoFix needless_match false positive for if-let
Jeong YunWon [Fri, 15 Apr 2022 10:33:24 +0000 (19:33 +0900)]
Fix needless_match false positive for if-let

when the else block doesn't match to given expr

2 years agoAdd `#[clippy::print_hir]` attribute for debugging
xFrednet [Fri, 15 Apr 2022 09:37:58 +0000 (11:37 +0200)]
Add `#[clippy::print_hir]` attribute for debugging

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 agofixup! Add `await_holding_invalid_type` lint
Lily Mara [Fri, 15 Apr 2022 21:54:19 +0000 (14:54 -0700)]
fixup! Add `await_holding_invalid_type` lint

2 years agofixup! Add `await_holding_invalid_type` lint
Lily Mara [Fri, 15 Apr 2022 21:45:58 +0000 (14:45 -0700)]
fixup! Add `await_holding_invalid_type` lint

2 years agoAdd `await_holding_invalid_type` lint
Lily Mara [Thu, 14 Apr 2022 23:52:10 +0000 (16:52 -0700)]
Add `await_holding_invalid_type` lint

changelog: [`await_holding_invalid_type`]

This lint allows users to create a denylist of types which are not allowed to be
held across await points. This is essentially a re-implementation of the
language-level [`must_not_suspend`
lint](https://github.com/rust-lang/rust/issues/83310). That lint has a lot of
work still to be done before it will reach Rust stable, and in the meantime
there are a lot of types which can trip up developers if they are used
improperly.

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