]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agofix underflow in `check_manual_split_once` lint
max [Sat, 8 Jan 2022 22:10:20 +0000 (23:10 +0100)]
fix underflow in `check_manual_split_once` lint

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

2 years agoRefactor
Piotr Mikulski [Fri, 24 Dec 2021 06:00:14 +0000 (22:00 -0800)]
Refactor

2 years agoclippy
Piotr Mikulski [Fri, 24 Dec 2021 05:47:31 +0000 (21:47 -0800)]
clippy

2 years agorefactor
Piotr Mikulski [Fri, 24 Dec 2021 05:46:21 +0000 (21:46 -0800)]
refactor

2 years agocargo dev fmt
Piotr Mikulski [Fri, 24 Dec 2021 05:44:13 +0000 (21:44 -0800)]
cargo dev fmt

2 years agoFix tests
Piotr Mikulski [Fri, 24 Dec 2021 05:43:30 +0000 (21:43 -0800)]
Fix tests

2 years agoFix tests
Piotr Mikulski [Fri, 24 Dec 2021 05:42:56 +0000 (21:42 -0800)]
Fix tests

2 years agorewrite the PR
Piotr Mikulski [Fri, 24 Dec 2021 05:41:00 +0000 (21:41 -0800)]
rewrite the PR

2 years agoImrpove `unwrap_or_else_default`
Piotr Mikulski [Fri, 24 Dec 2021 03:13:57 +0000 (19:13 -0800)]
Imrpove `unwrap_or_else_default`

2 years agoAuto merge of #8144 - Gh0stm4chine:master, r=xFrednet
bors [Thu, 23 Dec 2021 10:06:17 +0000 (10:06 +0000)]
Auto merge of #8144 - Gh0stm4chine:master, r=xFrednet

Add suggestion for neg_multiply lint

This fixes #8115 by adding a suggestion for [neg_multiply].

My first issue on Github, any feedback or input is welcome ðŸ˜ƒ

changelog: create a suggestion for `neg_multiply`

2 years agoAdd allow unused
Oussama [Thu, 23 Dec 2021 09:45:16 +0000 (10:45 +0100)]
Add allow unused

2 years agoAdd allow precedence lint to prevent rustfix from failing
Oussama [Thu, 23 Dec 2021 08:22:29 +0000 (09:22 +0100)]
Add allow precedence lint to prevent rustfix from failing

2 years agoBless clippy test.
Mara Bos [Wed, 22 Dec 2021 16:25:44 +0000 (17:25 +0100)]
Bless clippy test.

2 years agoAdd support for suggestion when using an expression
Oussama [Tue, 21 Dec 2021 21:00:14 +0000 (22:00 +0100)]
Add support for suggestion when using an expression

2 years agoadd suggestion for neg_multiply lint
Oussama [Sun, 19 Dec 2021 08:48:25 +0000 (09:48 +0100)]
add suggestion for neg_multiply lint

2 years agoAuto merge of #8150 - flip1995:clippy_utils_test, r=xFrednet
bors [Mon, 20 Dec 2021 22:53:47 +0000 (22:53 +0000)]
Auto merge of #8150 - flip1995:clippy_utils_test, r=xFrednet

Test clippy_utils in CI

r? `@xFrednet` Since you did the last refactor of the `str_utils` functions in #7873

changelog: Make sure tests in `clippy_utils` are passing by testing it in CI

2 years agoTest clippy_utils in CI
flip1995 [Mon, 20 Dec 2021 18:56:06 +0000 (19:56 +0100)]
Test clippy_utils in CI

This makes sure that the tests in clippy_utils are run in CI.

When looking into this I discovered that two tests were failing and
multiple doc tests were failing. This fixes those tests and enables a
few more doc tests.

2 years agoAuto merge of #8138 - r00ster91:safety, r=giraffate
bors [Mon, 20 Dec 2021 00:15:18 +0000 (00:15 +0000)]
Auto merge of #8138 - r00ster91:safety, r=giraffate

Fix `SAFETY` comment tag casing in undocumented_unsafe_blocks

This changes the lint introduced in #7748 to suggest adding a `SAFETY` comment instead of a `Safety` comment.

Searching for `// Safety:` in rust-lang/rust yields 67 results while `// SAFETY:` yields 1072.
I think it's safe to say that this comment tag is written in upper case, just like `TODO`, `FIXME` and so on are. As such I would expect this lint to follow the official convention as well.

Note that I intentionally introduced some casing diversity in `tests/ui/undocumented_unsafe_blocks.rs` to test more cases than just `Safety:`.

changelog: Capitalize `SAFETY` comment in [`undocumented_unsafe_blocks`]

2 years agoAuto merge of #8146 - GuillaumeGomez:must-use-self, r=xFrednet
bors [Sun, 19 Dec 2021 14:54:12 +0000 (14:54 +0000)]
Auto merge of #8146 - GuillaumeGomez:must-use-self, r=xFrednet

Don't emit RETURN_SELF_NOT_MUST_USE lint if `Self` already is marked as `#[must_use]`

New bug discovered with this lint. Hopefully, this is the last one.

---

changelog: none

2 years agoDon't emit RETURN_SELF_NOT_MUST_USE lint if `Self` already is marked as `#[must_use]`
Guillaume Gomez [Sun, 19 Dec 2021 14:10:36 +0000 (15:10 +0100)]
Don't emit RETURN_SELF_NOT_MUST_USE lint if `Self` already is marked as `#[must_use]`

2 years agoAuto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obk
bors [Sun, 19 Dec 2021 09:31:37 +0000 (09:31 +0000)]
Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obk

Remove `SymbolStr`

This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences.

Best reviewed one commit at a time.

r? `@oli-obk`

2 years agoAuto merge of #8143 - GuillaumeGomez:RETURN_SELF_NOT_MUST_USE, r=xFrednet
bors [Sat, 18 Dec 2021 15:06:09 +0000 (15:06 +0000)]
Auto merge of #8143 - GuillaumeGomez:RETURN_SELF_NOT_MUST_USE, r=xFrednet

Ensure that RETURN_SELF_NOT_MUST_USE is not emitted if the method already has `#[must_use]`

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

---

Edit:

changelog: none

(The lint is not in beta yet, this should therefore not be included inside the changelog :) )

2 years agoEnsure that RETURN_SELF_NOT_MUST_USE is not emitted if the method already has a must_...
Guillaume Gomez [Sat, 18 Dec 2021 14:26:16 +0000 (15:26 +0100)]
Ensure that RETURN_SELF_NOT_MUST_USE is not emitted if the method already has a must_use attribute

2 years agoAuto merge of #89841 - cormacrelf:let-else-typed, r=nagisa
bors [Fri, 17 Dec 2021 22:12:34 +0000 (22:12 +0000)]
Auto merge of #89841 - cormacrelf:let-else-typed, r=nagisa

Implement let-else type annotations natively

Tracking issue: #87335

Fixes #89688, fixes #89807, edit: fixes  #89960 as well

As explained in https://github.com/rust-lang/rust/issues/89688#issuecomment-940405082, the previous desugaring moved the let-else scrutinee into a dummy variable, which meant if you wanted to refer to it again in the else block, it had moved.

This introduces a new hir type, ~~`hir::LetExpr`~~ `hir::Let`, which takes over all the fields of `hir::ExprKind::Let(...)` and adds an optional type annotation. The `hir::Let` is then treated like a `hir::Local` when type checking a function body, specifically:

* `GatherLocalsVisitor` overrides a new `Visitor::visit_let_expr` and does pretty much exactly what it does for `visit_local`, assigning a local type to the `hir::Let` ~~(they could be deduplicated but they are right next to each other, so at least we know they're the same)~~
* It reuses the code in `check_decl_local` to typecheck the `hir::Let`, simply returning 'bool' for the expression type after doing that.

* ~~`FnCtxt::check_expr_let` passes this local type in to `demand_scrutinee_type`, and then imitates check_decl_local's pattern checking~~
* ~~`demand_scrutinee_type` (the blindest change for me, please give this extra scrutiny) uses this local type instead of of creating a new one~~
    * ~~Just realised the `check_expr_with_needs` was passing NoExpectation further down, need to pass the type there too. And apparently this Expectation API already exists.~~

Some other misc notes:

* ~~Is the clippy code supposed to be autoformatted? I tried not to give huge diffs but maybe some rustfmt changes simply haven't hit it yet.~~
* in `rustc_ast_lowering/src/block.rs`, I noticed some existing `self.alias_attrs()` calls in `LoweringContext::lower_stmts` seem to be copying attributes from the lowered locals/etc to the statements. Is that right? I'm new at this, I don't know.

2 years agoFix SAFETY comment tag casing in undocumented_unsafe_blocks
r00ster91 [Fri, 17 Dec 2021 19:48:38 +0000 (20:48 +0100)]
Fix SAFETY comment tag casing in undocumented_unsafe_blocks

2 years agoAuto merge of #8137 - flip1995:changelog, r=Manishearth
bors [Fri, 17 Dec 2021 17:01:05 +0000 (17:01 +0000)]
Auto merge of #8137 - flip1995:changelog, r=Manishearth

Fix commits and formatting of CHANGELOG.md

r? `@Manishearth`

Follow up to #8136

I think the beta commit update didn't take the backport we've done into account. I fixed the commit ranges. And while I was at it, I also applied my usual formatting to the changelog entries.

changelog: none

2 years agoFix commits and formatting of CHANGELOG.md
flip1995 [Fri, 17 Dec 2021 15:27:29 +0000 (16:27 +0100)]
Fix commits and formatting of CHANGELOG.md

2 years agoupdate: ```Sugg::not()``` replacing the comparison operator. #7320
hotate29 [Fri, 10 Dec 2021 17:32:23 +0000 (02:32 +0900)]
update: ```Sugg::not()``` replacing the comparison operator. #7320

When inverting an expression, the output is now like ```foo != 0``` instead of ```!(foo == 0)```, the comparison operator is now replaced.