Commit graph

6810 commits

Author SHA1 Message Date
dswij d58fdfbf3c Fix False Positive on enum_variants when prefixes are not camel-case 2021-12-25 21:54:35 +08:00
dswij f327f0e2b6 Refactor enum_variants 2021-12-25 21:54:35 +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
Elliot Bobrow 1b67aa74bd fix shadow_reuse false negative for if let bindings 2021-12-24 13:20:40 -08: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 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
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 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
flip1995 fad9407c5a
Merge remote-tracking branch 'upstream/master' into rustup 2021-12-17 13:22:25 +01:00
Samuel E. Moelius III b8913894a1 Expand is_clone_like comment 2021-12-15 05:25:47 -05:00
Matthias Krüger 55df990a9b Rollup merge of #91881 - Patrick-Poitras:stabilize-iter-zip, r=scottmcm
Stabilize `iter::zip`

Hello all!

As the tracking issue (#83574) for `iter::zip` completed the final commenting period without any concerns being raised, I hereby submit this stabilization PR on the issue.

As the pull request that introduced the feature (#82917) states, the `iter::zip` function is a shorter way to zip two iterators. As it's generally a quality-of-life/ergonomic improvement, it has been integrated into the codebase without any trouble, and has been
used in many places across the rust compiler and standard library since March without any issues.

For more details, I would refer to `@cuviper's` original PR, or the [function's documentation](https://doc.rust-lang.org/std/iter/fn.zip.html).
2021-12-15 01:28:08 +01:00
Samuel E. Moelius III 3beb6b1908 Address review comments 2021-12-14 18:36:19 -05:00
PFPoitras 288afb366a Remove iter::zip feature gate from clippy 2021-12-14 18:50:46 -04:00
Samuel E. Moelius III cb609a9904 Add comma 2021-12-13 12:27:47 -05:00
Esteban Kuber 1c3747e7dd Fix rebase and clippy tests 2021-12-13 17:09:16 +00:00
Esteban Kuber d8af82e4bb Fix clippy uses of QPath::LangItem 2021-12-13 17:09:16 +00:00
Samuel E. Moelius III 3807905e08 Handle to_vec on for loop expression #8069 2021-12-13 07:04:57 -05:00
Samuel E. Moelius III 290f74be4e Address review comments
* Share a list of methods with `implicit_clone`
* Ensure no overlap with `redundant_clone`
2021-12-13 06:31:17 -05:00
Samuel E. Moelius III 468c86e4a3 Add unnecessary_to_owned lint 2021-12-13 06:31:17 -05:00
Deadbeef adf8c381f2 Revert "Auto merge of #91491 - spastorino:revert-91354, r=oli-obk"
This reverts commit ff2439b7b9, reversing
changes made to 2a9e0831d6.
2021-12-12 12:34:46 +08:00
bors aa3648af50 Auto merge of #8100 - c410-f3r:blah-blah-blah, r=giraffate
Fix `blocks_in_if_conditions` false positive

Fix #8099

changelog: Fix [`blocks_in_if_conditions`] false positive with an empty closure
2021-12-09 23:50:02 +00:00
Caio 392b2eff4b Fix blocks_in_if_conditions false positive 2021-12-08 20:02:28 -03:00
bors 53059792e9 Auto merge of #8071 - GuillaumeGomez:method-must-use, r=xFrednet
Add new lint to warn when #[must_use] attribute should be used on a method

This lint is somewhat similar to https://rust-lang.github.io/rust-clippy/master/index.html#must_use_candidate but also different: it emits a warning by default and only targets methods (so not functions nor associated functions).

Someone suggested it to me after this tweet: https://twitter.com/m_ou_se/status/1466439813230477312

I think it would reduce the number of cases of API misuses quite a lot.

What do you think?

---

changelog: Added new [`return_self_not_must_use`] lint
2021-12-08 19:09:25 +00:00
bors 3c8f90bd5a Auto merge of #8030 - WaffleLapkin:ignore_trait_assoc_types_type_complexity, r=llogiq
Ignore associated types in traits when considering type complexity

changelog: Ignore associated types in traits when checking ``[`type_complexity`]`` lint.

fixes #1013
2021-12-08 11:54:03 +00:00
Maybe Waffle c176568abd Ignore associated items in trait *implementations* when considering type complexity 2021-12-08 14:38:59 +03:00
Guillaume Gomez 8dfb3ec8a4 Add new lint to warn when #[must_use] attribute should be used on a method 2021-12-08 11:16:14 +01:00
bors 86cea73449 Auto merge of #8086 - dswij:7991, r=giraffate
Fix bad suggestion on `option_if_let_else` when there is complex subpat

closes #7991

Prefer not warning any complex subpat in `option_if_let_else` rather than suggesting obscure suggestions.

changelog: [`option_if_let_else`] does not warn when complex subpat is present
2021-12-07 23:45:58 +00:00
Yechan Bae 5d63a28638 Move non_send_fields_in_send_ty back to nursery 2021-12-07 10:45:59 -05:00
Yechan Bae c0fd250c62 Fix grammar issues 2021-12-07 10:08:22 -05:00
Yechan Bae ee0d71e103 Clarify the purpose of the lint 2021-12-07 10:06:34 -05:00
dswij b5fa5b37cc option_if_let_else Do not warn when complex subpat is present 2021-12-07 15:47:28 +08:00
bors 1c7df44e2d Auto merge of #8085 - jqnatividad:8084-needless_lifetimes_typo, r=giraffate
`needless_lifetimes` Known problems typo

fixes #8084

[needless_lifetimes]

changelog: none
2021-12-07 00:45:59 +00:00
Joel Natividad d91b91ae57 needless_lifetimes Known problems typo
fixes #8084
2021-12-06 19:11:19 -05:00
bors f615ea474b Auto merge of #8080 - dswij:8019, r=giraffate
Fix FP on `question_mark` if returned object is not local

Closes #8019

changelog: [`question_mark`] Fix FP when returned object is not local
2021-12-07 00:07:46 +00:00
Cameron Steffen 16bbd243f9 Simplify needless_bool 2021-12-06 12:33:02 -06:00
Cameron Steffen f690ef6f5c Refactors with peel_blocks 2021-12-06 12:33:02 -06:00
Cameron Steffen 284b63a687 Rename remove_blocks to peel_blocks 2021-12-06 12:33:02 -06:00
bors 9e0852705e Auto merge of #8066 - rust-lang:needless_bool_parenthesize, r=camsteffen
Parenthesize blocks in `needless_bool` suggestion

Because the `if .. {}` statement already puts the condition in expression scope, contained blocks would be parsed as complete
statements, so any `&` binary expression whose left operand ended in a block would lead to a non-compiling suggestion.

We identify such expressions and add parentheses. Note that we don't make a difference between normal and unsafe blocks because the parsing problems are the same for both.

This fixes #8052.

---

changelog: none
2021-12-06 15:15:26 +00:00