Commit Graph

14751 Commits

Author SHA1 Message Date
bors
44be2d4b0e Auto merge of #9169 - Alexendoo:message-convention-regex, r=flip1995
Use `LazyLock` for `lint_message_convention` regexes

They were being recompiled for `Message::new` call, for me this shaves 7s off the time it takes to run the test. Also removes a redundant exception from the list and joins the various `message...` exceptions into one

changelog: none
2022-07-13 14:27:44 +00:00
Alex Macleod
018684dd9a Use LazyLock for lint_message_convention regexes 2022-07-13 14:10:39 +00:00
Dylan DPC
73a6240394 Rollup merge of #99011 - oli-obk:UnsoundCell, r=eddyb
`UnsafeCell` blocks niches inside its nested type from being available outside

fixes #87341

This implements the plan by `@eddyb` in https://github.com/rust-lang/rust/issues/87341#issuecomment-886083646

Somewhat related PR (not strictly necessary, but that cleanup made this PR simpler): #94527
2022-07-13 19:32:34 +05:30
Dylan DPC
9e1af3fd82 Rollup merge of #98574 - dingxiangfei2009:let-else-thir, r=oli-obk
Lower let-else in MIR

This MR will switch to lower let-else statements in MIR building instead.

To lower let-else in MIR, we build a mini-switch two branches. One branch leads to the matching case, and the other leads to the `else` block. This arrangement will allow temporary lifetime analysis running as-is so that the temporaries are properly extended according to the same rule applied to regular `let` statements.

cc https://github.com/rust-lang/rust/issues/87335

Fix #98672
2022-07-13 19:32:33 +05:30
bors
f78292a4ad Auto merge of #9156 - Rqnsom:manual_flatten, r=Alexendoo
fix [`manual_flatten`] help texts order

fixes  #8948

Whenever suggestion for this lint does not fit in one line,
legacy solution has some unexpected/unhandled behavior:
lint will then generate two help messages which seem to be shown in the wrong order.
The second help message in that case will contain the suggestion.

The first help message always refers to a suggestion message,
and **it should adapt** depending on the location of the suggestion:
- inline suggestion within the error/warning message
- suggestion separated into a second help text

This is my first contribution here, so I hope I didn't miss anything for creating this PR.

changelog: fix [`manual_flatten`] help texts order
2022-07-13 12:52:08 +00:00
Camille GILLOT
dcd248465e Clippy fallout. 2022-07-13 14:16:17 +02:00
Victor Nordam Suadicani
565d3fd67d Move to restriction 2022-07-13 12:59:55 +02:00
Guillaume Gomez
9e2f6895a8 Rollup merge of #98848 - flip1995:clippy-book, r=jyn514
Build the Clippy book as part of x.py doc

r? ``@ehuss`` since you said you would be interested in helping moving this forward.

cc ``@jyn514`` as part of the bootstrap team.
2022-07-13 10:38:42 +02:00
Korlo
852c38c543 fix for manual_flatten help texts order
Whenever suggestion for this lint does not fit in one line,
lint will generate two help messages. The second help message
will always contain the suggestion.

The first help message refers to suggestion message,
and it should adapt depending on the location of the suggestion:
- inline suggestion within the error/warning message
- suggestion separated into second help text
2022-07-13 09:33:17 +02:00
Victor-N-Suadicani
c26188e327 Moves format_push_string to pedantic. 2022-07-12 23:11:19 +02:00
Maybe Waffle
1c3f62c750 Fix clippy build 2022-07-12 21:00:14 +04:00
bors
07ab0e8741 Auto merge of #9157 - Rqnsom:pull_request_template, r=flip1995
update pull request template

Improved suggestion for formatting lint names in the PR template to use this format:
[`lint_name`]

changelog: none
2022-07-12 16:07:38 +00:00
bors
9ebacd4874 Auto merge of #8703 - aldhsu:add_repeated_where_clause_or_trait_bound, r=flip1995
Add `repeated_where_clause_or_trait_bound` lint

I thought I would try and scratch my own itch for #8674.

1. Is comparing the `Res` the correct way for ensuring we have the same trait?
2. Is there a way to get the spans for the bounds and clauses for suggestions?
I tried to use `GenericParam::bounds_span_for_suggestions` but it only gave me an empty span at the end of the spans.
I tried `WhereClause::span_for_predicates_or_empty_place` and it included the comma.
3. Is there a simpler way to get the trait names? I have used the spans of the traits because I didn't see a way to get it off the `Res` or `Def`.

changelog: Add ``[`repeated_where_clause_or_trait_bound`]`` lint.
2022-07-12 15:48:55 +00:00
Korlo
7f4e5d8cc4 update pull request template
Improved suggestion for formatting lint names in the template:

    changelog: [`lint_name`]: your change
2022-07-12 17:26:30 +02:00
Allen Hsu
8878d674b1 Lint for repeated traits within trait bounds or where clauses. 2022-07-12 22:03:55 +10:00
ouz-a
9d86ce6533 add new rval, pull deref early 2022-07-12 14:26:41 +03:00
bors
eabad8ea53 Auto merge of #9149 - kyoto7250:issue_9013, r=Jarcho
change applicability type to MaybeIncorrect in `explicit_counter_loop`

close #9013

This PR changes  applicability type to `MaybeIncorrect`,  because the suggestion is not `MachineApplicable`.

changelog: change applicability type to MaybeIncorrect in `explicit_counter_loop`
2022-07-12 06:43:42 +00:00
kyoto7250
134d0dee41 declare span variable before call 2022-07-12 11:28:15 +09:00
bors
3206fb4eb1 Auto merge of #9138 - Jarcho:branches_sharing_code_2, r=giraffate
Fixes for `branches_sharing_code`

fixes #7198
fixes #7452
fixes #7555
fixes #7589

changelog: Don't suggest moving modifications to locals used in any of the condition expressions in `branches_sharing_code`
changelog: Don't suggest moving anything after a local with a significant drop in `branches_sharing_code`
2022-07-12 00:38:54 +00:00
Ding Xiang Fei
af3ba22313 move else block into the Local struct 2022-07-11 23:20:37 +02:00
Ding Xiang Fei
9225ebd786 lower let-else in MIR instead 2022-07-11 23:20:36 +02:00
bors
8a801c7b83 Auto merge of #9154 - CeleritasCelery:master, r=flip1995
Remove broken link in CONTRIBUTING.md

changelog: none
2022-07-11 21:14:23 +00:00
Troy Hinckley
57a8f6dd9d Fix broken link in CONTRIBUTING.md 2022-07-11 15:49:11 -05:00
bors
7c1598b399 Auto merge of #9152 - mati865:patch-2, r=xFrednet
Fix Clippy version in `derive_partial_eq_without_eq` lint

It was first added to Rust in https://github.com/rust-lang/rust/pull/97248 which missed 1.62 just by few days.

changelog: none
2022-07-11 15:07:33 +00:00
Mateusz Mikuła
c8d32e53a2
Fix Clippy version in derive_partial_eq_without_eq lint
It was first added to Rust in https://github.com/rust-lang/rust/pull/97248 which missed 1.62 just by few days.
2022-07-11 17:01:46 +02:00
bors
8a62b6f523 Auto merge of #9144 - alex-semenyuk:or_fun_call_span_fix, r=giraffate
Fix span for or_fun_call

Closes #9033
changelog: [`or_fun_call`]: span points to the `unwrap_or` only instead of through the entire method chain expression
2022-07-11 09:03:20 +00:00
alex-semenyuk
c3c4cda50b Address review 2022-07-11 10:34:01 +03:00
bors
7ea4592a8b Auto merge of #9056 - Jarcho:let_unit_indirect, r=llogiq
Allow `let_unit_value` in more cases

fixes #8998

changelog: Lint `let_unit_value` less aggressively when the type is specified
2022-07-10 18:58:09 +00:00
kyoto7250
25fe4193ec change applicability type to MaybeIncorrect 2022-07-10 23:09:15 +09:00
alex-semenyuk
783992e693 Fix dogfood issue for or_fun_call 2022-07-10 13:34:58 +03:00
alex-semenyuk
97cd46fa33 Fix span for or_fun_call 2022-07-10 13:11:19 +03:00
bors
4d1b976b1d Auto merge of #9141 - alex-semenyuk:grammar_fix, r=dswij
Fix small mistakes

changelog: none
2022-07-09 15:58:58 +00:00
bors
3468294b58 Auto merge of #9140 - Jarcho:sig_drop, r=flip1995
Ignore `into_iter` in `significant_drop_in_scrutinee`

fixes #9135
changelog: Ignore the `IntoIterator::into_iter` call from for loops in `significant_drop_in_scrutinee`
2022-07-09 12:34:03 +00:00
Jason Newcomb
95b78799c3 Ignore the IntoIterator::into_iter call from for loops in significant_drop_in_scrutinee 2022-07-09 08:15:13 -04:00
alex-semenyuk
9015884325 Fix small mistakes 2022-07-09 13:00:24 +03:00
Jason Newcomb
55563f9ce1 Fixes for branches_sharing_code
* Don't suggest moving modifications to locals used in any of the condition expressions
* Don't suggest moving anything after a local with a significant drop
2022-07-08 20:07:55 -04:00
Jane Lusby
d053a3dae0 add opt in attribute for stable-in-unstable items 2022-07-08 21:18:15 +00:00
bors
526f02ef05 Auto merge of #9137 - alex-semenyuk:small_cosmetic_fix, r=xFrednet
Fix example header

changelog: fix example header
2022-07-08 19:14:51 +00:00
alexey semenyuk
4e60134ec3
Fix example header 2022-07-08 22:07:44 +03:00
Jason Newcomb
d251bd96e7 Add for_each_expr 2022-07-08 12:54:20 -04:00
bors
49f73e14a9 Auto merge of #8356 - J-ZhengLi:master-issue8288, r=dswij
Simplify if let statements

fixes: #8288

---

changelog: Allowing [`qustion_mark`] lint to check `if let` expressions that immediatly return unwrapped value
2022-07-08 16:12:00 +00:00
bors
d0b8f7508c Simplify if let statements
fixes: #8288

---

changelog: Allowing [`qustion_mark`] lint to check `if let` expressions that immediatly return unwrapped value
2022-07-08 16:12:00 +00:00
Matthias Krüger
1e033a9818 Rollup merge of #99026 - anall:buffix/clippy-9131, r=xFrednet
Add test for and fix rust-lang/rust-clippy#9131

This lint seems to have been broken by #98446 -- but of course, there was no clippy test for this case at the time.

`expr.span.ctxt().outer_expn_data()` now has `MacroKind::Derive` instead of `MacroKind::Attr` for something like:

```
#[derive(Clone, Debug)]
pub struct UnderscoreInStruct {
    _foo: u32,
}
```

---

changelog: none

closes: https://github.com/rust-lang/rust-clippy/issues/9131
2022-07-08 08:00:41 +02:00
bors
bee9da14cd Auto merge of #98482 - cjgillot:short-struct-span-closure, r=estebank
Shorten def_span of closures to just their header

Continuation of https://github.com/rust-lang/rust/pull/93967.
2022-07-08 03:05:15 +00:00
Jason Newcomb
9fa12def3c Improve while_let_on_iterator suggestion inside an FnOnce closure 2022-07-07 22:10:24 -04:00
Jason Newcomb
2872b7e0a4 Allow let () = .. as type inference for let_unit_value 2022-07-07 20:06:37 -04:00
Jason Newcomb
196174ddad Changes to let_unit_value
* View through locals in `let_unit_value` when determining if inference is required
* Don't remove typed let bindings for more functions
2022-07-07 20:06:36 -04:00
bors
54feac18d1 Auto merge of #8958 - Alexendoo:simple_filter_map, r=giraffate
Lint simple expressions in `manual_filter_map`, `manual_find_map`

changelog: Lint simple expressions in [`manual_filter_map`], [`manual_find_map`]

The current comparison rules out `.find(|a| a.is_some()).map(|b| b.unwrap())` because `a` being a reference can effect more complicated expressions, this adds a simple check for that case and adds the necessary derefs

There's some overlap with `option_filter_map` so `lint_filter_some_map_unwrap` now returns a `bool` to indicate it linted
2022-07-07 23:39:12 +00:00
bors
2058b92777 Auto merge of #9120 - anall:bugfix/ice9041, r=Jarcho
Fix ICE in sugg::DerefDelegate with (named) closures

rustc comiler internals helpfully tell us how to fix the issue:
```
  to get the signature of a closure, use `substs.as_closure().sig()` not `fn_sig()`
```
Fixes ICE in #9041

This also makes this code in `sugg::DerefDelegate` match a different use `typ.fn_sig(…)` I found: in `mixed_read_write_in_expression` -- being strict on the value of `typ.kind()` will hopefully reduce any future possibility of ICE crashes in this area.

---

changelog: none
2022-07-07 23:04:29 +00:00
Andrea Nall
782b484b79 Fix ICE in sugg::DerefDelegate with (named) closures
rustc comiler internals helpfully tell us how to fix the issue:

  to get the signature of a closure, use `substs.as_closure().sig()` not `fn_sig()`

Fixes ICE in #9041
2022-07-07 16:10:36 -05:00