]> git.lizzy.rs Git - rust.git/log
rust.git
23 months agoAuto merge of #9148 - arieluy:then_some_unwrap_or, r=Jarcho
bors [Mon, 18 Jul 2022 12:45:11 +0000 (12:45 +0000)]
Auto merge of #9148 - arieluy:then_some_unwrap_or, r=Jarcho

Add new lint `obfuscated_if_else`

part of #9100, additional commits could make it work with `then` and `unwrap_or_else` as well

changelog: Add new lint `obfuscated_if_else`

23 months agoAuto merge of #9199 - Xiretza:unused-self-exported-api, r=Jarcho
bors [Mon, 18 Jul 2022 12:29:22 +0000 (12:29 +0000)]
Auto merge of #9199 - Xiretza:unused-self-exported-api, r=Jarcho

unused_self: respect avoid-breaking-exported-api

```
changelog: [`unused_self`]: Now respects the `avoid-breaking-exported-api` config option
```

Fixes #9195.

I mostly copied the implementation from `unnecessary_wraps`, since I don't have much understanding of rustc internals.

23 months agoAuto merge of #9146 - arieluy:type_params, r=dswij
bors [Mon, 18 Jul 2022 10:13:39 +0000 (10:13 +0000)]
Auto merge of #9146 - arieluy:type_params, r=dswij

Fix `mismatching_type_param_order` false positive

changelog: Don't lint `mismatching_type_param_order` on complicated generic params

fixes #8962

23 months agounused_self: respect avoid-breaking-exported-api
Xiretza [Mon, 18 Jul 2022 08:36:48 +0000 (10:36 +0200)]
unused_self: respect avoid-breaking-exported-api

23 months agoAuto merge of #9176 - JoelMon:patch-1, r=flip1995
bors [Mon, 18 Jul 2022 07:46:30 +0000 (07:46 +0000)]
Auto merge of #9176 - JoelMon:patch-1, r=flip1995

Rephrased text to remove passive voice for a more active one.

changelog: none

23 months agoRephrased text to remove passive voice for a more active one.
Joel Montes de Oca [Thu, 14 Jul 2022 14:20:08 +0000 (10:20 -0400)]
Rephrased text to remove passive voice for a more active one.

Co-authored-by: Alex <69764315+Serial-ATA@users.noreply.github.com>
23 months agoAdd new lint `obfuscated_if_else`
Ariel Uy [Sun, 10 Jul 2022 21:37:38 +0000 (14:37 -0700)]
Add new lint `obfuscated_if_else`

New lint suggests using `if .. else ..` instead of
`.then_some(..).unwrap_or(..)`.

23 months agoAuto merge of #9196 - alex-semenyuk:invalid_regex, r=Jarcho
bors [Sun, 17 Jul 2022 23:08:04 +0000 (23:08 +0000)]
Auto merge of #9196 - alex-semenyuk:invalid_regex, r=Jarcho

Fix example for `clippy::invalid_regex`

Close #9194
changelog: previous example doesn't trigger lint

23 months agoFix example for `clippy::invalid_regex`
alexey semenyuk [Sun, 17 Jul 2022 21:35:34 +0000 (00:35 +0300)]
Fix example for `clippy::invalid_regex`

23 months agoFix `mismatching_type_param_order` false positive
Ariel Uy [Sun, 10 Jul 2022 16:39:36 +0000 (09:39 -0700)]
Fix `mismatching_type_param_order` false positive

Previously was giving false positive when an impl had a nontrivial
generic argument such as a tuple. Don't lint on these cases.

23 months agoAuto merge of #9022 - alex-semenyuk:needless_option_take_more_docs, r=Jarcho
bors [Sun, 17 Jul 2022 13:33:40 +0000 (13:33 +0000)]
Auto merge of #9022 - alex-semenyuk:needless_option_take_more_docs, r=Jarcho

`NEEDLESS_OPTION_TAKE` doc improvements

changelog: More info on `NEEDLESS_OPTION_TAKE`

23 months agoNEEDLESS_OPTION_TAKE doc improvements
alexey semenyuk [Sun, 19 Jun 2022 14:15:14 +0000 (14:15 +0000)]
NEEDLESS_OPTION_TAKE doc improvements

NEEDLESS_OPTION_TAKE doc improvements

NEEDLESS_OPTION_TAKE doc improvements

NEEDLESS_OPTION_TAKE doc improvements

NEEDLESS_OPTION_TAKE doc improvements

NEEDLESS_OPTION_TAKE doc improvements

NEEDLESS_OPTION_TAKE doc improvements

NEEDLESS_OPTION_TAKE doc improvements

23 months agoAuto merge of #9171 - Serial-ATA:highlight-js, r=xFrednet
bors [Sat, 16 Jul 2022 20:02:44 +0000 (20:02 +0000)]
Auto merge of #9171 - Serial-ATA:highlight-js, r=xFrednet

Update highlight.js

changelog: none

With [highlight.js v11.6.0](https://github.com/highlightjs/highlight.js/releases/tag/11.6.0), the lint list can finally update from `9.5.0`. No more EOL warning in console! :smile:

I also made it switch to the `github-dark` theme when using `coal`, instead of just always using the normal github light theme.

r? `@xFrednet`

23 months agoAuto merge of #9172 - Guilherme-Vasconcelos:master, r=flip1995
bors [Fri, 15 Jul 2022 16:04:30 +0000 (16:04 +0000)]
Auto merge of #9172 - Guilherme-Vasconcelos:master, r=flip1995

Rename rustcSource in contributing documentation

According to [rust-analyzer docs](https://rust-analyzer.github.io/manual.html#toolchain:~:text=rust%2Danalyzer.rustc.source), rustcSource has been renamed to rustc.source.

changelog: none

23 months agoRename rustcSource in contributing docs
Guilherme-Vasconcelos [Wed, 13 Jul 2022 00:06:10 +0000 (21:06 -0300)]
Rename rustcSource in contributing docs

23 months agoAuto merge of #9178 - alex-semenyuk:match_like_matches_macro_fix, r=Jarcho
bors [Fri, 15 Jul 2022 13:57:46 +0000 (13:57 +0000)]
Auto merge of #9178 - alex-semenyuk:match_like_matches_macro_fix, r=Jarcho

match_like_matches_macro does not trigger when one arm contains conta…

Close #9163
changelog: none

23 months agoAuto merge of #9174 - flip1995:rustup, r=Jarcho
bors [Fri, 15 Jul 2022 13:38:01 +0000 (13:38 +0000)]
Auto merge of #9174 - flip1995:rustup, r=Jarcho

Rustup

r? `@ghost`

changelog: none

23 months agoAuto merge of #9103 - i509VCB:std-instead-of-core, r=Manishearth
bors [Fri, 15 Jul 2022 11:46:24 +0000 (11:46 +0000)]
Auto merge of #9103 - i509VCB:std-instead-of-core, r=Manishearth

Add `std_instead_of_core`, `std_instead_of_alloc`, `alloc_instead_of_core`

Closes #7724

Introduces 3 new lints:
- `std_instead_of_core` - lints items resolved through `std` which are available in `core`
- `std_instead_of_alloc` - lints items resolved through `std` which are available in `alloc`
- `alloc_instead_of_core` - lints items resolved through `alloc` which are available in `core`

Though the original issue only mentions `std_instead_of_alloc`, the other two lints could be useful as well.

questions:
- what do I call the file the lints live in? I was thinking `std_reexports`?

changelog: new lint's: [`std_instead_of_core`], [`std_instead_of_alloc`], [`alloc_instead_of_core`]

23 months agoBump nightly version -> 2022-07-15
Philipp Krones [Fri, 15 Jul 2022 07:49:38 +0000 (09:49 +0200)]
Bump nightly version -> 2022-07-15

23 months agoMerge remote-tracking branch 'upstream/master' into rustup
Philipp Krones [Fri, 15 Jul 2022 07:49:15 +0000 (09:49 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

23 months agomatch_like_matches_macro does not trigger when one arm contains contains a block...
alex-semenyuk [Fri, 15 Jul 2022 06:15:31 +0000 (09:15 +0300)]
match_like_matches_macro does not trigger when one arm contains contains a block with only a bool literal

23 months agostd_instead_of_core, std_instead_of_alloc, alloc_instead_of_core
i509VCB [Sat, 2 Jul 2022 04:59:03 +0000 (23:59 -0500)]
std_instead_of_core, std_instead_of_alloc, alloc_instead_of_core

23 months agoAuto merge of #95956 - yaahc:stable-in-unstable, r=cjgillot
bors [Thu, 14 Jul 2022 13:42:09 +0000 (13:42 +0000)]
Auto merge of #95956 - yaahc:stable-in-unstable, r=cjgillot

Support unstable moves via stable in unstable items

part of https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/moving.20items.20to.20core.20unstably and a blocker of https://github.com/rust-lang/rust/pull/90328.

The libs-api team needs the ability to move an already stable item to a new location unstably, in this case for Error in core. Otherwise these changes are insta-stable making them much harder to merge.

This PR attempts to solve the problem by checking the stability of path segments as well as the last item in the path itself, which is currently the only thing checked.

23 months agoAuto merge of #9170 - Rqnsom:box_collection, r=Jarcho
bors [Thu, 14 Jul 2022 13:02:06 +0000 (13:02 +0000)]
Auto merge of #9170 - Rqnsom:box_collection, r=Jarcho

[`box_collection`]: raise warn for all std collections

So far, only [`Vec`, `String`, `HashMap`] were considered.

Extend collection checklist for this lint with:
- `HashSet`
- `VecDeque`
- `LinkedList`
- `BTreeMap`
- `BTreeSet`
- `BinaryHeap`

changelog: [`box_collection`]: raise warn for all std collections

23 months agoAuto merge of #9161 - Victor-N-Suadicani:move_format_push_string_to_pedantic, r=flip1995
bors [Thu, 14 Jul 2022 12:11:34 +0000 (12:11 +0000)]
Auto merge of #9161 - Victor-N-Suadicani:move_format_push_string_to_pedantic, r=flip1995

Move format_push_string to restriction

Fixes #9077 (kinda) by moving the lint to the restriction group. As I noted in that issue, I think the suggested change is too much and as the OP of the issue points out, the ramifications of the change are not necessarily easily understood. As such I don't think the lint should be enabled by default.

changelog: [`format_push_string`]: moved to restriction (see #9077).

23 months agoAdd Known problems section
Victor Nordam Suadicani [Thu, 14 Jul 2022 11:26:56 +0000 (13:26 +0200)]
Add Known problems section

23 months agoAuto merge of #99231 - Dylan-DPC:rollup-0tl8c0o, r=Dylan-DPC
bors [Thu, 14 Jul 2022 11:00:30 +0000 (11:00 +0000)]
Auto merge of #99231 - Dylan-DPC:rollup-0tl8c0o, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #97720 (Always create elided lifetime parameters for functions)
 - #98315 (Stabilize `core::ffi:c_*` and rexport in `std::ffi`)
 - #98705 (Implement `for<>` lifetime binder for closures)
 - #99126 (remove allow(rustc::potential_query_instability) in rustc_span)
 - #99139 (Give a better error when `x dist` fails for an optional tool)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

23 months agoRollup merge of #98705 - WaffleLapkin:closure_binder, r=cjgillot
Dylan DPC [Thu, 14 Jul 2022 08:44:21 +0000 (14:14 +0530)]
Rollup merge of #98705 - WaffleLapkin:closure_binder, r=cjgillot

Implement `for<>` lifetime binder for closures

This PR implements RFC 3216 ([TI](https://github.com/rust-lang/rust/issues/97362)) and allows code like the following:

```rust
let _f = for<'a, 'b> |a: &'a A, b: &'b B| -> &'b C { b.c(a) };
//       ^^^^^^^^^^^--- new!
```

cc ``@Aaron1011`` ``@cjgillot``

23 months agoRollup merge of #97720 - cjgillot:all-fresh, r=petrochenkov
Dylan DPC [Thu, 14 Jul 2022 08:44:19 +0000 (14:14 +0530)]
Rollup merge of #97720 - cjgillot:all-fresh, r=petrochenkov

Always create elided lifetime parameters for functions

Anonymous and elided lifetimes in functions are sometimes (async fns) --and sometimes not (regular fns)-- desugared to implicit generic parameters.

This difference of treatment makes it some downstream analyses more complicated to handle.  This step is a pre-requisite to perform lifetime elision resolution on AST.

There is currently an inconsistency in the treatment of argument-position impl-trait for functions and async fns:
```rust
trait Foo<'a> {}
fn foo(t: impl Foo<'_>) {} //~ ERROR missing lifetime specifier
async fn async_foo(t: impl Foo<'_>) {} //~ OK
fn bar(t: impl Iterator<Item = &'_ u8>) {} //~ ERROR missing lifetime specifier
async fn async_bar(t: impl Iterator<Item = &'_ u8>) {} //~ OK
```

The current implementation reports "missing lifetime specifier" on `foo`, but **accepts it** in `async_foo`.
This PR **proposes to accept** the anonymous lifetime in both cases as an extra generic lifetime parameter.
This change would be insta-stable, so let's ping t-lang.
Anonymous lifetimes in GAT bindings keep being forbidden:
```rust
fn foo(t: impl Foo<Assoc<'_> = Bar<'_>>) {}
                         ^^        ^^
                       forbidden   ok
```
I started a discussion here: https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Anonymous.20lifetimes.20in.20universal.20impl-trait/near/284968606

r? ``@petrochenkov``

23 months agoAuto merge of #9173 - giraffate:fix_the_minimal_version_for_clap, r=xFrednet
bors [Thu, 14 Jul 2022 08:27:58 +0000 (08:27 +0000)]
Auto merge of #9173 - giraffate:fix_the_minimal_version_for_clap, r=xFrednet

Fix the minimal version for `clap`

changelog: none

`clap >= 3.2.0` for lintcheck  has been needed from https://github.com/rust-lang/rust-clippy/pull/8997.

23 months agoAuto merge of #98975 - jyn514:unstable_opts, r=wesleywiser
bors [Thu, 14 Jul 2022 08:14:31 +0000 (08:14 +0000)]
Auto merge of #98975 - jyn514:unstable_opts, r=wesleywiser

Rename `debugging_opts` to `unstable_opts`

This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`).
Rename it to be more clear.

cc https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Codegen.20options.20.2F.20debugging.20options

r? `@Amanieu` cc `@nikic` `@joshtriplett`

23 months agoFix the minimal version for `clap`
Takayuki Nakata [Thu, 14 Jul 2022 00:46:46 +0000 (09:46 +0900)]
Fix the minimal version for `clap`

23 months agoRename `debugging_opts` to `unstable_opts`
Joshua Nelson [Wed, 6 Jul 2022 12:44:47 +0000 (07:44 -0500)]
Rename `debugging_opts` to `unstable_opts`

This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`).
Rename it to be more clear.

23 months agoadd array tests, cleanup, tidy, and bless
Ralf Jung [Thu, 30 Jun 2022 14:17:49 +0000 (10:17 -0400)]
add array tests, cleanup, tidy, and bless

23 months agoUpdate highlight.js
Serial [Tue, 17 May 2022 16:12:31 +0000 (12:12 -0400)]
Update highlight.js

23 months agoAuto merge of #99210 - Dylan-DPC:rollup-879cp1t, r=Dylan-DPC
bors [Wed, 13 Jul 2022 17:13:27 +0000 (17:13 +0000)]
Auto merge of #99210 - Dylan-DPC:rollup-879cp1t, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #98574 (Lower let-else in MIR)
 - #99011 (`UnsafeCell` blocks niches inside its nested type from being available outside)
 - #99030 (diagnostics: error messages when struct literals fail to parse)
 - #99155 (Keep unstable target features for asm feature checking)
 - #99199 (Refactor: remove an unnecessary `span_to_snippet`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

23 months agoAuto merge of #9134 - Jarcho:while_let_iter_closure, r=dswij
bors [Wed, 13 Jul 2022 16:20:14 +0000 (16:20 +0000)]
Auto merge of #9134 - Jarcho:while_let_iter_closure, r=dswij

Improve `while_let_on_iterator` suggestion inside an `FnOnce` closure

changelog: Improve `while_let_on_iterator` suggestion inside an `FnOnce` closure

2 years agobox_collection: raise warn for all std collections
Korlo [Wed, 13 Jul 2022 15:02:09 +0000 (17:02 +0200)]
box_collection: raise warn for all std collections

So far, only [Vec, String, Hashmap] were considered.

Extend collection checklist for this lint with:
- HashSet
- VecDeque
- LinkedList
- BTreeMap
- BTreeSet
- BinaryHeap

2 years agoAuto merge of #9159 - alex-semenyuk:fix_typos, r=dswij
bors [Wed, 13 Jul 2022 14:48:32 +0000 (14:48 +0000)]
Auto merge of #9159 - alex-semenyuk:fix_typos, r=dswij

Fix typos

changelog: none

2 years agoFix typos
bors [Wed, 13 Jul 2022 14:48:32 +0000 (14:48 +0000)]
Fix typos

changelog: none

2 years agoAuto merge of #98145 - ouz-a:some_branch, r=oli-obk
bors [Wed, 13 Jul 2022 14:32:33 +0000 (14:32 +0000)]
Auto merge of #98145 - ouz-a:some_branch, r=oli-obk

Pull Derefer before ElaborateDrops

_Follow up work to #97025 #96549 #96116 #95887 #95649_

This moves `Derefer` before `ElaborateDrops` and creates a new `Rvalue` called `VirtualRef` that allows us to bypass many constraints for `DerefTemp`.

r? `@oli-obk`

2 years agoAuto merge of #9169 - Alexendoo:message-convention-regex, r=flip1995
bors [Wed, 13 Jul 2022 14:27:44 +0000 (14:27 +0000)]
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

2 years agoUse LazyLock for lint_message_convention regexes
Alex Macleod [Wed, 13 Jul 2022 14:10:39 +0000 (14:10 +0000)]
Use LazyLock for lint_message_convention regexes

2 years agoRollup merge of #99011 - oli-obk:UnsoundCell, r=eddyb
Dylan DPC [Wed, 13 Jul 2022 14:02:34 +0000 (19:32 +0530)]
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

2 years agoRollup merge of #98574 - dingxiangfei2009:let-else-thir, r=oli-obk
Dylan DPC [Wed, 13 Jul 2022 14:02:33 +0000 (19:32 +0530)]
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

2 years agoAuto merge of #9156 - Rqnsom:manual_flatten, r=Alexendoo
bors [Wed, 13 Jul 2022 12:52:08 +0000 (12:52 +0000)]
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

2 years agoClippy fallout.
Camille GILLOT [Sat, 4 Jun 2022 12:17:00 +0000 (14:17 +0200)]
Clippy fallout.

2 years agoMove to restriction
Victor Nordam Suadicani [Wed, 13 Jul 2022 10:59:55 +0000 (12:59 +0200)]
Move to restriction

2 years agoRollup merge of #98848 - flip1995:clippy-book, r=jyn514
Guillaume Gomez [Wed, 13 Jul 2022 08:38:42 +0000 (10:38 +0200)]
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.

2 years agofix for manual_flatten help texts order
Korlo [Mon, 11 Jul 2022 14:53:04 +0000 (16:53 +0200)]
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

2 years agoMoves format_push_string to pedantic.
Victor-N-Suadicani [Tue, 12 Jul 2022 21:11:19 +0000 (23:11 +0200)]
Moves format_push_string to pedantic.

2 years agoFix clippy build
Maybe Waffle [Thu, 30 Jun 2022 10:18:51 +0000 (14:18 +0400)]
Fix clippy build

2 years agoAuto merge of #9157 - Rqnsom:pull_request_template, r=flip1995
bors [Tue, 12 Jul 2022 16:07:38 +0000 (16:07 +0000)]
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

2 years agoAuto merge of #8703 - aldhsu:add_repeated_where_clause_or_trait_bound, r=flip1995
bors [Tue, 12 Jul 2022 15:48:55 +0000 (15:48 +0000)]
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.

2 years agoupdate pull request template
Korlo [Tue, 12 Jul 2022 09:17:30 +0000 (11:17 +0200)]
update pull request template

Improved suggestion for formatting lint names in the template:

    changelog: [`lint_name`]: your change

2 years agoLint for repeated traits within trait bounds or where clauses.
Allen Hsu [Tue, 12 Apr 2022 14:21:08 +0000 (00:21 +1000)]
Lint for repeated traits within trait bounds or where clauses.

2 years agoadd new rval, pull deref early
ouz-a [Mon, 13 Jun 2022 13:37:41 +0000 (16:37 +0300)]
add new rval, pull deref early

2 years agoAuto merge of #9149 - kyoto7250:issue_9013, r=Jarcho
bors [Tue, 12 Jul 2022 06:43:42 +0000 (06:43 +0000)]
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`

2 years agodeclare span variable before call
kyoto7250 [Tue, 12 Jul 2022 02:00:22 +0000 (11:00 +0900)]
declare span variable before call

2 years agoAuto merge of #9138 - Jarcho:branches_sharing_code_2, r=giraffate
bors [Tue, 12 Jul 2022 00:38:54 +0000 (00:38 +0000)]
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`

2 years agomove else block into the `Local` struct
Ding Xiang Fei [Tue, 5 Jul 2022 21:31:18 +0000 (23:31 +0200)]
move else block into the `Local` struct

2 years agolower let-else in MIR instead
Ding Xiang Fei [Thu, 2 Jun 2022 14:39:47 +0000 (22:39 +0800)]
lower let-else in MIR instead

2 years agoAuto merge of #9154 - CeleritasCelery:master, r=flip1995
bors [Mon, 11 Jul 2022 21:14:23 +0000 (21:14 +0000)]
Auto merge of #9154 - CeleritasCelery:master, r=flip1995

Remove broken link in CONTRIBUTING.md

changelog: none

2 years agoFix broken link in CONTRIBUTING.md
Troy Hinckley [Mon, 11 Jul 2022 20:49:11 +0000 (15:49 -0500)]
Fix broken link in CONTRIBUTING.md

2 years agoAuto merge of #9152 - mati865:patch-2, r=xFrednet
bors [Mon, 11 Jul 2022 15:07:33 +0000 (15:07 +0000)]
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

2 years agoFix Clippy version in `derive_partial_eq_without_eq` lint
Mateusz Mikuła [Mon, 11 Jul 2022 15:01:46 +0000 (17:01 +0200)]
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.

2 years agoAuto merge of #9144 - alex-semenyuk:or_fun_call_span_fix, r=giraffate
bors [Mon, 11 Jul 2022 09:03:20 +0000 (09:03 +0000)]
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

2 years agoAddress review
alex-semenyuk [Mon, 11 Jul 2022 07:34:01 +0000 (10:34 +0300)]
Address review

2 years agoAuto merge of #9056 - Jarcho:let_unit_indirect, r=llogiq
bors [Sun, 10 Jul 2022 18:58:09 +0000 (18:58 +0000)]
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

2 years agochange applicability type to MaybeIncorrect
kyoto7250 [Sun, 10 Jul 2022 14:01:13 +0000 (23:01 +0900)]
change applicability type to MaybeIncorrect

2 years agoFix dogfood issue for or_fun_call
alex-semenyuk [Sun, 10 Jul 2022 10:34:58 +0000 (13:34 +0300)]
Fix dogfood issue for or_fun_call

2 years agoFix span for or_fun_call
alex-semenyuk [Sun, 10 Jul 2022 10:11:19 +0000 (13:11 +0300)]
Fix span for or_fun_call

2 years agoAuto merge of #9141 - alex-semenyuk:grammar_fix, r=dswij
bors [Sat, 9 Jul 2022 15:58:58 +0000 (15:58 +0000)]
Auto merge of #9141 - alex-semenyuk:grammar_fix, r=dswij

Fix small mistakes

changelog: none

2 years agoAuto merge of #9140 - Jarcho:sig_drop, r=flip1995
bors [Sat, 9 Jul 2022 12:34:03 +0000 (12:34 +0000)]
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`

2 years agoIgnore the `IntoIterator::into_iter` call from for loops in `significant_drop_in_scru...
Jason Newcomb [Sat, 9 Jul 2022 12:15:13 +0000 (08:15 -0400)]
Ignore the `IntoIterator::into_iter` call from for loops in `significant_drop_in_scrutinee`

2 years agoFix small mistakes
alex-semenyuk [Sat, 9 Jul 2022 10:00:24 +0000 (13:00 +0300)]
Fix small mistakes

2 years agoFixes for `branches_sharing_code`
Jason Newcomb [Fri, 8 Jul 2022 19:29:23 +0000 (15:29 -0400)]
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

2 years agoadd opt in attribute for stable-in-unstable items
Jane Lusby [Mon, 9 May 2022 22:18:53 +0000 (15:18 -0700)]
add opt in attribute for stable-in-unstable items

2 years agoAuto merge of #9137 - alex-semenyuk:small_cosmetic_fix, r=xFrednet
bors [Fri, 8 Jul 2022 19:14:51 +0000 (19:14 +0000)]
Auto merge of #9137 - alex-semenyuk:small_cosmetic_fix, r=xFrednet

Fix example header

changelog: fix example header

2 years agoFix example header
alexey semenyuk [Fri, 8 Jul 2022 19:07:44 +0000 (22:07 +0300)]
Fix example header

2 years agoAdd `for_each_expr`
Jason Newcomb [Fri, 8 Jul 2022 16:54:20 +0000 (12:54 -0400)]
Add `for_each_expr`

2 years agoAuto merge of #8356 - J-ZhengLi:master-issue8288, r=dswij
bors [Fri, 8 Jul 2022 16:12:00 +0000 (16:12 +0000)]
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

2 years agoSimplify if let statements
bors [Fri, 8 Jul 2022 16:12:00 +0000 (16:12 +0000)]
Simplify if let statements

fixes: #8288

---

changelog: Allowing [`qustion_mark`] lint to check `if let` expressions that immediatly return unwrapped value

2 years agoRollup merge of #99026 - anall:buffix/clippy-9131, r=xFrednet
Matthias Krüger [Fri, 8 Jul 2022 06:00:41 +0000 (08:00 +0200)]
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

2 years agoAuto merge of #98482 - cjgillot:short-struct-span-closure, r=estebank
bors [Fri, 8 Jul 2022 03:05:15 +0000 (03:05 +0000)]
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.

2 years agoImprove `while_let_on_iterator` suggestion inside an `FnOnce` closure
Jason Newcomb [Thu, 7 Jul 2022 14:45:20 +0000 (10:45 -0400)]
Improve `while_let_on_iterator` suggestion inside an `FnOnce` closure

2 years agoAllow `let () = ..` as type inference for `let_unit_value`
Jason Newcomb [Mon, 27 Jun 2022 16:48:38 +0000 (12:48 -0400)]
Allow `let () = ..` as type inference for `let_unit_value`

2 years agoChanges to `let_unit_value`
Jason Newcomb [Sat, 18 Jun 2022 02:21:42 +0000 (22:21 -0400)]
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

2 years agoAuto merge of #8958 - Alexendoo:simple_filter_map, r=giraffate
bors [Thu, 7 Jul 2022 23:39:12 +0000 (23:39 +0000)]
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

2 years agoAuto merge of #9120 - anall:bugfix/ice9041, r=Jarcho
bors [Thu, 7 Jul 2022 23:04:29 +0000 (23:04 +0000)]
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

2 years agoFix ICE in sugg::DerefDelegate with (named) closures
Andrea Nall [Mon, 4 Jul 2022 18:25:31 +0000 (13:25 -0500)]
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

2 years agoAdd test for and fix rust-lang/rust-clippy#9131
Andrea Nall [Thu, 7 Jul 2022 19:30:37 +0000 (19:30 +0000)]
Add test for and fix rust-lang/rust-clippy#9131

This lint seems to have been broken by #98446

2 years agoAuto merge of #9132 - hellow554:maybe_trait_bound_on_type_repetition, r=Manishearth
bors [Thu, 7 Jul 2022 15:29:43 +0000 (15:29 +0000)]
Auto merge of #9132 - hellow554:maybe_trait_bound_on_type_repetition, r=Manishearth

Maybe trait bound on type repetition

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: fix maybe trait on [`type_repetition_in_bounds`] lint

I simplified the two for loops, which did exactly the same. Only downside is, that I need a `copied`, but that's to convert from `&&` to `&`, to that should be a noop?

One more thing: I only handle [`TraitBoundModifier::Maybe`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/enum.TraitBoundModifier.html#variant.Maybe). Can anyone give me an example (and testcase) for [`TraitBoundModifier::MaybeConst`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/enum.TraitBoundModifier.html#variant.MaybeConst)?

closes #8770

2 years agoRollup merge of #98930 - tmiasko:pub-basic-blocks, r=oli-obk
Dylan DPC [Thu, 7 Jul 2022 12:36:53 +0000 (18:06 +0530)]
Rollup merge of #98930 - tmiasko:pub-basic-blocks, r=oli-obk

Make MIR basic blocks field public

This makes it possible to mutably borrow different fields of the MIR
body without resorting to methods like `basic_blocks_local_decls_mut_and_var_debug_info`.

To preserve validity of control flow graph caches in the presence of
modifications, a new struct `BasicBlocks` wraps together basic blocks
and control flow graph caches.

The `BasicBlocks` dereferences to `IndexVec<BasicBlock, BasicBlockData>`.
On the other hand a mutable access requires explicit `as_mut()` call.

2 years agoRollup merge of #98507 - xFrednet:rfc-2383-manual-expectation-magic, r=wesleywiser
Dylan DPC [Thu, 7 Jul 2022 12:36:50 +0000 (18:06 +0530)]
Rollup merge of #98507 - xFrednet:rfc-2383-manual-expectation-magic, r=wesleywiser

Finishing touches for `#[expect]` (RFC 2383)

This PR adds documentation and some functionality to rustc's lint passes, to manually fulfill expectations. This is needed for some lints in Clippy. Hopefully, it should be one of the last things before we can move forward with stabilizing this feature.

As part of this PR, I've also updated `clippy::duplicate_mod` to showcase how this new functionality can be used and to ensure that it works correctly.

---

changelog: [`duplicate_mod`]: Fixed lint attribute interaction

r? `@wesleywiser`

cc: https://github.com/rust-lang/rust/issues/97660, https://github.com/rust-lang/rust/issues/85549

And I guess that's it. Here have a magical unicorn :unicorn:

2 years agoLint simple expressions in manual_filter_map, manual_find_map
Alex Macleod [Mon, 6 Jun 2022 15:09:37 +0000 (15:09 +0000)]
Lint simple expressions in manual_filter_map, manual_find_map

2 years ago`UnsafeCell` now has no niches, ever.
Oli Scherer [Thu, 7 Jul 2022 10:46:22 +0000 (10:46 +0000)]
`UnsafeCell` now has no niches, ever.

2 years agofix incorrect suggestion for maybe trait bounds
Marcel Hellwig [Thu, 7 Jul 2022 10:24:17 +0000 (12:24 +0200)]
fix incorrect suggestion for maybe trait bounds

2 years agotrait_bounds: rework two loops into one
Marcel Hellwig [Thu, 7 Jul 2022 09:59:55 +0000 (11:59 +0200)]
trait_bounds: rework two loops into one

the two loops did practically the same, only the type were different (&&
vs &), so I used `copied` to convert `&&` and chained them together.
Instead of parsing the trait info manually, I use the already provided
method `get_trait_info_from_bound`.
Also, instead of using manual string writing, I used `join` by
`itertools`.

2 years agoShorten span for closures.
Camille GILLOT [Mon, 27 Jun 2022 05:45:35 +0000 (07:45 +0200)]
Shorten span for closures.