Commit graph

13089 commits

Author SHA1 Message Date
dswij
df2e4d17c6 update enum_variants test 2021-12-25 21:55:20 +08:00
dswij
c76e2d1e59 Add str_util helpers to split camelcase strings 2021-12-25 21:55:15 +08:00
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
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
hotate29
a172439f29
Change to enclose both sides of Range in parentheses. 2021-12-25 02:24:31 +09:00
hotate29
07b6927180
Change ``floating_point_arthmetic::detect_hypot()`` to enclose the expression in parentheses. 2021-12-25 02:02:37 +09:00
hotate29
45a3b51c6d
Use helper functions in ``Sugg`` tests. 2021-12-25 00:29:30 +09:00
hotate29
0b6d1fdea2
refactor ``Sugg::BinOp`` 2021-12-25 00:29:29 +09:00
hotate29
b3b65a1bf6
Add test 2021-12-25 00:29:24 +09: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
Mara Bos
01217f6f4c Bless clippy test. 2021-12-22 17:25:44 +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
879eccead7 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`
2021-12-19 09:31:37 +00: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
bors
af1eea3f0a 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.
2021-12-17 22:12:34 +00: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
hotate29
13ad14b22d
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.
2021-12-18 00:07:36 +09: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
flip1995
ece0946d7f Merge commit '23d11428de3e973b34a5090a78d62887f821c90e' into clippyup 2021-12-17 13:40:22 +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