]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAdd manual_bits lint
Paolo Barbolini [Sun, 2 Jan 2022 22:34:10 +0000 (23:34 +0100)]
Add manual_bits lint

2 years agoAuto merge of #8190 - camsteffen:no-in-band-liftetimes, r=flip1995
bors [Wed, 12 Jan 2022 14:25:11 +0000 (14:25 +0000)]
Auto merge of #8190 - camsteffen:no-in-band-liftetimes, r=flip1995

Stop using `in_band_lifetimes`

Per rust-lang/rust#91867

changelog: none

2 years agoAuto merge of #8198 - camsteffen:no-method-call-macro, r=flip1995
bors [Wed, 12 Jan 2022 13:59:12 +0000 (13:59 +0000)]
Auto merge of #8198 - camsteffen:no-method-call-macro, r=flip1995

Remove method_call! macro

This is possible now that `SymbolStr` is removed from rustc.

changelog: none

2 years agoAuto merge of #8268 - Jarcho:deref_addrof_8247, r=flip1995
bors [Wed, 12 Jan 2022 13:25:58 +0000 (13:25 +0000)]
Auto merge of #8268 - Jarcho:deref_addrof_8247, r=flip1995

Fix `deref_addrof`

fixes #8247

This would supersede #8259

changelog: Don't lint `deref_addrof` when the dereference and the borrow occur in different contexts

2 years agoDon't lint `deref_addrof` when the two operations occur in different expansions
Jason Newcomb [Wed, 12 Jan 2022 05:25:42 +0000 (00:25 -0500)]
Don't lint `deref_addrof` when the two operations occur in different expansions

2 years agoAuto merge of #8262 - 1nF0rmed:chore-update-borrowed-box-doc, r=camsteffen
bors [Tue, 11 Jan 2022 17:07:50 +0000 (17:07 +0000)]
Auto merge of #8262 - 1nF0rmed:chore-update-borrowed-box-doc, r=camsteffen

Improve documentation for `borrowed-box` lint

fixes #8161

Updates documentation to elaborate more on how removing Box from a function parameter can generalize the function.

changelog: none

2 years agoImprove documentation for `borrowed-box` lint
Pradyumna Rahul [Mon, 10 Jan 2022 16:14:10 +0000 (21:44 +0530)]
Improve documentation for `borrowed-box` lint

2 years agoStop using in_band_lifetimes
Cameron Steffen [Tue, 11 Jan 2022 15:52:23 +0000 (09:52 -0600)]
Stop using in_band_lifetimes

2 years agoAuto merge of #8210 - guerinoni:master, r=Manishearth
bors [Tue, 11 Jan 2022 15:45:50 +0000 (15:45 +0000)]
Auto merge of #8210 - guerinoni:master, r=Manishearth

Add borrow_as_ptr lint

Closes: #6995
- \[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: new lint: [`borrow_as_ptr`]

2 years agoAdd borrow_as_ptr lint
Federico Guerinoni [Sun, 2 Jan 2022 13:26:44 +0000 (14:26 +0100)]
Add borrow_as_ptr lint

Closes: #6995
Signed-off-by: Federico Guerinoni <guerinoni.federico@gmail.com>
Co-authored-by: Paolo Barbolini <paolo@paolo565.org>
2 years agoAuto merge of #8260 - taiki-e:mutex_atomic, r=llogiq
bors [Tue, 11 Jan 2022 08:09:11 +0000 (08:09 +0000)]
Auto merge of #8260 - taiki-e:mutex_atomic, r=llogiq

Downgrade mutex_atomic to nursery

See #1516 and #4295.

There are suggestions about removing this lint from the default warned lints in both issues.
Also, [`mutex_integer`](https://rust-lang.github.io/rust-clippy/master/index.html#mutex_integer) lint that has the same problems as this lint is in `nursery` group.

changelog: Moved [`mutex_atomic`] to `nursery`

2 years agoAuto merge of #8261 - taiki-e:disallowed, r=giraffate
bors [Mon, 10 Jan 2022 23:51:39 +0000 (23:51 +0000)]
Auto merge of #8261 - taiki-e:disallowed, r=giraffate

Warn disallowed_methods and disallowed_types by default

Closes #7841

changelog: Moved [`disallowed_methods`] and [`disallowed_types`] to `style`

2 years agoWarn disallowed_methods and disallowed_types by default
Taiki Endo [Mon, 10 Jan 2022 17:17:14 +0000 (02:17 +0900)]
Warn disallowed_methods and disallowed_types by default

2 years agoDowngrade mutex_atomic to nursery
Taiki Endo [Mon, 10 Jan 2022 14:36:13 +0000 (23:36 +0900)]
Downgrade mutex_atomic to nursery

2 years agoAuto merge of #8228 - Jarcho:iter_not_returning_iterator_8225, r=giraffate
bors [Mon, 10 Jan 2022 12:34:15 +0000 (12:34 +0000)]
Auto merge of #8228 - Jarcho:iter_not_returning_iterator_8225, r=giraffate

fix `iter_not_returning_iterator`

fixes #8225

changelog: Handle type projections in `iter_not_returning_iterator`
changelog: Don't lint `iter_not_returning_iterator` in trait implementations
changelog: Lint `iter_not_returning_iterator` in trait definitions

2 years agoAuto merge of #8257 - camsteffen:internal-features, r=giraffate
bors [Mon, 10 Jan 2022 12:18:05 +0000 (12:18 +0000)]
Auto merge of #8257 - camsteffen:internal-features, r=giraffate

Combine internal cargo features

changelog: none

This is just simpler and I don't see any downsides.

2 years agoAuto merge of #8252 - dswij:8229, r=xFrednet
bors [Mon, 10 Jan 2022 10:31:59 +0000 (10:31 +0000)]
Auto merge of #8252 - dswij:8229, r=xFrednet

cover trait for `trait_duplication_in_bounds`

closes #8229

changelog: [`trait_duplication_in_bounds`] covers trait functions with `Self` bounds

2 years ago`trait_duplication_in_bounds` Update description and add test
dswij [Mon, 10 Jan 2022 04:45:01 +0000 (12:45 +0800)]
`trait_duplication_in_bounds` Update description and add test

2 years agoCombine internal features in clippy_lints
Cameron Steffen [Mon, 10 Jan 2022 00:22:38 +0000 (18:22 -0600)]
Combine internal features in clippy_lints

2 years agoCombine internal features in clippy_utils
Cameron Steffen [Mon, 10 Jan 2022 00:16:05 +0000 (18:16 -0600)]
Combine internal features in clippy_utils

2 years agoAuto merge of #8236 - PatchMixolydic:single_char_lifetime_names, r=llogiq
bors [Sun, 9 Jan 2022 14:27:36 +0000 (14:27 +0000)]
Auto merge of #8236 - PatchMixolydic:single_char_lifetime_names, r=llogiq

new lint: `single_char_lifetime_names`

This pull request adds a lint against single character lifetime names, as they might not divulge enough information about the purpose of the lifetime. This can make code harder to understand. I placed this in `restriction` rather than `pedantic` (as suggested in #8233) since most of the Rust ecosystem already uses single character lifetime names (to my knowledge, at least) and since single character lifetime names aren't incorrect. I'd be happy to change this upon request, however. Fixes #8233.

- [x] Followed lint naming conventions
- [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: new lint: [`single_char_lifetime_names`]

2 years agonew lint: `single_char_lifetime_names`
bors [Sun, 9 Jan 2022 14:27:36 +0000 (14:27 +0000)]
new lint: `single_char_lifetime_names`

This pull request adds a lint against single character lifetime names, as they might not divulge enough information about the purpose of the lifetime. This can make code harder to understand. I placed this in `restriction` rather than `pedantic` (as suggested in #8233) since most of the Rust ecosystem already uses single character lifetime names (to my knowledge, at least) and since single character lifetime names aren't incorrect. I'd be happy to change this upon request, however. Fixes #8233.

- [x] Followed lint naming conventions
- [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: new lint: [`single_char_lifetime_names`]

2 years agocover trait for `trait_duplication_in_bounds`
dswij [Thu, 6 Jan 2022 10:43:44 +0000 (18:43 +0800)]
cover trait for `trait_duplication_in_bounds`

2 years agoAuto merge of #8249 - sourcefrog:depinfo, r=Manishearth
bors [Sun, 9 Jan 2022 00:19:19 +0000 (00:19 +0000)]
Auto merge of #8249 - sourcefrog:depinfo, r=Manishearth

Set binary-dep-depinfo in .cargo/config.toml

Fixes #8248

According to https://doc.rust-lang.org/cargo/reference/unstable this
seems to be the right place to set it, and it does fix the build for me.

I haven't removed the other `rustflags` because perhaps it's needed on
different cargo/rust versions?

---

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

changelog: none

2 years agoSet binary-dep-depinfo in .cargo/config.toml
Martin Pool [Sat, 8 Jan 2022 22:12:53 +0000 (14:12 -0800)]
Set binary-dep-depinfo in .cargo/config.toml

Fixes #8248

According to https://doc.rust-lang.org/cargo/reference/unstable this
seems to be the right place to set it, and it does fix the build for me.

I haven't removed the other `rustflags` because perhaps it's needed on
different cargo/rust versions?

2 years agoAuto merge of #8201 - smoelius:master, r=camsteffen
bors [Sat, 8 Jan 2022 16:33:48 +0000 (16:33 +0000)]
Auto merge of #8201 - smoelius:master, r=camsteffen

Change `unnecessary_to_owned` `into_iter` suggestions to `MaybeIncorrect`

I am having a hard time finding a good solution for #8148, so I am wondering if is enough to just change the suggestion's applicability to `MaybeIncorrect`?

I apologize, as I realize this is a bit of a cop out.

changelog: none

2 years agoAdd `unnecessary_to_owned` "Known problems" section
Samuel E. Moelius III [Sat, 8 Jan 2022 14:09:52 +0000 (09:09 -0500)]
Add `unnecessary_to_owned` "Known problems" section

2 years agoAuto merge of #8234 - Alexendoo:lintcheck-allow-renamed-dir, r=xFrednet
bors [Fri, 7 Jan 2022 20:31:24 +0000 (20:31 +0000)]
Auto merge of #8234 - Alexendoo:lintcheck-allow-renamed-dir, r=xFrednet

Allow running lintcheck with a renamed rust-clippy dir

I have Clippy checked out in `rust/clippy` rather than `rust/rust-clippy`, this allows lintcheck to still run in that case

changelog: none

2 years agoAllow running lintcheck with a renamed rust-clippy dir
Alex Macleod [Thu, 6 Jan 2022 13:06:24 +0000 (13:06 +0000)]
Allow running lintcheck with a renamed rust-clippy dir

2 years agoHandle type projections in `iter_not_returning_iterator`
Jason Newcomb [Wed, 5 Jan 2022 18:57:45 +0000 (13:57 -0500)]
Handle type projections in `iter_not_returning_iterator`

2 years agoLint `iter_not_returning_iterator` on the trait definition rather than the implementation
Jason Newcomb [Wed, 5 Jan 2022 18:46:35 +0000 (13:46 -0500)]
Lint `iter_not_returning_iterator` on the trait definition rather than the implementation

2 years agoChange `unnecessary_to_owned` `into_iter` suggestions to `MaybeIncorrect`
Samuel E. Moelius III [Thu, 30 Dec 2021 23:43:34 +0000 (18:43 -0500)]
Change `unnecessary_to_owned` `into_iter` suggestions to `MaybeIncorrect`

2 years agoAuto merge of #8221 - Jarcho:while_let_on_iterator_8113, r=llogiq
bors [Wed, 5 Jan 2022 06:45:58 +0000 (06:45 +0000)]
Auto merge of #8221 - Jarcho:while_let_on_iterator_8113, r=llogiq

Better detect when a field can be moved from in `while_let_on_iterator`

fixes #8113

changelog: Better detect when a field can be moved from in `while_let_on_iterator`

2 years agoAuto merge of #8224 - Jarcho:type_repetition_in_bounds_8162, r=llogiq
bors [Wed, 5 Jan 2022 01:05:18 +0000 (01:05 +0000)]
Auto merge of #8224 - Jarcho:type_repetition_in_bounds_8162, r=llogiq

Fix `type_repetition_in_bounds`

fixes #7360
fixes #8162
fixes #8056

changelog: Check for full equality in `type_repetition_in_bounds` rather than just equal hashes

2 years agoAuto merge of #8223 - camsteffen:remove-in-macro, r=llogiq
bors [Wed, 5 Jan 2022 00:49:23 +0000 (00:49 +0000)]
Auto merge of #8223 - camsteffen:remove-in-macro, r=llogiq

Remove in_macro from clippy_utils

changelog: none

Previously done in #7897 but reverted in #8170. I'd like to keep `in_macro` out of utils because if a span is from expansion in any way (desugaring or macro), we should not proceed without understanding the nature of the expansion IMO.

r? `@llogiq`

2 years agoAuto merge of #8219 - camsteffen:macro-decoupling, r=llogiq
bors [Tue, 4 Jan 2022 22:32:02 +0000 (22:32 +0000)]
Auto merge of #8219 - camsteffen:macro-decoupling, r=llogiq

New macro utils

changelog: none

Sorry, this is a big one. A lot of interrelated changes and I wanted to put the new utils to use to make sure they are somewhat battle-tested. We may want to divide some of the lint-specific refactoring commits into batches for smaller reviewing tasks. I could also split into more PRs.

Introduces a bunch of new utils at `clippy_utils::macros::...`. Please read through the docs and give any feedback! I'm happy to introduce `MacroCall` and various functions to retrieve an instance. It feels like the missing puzzle piece. I'm also introducing `ExpnId` from rustc as "useful for Clippy too". `@rust-lang/clippy`

Fixes #7843 by not parsing every node of macro implementations, at least the major offenders.

I probably want to get rid of `is_expn_of` at some point.

2 years agoNew macro utils
bors [Tue, 4 Jan 2022 22:32:02 +0000 (22:32 +0000)]
New macro utils

changelog: none

Sorry, this is a big one. A lot of interrelated changes and I wanted to put the new utils to use to make sure they are somewhat battle-tested. We may want to divide some of the lint-specific refactoring commits into batches for smaller reviewing tasks. I could also split into more PRs.

Introduces a bunch of new utils at `clippy_utils::macros::...`. Please read through the docs and give any feedback! I'm happy to introduce `MacroCall` and various functions to retrieve an instance. It feels like the missing puzzle piece. I'm also introducing `ExpnId` from rustc as "useful for Clippy too". `@rust-lang/clippy`

Fixes #7843 by not parsing every node of macro implementations, at least the major offenders.

I probably want to get rid of `is_expn_of` at some point.

2 years agoCheck for full equality in `type_repetition_in_bounds` rather than just equal hashes
Jason Newcomb [Tue, 4 Jan 2022 19:20:27 +0000 (14:20 -0500)]
Check for full equality in `type_repetition_in_bounds` rather than just equal hashes

2 years agoAuto merge of #8220 - Jarcho:manual_swap_8154, r=camsteffen
bors [Tue, 4 Jan 2022 18:23:39 +0000 (18:23 +0000)]
Auto merge of #8220 - Jarcho:manual_swap_8154, r=camsteffen

Consider auto-deref when linting `manual_swap`

fixes #8154

changelog: Don't lint `manual_swap` when a field access involves auto-deref

2 years agoConsider auto-deref when linting `manual_swap`
Jason Newcomb [Tue, 4 Jan 2022 03:13:52 +0000 (22:13 -0500)]
Consider auto-deref when linting `manual_swap`

2 years agoRemove in_macro from utils
Cameron Steffen [Tue, 4 Jan 2022 17:58:39 +0000 (11:58 -0600)]
Remove in_macro from utils

2 years agoBetter detect when a field can be moved from in `while_let_on_iterator`
Jason Newcomb [Tue, 4 Jan 2022 04:13:31 +0000 (23:13 -0500)]
Better detect when a field can be moved from in `while_let_on_iterator`

2 years agoAuto merge of #8216 - pmnoxx:piotr-fix-clippy-warnings, r=xFrednet
bors [Mon, 3 Jan 2022 16:54:39 +0000 (16:54 +0000)]
Auto merge of #8216 - pmnoxx:piotr-fix-clippy-warnings, r=xFrednet

Fix `clippy::use-self`` warning in ` src/main.rs`

`ClippyCmd` warnings gets generated due to addition of `clippy::use-self`. This PR fixes that.

```
warning: unnecessary structure name repetition
  --> src/main.rs:99:9
   |
99 |         ClippyCmd {
   |         ^^^^^^^^^ help: use the applicable keyword: `Self`
   |
   = note: `-W clippy::use-self` implied by `-W clippy::nursery`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#use_self
```

---

changelog: none

2 years agoFix clippy warnings
Piotr Mikulski [Mon, 3 Jan 2022 14:11:11 +0000 (06:11 -0800)]
Fix clippy warnings

2 years agoAuto merge of #8204 - wigy-opensource-developer:fix-7210, r=xFrednet
bors [Sun, 2 Jan 2022 18:50:44 +0000 (18:50 +0000)]
Auto merge of #8204 - wigy-opensource-developer:fix-7210, r=xFrednet

[`erasing_op`] lint ignored when operation `Output` type is different from the type of constant `0`

fixes #7210

changelog: [`erasing_op`] lint ignored when operation `Output` type is different from the type of constant `0`

2 years agoerasing_op lint ignored when output type is different from the non-const one
Wigy [Fri, 31 Dec 2021 08:37:39 +0000 (09:37 +0100)]
erasing_op lint ignored when output type is different from the non-const one

2 years agoAuto merge of #8208 - nmathewson:selfkind_no_fix, r=xFrednet
bors [Sun, 2 Jan 2022 17:14:18 +0000 (17:14 +0000)]
Auto merge of #8208 - nmathewson:selfkind_no_fix, r=xFrednet

wrong_self_convention: Match `SelfKind::No` more restrictively

The `wrong_self_convention` lint uses a `SelfKind` type to decide
whether a method has the right kind of "self" for its name, or whether
the kind of "self" it has makes its name confusable for a method in
a common trait.  One possibility is `SelfKind::No`, which is supposed
to mean "No `self`".

Previously, SelfKind::No matched everything _except_ Self, including
references to Self.  This patch changes it to match Self, &Self, &mut
Self, Box<Self>, and so on.

For example, this kind of method was allowed before:

```
impl S {
    // Should trigger the lint, because
    // "methods called `is_*` usually take `self` by reference or no `self`"
    fn is_foo(&mut self) -> bool { todo!() }
}
```

But since SelfKind::No matched "&mut self", no lint was triggered
(see #8142).

With this patch, the code above now gives a lint as expected.

fixes #8142

changelog: [`wrong_self_convention`] rejects `self` references in more cases

2 years agoAuto merge of #8209 - xFrednet:8197-mention-attribute-on-struct, r=llogiq
bors [Sat, 1 Jan 2022 13:16:49 +0000 (13:16 +0000)]
Auto merge of #8209 - xFrednet:8197-mention-attribute-on-struct, r=llogiq

return_self_not_must_use document `#[must_use]` on the type

Inspired by a discussion in rust-lang/rust-clippy#8197

---

r? `@llogiq`

changelog: none

The lint is this on nightly, therefore no changelog entry for you xD

2 years agoreturn_self_not_must_use document `#[must_use]` on the type
bors [Sat, 1 Jan 2022 13:16:49 +0000 (13:16 +0000)]
return_self_not_must_use document `#[must_use]` on the type

Inspired by a discussion in rust-lang/rust-clippy#8197

---

r? `@llogiq`

changelog: none

The lint is this on nightly, therefore no changelog entry for you xD

2 years agowrong_self_convention: Match `SelfKind::No` more restrictively
Nick Mathewson [Sat, 1 Jan 2022 04:39:40 +0000 (23:39 -0500)]
wrong_self_convention: Match `SelfKind::No` more restrictively

The `wrong_self_convention` lint uses a `SelfKind` type to decide
whether a method has the right kind of "self" for its name, or whether
the kind of "self" it has makes its name confusable for a method in
a common trait.  One possibility is `SelfKind::No`, which is supposed
to mean "No `self`".

Previously, SelfKind::No matched everything _except_ Self, including
references to Self.  This patch changes it to match Self, &Self, &mut
Self, Box<Self>, and so on.

For example, this kind of method was allowed before:

```
impl S {
    // Should trigger the lint, because
    // "methods called `is_*` usually take `self` by reference or no `self`"
    fn is_foo(&mut self) -> bool { todo!() }
}
```

But since SelfKind::No matched "&mut self", no lint was triggered
(see #8142).

With this patch, the code above now gives a lint as expected.

Fixes #8142

changelog: [`wrong_self_convention`] rejects `self` references in more cases

2 years agoAuto merge of #8193 - ebobrow:redundant_closure_fp, r=Manishearth
bors [Fri, 31 Dec 2021 19:01:42 +0000 (19:01 +0000)]
Auto merge of #8193 - ebobrow:redundant_closure_fp, r=Manishearth

fix [`redundant_closure`] fp with `Rc<F>`/`Arc<F>`

fixes #8073

changelog: don't trigger [`redundant_closure`] on `Arc<F>` or `Rc<F>`

2 years agoAuto merge of #8179 - nmathewson:unused_async_io_amount, r=xFrednet
bors [Fri, 31 Dec 2021 17:36:04 +0000 (17:36 +0000)]
Auto merge of #8179 - nmathewson:unused_async_io_amount, r=xFrednet

Extend unused_io_amount to cover async io.

Clippy helpfully warns about code like this, telling you that you
probably meant "write_all":

    fn say_hi<W:Write>(w: &mut W) {
       w.write(b"hello").unwrap();
    }

This patch attempts to extend the lint so it also covers this
case:

    async fn say_hi<W:AsyncWrite>(w: &mut W) {
       w.write(b"hello").await.unwrap();
    }

(I've run into this second case several times in my own programming,
and so have my coworkers, so unless we're especially accident-prone
in this area, it's probably worth addressing?)

Since this is my first attempt at a clippy patch, I've probably
made all kinds of mistakes: please help me fix them?  I'd like
to learn more here.

Open questions I have:

  * Should this be a separate lint from unused_io_amount?  Maybe
    unused_async_io_amount?  If so, how should I structure their
    shared code?
  * Should this cover tokio's AsyncWrite too?
  * Is it okay to write lints for stuff that isn't part of
    the standard library?  I see that "regex" also has lints,
    and I figure that "futures" is probably okay too, since it's
    an official rust-lang repository.
  * What other tests are needed?
  * How should I improve the code?

Thanks for your time!

---

changelog: [`unused_io_amount`] now supports async read and write traits

2 years agounused_io_amount: Use span_lint_and_help.
Nick Mathewson [Fri, 31 Dec 2021 17:20:02 +0000 (12:20 -0500)]
unused_io_amount: Use span_lint_and_help.

This improves the quality of the genrated output and makes it
more in line with other lint messages.

changelog: [`unused_io_amount`]: Improve help text

2 years agoExtend [`unused_io_amount`] to cover AsyncRead and AsyncWrite.
Nick Mathewson [Mon, 27 Dec 2021 16:17:17 +0000 (11:17 -0500)]
Extend [`unused_io_amount`] to cover AsyncRead and AsyncWrite.

Clippy helpfully warns about code like this, telling you that you
probably meant "write_all":

    fn say_hi<W:Write>(w: &mut W) {
       w.write(b"hello").unwrap();
    }

This patch attempts to extend the lint so it also covers this
case:

    async fn say_hi<W:AsyncWrite>(w: &mut W) {
       w.write(b"hello").await.unwrap();
    }

(I've run into this second case several times in my own programming,
and so have my coworkers, so unless we're especially accident-prone
in this area, it's probably worth addressing?)

This patch covers the Async{Read,Write}Ext traits in futures-rs,
and in tokio, since both are quite widely used.

changelog: [`unused_io_amount`] now supports AsyncReadExt and AsyncWriteExt.

2 years agoRemove method_call! macro
Cameron Steffen [Thu, 30 Dec 2021 19:37:14 +0000 (13:37 -0600)]
Remove method_call! macro

2 years agoAuto merge of #8196 - flip1995:rustup, r=flip1995
bors [Thu, 30 Dec 2021 13:22:47 +0000 (13:22 +0000)]
Auto merge of #8196 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

2 years agoBump nightly version -> 2021-12-30
flip1995 [Thu, 30 Dec 2021 13:18:01 +0000 (14:18 +0100)]
Bump nightly version -> 2021-12-30

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 30 Dec 2021 13:04:13 +0000 (14:04 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agofix [`redundant_closure`] fp with `Arc`
Elliot Bobrow [Wed, 29 Dec 2021 16:52:40 +0000 (08:52 -0800)]
fix [`redundant_closure`] fp with `Arc`

2 years agoAuto merge of #8117 - hotate29:issue7320, r=camsteffen
bors [Tue, 28 Dec 2021 22:15:53 +0000 (22:15 +0000)]
Auto merge of #8117 - hotate29:issue7320, r=camsteffen

update: ```Sugg::not()``` replacing the comparison operator. #7320

fixes #7320

changelog: ```needless_bool```: Changed to make a smart suggestion.

2 years agoAuto merge of #8183 - alex-ozdemir:limit-ident, r=camsteffen
bors [Tue, 28 Dec 2021 22:01:57 +0000 (22:01 +0000)]
Auto merge of #8183 - alex-ozdemir:limit-ident, r=camsteffen

Limit the ``[`identity_op`]`` lint to integral operands.

changelog: limit ``[`identity_op`]`` to integral operands

In the ``[`identity_op`]`` lint, if the operands are non-integers, then the lint is likely
wrong.

2 years agoAuto merge of #8187 - ApamNapat:fix_7651, r=llogiq
bors [Tue, 28 Dec 2021 17:11:40 +0000 (17:11 +0000)]
Auto merge of #8187 - ApamNapat:fix_7651, r=llogiq

Fixed issues with to_radians and to_degrees lints

fixes #7651

I fixed the original problem as described in the issue, but the bug remains for complex expressions (the commented out TC I added is an example). I would also love some feedback on how to cleanup my code and reduce duplication. I hope it's not a problem that the issue has been claimed by someone else - that was over two months ago.

changelog: ``[`suboptimal_flops`]`` no longer proposes broken code with `to_radians` and `to_degrees`

2 years agoFixed issues with to_radians and to_degrees lints
BB [Tue, 28 Dec 2021 16:45:43 +0000 (17:45 +0100)]
Fixed issues with to_radians and to_degrees lints

2 years agocontants peel_refs to catch `x << &0`
Alex Ozdemir [Tue, 28 Dec 2021 16:32:55 +0000 (08:32 -0800)]
contants peel_refs to catch `x << &0`

2 years agotest
Alex Ozdemir [Tue, 28 Dec 2021 16:19:47 +0000 (08:19 -0800)]
test

2 years agoAuto merge of #8127 - dswij:8090, r=xFrednet
bors [Tue, 28 Dec 2021 12:01:21 +0000 (12:01 +0000)]
Auto merge of #8127 - dswij:8090, r=xFrednet

Fix `enum_variants` FP on prefixes that are not camel-case

closes #8090

Fix FP on `enum_variants` when prefixes are only a substring of a camel-case word. Also adds some util helpers on `str_utils` to help parsing camel-case strings.

This changes how the lint behaves:

1. previously if the Prefix is only a length of 1, it's going to get ignored, i.e. these were previously ignored and now is warned
```rust
enum Foo {
    cFoo,
    cBar,
    cBaz,
}

enum Something {
    CCall,
    CCreate,
    CCryogenize,
}
```

2. non-ascii characters that doesn't have casing will not be split,
```rust
enum NonCaps {
    PrefixXXX,
    PrefixTea,
    PrefixCake,
}
```
will be considered as `PrefixXXX`, `Prefix`, `Prefix`, so this won't lint as opposed to fired previously.

changelog: [`enum_variant_names`] Fix FP when first prefix are only a substring of a camel-case word.

---

 (Edited by `@xFrednet` removed some non ascii characters)

2 years agoAuto merge of #8185 - dswij:8177, r=llogiq
bors [Tue, 28 Dec 2021 11:15:53 +0000 (11:15 +0000)]
Auto merge of #8185 - dswij:8177, r=llogiq

`needless_return` suggest return unit type on void returns

closes #8177

previously, `needless_return` suggests an empty block `{}` to replace void `return` on match arms, this PR improve the suggestion by suggesting a unit instead.

changelog: `needless_return` suggests `()` instead of `{}` on match arms

2 years ago`needless_return` suggest return unit type on void returns
bors [Tue, 28 Dec 2021 11:15:53 +0000 (11:15 +0000)]
`needless_return` suggest return unit type on void returns

closes #8177

previously, `needless_return` suggests an empty block `{}` to replace void `return` on match arms, this PR improve the suggestion by suggesting a unit instead.

changelog: `needless_return` suggests `()` instead of `{}` on match arms

2 years agoAuto merge of #8175 - Kage-Yami:feature/document-8145, r=llogiq
bors [Tue, 28 Dec 2021 09:29:08 +0000 (09:29 +0000)]
Auto merge of #8175 - Kage-Yami:feature/document-8145, r=llogiq

Readme: note that config changes don't apply to already compiled code

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

changelog: added a note to the Readme that config changes don't apply to already compiled code

2 years agoReadme: note that config changes don't apply to already compiled code
bors [Tue, 28 Dec 2021 09:29:08 +0000 (09:29 +0000)]
Readme: note that config changes don't apply to already compiled code

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

changelog: added a note to the Readme that config changes don't apply to already compiled code

2 years agoAuto merge of #8182 - rust-lang:cache-test-items, r=giraffate
bors [Tue, 28 Dec 2021 05:50:20 +0000 (05:50 +0000)]
Auto merge of #8182 - rust-lang:cache-test-items, r=giraffate

cache test item names

This avoids quadratic behavior (collecting all test item names for each `eq_op` instance within the module). However, it invests a good deal of memory to buy this speedup. If that becomes a problem, I may need to change the cache to only store the chain of last visited modules.

This hopefully fixes #8171.

---

changelog: none

2 years agocache test item names
Andre Bogus [Mon, 27 Dec 2021 23:13:03 +0000 (00:13 +0100)]
cache test item names

2 years agoAuto merge of #8181 - ApamNapat:typos_fixes, r=giraffate
bors [Tue, 28 Dec 2021 00:29:24 +0000 (00:29 +0000)]
Auto merge of #8181 - ApamNapat:typos_fixes, r=giraffate

Fixed some typos in README and CONTRIBUTING

changelog: none

2 years agoLimit the identity_op lint to integral operands.
Alex Ozdemir [Tue, 28 Dec 2021 00:06:27 +0000 (16:06 -0800)]
Limit the identity_op lint to integral operands.

If operands are being applied to non-integers, then the lint is likely
wrong.

2 years agoFixed some typos in README and CONTRIBUTING
BB [Mon, 27 Dec 2021 23:08:25 +0000 (00:08 +0100)]
Fixed some typos in README and CONTRIBUTING

2 years agoAuto merge of #8170 - rust-lang:numbered-fields, r=xFrednet
bors [Mon, 27 Dec 2021 21:02:15 +0000 (21:02 +0000)]
Auto merge of #8170 - rust-lang:numbered-fields, r=xFrednet

new lint: `init-numbered-fields`

This fixes #7985.

r? `@xFrednet`

---

changelog: new lint: [`init_numbered_fields`]

2 years agoAuto merge of #8175 - Kage-Yami:feature/document-8145, r=llogiq
bors [Mon, 27 Dec 2021 20:43:48 +0000 (20:43 +0000)]
Auto merge of #8175 - Kage-Yami:feature/document-8145, r=llogiq

Readme: note that config changes don't apply to already compiled code

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

changelog: added a note to the Readme that config changes don't apply to already compiled code

2 years agoReadme: note that config changes don't apply to already compiled code
bors [Mon, 27 Dec 2021 20:43:48 +0000 (20:43 +0000)]
Readme: note that config changes don't apply to already compiled code

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

changelog: added a note to the Readme that config changes don't apply to already compiled code

2 years agonew lint: `init-numbered-fields`
Andre Bogus [Sat, 25 Dec 2021 15:52:58 +0000 (16:52 +0100)]
new lint: `init-numbered-fields`

2 years agoAuto merge of #8133 - surechen:fix_8128, r=xFrednet
bors [Sun, 26 Dec 2021 14:05:35 +0000 (14:05 +0000)]
Auto merge of #8133 - surechen:fix_8128, r=xFrednet

Fix 8128

Fixes #8128

changelog: Fix  error suggestion of `skip(..).next()` for immutable variable.

2 years agoFixes #8128
surechen [Fri, 17 Dec 2021 02:03:59 +0000 (10:03 +0800)]
Fixes #8128

changelog: Fix error suggestion of skip(..).next() for immutable variable.

2 years agoAdd limitation description for `enum_variant_names`
dswij [Fri, 24 Dec 2021 04:32:12 +0000 (12:32 +0800)]
Add limitation description for `enum_variant_names`

`enum_variant_names` will consider characters with no case to be a part
of prefixes/suffixes substring that are compared. This means `Foo1` and
`Foo2` has different prefixes (`Foo1` and `Foo2` prefix respeectively).
This applies to all non-ascii characters with no casing.

2 years agoSome minor cleanup
dswij [Fri, 24 Dec 2021 04:10:34 +0000 (12:10 +0800)]
Some minor cleanup

2 years agoFix reversed suggestion on postfix
dswij [Thu, 23 Dec 2021 05:55:41 +0000 (13:55 +0800)]
Fix reversed suggestion on postfix

2 years agoUpdate str_utils test
dswij [Thu, 23 Dec 2021 03:32:04 +0000 (11:32 +0800)]
Update str_utils test

2 years agoupdate `enum_variants` test
dswij [Wed, 22 Dec 2021 09:04:48 +0000 (17:04 +0800)]
update `enum_variants` test

2 years agoAdd str_util helpers to split camelcase strings
dswij [Wed, 22 Dec 2021 15:18:24 +0000 (23:18 +0800)]
Add str_util helpers to split camelcase strings

2 years agoFix False Positive on `enum_variants` when prefixes are not camel-case
dswij [Wed, 22 Dec 2021 15:18:11 +0000 (23:18 +0800)]
Fix False Positive on `enum_variants` when prefixes are not camel-case

2 years agoRefactor `enum_variants`
dswij [Wed, 15 Dec 2021 04:08:13 +0000 (12:08 +0800)]
Refactor `enum_variants`

2 years agoAuto merge of #8167 - rust-lang:fix-8166, r=xFredNet
bors [Sat, 25 Dec 2021 13:38:08 +0000 (13:38 +0000)]
Auto merge of #8167 - rust-lang:fix-8166, r=xFredNet

fix an ICE on unwrapping a None

This very likely fixes #8166 though I wasn't able to meaningfully reduce a test case. This line is the only call to `unwrap` within that function, which was the one in the stack trace that triggered the ICE, so I think we'll be OK.

`@hackmad` can you pull and build this branch and check if it indeed fixes your problem?

---

changelog: Fixed ICE in [`unnecessary_cast`]

2 years agofix an ICE on unwrapping a None
Andre Bogus [Sat, 25 Dec 2021 12:11:54 +0000 (13:11 +0100)]
fix an ICE on unwrapping a None

2 years agoAuto merge of #8165 - ebobrow:shadow_reuse_fn, r=xFrednet
bors [Sat, 25 Dec 2021 11:58:25 +0000 (11:58 +0000)]
Auto merge of #8165 - ebobrow:shadow_reuse_fn, r=xFrednet

fix [`shadow_reuse`] false negative for if let bindings

fixes #8087

changelog: trigger [`shadow_reuse`] instead of [`shadow_unrelated`] on shadowed `if let` bindings

2 years agofix `shadow_reuse` false negative for if let bindings
Elliot Bobrow [Fri, 24 Dec 2021 21:20:40 +0000 (13:20 -0800)]
fix `shadow_reuse` false negative for if let bindings

2 years agoChange to enclose both sides of Range in parentheses.
hotate29 [Tue, 21 Dec 2021 12:45:55 +0000 (21:45 +0900)]
Change to enclose both sides of Range in parentheses.

2 years agoChange ```floating_point_arthmetic::detect_hypot()``` to enclose the expression in...
hotate29 [Fri, 24 Dec 2021 14:54:15 +0000 (23:54 +0900)]
Change ```floating_point_arthmetic::detect_hypot()``` to enclose the expression in parentheses.

2 years agoUse helper functions in ```Sugg``` tests.
hotate29 [Tue, 21 Dec 2021 13:20:58 +0000 (22:20 +0900)]
Use helper functions in ```Sugg``` tests.

2 years agorefactor ```Sugg::BinOp```
hotate29 [Wed, 15 Dec 2021 14:23:36 +0000 (23:23 +0900)]
refactor ```Sugg::BinOp```

2 years agoAdd test
hotate29 [Tue, 14 Dec 2021 12:27:55 +0000 (21:27 +0900)]
Add test

2 years agoAuto merge of #8163 - pmnoxx:piotr-improve-unwrap-or-default, r=Manishearth
bors [Fri, 24 Dec 2021 12:34:09 +0000 (12:34 +0000)]
Auto merge of #8163 - pmnoxx:piotr-improve-unwrap-or-default, r=Manishearth

Improve `unwrap_or_else_default` when handling `unwrap_or_else(XXX::new)`

changelog:  change `unwrap_or_else_default` to work with std constructors like `Vec::new`, `HashSet::new`, `HashMap::new`.

Notes:
- Code to handle detecting those constructors is already there. I moved it out to `is_default_equivalent_call`

2 years agoSimplify code
Piotr Mikulski [Fri, 24 Dec 2021 06:12:08 +0000 (22:12 -0800)]
Simplify code