Commit graph

13032 commits

Author SHA1 Message Date
bors
fc72e910fb 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
2021-12-28 11:15:53 +00:00
bors
3354876876 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
2021-12-28 05:50:20 +00:00
Andre Bogus
8da9a823cb cache test item names 2021-12-28 06:39:21 +01:00
bors
5d194d1952 Auto merge of #8181 - ApamNapat:typos_fixes, r=giraffate
Fixed some typos in README and CONTRIBUTING

changelog: none
2021-12-28 00:29:24 +00:00
BB
b59ff5861a Fixed some typos in README and CONTRIBUTING 2021-12-28 00:08:25 +01:00
bors
adba132411 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`]
2021-12-27 21:02:15 +00:00
bors
44719b5834 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
2021-12-27 20:43:48 +00:00
bors
c749b2d393 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
2021-12-27 20:43:48 +00:00
Andre Bogus
3ebd2bc2e4 new lint: init-numbered-fields 2021-12-26 16:19:22 +01:00
bors
bb7b6beca3 Auto merge of #8133 - surechen:fix_8128, r=xFrednet
Fix 8128

Fixes #8128

changelog: Fix  error suggestion of `skip(..).next()` for immutable variable.
2021-12-26 14:05:35 +00:00
surechen
4ffd66074a Fixes #8128
changelog: Fix error suggestion of skip(..).next() for immutable variable.
2021-12-26 21:37:57 +08:00
bors
547efad945 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`]
2021-12-25 13:38:08 +00:00
Andre Bogus
23ffa3ca04 fix an ICE on unwrapping a None 2021-12-25 13:11:54 +01:00
bors
eb24acf60d 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
2021-12-25 11:58:25 +00:00
Elliot Bobrow
1b67aa74bd fix shadow_reuse false negative for if let bindings 2021-12-24 13:20:40 -08:00
bors
8529b2a056 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`
2021-12-24 12:34:09 +00:00
Piotr Mikulski
2a47dbc7a6 Simplify code 2021-12-23 22:12:08 -08:00
Piotr Mikulski
01b7411482 Refactor 2021-12-23 22:00:20 -08:00
Piotr Mikulski
4b3a87f886 clippy 2021-12-23 21:47:31 -08:00
Piotr Mikulski
8b19845ffb refactor 2021-12-23 21:46:21 -08:00
Piotr Mikulski
ab77c924e9 cargo dev fmt 2021-12-23 21:44:13 -08:00
Piotr Mikulski
db236e668c Fix tests 2021-12-23 21:43:44 -08:00
Piotr Mikulski
88871bffdf Fix tests 2021-12-23 21:42:56 -08:00
Piotr Mikulski
26cc55133e rewrite the PR 2021-12-23 21:41:25 -08:00
Piotr Mikulski
79cf41297a Imrpove unwrap_or_else_default 2021-12-23 19:16:05 -08:00
bors
9ae40436d2 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`
2021-12-23 10:06:17 +00:00
Oussama
13cc452286 Add allow unused 2021-12-23 10:51:17 +01:00
Oussama
dce3151872 Add allow precedence lint to prevent rustfix from failing 2021-12-23 09:22:29 +01:00
Oussama
88e40bc73d Add support for suggestion when using an expression 2021-12-21 22:00:14 +01:00
Oussama
5ad37b1a4b add suggestion for neg_multiply lint 2021-12-21 20:53:01 +01:00
bors
fea103d302 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
2021-12-20 22:53:47 +00:00
flip1995
eb47398773
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.
2021-12-20 19:56:06 +01:00
bors
790513056f 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`]
2021-12-20 00:15:18 +00:00
bors
1962ce08ef 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
2021-12-19 14:54:12 +00:00
Guillaume Gomez
07a00efe61 Don't emit RETURN_SELF_NOT_MUST_USE lint if Self already is marked as #[must_use] 2021-12-19 15:48:57 +01:00
bors
25e90ec1ab 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 :) )
2021-12-18 15:06:09 +00:00
Guillaume Gomez
4da5520205 Ensure that RETURN_SELF_NOT_MUST_USE is not emitted if the method already has a must_use attribute 2021-12-18 15:26:16 +01:00
r00ster91
eba441391d Fix SAFETY comment tag casing in undocumented_unsafe_blocks 2021-12-17 20:48:38 +01:00
bors
a3bf9d1dcf 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
2021-12-17 17:01:05 +00:00
flip1995
adcd3ded13
Fix commits and formatting of CHANGELOG.md 2021-12-17 16:27:29 +01:00
bors
0da30f1850 Auto merge of #8136 - Manishearth:changelog, r=giraffate
Update changelog

Apologies for the delay!

changelog: none
2021-12-17 14:24:35 +00:00
Manish Goregaokar
69bd99f8e0
Update CHANGELOG.md
Co-authored-by: Takayuki Nakata <f.seasons017@gmail.com>
2021-12-17 19:51:01 +05:30
Manish Goregaokar
8160ccd3ac
Update CHANGELOG.md
Co-authored-by: Takayuki Nakata <f.seasons017@gmail.com>
2021-12-17 19:50:53 +05:30
Manish Goregaokar
80e986485c Update changelog 2021-12-17 19:39:07 +05:30
bors
50d4e56604 Auto merge of #8135 - flip1995:backport_remerge, r=flip1995
Beta branch remerge

r? `@ghost`

changelog: none
2021-12-17 13:52:54 +00:00
flip1995
4e3fac9118
Merge remote-tracking branch 'upstream/beta' into backport_remerge 2021-12-17 14:51:51 +01:00
bors
23d11428de Auto merge of #8134 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2021-12-17 12:24:03 +00:00
flip1995
646a9cf559
Bump nightly version -> 2021-12-17 2021-12-17 13:22:34 +01:00
flip1995
fad9407c5a
Merge remote-tracking branch 'upstream/master' into rustup 2021-12-17 13:22:25 +01:00
bors
40fd785199 Auto merge of #7978 - smoelius:master, r=llogiq
Add `unnecessary_to_owned` lint

This PR adds a lint to check for unnecessary calls to `ToOwned::to_owned` and other similar functions (e.g., `Cow::into_owned`, `ToString::to_string`, etc.).

The lint checks for expressions of the form `&receiver.to_owned_like()` used in a position requiring type `&T` where one of the following is true:
* `receiver`'s type is `T` exactly
* `receiver`'s type implements `Deref<Target = T>`
* `receiver`'s type implements `AsRef<T>`

The lint additionally checks for expressions of the form `receiver.to_owned_like()` used as arguments of type `impl AsRef<T>`.

It would be nice if the lint could also check for expressions used as arguments to functions like the following:
```
fn foo<T: AsRef<str>>(x: T) { ... }
```
However, I couldn't figure out how to determine whether a function input type was instantiated from a parameter with a trait bound.

If someone could offer me some guidance, I would be happy to add such functionality.

Closes #7933

changelog: Add [`unnecessary_to_owned`] lint
2021-12-15 10:46:43 +00:00