]> git.lizzy.rs Git - rust.git/log
rust.git
23 months agoAuto merge of #9215 - alex-semenyuk:enable_test_entrypoint_recursion, r=Jarcho
bors [Thu, 21 Jul 2022 15:45:50 +0000 (15:45 +0000)]
Auto merge of #9215 - alex-semenyuk:enable_test_entrypoint_recursion, r=Jarcho

Enable test for entrypoint_recursion for windows

Verified that this test actually works on windows
changelog: none

23 months agoAuto merge of #9216 - smoelius:master, r=flip1995
bors [Thu, 21 Jul 2022 07:58:27 +0000 (07:58 +0000)]
Auto merge of #9216 - smoelius:master, r=flip1995

Add `ui_cargo_toml_metadata` test

This PR adds a test to check the metadata of packages in the `ui_cargo` directory.

A recent change to Cargo causes it to warn when it finds multiple packages with the same name in a git dependency (the issue is described [here](https://github.com/rust-lang/cargo/issues/10752)).

Many (if  not all) Dylint libraries depend upon `clippy_utils`. As a result of the change, one now sees the following when building a Dylint library:
```
warning: skipping duplicate package `fail` found at `/home/smoelius/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/0cb0f76/tests/ui-cargo/module_style/pass_mod`
warning: skipping duplicate package `fail` found at `/home/smoelius/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/0cb0f76/tests/ui-cargo/module_style/fail_no_mod`
warning: skipping duplicate package `cargo_common_metadata` found at `/home/smoelius/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/0cb0f76/tests/ui-cargo/cargo_common_metadata/fail_publish_true`
warning: skipping duplicate package `fail-cargo` found at `/home/smoelius/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/0cb0f76/tests/ui-cargo/cargo_rust_version/pass_cargo`
warning: skipping duplicate package `fail-clippy` found at `/home/smoelius/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/0cb0f76/tests/ui-cargo/cargo_rust_version/fail_clippy`
warning: skipping duplicate package `fail-both-same` found at `/home/smoelius/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/0cb0f76/tests/ui-cargo/cargo_rust_version/fail_both_same`
warning: skipping duplicate package `fail-file-attr` found at `/home/smoelius/.cargo/git/checkouts/rust-clippy-4b72815e96774b3d/0cb0f76/tests/ui-cargo/cargo_rust_version/fail_file_attr`
```
There appear to be two contributing factors:
- Some packages in `ui_cargo` could have a `publish = false` added to them.
- Some packages in `ui_cargo` seem to be inconsistently named.

The new test checks that each package in the `ui_cargo` directory has a name matching one of its parent directories, and `publish = false` in its metadata (with a few exceptions).

Note that the packages in `cargo_common_metadata` require special care because `publish` is the subject of some of the `cargo_common_metadata` tests.

Also note that this PR adds `walkdir` as a dev dependency to the `clippy` package. However, it was already a dependency of `clippy_dev` and `lintcheck`. So hopefully this is acceptable.

Our continued thanks for making `clippy_utils` available, BTW. :)

r? `@flip1995`

changelog: none

23 months agoAuto merge of #9217 - Serial-ATA:extra-newlines, r=giraffate
bors [Thu, 21 Jul 2022 06:04:43 +0000 (06:04 +0000)]
Auto merge of #9217 - Serial-ATA:extra-newlines, r=giraffate

Remove extra newlines in [`significant_drop_in_scrutinee`] docs

changelog: none

23 months agoRemove extra newlines in [`significant_drop_in_scrutinee`] docs
Serial [Thu, 21 Jul 2022 01:35:11 +0000 (21:35 -0400)]
Remove extra newlines in [`significant_drop_in_scrutinee`] docs

23 months agoEnable test for entrypoint_recursion for windows
alex-semenyuk [Wed, 20 Jul 2022 18:41:12 +0000 (21:41 +0300)]
Enable test for entrypoint_recursion for windows

23 months agoAuto merge of #9207 - Jarcho:todo_arm, r=giraffate
bors [Wed, 20 Jul 2022 01:38:00 +0000 (01:38 +0000)]
Auto merge of #9207 - Jarcho:todo_arm, r=giraffate

Check for `todo!` on every expression in `SpanlessEq`

fixes #9204
changelog: [`match_same_arms`](https://rust-lang.github.io/rust-clippy/master/index.html#match_same_arms): Don't lint on arms with `todo!`

23 months agoAuto merge of #9210 - evantypanski:issue9160, r=Manishearth
bors [Tue, 19 Jul 2022 21:16:34 +0000 (21:16 +0000)]
Auto merge of #9210 - evantypanski:issue9160, r=Manishearth

Fix suggestion causing error for [`needless_borrow`] function in field

Fixes #9160

changelog: [`needless_borrow`]: Fix suggestion removing parens from calling a field

23 months agoUse parens around [`needless_borrow`] field calls
Evan Typanski [Tue, 19 Jul 2022 19:17:24 +0000 (15:17 -0400)]
Use parens around [`needless_borrow`] field calls

23 months agoCheck for `todo!` on every expression in `SpanlessEq`
Jason Newcomb [Tue, 19 Jul 2022 13:53:00 +0000 (09:53 -0400)]
Check for `todo!` on every expression in `SpanlessEq`

23 months agoAuto merge of #9202 - PaulTheNeko:patch-1, r=Manishearth
bors [Mon, 18 Jul 2022 16:10:06 +0000 (16:10 +0000)]
Auto merge of #9202 - PaulTheNeko:patch-1, r=Manishearth

Fix typo in alloc_instead_of_core

The description previously claimed it ensures items are imported from alloc, to ensure a crate won't require alloc, which can't be true.

I'm not sure know how to better phrase the changelog entry below.

changelog: [`alloc_instead_of_core`]: fixed typo in description

23 months agoFix typo in alloc_instead_of_core
Paul [Mon, 18 Jul 2022 14:24:30 +0000 (16:24 +0200)]
Fix typo in alloc_instead_of_core

The description previously claimed it ensures items are imported from alloc, to ensure a crate won't require alloc, which can't be true.

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 `ui_cargo_toml_metadata` test
Samuel E. Moelius III [Sun, 17 Jul 2022 22:10:01 +0000 (18:10 -0400)]
Add `ui_cargo_toml_metadata` test

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

23 months 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

23 months 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

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

changelog: none

23 months 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`

23 months 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

23 months 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

23 months 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

23 months 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

23 months 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

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

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

23 months 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.

23 months 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

23 months 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