]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoRemove powi, "square can be computed more efficiently"
Bruno A. Muciño [Tue, 18 May 2021 02:59:08 +0000 (21:59 -0500)]
Remove powi, "square can be computed more efficiently"

powi(2) produces exactly the same native code as x * x

3 years agoAuto merge of #7165 - camsteffen:question-mark, r=Manishearth
bors [Sat, 8 May 2021 00:04:14 +0000 (00:04 +0000)]
Auto merge of #7165 - camsteffen:question-mark, r=Manishearth

Fix needless_quesiton_mark false positive

changelog: Fix [`needless_question_mark`] false positive where the inner value is implicity dereferenced by the question mark.

Fixes #7107

3 years agoAuto merge of #7183 - th1000s:write_nl_hint, r=flip1995
bors [Fri, 7 May 2021 12:13:35 +0000 (12:13 +0000)]
Auto merge of #7183 - th1000s:write_nl_hint, r=flip1995

Handle write!(buf, "\n") case better

Make `write!(buf, "\n")` suggest `writeln!(buf)` by removing
the trailing comma from `writeln!(buf, )`.

changelog: [`write_with_newline`] suggestion on only "\n" improved

3 years agoAuto merge of #7182 - mgacek8:wrong_self_convention_to__variant, r=flip1995
bors [Fri, 7 May 2021 08:32:06 +0000 (08:32 +0000)]
Auto merge of #7182 - mgacek8:wrong_self_convention_to__variant, r=flip1995

For `to_*` variant don't lint in trait impl taking `self` when non-`Copy` type

Lint name: `wrong_self_convention`.
It relaxes rules for `to_*` variant, so it doesn't lint in trait definitions and implementations anymore.
Although, non-`Copy` type implementing trait's `to_*` method taking
`self` feels not good (consumes ownership, so should be rather named `into_`), it would be better if this case was a pedantic lint (allow-by-default) instead.
More information in the discussion with `@flip1995` [here](https://github.com/rust-lang/rust-clippy/pull/7002#discussion_r627363450)

changelog: `wrong_self_convention`: For `to_*` variant don't lint in trait impl taking `self` when non-`Copy` type
r? `@flip1995`

3 years agoAuto merge of #7185 - kpreid:patch-1, r=giraffate
bors [Fri, 7 May 2021 02:05:54 +0000 (02:05 +0000)]
Auto merge of #7185 - kpreid:patch-1, r=giraffate

Fix duplicated "Rust 1.52" version section header

The most recent changelog update 037ddf282bbf011babd4b7f9a851f6028fc6fd70 accompanying the 1.52 release added a second "Rust 1.52" section header, with the result that the Rust release announcement https://blog.rust-lang.org/2021/05/06/Rust-1.52.0.html is linking to the "current beta" changelog section for Clippy rather than the stable changelog. I don't know the release process but based on previous changes to this file, I assume the correct thing to do is to mark the topmost section as being for Rust 1.53, not 1.52.

changelog: none

3 years agoFix duplicated "Rust 1.52" version section header
Kevin Reid [Fri, 7 May 2021 00:18:45 +0000 (17:18 -0700)]
Fix duplicated "Rust 1.52" version section header

The most recent changelog update 037ddf282bbf011babd4b7f9a851f6028fc6fd70 accompanying the 1.52 release added a second "Rust 1.52" section header, with the result that the Rust release announcement https://blog.rust-lang.org/2021/05/06/Rust-1.52.0.html is linking to the "current beta" changelog section for Clippy rather than the stable changelog. I don't know the release process but based on previous changes to this file, I assume the correct thing to do is to mark the topmost section as being for Rust 1.53, not 1.52.

3 years agoHandle write!(buf, "\n") case better
Thomas Otto [Thu, 6 May 2021 21:51:01 +0000 (23:51 +0200)]
Handle write!(buf, "\n") case better

Make `write!(buf, "\n")` suggest `writeln!(buf)` by removing
the trailing comma from `writeln!(buf, )`.

changelog: [`write_with_newline`] suggestion on only "\n" improved

3 years agowrong_self_convention: For `to_*` variant don't lint in trait impl taking `self`...
Mateusz Gacek [Thu, 6 May 2021 17:49:31 +0000 (10:49 -0700)]
wrong_self_convention: For `to_*` variant don't lint in trait impl taking `self` when non-`Copy` type

It relaxes rules for `to_*` variant, so it doesn't lint in trait definitions
and implementations anymore.
Although, non-`Copy` type implementing trait's `to_*` method taking
`self` feels not good (consumes ownership, so should be rather named `into_`), it would be better if this case was a pedantic lint (allow-by-default) instead.

3 years agoAuto merge of #7180 - flip1995:changelog, r=camsteffen
bors [Thu, 6 May 2021 16:03:45 +0000 (16:03 +0000)]
Auto merge of #7180 - flip1995:changelog, r=camsteffen

Update CHANGELOG.md

This changelog is **big**. :tada:

[Rendered](https://github.com/flip1995/rust-clippy/blob/changelog/CHANGELOG.md)

changelog: none

3 years agoUpdate CHANGELOG.md
flip1995 [Thu, 6 May 2021 13:22:17 +0000 (15:22 +0200)]
Update CHANGELOG.md

3 years agoAuto merge of #7178 - flip1995:rustup, r=flip1995
bors [Thu, 6 May 2021 09:45:37 +0000 (09:45 +0000)]
Auto merge of #7178 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

3 years agoBump Clippy version -> 0.1.54
flip1995 [Thu, 6 May 2021 09:32:34 +0000 (11:32 +0200)]
Bump Clippy version -> 0.1.54

3 years agoBump nightly version -> 2021-05-06
flip1995 [Thu, 6 May 2021 09:32:27 +0000 (11:32 +0200)]
Bump nightly version -> 2021-05-06

3 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 6 May 2021 09:22:33 +0000 (11:22 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

3 years agoAuto merge of #7177 - giraffate:add_a_missing_lint_to_msrv_config_doc, r=flip1995
bors [Thu, 6 May 2021 08:43:36 +0000 (08:43 +0000)]
Auto merge of #7177 - giraffate:add_a_missing_lint_to_msrv_config_doc, r=flip1995

Add a missing lint to MSRV config doc

A follow-up of https://github.com/rust-lang/rust-clippy/pull/6859.

changelog: Add a missing lint to MSRV config doc

3 years agoAuto merge of #7166 - TaKO8Ki:refactor_misc_early_module, r=llogiq
bors [Thu, 6 May 2021 07:46:52 +0000 (07:46 +0000)]
Auto merge of #7166 - TaKO8Ki:refactor_misc_early_module, r=llogiq

Refactor: arrange lints in misc_early module

This PR arranges misc_early lints so that they can be accessed more easily.
Basically, I refactored them following the instruction described in #6680.

cc: `@Y-Nak,` `@flip1995,` `@magurotuna`

changelog: Move lints in misc_early module into their own modules.

3 years agoAdd a missing lint to MSRV config doc
Takayuki Nakata [Thu, 6 May 2021 05:04:50 +0000 (14:04 +0900)]
Add a missing lint to MSRV config doc

3 years agoAuto merge of #7175 - camsteffen:filter-map-none, r=Manishearth
bors [Wed, 5 May 2021 22:57:05 +0000 (22:57 +0000)]
Auto merge of #7175 - camsteffen:filter-map-none, r=Manishearth

Fix unnecessary_filter_map false positive

changelog: Fix an [`unnecessary_filter_map`] false positive

Fixes #6804

3 years agoFix unnecessary_filter_map false positive
Cameron Steffen [Wed, 5 May 2021 21:05:16 +0000 (16:05 -0500)]
Fix unnecessary_filter_map false positive

3 years agoAuto merge of #7174 - camsteffen:eval-order-async, r=flip1995
bors [Wed, 5 May 2021 21:18:05 +0000 (21:18 +0000)]
Auto merge of #7174 - camsteffen:eval-order-async, r=flip1995

Fix eval_order_dependence async false positive

changelog: Fix [`eval_order_dependence`] false positive in async code

Fixes #6925

3 years agoFix eval_order_dependence async false positive
Cameron Steffen [Wed, 5 May 2021 20:02:47 +0000 (15:02 -0500)]
Fix eval_order_dependence async false positive

3 years agoImprove eval_order_dependence output
Cameron Steffen [Wed, 5 May 2021 19:44:32 +0000 (14:44 -0500)]
Improve eval_order_dependence output

3 years agoAuto merge of #7170 - flip1995:revert_drop_order, r=llogiq
bors [Wed, 5 May 2021 17:33:46 +0000 (17:33 +0000)]
Auto merge of #7170 - flip1995:revert_drop_order, r=llogiq

Fix stack overflow issue in `redundant_pattern_matching`

Fixes #7169

~~cc `@Jarcho` Since tomorrow is release day and we need to get this also fixed in beta, I'll just revert the PR instead of looking into the root issue. Your changes are good, so if you have an idea what could cause this stack overflow and know how to fix it, please open a PR that reverts this revert with a fix.~~

r? `@llogiq`

changelog: none (fixes stack overflow, but this was introduced in this release cycle)

3 years agoAuto merge of #6887 - xFrednet:4310-internal-metadata-extraction-lint, r=xFrednet
bors [Wed, 5 May 2021 17:11:14 +0000 (17:11 +0000)]
Auto merge of #6887 - xFrednet:4310-internal-metadata-extraction-lint, r=xFrednet

A metadata collection monster

This PR introduces a metadata collection lint as discussed in #4310. It currently collects:
* The lint ID
* The lint declaration file and location (for #1303)
* The lint group
* The documentation
* The applicability (if resolvable)
* If the suggestion is a multi-part-suggestion

This data has a slightly different structure than the current [lints.json](https://github.com/rust-lang/rust-clippy/blob/gh-pages/master/lints.json) and doesn't include depreciated lints yet. I plan to adapt the website to the new format and include depreciated lints in a follow-up PR :). The current collected json looks like this: [metadata_collection.json](https://gist.github.com/xFrednet/6b9e2c3f725f476ba88db9563f67e119)

The entire implementation is guarded behind the `metadata-collector-lint` feature and the `ENABLE_METADATA_COLLECTION` environment value to prevent default collection. You can test the implementation via:
```sh
$ ENABLE_METADATA_COLLECTION=1 cargo test --test dogfood --all-features
```

changelog: none

---

The size of this PR sadly also grew into a small monster, sorry! I definitely plan to improve on this! And it's totally okay if you take your time with this :)

r? `@phansch`
cc: `@flip1995`

3 years agoApplying PR suggestions (mostly typos)
xFrednet [Wed, 31 Mar 2021 18:03:38 +0000 (20:03 +0200)]
Applying PR suggestions (mostly typos)
Co-authored-by: flip1995 <hello@philkrones.com>
Co-authored-by: phansch <dev@phansch.net>
3 years agoApplying PR suggestions
xFrednet [Fri, 12 Mar 2021 19:59:41 +0000 (20:59 +0100)]
Applying PR suggestions

3 years agoENABLE_METADATA_COLLECTION env-value to disable default metadata collection
xFrednet [Fri, 12 Mar 2021 20:52:01 +0000 (21:52 +0100)]
ENABLE_METADATA_COLLECTION env-value to disable default metadata collection

3 years agoMetadata collection: Rounding up the implementation
xFrednet [Wed, 10 Mar 2021 22:04:12 +0000 (23:04 +0100)]
Metadata collection: Rounding up the implementation

3 years agoMetadata collection: Resolve lint from locals
xFrednet [Sat, 6 Mar 2021 00:11:41 +0000 (01:11 +0100)]
Metadata collection: Resolve lint from locals

3 years agoMetadata collection: Refining the implementation
xFrednet [Mon, 1 Mar 2021 11:25:14 +0000 (12:25 +0100)]
Metadata collection: Refining the implementation

3 years agoMetadata collection: processing emission closures (417/455)
xFrednet [Sun, 28 Feb 2021 15:11:45 +0000 (16:11 +0100)]
Metadata collection: processing emission closures (417/455)

3 years agoMetadata Collection: Collecting direct emission applicabilities (324/455)
xFrednet [Sat, 27 Feb 2021 17:39:02 +0000 (18:39 +0100)]
Metadata Collection: Collecting direct emission applicabilities (324/455)

3 years agoMetadata collection: Collecting Applicability assign values
xFrednet [Sat, 20 Feb 2021 12:50:09 +0000 (13:50 +0100)]
Metadata collection: Collecting Applicability assign values

3 years agoMetadata collection: Some refactoring for readability
xFrednet [Sat, 20 Feb 2021 12:12:30 +0000 (13:12 +0100)]
Metadata collection: Some refactoring for readability

3 years agoMetadata collection: Tracking Applicability mut borrows
xFrednet [Fri, 19 Feb 2021 23:35:28 +0000 (00:35 +0100)]
Metadata collection: Tracking Applicability mut borrows

3 years agoMetadata collection: Collecting Applicability assign values
xFrednet [Thu, 18 Feb 2021 22:40:33 +0000 (23:40 +0100)]
Metadata collection: Collecting Applicability assign values

3 years agoMetadata collection lint: Start Applicability value tracking
xFrednet [Wed, 17 Feb 2021 23:20:19 +0000 (00:20 +0100)]
Metadata collection lint: Start Applicability value tracking

3 years agoMetadata collection lint: Basic applicability collection
xFrednet [Sun, 14 Feb 2021 15:17:07 +0000 (16:17 +0100)]
Metadata collection lint: Basic applicability collection

3 years agoMetadata collection lint: Basic lint collection
xFrednet [Sun, 31 Jan 2021 13:46:09 +0000 (14:46 +0100)]
Metadata collection lint: Basic lint collection

WIP-2021-02-01

WIP-2021-02-01

WIP-2021-02-13

3 years agoAuto merge of #7163 - mgacek8:issue7110_needless_collect_with_type_annotations, r...
bors [Wed, 5 May 2021 15:43:02 +0000 (15:43 +0000)]
Auto merge of #7163 - mgacek8:issue7110_needless_collect_with_type_annotations, r=flip1995

needless_collect: Lint cases with type annotations for indirect usage and recognize `BinaryHeap`

fixes #7110
changelog: needless_collect: Lint cases with type annotations for indirect usage and recognize `BinaryHeap`.

3 years agoAuto merge of #84200 - CDirkx:os, r=m-ou-se
bors [Wed, 5 May 2021 14:15:19 +0000 (14:15 +0000)]
Auto merge of #84200 - CDirkx:os, r=m-ou-se

Move all `sys::ext` modules to `os`

This PR moves all `sys::ext` modules to `os`, centralizing the location of all `os` code and simplifying the dependencies between `os` and `sys`.

Because this also removes all uses `cfg_if!` on publicly exported items, where after #81969 there were still a few left, this should properly work around https://github.com/rust-analyzer/rust-analyzer/issues/6038.

`@rustbot` label: +T-libs-impl

3 years agoAdd regression test for stack overflow in redundant_pattern_matching
flip1995 [Wed, 5 May 2021 13:35:14 +0000 (15:35 +0200)]
Add regression test for stack overflow in redundant_pattern_matching

3 years agoFix stack overflow in `redundant_pattern_matching`
Cameron Steffen [Wed, 5 May 2021 13:57:09 +0000 (08:57 -0500)]
Fix stack overflow in `redundant_pattern_matching`

3 years agoneedless_collect: use `node_type_opt` instead of `node_type`
Mateusz Gacek [Wed, 5 May 2021 11:52:03 +0000 (04:52 -0700)]
needless_collect: use `node_type_opt` instead of `node_type`

It may prevent future ICEs.

3 years agoAuto merge of #7167 - camsteffen:unused-unit-macro, r=flip1995
bors [Wed, 5 May 2021 11:45:34 +0000 (11:45 +0000)]
Auto merge of #7167 - camsteffen:unused-unit-macro, r=flip1995

Fix unused_unit macro false positive

changelog: Fix [`unused_unit`] false positive with macros

Fixes #7055

3 years agoFix unused_unit macro false positive
Cameron Steffen [Tue, 4 May 2021 22:20:15 +0000 (17:20 -0500)]
Fix unused_unit macro false positive

3 years agoreplace lit_snip type with &str
Takayuki [Tue, 4 May 2021 21:53:04 +0000 (06:53 +0900)]
replace lit_snip type with &str

3 years agorefactor unseparated_literal_suffix
Takayuki [Tue, 4 May 2021 21:39:38 +0000 (06:39 +0900)]
refactor unseparated_literal_suffix

3 years agoFix needless_quesiton_mark false positive
Cameron Steffen [Tue, 4 May 2021 21:22:43 +0000 (16:22 -0500)]
Fix needless_quesiton_mark false positive

3 years agomove zero_prefixed_literal to its own module
Takayuki [Tue, 4 May 2021 21:18:58 +0000 (06:18 +0900)]
move zero_prefixed_literal to its own module

3 years agoneedless_collect: Add `BinaryHeap` for indirect usage lint
Mateusz Gacek [Tue, 4 May 2021 19:36:20 +0000 (12:36 -0700)]
needless_collect: Add `BinaryHeap` for indirect usage lint

3 years agoFix copy_iterator uitest
Mateusz Gacek [Tue, 4 May 2021 06:58:41 +0000 (23:58 -0700)]
Fix copy_iterator uitest

3 years agoneedless_collect: Lint cases with type annotations
Mateusz Gacek [Mon, 3 May 2021 20:36:08 +0000 (13:36 -0700)]
needless_collect: Lint cases with type annotations

3 years agomove mixed_case_hex_literals to its own module
Takayuki [Tue, 4 May 2021 17:21:26 +0000 (02:21 +0900)]
move mixed_case_hex_literals to its own module

3 years agomove unseparated_literal_suffix to its own module
Takayuki [Tue, 4 May 2021 17:10:24 +0000 (02:10 +0900)]
move unseparated_literal_suffix to its own module

3 years agomove unneeded_field_pattern to its own module
Takayuki [Tue, 4 May 2021 16:44:38 +0000 (01:44 +0900)]
move unneeded_field_pattern to its own module

3 years agoAuto merge of #7157 - camsteffen:hash-pat, r=flip1995
bors [Tue, 4 May 2021 14:45:43 +0000 (14:45 +0000)]
Auto merge of #7157 - camsteffen:hash-pat, r=flip1995

SpanlessHash add Pat

changelog: none

Closes #7149

3 years agoSpanlessHash Pat
Cameron Steffen [Tue, 4 May 2021 13:43:15 +0000 (08:43 -0500)]
SpanlessHash Pat

3 years agomove unneeded_wildcard_pattern to its own module
Takayuki [Tue, 4 May 2021 10:50:48 +0000 (19:50 +0900)]
move unneeded_wildcard_pattern to its own module

3 years agomove redundant_pattern to its own module
Takayuki [Tue, 4 May 2021 08:28:32 +0000 (17:28 +0900)]
move redundant_pattern to its own module

3 years agomove double_neg to its own module
Takayuki [Tue, 4 May 2021 08:20:22 +0000 (17:20 +0900)]
move double_neg to its own module

3 years agoAuto merge of #83213 - rylev:update-lints-to-errors, r=nikomatsakis
bors [Tue, 4 May 2021 08:09:23 +0000 (08:09 +0000)]
Auto merge of #83213 - rylev:update-lints-to-errors, r=nikomatsakis

Update BARE_TRAIT_OBJECT and ELLIPSIS_INCLUSIVE_RANGE_PATTERNS to errors in Rust 2021

This addresses https://github.com/rust-lang/rust/pull/81244 by updating two lints to errors in the Rust 2021 edition.

r? `@estebank`

3 years agomove builtin_type_shadow to its own module
Takayuki [Tue, 4 May 2021 08:04:10 +0000 (17:04 +0900)]
move builtin_type_shadow to its own module

3 years agomove misc_early to misc_early/mod.rs
Takayuki [Tue, 4 May 2021 07:38:34 +0000 (16:38 +0900)]
move misc_early to misc_early/mod.rs

3 years agoChange `std::sys::unix::ext::fs::PermissionsExt::from_mode` to `std::os::imp::unix...
Christiaan Dirkx [Sun, 25 Apr 2021 11:10:19 +0000 (13:10 +0200)]
Change `std::sys::unix::ext::fs::PermissionsExt::from_mode` to `std::os::imp::unix::fs::PermissionsExt::from_mode` in Clippy

3 years agoAuto merge of #7156 - hellow554:single_char_strip, r=flip1995
bors [Mon, 3 May 2021 14:44:44 +0000 (14:44 +0000)]
Auto merge of #7156 - hellow554:single_char_strip, r=flip1995

[single_char_pattern] add strip_prefix and strip_suffix

Title says it all. Adjusted ui tests.

I added the second commit in case you don't like that I moved that table into `single_char_pattern.rs` directly. I don't see any reason why it shouldn't be in that file. It isn't used anywhere else.

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

changelog: add strip_prefix and strip_suffix to single_char_pattern lint

3 years agomove PATTERN_METHODS table directly into file
Marcel Hellwig [Mon, 3 May 2021 14:21:27 +0000 (16:21 +0200)]
move PATTERN_METHODS table directly into file

also removed rustfmt::skip

3 years agoadd strip_{prefix,suffix} to PATTERN_METHODS
Marcel Hellwig [Mon, 3 May 2021 14:18:41 +0000 (16:18 +0200)]
add strip_{prefix,suffix} to PATTERN_METHODS

this will warn, if a single_char_pattern is used in one of the above
methods

3 years agoAuto merge of #7154 - camsteffen:better-conf, r=flip1995
bors [Mon, 3 May 2021 14:13:51 +0000 (14:13 +0000)]
Auto merge of #7154 - camsteffen:better-conf, r=flip1995

`Conf` macro improvements part 2

changelog: none

Follow-up to #7150

I made the default value required again for `define_Conf!` so that it can be parsed by the magic Python. I guess it's just as well for readability.

r? `@flip1995`

3 years agoUpdate config contributing docs
Cameron Steffen [Sun, 2 May 2021 22:53:01 +0000 (17:53 -0500)]
Update config contributing docs

3 years agoFix config parsing
Cameron Steffen [Sun, 2 May 2021 22:50:22 +0000 (17:50 -0500)]
Fix config parsing

3 years agoFix error punctuation
Cameron Steffen [Sun, 2 May 2021 21:56:46 +0000 (16:56 -0500)]
Fix error punctuation

3 years agoAuto merge of #7150 - camsteffen:better-conf, r=llogiq
bors [Sun, 2 May 2021 14:00:09 +0000 (14:00 +0000)]
Auto merge of #7150 - camsteffen:better-conf, r=llogiq

`Conf` macro improvements

changelog: Allow `default_trait_access` in macros

Mainly this is a change to use serde as in [Manually implementing Deserialize for a struct](https://serde.rs/deserialize-struct.html), which opens the door for a cleaner implementation overall.

* Allow `default_trait_access` in macros (tangential, but used in this PR)
* Deserialize into `TryConf { conf, errors }` instead of using a global `ERRORS` variable.
* Improve the `define_Conf!` macro
* Remove the redundant string literal `(name, "name", ..)`
* Support deprecated configs with `#[conf_deprecated(message)]`. Message shows in error.
* Make the default value optional. Use `Default::default()` if omitted.
* Invalid config value error now shows the key (see test output)
* Cleaner `impl Default for Conf` (no `toml::from_str("")`)

3 years agoAdd ErrorKind::OutOfMemory
Kornel [Fri, 30 Apr 2021 11:15:38 +0000 (12:15 +0100)]
Add ErrorKind::OutOfMemory

3 years agoRefactor config deserialization
Cameron Steffen [Wed, 28 Apr 2021 02:04:06 +0000 (21:04 -0500)]
Refactor config deserialization

3 years agoDisable default_trait_access in macros
Cameron Steffen [Wed, 28 Apr 2021 02:03:48 +0000 (21:03 -0500)]
Disable default_trait_access in macros

3 years agoAuto merge of #7146 - mgacek8:mgacek8-small-fix, r=flip1995
bors [Fri, 30 Apr 2021 15:39:09 +0000 (15:39 +0000)]
Auto merge of #7146 - mgacek8:mgacek8-small-fix, r=flip1995

Small fix in CONTRIBUTING.md

This is a section for `IntelliJ Rust`, not `rust-analyzer`.
changelog: none

3 years agoSmall fix in CONTRIBUTING.md
Mateusz Gacek [Fri, 30 Apr 2021 15:27:42 +0000 (17:27 +0200)]
Small fix in CONTRIBUTING.md

3 years agoAuto merge of #7144 - rust-lang:while_immutable_mut_cond, r=flip1995
bors [Fri, 30 Apr 2021 15:08:27 +0000 (15:08 +0000)]
Auto merge of #7144 - rust-lang:while_immutable_mut_cond, r=flip1995

while_immutable_cond: check condition for mutation

This fixes #6689 by also checking the bindings mutated in the condition, whereas it was previously only checked in the loop body.

---

changelog: Fix FP in [`while_immutable_cond`] where mutation in the loop variable wasn't picked up.

3 years agoAuto merge of #6951 - Jarcho:implicit_return_fp, r=flip1995
bors [Fri, 30 Apr 2021 14:55:56 +0000 (14:55 +0000)]
Auto merge of #6951 - Jarcho:implicit_return_fp, r=flip1995

`implicit_return` improvements

fixes: #6940

changelog: Fix `implicit_return` suggestion for async functions
changelog: Improve `implicit_return` suggestions when returning the result of a macro
changelog: Check for `break` expressions inside a loop which are then implicitly returned
changelog: Allow all diverging functions in `implicit_return`, not just panic functions

3 years agoAuto merge of #84401 - crlf0710:impl_main_by_path, r=petrochenkov
bors [Fri, 30 Apr 2021 06:59:37 +0000 (06:59 +0000)]
Auto merge of #84401 - crlf0710:impl_main_by_path, r=petrochenkov

Implement RFC 1260 with feature_name `imported_main`.

This is the second extraction part of #84062 plus additional adjustments.
This (mostly) implements RFC 1260.

However there's still one test case failure in the extern crate case. Maybe `LocalDefId` doesn't work here? I'm not sure.

cc https://github.com/rust-lang/rust/issues/28937
r? `@petrochenkov`

3 years agoAuto merge of #7118 - TaKO8Ki:fix-false-positive-in-comparison-chain, r=giraffate
bors [Fri, 30 Apr 2021 06:30:38 +0000 (06:30 +0000)]
Auto merge of #7118 - TaKO8Ki:fix-false-positive-in-comparison-chain, r=giraffate

Fix a false-positive inside const fn in `comparison_chain`

closes https://github.com/rust-lang/rust-clippy/issues/7082

changelog: fix a false-positive inside const fn in [`comparison_chain`]

3 years agouse `in_constant`
Takayuki [Fri, 30 Apr 2021 05:40:35 +0000 (14:40 +0900)]
use `in_constant`

3 years agoFix clippy error
Ryan Levick [Thu, 29 Apr 2021 16:37:22 +0000 (18:37 +0200)]
Fix clippy error

3 years agoAuto merge of #7141 - camsteffen:conf-file, r=flip1995
bors [Thu, 29 Apr 2021 14:57:24 +0000 (14:57 +0000)]
Auto merge of #7141 - camsteffen:conf-file, r=flip1995

Remove leftover plugin conf_file code

changelog: none

Removes dead code that used to support the following syntax:

```rust
#![plugin(clippy(conf_file="path/to/clippy's/configuration"))]
```

RLS (and others?) will need to remove the `&[]` from `clippy_lints::read_conf(&[], sess)`.

r? `@flip1995`

3 years agoAuto merge of #84189 - jyn514:clippy-dev, r=Mark-Simulacrum
bors [Thu, 29 Apr 2021 12:03:43 +0000 (12:03 +0000)]
Auto merge of #84189 - jyn514:clippy-dev, r=Mark-Simulacrum

Implement `x.py test src/tools/clippy --bless`

- Add clippy_dev to the rust workspace

  Before, it would give an error that it wasn't either included or
  excluded from the workspace:

  ```
  error: current package believes it's in a workspace when it's not:
  current:   /home/joshua/rustc/src/tools/clippy/clippy_dev/Cargo.toml
  workspace: /home/joshua/rustc/Cargo.toml

  this may be fixable by adding `src/tools/clippy/clippy_dev` to the `workspace.members` array of the manifest located at: /home/joshua/rustc/Cargo.toml
  Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest.
  ```

- Change clippy's copy of compiletest not to special-case
  rust-lang/rust. Using OUT_DIR confused `clippy_dev` and it couldn't find
  the test outputs. This is one of the reasons why `cargo dev bless` used
  to silently do nothing (the others were that `CARGO_TARGET_DIR` and
  `PROFILE` weren't set appropriately).

- Run clippy_dev on test failure

I tested this by removing a couple lines from a stderr file, and they
were correctly replaced.

- Fix clippy_dev warnings

3 years agowhile_immutable_cond: check condition for mutation
Andre Bogus [Thu, 29 Apr 2021 08:10:58 +0000 (10:10 +0200)]
while_immutable_cond: check condition for mutation

3 years agoRollup merge of #84484 - jyn514:check-tools, r=Mark-Simulacrum
Jack Huey [Thu, 29 Apr 2021 02:59:22 +0000 (22:59 -0400)]
Rollup merge of #84484 - jyn514:check-tools, r=Mark-Simulacrum

Don't rebuild rustdoc and clippy after checking bootstrap

This works by unconditionally passing -Z unstable-options to the
compiler. This has no affect in practice since bootstrap doesn't use
`deny(rustc::internal)`.

Fixes https://github.com/rust-lang/rust/issues/82461.

r? ```@Mark-Simulacrum```

3 years agoImplement RFC 1260 with feature_name `imported_main`.
Charles Lew [Sun, 25 Apr 2021 17:09:35 +0000 (01:09 +0800)]
Implement RFC 1260 with feature_name `imported_main`.

3 years agoRemove leftover plugin conf_file code
Cameron Steffen [Wed, 28 Apr 2021 19:29:13 +0000 (14:29 -0500)]
Remove leftover plugin conf_file code

3 years agoAuto merge of #7140 - matthiaskrgr:ice_std, r=llogiq
bors [Tue, 27 Apr 2021 23:39:41 +0000 (23:39 +0000)]
Auto merge of #7140 - matthiaskrgr:ice_std, r=llogiq

fix ice when checking rustc libstd

```
thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', src/tools/clippy/clippy_lints/src/matches.rs:1595:53
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

I don't have a minimised testcase because I don't have time to reduce libstd down to a few lines right now.

---
changelog: fix index out of bounds access when checking rustc libstd

3 years agofix ice when checking rustc libstd
Matthias Krüger [Tue, 27 Apr 2021 21:16:19 +0000 (23:16 +0200)]
fix ice when checking rustc libstd

thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', src/tools/clippy/clippy_lints/src/matches.rs:1595:53
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I don't have a minimised testcase because I don't have time to reduce libstd down to a few lines right now.

3 years agoSwitch `rustc::internal` from deny to warn
Joshua Nelson [Tue, 27 Apr 2021 17:00:36 +0000 (13:00 -0400)]
Switch `rustc::internal` from deny to warn

These should still obey deny-warnings.

3 years agoImplement `x.py test src/tools/clippy --bless`
Joshua Nelson [Wed, 14 Apr 2021 13:20:49 +0000 (09:20 -0400)]
Implement `x.py test src/tools/clippy --bless`

- Add clippy_dev to the rust workspace

  Before, it would give an error that it wasn't either included or
  excluded from the workspace:

  ```
  error: current package believes it's in a workspace when it's not:
  current:   /home/joshua/rustc/src/tools/clippy/clippy_dev/Cargo.toml
  workspace: /home/joshua/rustc/Cargo.toml

  this may be fixable by adding `src/tools/clippy/clippy_dev` to the `workspace.members` array of the manifest located at: /home/joshua/rustc/Cargo.toml
  Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest.
  ```

- Change clippy's copy of compiletest not to special-case
  rust-lang/rust. Using OUT_DIR confused `clippy_dev` and it couldn't find
  the test outputs. This is one of the reasons why `cargo dev bless` used
  to silently do nothing (the others were that `CARGO_TARGET_DIR` and
  `PROFILE` weren't set appropriately).

- Run clippy_dev on test failure

I tested this by removing a couple lines from a stderr file, and they
were correctly replaced.

- Fix clippy_dev warnings

3 years agoMerge commit '7c7683c8efe447b251d6c5ca6cce51233060f6e8' into clippyup
flip1995 [Tue, 27 Apr 2021 14:55:11 +0000 (16:55 +0200)]
Merge commit '7c7683c8efe447b251d6c5ca6cce51233060f6e8' into clippyup

3 years agoAuto merge of #7128 - Jarcho:const_fn_ice, r=flip1995
bors [Tue, 27 Apr 2021 14:21:11 +0000 (14:21 +0000)]
Auto merge of #7128 - Jarcho:const_fn_ice, r=flip1995

Fix ICE checking for feature gated const fn

fixes: #7126
changelog: Fix ICE in `missing_const_for_fn` when using a feature-gated `const fn`

3 years agoAuto merge of #7138 - mgacek8:issue6808_iter_cloned_collect_FN_with_large_array,...
bors [Tue, 27 Apr 2021 13:44:51 +0000 (13:44 +0000)]
Auto merge of #7138 - mgacek8:issue6808_iter_cloned_collect_FN_with_large_array, r=Manishearth

Fix FN in `iter_cloned_collect` with a large array

fixes #6808
changelog: Fix FN in `iter_cloned_collect` with a large array

I spotted that [is_iterable_array](https://github.com/rust-lang/rust-clippy/blob/a362a4d1d0edb66aef186c1d27b28c60573078f4/clippy_lints/src/loops/explicit_iter_loop.rs#L67-L75) function that `explicit_iter_loop` lint is using only works for array sizes <= 32.
There is this comment:
> IntoIterator is currently only implemented for array sizes <= 32 in rustc

I'm a bit confused, because I read that [IntoIterator for arrays](https://doc.rust-lang.org/src/core/array/mod.rs.html#194-201) with const generic `N` is stable since = "1.0.0". Although Const Generics MVP were stabilized in Rust 1.51.

Should I set MSRV for the current change? I will try to test with older compilers soon.

3 years agoAuto merge of #7136 - mgacek8:issue6965_manual_unwrap_or_invalid_sugg_macro_expansion...
bors [Mon, 26 Apr 2021 21:39:40 +0000 (21:39 +0000)]
Auto merge of #7136 - mgacek8:issue6965_manual_unwrap_or_invalid_sugg_macro_expansion, r=llogiq

manual_unwrap_or: fix invalid code suggestion, due to macro expansion

fixes #6965

changelog: fix invalid code suggestion in `manual_unwrap_or` lint, due to macro expansion

3 years agoAuto merge of #7137 - camsteffen:msrv-mod, r=llogiq
bors [Mon, 26 Apr 2021 21:25:19 +0000 (21:25 +0000)]
Auto merge of #7137 - camsteffen:msrv-mod, r=llogiq

Refactor MSRV aliases

changelog: Remove MSRV from `needless_question_mark` and change MSRV for `missing_const_for_fn` from 1.37.0 to 1.46.0.

First [mentioned on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Better.20MSRV.20testing.20idea/near/236215074).

* Moves MSRV constants into `clippy_utils::msrvs`. Now they are named to represent a stabilized feature flag or library item that is required for a lint's suggestion.
* `needless_question_mark` no longer has MSRV. Not needed since it does not suggest adding `?`.
* `missing_const_for_fn` MSRV was changed from 1.37.0 to 1.46.0. This seems to be a past mistake.

3 years agoUpdate MSRV contribution docs
Cameron Steffen [Mon, 26 Apr 2021 20:47:39 +0000 (15:47 -0500)]
Update MSRV contribution docs