]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoreceive iter method name as an argument
Takayuki Maeda [Fri, 26 Feb 2021 07:21:43 +0000 (16:21 +0900)]
receive iter method name as an argument

3 years agoremove if_chain
Takayuki Maeda [Fri, 26 Feb 2021 06:49:03 +0000 (15:49 +0900)]
remove if_chain

3 years agoreturn when the ty doesn't have `len()`
Takayuki Maeda [Thu, 25 Feb 2021 19:11:01 +0000 (04:11 +0900)]
return when the ty doesn't have `len()`

3 years agomove `lints()` to `iter_count.rs`
Takayuki Maeda [Thu, 25 Feb 2021 17:18:52 +0000 (02:18 +0900)]
move `lints()` to `iter_count.rs`

3 years agolint for `into_iter().count()`
Takayuki Maeda [Thu, 25 Feb 2021 16:54:51 +0000 (01:54 +0900)]
lint for `into_iter().count()`

3 years agoallow clippy::iter_count
Takayuki Maeda [Thu, 25 Feb 2021 14:07:15 +0000 (23:07 +0900)]
allow clippy::iter_count

3 years agonew lint: iter_count
Takayuki Maeda [Thu, 25 Feb 2021 14:06:50 +0000 (23:06 +0900)]
new lint: iter_count

3 years agoAuto merge of #6730 - anall:feature/owned_to_owned_methods, r=camsteffen
bors [Sat, 27 Feb 2021 01:40:05 +0000 (01:40 +0000)]
Auto merge of #6730 - anall:feature/owned_to_owned_methods, r=camsteffen

added new lint `owned_to_owned`

Adding new lint `owned_to_owned`

Creating draft PR to have this looked over.
I think this takes all advice I received into account.

I did have to update the `redundant_clone` test to ignore this lint -- I felt that was the safest action.

closes: #6715
changelog: added new lint `implicit_clone`

3 years agoadded new lint `implicit_clone`
Andrea Nall [Fri, 12 Feb 2021 04:27:04 +0000 (04:27 +0000)]
added new lint `implicit_clone`

3 years agoRevert #6796: Downgrade manual_map to nursery
Jason Newcomb [Fri, 26 Feb 2021 21:27:41 +0000 (16:27 -0500)]
Revert #6796: Downgrade manual_map to nursery

3 years agoFix `manual_map`: don't lint when partially moved values are used.
Jason Newcomb [Fri, 26 Feb 2021 16:50:12 +0000 (11:50 -0500)]
Fix `manual_map`: don't lint when partially moved values are used.
Fix `manual_map`: don't lint when `return`, `break`, and `continue` are used.

3 years agoAuto merge of #6800 - matthiaskrgr:lintcheck_stats, r=llogiq
bors [Fri, 26 Feb 2021 19:30:57 +0000 (19:30 +0000)]
Auto merge of #6800 - matthiaskrgr:lintcheck_stats, r=llogiq

lintcheck: print stats how lint counts change

The stats look like this:
````
Stats:
clippy::manual_map 0 => 10
clippy::missing_panics_doc 54 => 56
clippy::upper_case_acronyms 18 => 4
````

changelog: lintcheck: print stats about changing lint counts in the log

3 years agoRevert "Fix versioncheck test"
Cameron Steffen [Fri, 26 Feb 2021 18:30:43 +0000 (12:30 -0600)]
Revert "Fix versioncheck test"

This reverts commit 1e7b1ccb2a05f80ae0a580401e7565fb1c0a4917.

3 years agoAdd package arguments to dogfood test
Cameron Steffen [Fri, 26 Feb 2021 18:12:33 +0000 (12:12 -0600)]
Add package arguments to dogfood test

This is necessary after migrating to RUSTC_WORKSPACE_WRAPPER.

3 years agoRevert "Add workspace to manifest"
Cameron Steffen [Fri, 26 Feb 2021 18:11:47 +0000 (12:11 -0600)]
Revert "Add workspace to manifest"

This reverts commit 9bcb257985d5a16355bdd62998935f16d09b42e2.

3 years agoRevert "Fix lintcheck by excluding checked crates from workspace"
Cameron Steffen [Fri, 26 Feb 2021 18:11:35 +0000 (12:11 -0600)]
Revert "Fix lintcheck by excluding checked crates from workspace"

This reverts commit aea55d2c6239e42a0a337d610d19061521565615.

3 years agoRevert "Test workspace at once"
Cameron Steffen [Fri, 26 Feb 2021 18:10:24 +0000 (12:10 -0600)]
Revert "Test workspace at once"

This reverts commit e355652fec704f307b50d42fb6a08172dc1e08bf.

3 years agoAuto merge of #6796 - dtolnay-contrib:manualmap, r=flip1995
bors [Fri, 26 Feb 2021 15:28:10 +0000 (15:28 +0000)]
Auto merge of #6796 - dtolnay-contrib:manualmap, r=flip1995

Downgrade manual_map to nursery

I believe #6795 should be considered a blocker for this lint to be considered for enabling by default.

---

changelog: remove manual_map from default list of enabled lints

3 years agolintcheck: update logs and do minor fixes
Matthias Krüger [Fri, 26 Feb 2021 10:18:59 +0000 (11:18 +0100)]
lintcheck: update logs and do minor fixes

3 years agolintcheck: print stats how lint counts have changed between runs
Matthias Krüger [Tue, 23 Feb 2021 20:23:36 +0000 (21:23 +0100)]
lintcheck: print stats how lint counts have changed between runs

3 years agolintcheck: fix bug when getting the config toml path.
Matthias Krüger [Tue, 23 Feb 2021 20:27:32 +0000 (21:27 +0100)]
lintcheck: fix bug when getting the config toml path.

In order to check if we need to recheck crates, I was getting the path from clap only
which is None if we don't pass it via cmdline args.

Use the dedicated lintcheck_config_toml() fnuction instead!

3 years agoDowngrade manual_map to nursery
David Tolnay [Fri, 26 Feb 2021 04:31:24 +0000 (20:31 -0800)]
Downgrade manual_map to nursery

3 years agoAuto merge of #6601 - mdm:fix-unit-args-false-positive, r=camsteffen
bors [Thu, 25 Feb 2021 21:16:02 +0000 (21:16 +0000)]
Auto merge of #6601 - mdm:fix-unit-args-false-positive, r=camsteffen

Fix false positive for unit_arg lint

Fixes #6447

To avoid false positives don't complain about unit args when they come from a path expression, e.g. a local variable.

**Note:** This is my first contribution to Clippy, so I might have messed up somewhere. Any feedback is welcome and I'm happy to work out any kinks.

---

changelog: Do not lint unit arguments when they come from a path expression.

3 years agoAdd original test case from issue
Marc Dominik Migge [Thu, 25 Feb 2021 21:03:11 +0000 (22:03 +0100)]
Add original test case from issue

3 years agoAuto merge of #6790 - mgacek8:issue_6748, r=Manishearth
bors [Thu, 25 Feb 2021 15:05:06 +0000 (15:05 +0000)]
Auto merge of #6790 - mgacek8:issue_6748, r=Manishearth

or_fun_call: fix suggestion for `or_insert(vec![])`

fixes #6748
changelog: or_fun_call: fix suggestion for `or_insert(vec![])` on `std::collections::hash_map::Entry` or `std::collections::btree_map::Entry`

3 years agoor_fun_call: fix suggestion for `or_insert(vec![])`
Mateusz Gacek [Wed, 24 Feb 2021 20:06:26 +0000 (21:06 +0100)]
or_fun_call: fix suggestion for `or_insert(vec![])`

Applies for `std::collections::hash_map::Entry` and `std::collections::btree_map::Entry`

Example:
Previously, for the following code:
`let _ = hash_map.entry("test".to_owned()).or_insert(vec![]);`
clippy would suggest to use:
`or_insert_with(vec![])`, which causes a compiler error (E0277).

Now clippy suggests:
`or_insert_with(Vec::new)`

3 years agoAuto merge of #6789 - flip1995:rustup, r=flip1995
bors [Thu, 25 Feb 2021 09:49:12 +0000 (09:49 +0000)]
Auto merge of #6789 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: None

3 years agoBump nightly version -> 2021-02-25
flip1995 [Thu, 25 Feb 2021 09:40:24 +0000 (10:40 +0100)]
Bump nightly version -> 2021-02-25

3 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 25 Feb 2021 09:40:00 +0000 (10:40 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

3 years agoAuto merge of #6788 - matthiaskrgr:upper_case_acronyms, r=flip1995
bors [Thu, 25 Feb 2021 09:01:41 +0000 (09:01 +0000)]
Auto merge of #6788 - matthiaskrgr:upper_case_acronyms, r=flip1995

move upper_case_acronyms back to style, but make the default behaviour less aggressive by default (can be unleashed via config option)

Previous discussion in the bi-weekly clippy meeting for reference: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Meeting.202021-02-23/near/227458019

Move the `upper_case_acronyms` lint back to the style group.
Only warn on fully-capitalized names by default.
Add add a clippy-config option `upper-case-acronyms-aggressive: true/false` to enabled more aggressive linting on
all substrings that could be capitalized acronyms.

---
changelog: reenable upper_case_acronyms by default but make the more aggressive linting opt-in via config option

3 years agorun cargo dev update_lints
Matthias Krüger [Wed, 24 Feb 2021 23:10:06 +0000 (00:10 +0100)]
run cargo dev update_lints

fix sentence / address review comments

3 years agoAuto merge of #6783 - avitex:add-opendns-ident, r=giraffate
bors [Thu, 25 Feb 2021 00:22:39 +0000 (00:22 +0000)]
Auto merge of #6783 - avitex:add-opendns-ident, r=giraffate

Add OpenDNS to `doc-valid-idents`

changelog: This commit adds `"OpenDNS"` to doc-valid-idents to avoid `doc_markdown` false positives.

3 years agoupper_case_acronyms: add io-toml tests and bless previous tests
Matthias Krüger [Wed, 24 Feb 2021 22:41:32 +0000 (23:41 +0100)]
upper_case_acronyms: add io-toml tests and bless previous tests

3 years agoupper_case_acronyms: add optional aggressive mode and relax default
Matthias Krüger [Wed, 24 Feb 2021 22:20:49 +0000 (23:20 +0100)]
upper_case_acronyms: add optional aggressive mode and relax default

Moves the lint back from pedantic to style group.
The lint default now only warns on names that are completely capitalized, like "WORD"
and only if the name is longer than 2 chars (so that names where each of the letter represents a word are still distinguishable).
For example: FP (false positive) would still be "valid" and not warned about (but EOF would warn).

A "upper_case_acronyms_aggressive: true/false" config option was added that restores the original lint behaviour to warn
on any kind of camel case name that had more than one capital letter following another capital letter.

3 years agoadd test coverage for all `doc-valid-idents`
avitex [Wed, 24 Feb 2021 22:26:11 +0000 (09:26 +1100)]
add test coverage for all `doc-valid-idents`

3 years agoAdd OpenDNS to `doc-valid-idents`
avitex [Wed, 24 Feb 2021 04:04:00 +0000 (15:04 +1100)]
Add OpenDNS to `doc-valid-idents`

3 years agoAuto merge of #6786 - smoelius:move-conf-rs-back-into-clippy-lints, r=flip1995
bors [Wed, 24 Feb 2021 14:51:14 +0000 (14:51 +0000)]
Auto merge of #6786 - smoelius:move-conf-rs-back-into-clippy-lints, r=flip1995

Move conf.rs back into clippy_lints

This is an alternative solution to #6785 to fix the CI break caused by #6756.

changelog: none

3 years agoDon't lint unit args if expression kind is path
Marc Dominik Migge [Wed, 24 Feb 2021 12:31:04 +0000 (13:31 +0100)]
Don't lint unit args if expression kind is path

3 years agoMove conf.rs back into clippy_lints
Samuel E. Moelius III [Wed, 24 Feb 2021 11:12:27 +0000 (06:12 -0500)]
Move conf.rs back into clippy_lints

3 years agoAuto merge of #6756 - smoelius:clippy_utils, r=flip1995,obi-obk
bors [Wed, 24 Feb 2021 09:43:23 +0000 (09:43 +0000)]
Auto merge of #6756 - smoelius:clippy_utils, r=flip1995,obi-obk

Factor out `clippy_utils` crate

As discussed in https://github.com/rust-lang/rust-clippy/pull/6746, this PR factors out `clippy_lints::utils` as its own crate, `clippy_utils` .

This change will allow `clippy_utils` to be used in lints outside of Clippy.

There is no plan to publish this crate on `crates.io` (see https://github.com/rust-lang/rust-clippy/pull/6746#issuecomment-780747522). Dependent crates should obtain it from GitHub.

changelog: Factor out `clippy_utils` so it can be used by external tools (not published)

3 years agoAuto merge of #6782 - ojeda:readme-as-wrapper, r=flip1995
bors [Wed, 24 Feb 2021 09:31:26 +0000 (09:31 +0000)]
Auto merge of #6782 - ojeda:readme-as-wrapper, r=flip1995

README: Add subsection on running Clippy as a rustc wrapper

This is useful for projects that do not use cargo.

changelog: README: Add subsection on running Clippy as a rustc wrapper

3 years agoREADME: Add subsection on running Clippy as a rustc wrapper
Miguel Ojeda [Tue, 23 Feb 2021 14:54:40 +0000 (15:54 +0100)]
README: Add subsection on running Clippy as a rustc wrapper

This is useful for projects that do not use cargo.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
3 years agoMove `declare_clippy_lint` back into clippy_lints
Samuel E. Moelius III [Thu, 18 Feb 2021 17:25:35 +0000 (12:25 -0500)]
Move `declare_clippy_lint` back into clippy_lints

3 years agoUpdate references in doc directory
Samuel E. Moelius III [Thu, 18 Feb 2021 11:08:46 +0000 (06:08 -0500)]
Update references in doc directory

3 years agoUpdate clippy_utils/Cargo.toml
Samuel E. Moelius [Thu, 18 Feb 2021 10:41:37 +0000 (05:41 -0500)]
Update clippy_utils/Cargo.toml

Co-authored-by: Philipp Krones <hello@philkrones.com>
3 years agoTypo
Samuel E. Moelius III [Thu, 18 Feb 2021 02:54:15 +0000 (21:54 -0500)]
Typo

3 years agoRemove file accidentally re-added during rebase
Samuel E. Moelius III [Thu, 18 Feb 2021 02:51:21 +0000 (21:51 -0500)]
Remove file accidentally re-added during rebase

3 years agoUpdate custom_ice_message.stderr
Samuel E. Moelius III [Thu, 18 Feb 2021 02:04:38 +0000 (21:04 -0500)]
Update custom_ice_message.stderr

3 years agoFix update_lints
Samuel E. Moelius III [Thu, 18 Feb 2021 01:54:14 +0000 (20:54 -0500)]
Fix update_lints

3 years agoFix doc test
Samuel E. Moelius III [Wed, 17 Feb 2021 23:53:21 +0000 (18:53 -0500)]
Fix doc test

3 years agoBump clippy_utils version
Samuel E. Moelius III [Wed, 17 Feb 2021 22:05:52 +0000 (17:05 -0500)]
Bump clippy_utils version

3 years agoFix versioncheck test
Samuel E. Moelius III [Wed, 17 Feb 2021 22:05:32 +0000 (17:05 -0500)]
Fix versioncheck test

3 years agoFix one import
Samuel E. Moelius III [Wed, 17 Feb 2021 22:03:29 +0000 (17:03 -0500)]
Fix one import

3 years agoImprove tests
Samuel E. Moelius III [Wed, 17 Feb 2021 17:30:48 +0000 (12:30 -0500)]
Improve tests

3 years agoRemove unused features
Samuel E. Moelius III [Sat, 13 Feb 2021 23:49:22 +0000 (18:49 -0500)]
Remove unused features

3 years agoRemove unused dependencies
Samuel E. Moelius III [Sat, 13 Feb 2021 23:46:11 +0000 (18:46 -0500)]
Remove unused dependencies

3 years agoGet tests to pass
Samuel E. Moelius III [Sat, 13 Feb 2021 14:04:50 +0000 (09:04 -0500)]
Get tests to pass

3 years agoUpdate clippy_utils/src/lib.rs
Samuel E. Moelius III [Thu, 11 Feb 2021 20:03:52 +0000 (15:03 -0500)]
Update clippy_utils/src/lib.rs

3 years agoUpdate clippy_lints/src/lib.rs
Samuel E. Moelius III [Thu, 11 Feb 2021 20:03:28 +0000 (15:03 -0500)]
Update clippy_lints/src/lib.rs

3 years agoFactor out `clippy_utils` crate
Samuel E. Moelius III [Wed, 17 Feb 2021 17:42:21 +0000 (12:42 -0500)]
Factor out `clippy_utils` crate

3 years agoAuto merge of #6573 - Jarcho:option_match_map, r=llogiq
bors [Tue, 23 Feb 2021 21:56:25 +0000 (21:56 +0000)]
Auto merge of #6573 - Jarcho:option_match_map, r=llogiq

New lint: option_manual_map

fixes: #6
changelog: Added lint: `match_map`

3 years agoAuto merge of #6781 - matthiaskrgr:lintcheck_fix, r=matthiaskrgr
bors [Tue, 23 Feb 2021 12:05:24 +0000 (12:05 +0000)]
Auto merge of #6781 - matthiaskrgr:lintcheck_fix, r=matthiaskrgr

lintcheck fix build (forgot to pass function parameter) and runtime (…

…don't check metadata of directory if it does not exist)

Accidentally broke lintcheck in my previous commit.

changelog: None

3 years agolintcheck fix build (forgot to pass function parameter) and runtime (don't check...
Matthias Krüger [Tue, 23 Feb 2021 11:58:12 +0000 (12:58 +0100)]
lintcheck fix build (forgot to pass function parameter) and runtime (don't check metadata of directory if it does not exist)

3 years agoAuto merge of #6780 - matthiaskrgr:lintcheck2, r=flip1995
bors [Tue, 23 Feb 2021 08:31:28 +0000 (08:31 +0000)]
Auto merge of #6780 - matthiaskrgr:lintcheck2, r=flip1995

lintcheck: fully rerun lintcheck if clippy was rebuilt since last log update

Automatically clean lintchecks shared target dir (will force clippy to recheck sources) if
the clippy binaries are older than the lintcheck logs.

Also updated lintcheck logs in the pr.

changelog: lintcheck: fully rerun lintcheck if clippy was rebuilt since last log update

3 years agolintcheck: rerun if clippy changed
Matthias Krüger [Mon, 22 Feb 2021 23:40:50 +0000 (00:40 +0100)]
lintcheck: rerun if clippy changed

Automatically clean lintchecks shared target dir (will force clippy to recheck sources) if
the clippy binaries are older than the lintcheck logs.

Also update lintcheck logs

3 years agoAuto merge of #6777 - giraffate:remove_unneeded_blank_lines_from_doc, r=phansch
bors [Tue, 23 Feb 2021 06:05:27 +0000 (06:05 +0000)]
Auto merge of #6777 - giraffate:remove_unneeded_blank_lines_from_doc, r=phansch

Remove unneeded blank lines from doc

Remove unneeded blank lines like below.
<img width="1142" alt="スクリーンショット 2021-02-22 23 01 17" src="https://user-images.githubusercontent.com/17407489/108719295-bb9ff800-7562-11eb-9338-8f2571e61c56.png">

changelog: none

3 years agoAuto merge of #6774 - Y-Nak:quick-fix-bless, r=phansch
bors [Tue, 23 Feb 2021 05:53:59 +0000 (05:53 +0000)]
Auto merge of #6774 - Y-Nak:quick-fix-bless, r=phansch

Quick fix cargo dev bless

fixes #6757
r? `@phansch`

Trying to do a quick fix of `bless`, I'm not sure how much work it will need to do transition to `bless` built in `compiletest`, so please feel free to close this PR if it will not need so much.

changelog: none

3 years agoRemove unneeded blank lines from doc
Takayuki Nakata [Mon, 22 Feb 2021 14:02:04 +0000 (23:02 +0900)]
Remove unneeded blank lines from doc

3 years agoAuto merge of #6775 - matthiaskrgr:upper_case_pedantic, r=flip1995
bors [Mon, 22 Feb 2021 11:40:20 +0000 (11:40 +0000)]
Auto merge of #6775 - matthiaskrgr:upper_case_pedantic, r=flip1995

upper_case_acronyms: move lint from style to pedantic lint group

The lint does point out inconsistency with the Rust naming convention,
but the fact that rustc does not warn about the inconsistency by default
means that clippy probably should not warn by default either.

changelog: move upper_case_acronyms lint from style to pedantic group.

3 years agoupper_case_acronyms: move lint from style to pedantic lint group
Matthias Krüger [Mon, 22 Feb 2021 11:30:28 +0000 (12:30 +0100)]
upper_case_acronyms: move lint from style to pedantic lint group

The lint does point out inconsistency with the Rust naming convention,
but the fact that rustc does not warn about the inconsistency by default
means that clippy probably should not warn by default either.

changelog: move upper_case_acronyms lint from style to pedantic group.

3 years agoAuto merge of #6769 - Y-Nak:inconsistent-struct-constructor, r=matthiaskrgr
bors [Mon, 22 Feb 2021 09:29:20 +0000 (09:29 +0000)]
Auto merge of #6769 - Y-Nak:inconsistent-struct-constructor, r=matthiaskrgr

Inconsistent struct constructor

fixes: #6352
r? `@matthiaskrgr`

I added the lint that checks for the struct constructors where the order of the field init shorthands is inconsistent with that in the struct definition.

changelog: Add style lint: `inconsistent_struct_constructor`

3 years agoFix dogfood errors
Jason Newcomb [Fri, 19 Feb 2021 19:04:37 +0000 (14:04 -0500)]
Fix dogfood errors

3 years agoQuick fix cargo dev bless
Yoshitomo Nakanishi [Mon, 22 Feb 2021 03:32:41 +0000 (12:32 +0900)]
Quick fix cargo dev bless

3 years agoAdd: option_manual_map lint
Jason Newcomb [Sun, 10 Jan 2021 14:46:03 +0000 (09:46 -0500)]
Add: option_manual_map lint

3 years agoDescribe the order of fields in struct ctor doesn't affect the resulted instance
Yoshitomo Nakanishi [Mon, 22 Feb 2021 02:45:25 +0000 (11:45 +0900)]
Describe the order of fields in struct ctor doesn't affect the resulted instance

3 years agoAuto merge of #6771 - MortenLohne:master, r=flip1995
bors [Sun, 21 Feb 2021 16:10:03 +0000 (16:10 +0000)]
Auto merge of #6771 - MortenLohne:master, r=flip1995

Fix FP in inherent_to_string when the function has generic parameters

Minimal example of the false positive:
````
struct G;

impl G {
    fn to_string<const _N: usize>(&self) -> String {
        "G.to_string()".to_string()
    }
}

fn main() {
    let g = G;
    g.to_string::<1>();
}
````
Clippy emits an `inherent_to_string` warning, and suggests that we implement `Display` for `G` instead. However, this is not possible, since the generic parameter _N only exists in this function, not in `G` itself. This particular example uses const generics, which is where the issue is most likely to come up, but this PR skips the lint if the `to_string` function has any kind of generic parameters.

changelog: Fix FP in `inherent_to_string`

3 years agoAuto merge of #6770 - ThibsG:PostfixEnumVariant, r=flip1995
bors [Sun, 21 Feb 2021 15:58:47 +0000 (15:58 +0000)]
Auto merge of #6770 - ThibsG:PostfixEnumVariant, r=flip1995

Fix camel case postfix for `enum_variant_names` lint

Fix camel case postfix

Fixes: #4639
changelog: none

3 years agoAuto merge of #6765 - camsteffen:unnecessary-wraps-pedantic, r=flip1995
bors [Sun, 21 Feb 2021 15:33:50 +0000 (15:33 +0000)]
Auto merge of #6765 - camsteffen:unnecessary-wraps-pedantic, r=flip1995

Change unnecessary_wraps to pedantic

changelog: Change unnecessary_wraps to pedantic

There seems to be enough evidence that this lint is not wanted as warn-by-default. Attempted before at #6380. False positives at #6721 and #6427. Actually requested to change the category at #6726.

Closes #6726

3 years agoAuto merge of #6754 - camsteffen:spanlesseq-res, r=flip1995
bors [Sun, 21 Feb 2021 15:22:35 +0000 (15:22 +0000)]
Auto merge of #6754 - camsteffen:spanlesseq-res, r=flip1995

Teach SpanlessEq binding IDs

changelog: Fix collapsible_match false positive

Fixes #6740

This PR changes the way `SpanlessEq` determines whether two local variables are the same. Instead of checking that the names match, it checks that the `HirId`s match. If local bindings are declared within the expressions that are being compared, `SpanlessEq` will remember bindings that correspond to each other in a `FxHashMap<HirId, HirId>`. This makes `SpanlessEq` more flexible while also fixing false positives.

Example: `{ let x = 1; x + 2 }` is equal to `{ let y = 1; y + 2 }`.

CC `@xFrednet` I think this will resolve some concerns in #6463

3 years agoFix FP in inherent_to_string when the function has generic parameters
Morten Lohne [Sat, 20 Feb 2021 22:47:49 +0000 (23:47 +0100)]
Fix FP in inherent_to_string when the function has generic parameters

3 years agoFix unnecessary_sort_by.rs that fails the dogfood test
Yoshitomo Nakanishi [Sat, 20 Feb 2021 14:02:18 +0000 (23:02 +0900)]
Fix unnecessary_sort_by.rs that fails the dogfood test

3 years agoNew lint: inconsistent_struct_constructor
Yoshitomo Nakanishi [Sat, 20 Feb 2021 13:52:56 +0000 (22:52 +0900)]
New lint: inconsistent_struct_constructor

3 years agoFix camel case postfix for `enum_variant_names` lint
ThibsG [Sat, 20 Feb 2021 18:48:04 +0000 (19:48 +0100)]
Fix camel case postfix for `enum_variant_names` lint

3 years agoAuto merge of #6717 - booleancoercion:master, r=llogiq
bors [Sat, 20 Feb 2021 09:33:11 +0000 (09:33 +0000)]
Auto merge of #6717 - booleancoercion:master, r=llogiq

Add the from_str_radix_10 lint

changelog: added the new `from_str_radix_10` which sometimes replaces calls to `primitive::from_str_radix` to `str::parse`

This is ready to be merged, although maybe the category should be `pedantic` instead of `style`? I'm not sure where it fits better.

Closes #6713.

3 years agoAuto merge of #6766 - matthiaskrgr:nestedmatch, r=flip1995
bors [Sat, 20 Feb 2021 00:36:53 +0000 (00:36 +0000)]
Auto merge of #6766 - matthiaskrgr:nestedmatch, r=flip1995

collapsible_match: fix lint message capitalization

(see https://rustc-dev-guide.rust-lang.org/diagnostics.html for details)

---

*Please write a short comment explaining your change (or "none" for internal only changes)*
changelog: collapsible_match: fix lint message capitalization

3 years agoAuto merge of #6764 - matthiaskrgr:lintcheck_par_iter, r=flip1995
bors [Sat, 20 Feb 2021 00:25:10 +0000 (00:25 +0000)]
Auto merge of #6764 - matthiaskrgr:lintcheck_par_iter, r=flip1995

lintcheck: parallelize

By default we use a single thread and one target dir as before.

If `-j n` is passed, use `n` target dirs and run one clippy in each of them.
We need several target dirs because cargo would lock them for a single process otherwise which would prevent the parallelism.
`-j 0` makes rayon use  $thread_count/2 (which I assume is the number of physical cores of a machine) for the number of threads.

Other change:
Show output of clippy being compiled when building it for lintcheck (makes it easier to spot compiler errors etc)
Show some progress indication in the "Linting... foo 1.2.3"  message.
Sort crates before linting (previously crates would be split randomly between target dirs, with the sorting, we try to make sure that even crates land in target dir 0 and odd ones in target dir 1 etc..)

*Please write a short comment explaining your change (or "none" for internal only changes)*
changelog: parallelize lintcheck with rayon

3 years agolintcheck: add -j <N> option to configure threads.
Matthias Krüger [Fri, 19 Feb 2021 22:20:05 +0000 (23:20 +0100)]
lintcheck: add -j <N> option to configure threads.

defaults to 1
-j 0 choses the number of threads automtically (= number of physical cores)

3 years agolintcheck: sort crates before linting
Matthias Krüger [Fri, 19 Feb 2021 21:16:53 +0000 (22:16 +0100)]
lintcheck: sort crates before linting

3 years agolintcheck: show progress percentage in the "Linting..." message
Matthias Krüger [Fri, 19 Feb 2021 21:06:50 +0000 (22:06 +0100)]
lintcheck: show progress percentage in the "Linting..." message

3 years agolintheck: show output (and compiler errors!) when compiling clippy for lintcheck
Matthias Krüger [Fri, 19 Feb 2021 20:52:34 +0000 (21:52 +0100)]
lintheck: show output (and compiler errors!) when compiling clippy for lintcheck

3 years agolintcheck: tweak some comments
Matthias Krüger [Fri, 19 Feb 2021 20:48:52 +0000 (21:48 +0100)]
lintcheck: tweak some comments

3 years agoFixed the known problems section
bool [Fri, 19 Feb 2021 20:00:23 +0000 (22:00 +0200)]
Fixed the known problems section

3 years agoUpdated from_str_radix_10 sugg to be slightly smarter and ran bless
bool [Fri, 19 Feb 2021 17:36:28 +0000 (19:36 +0200)]
Updated from_str_radix_10 sugg to be slightly smarter and ran bless

3 years agoMove try_print_query_stack to rustc_interface.
Camille GILLOT [Wed, 8 Apr 2020 18:47:36 +0000 (20:47 +0200)]
Move try_print_query_stack to rustc_interface.

3 years agocollapsible_match: fix lint message capitalization
Matthias Krüger [Fri, 19 Feb 2021 09:02:17 +0000 (10:02 +0100)]
collapsible_match: fix lint message capitalization

(see https://rustc-dev-guide.rust-lang.org/diagnostics.html for details)

3 years agoChange known problems
Cameron Steffen [Fri, 19 Feb 2021 02:23:49 +0000 (20:23 -0600)]
Change known problems

3 years agoChange unnecessary_wraps to pedantic
Cameron Steffen [Fri, 19 Feb 2021 02:02:58 +0000 (20:02 -0600)]
Change unnecessary_wraps to pedantic

3 years agoRollup merge of #82238 - petrochenkov:nocratemod, r=Aaron1011
Dylan DPC [Fri, 19 Feb 2021 01:49:08 +0000 (02:49 +0100)]
Rollup merge of #82238 - petrochenkov:nocratemod, r=Aaron1011

ast: Keep expansion status for out-of-line module items

I.e. whether a module `mod foo;` is already loaded from a file or not.
This is a pre-requisite to correctly treating inner attributes on such modules (https://github.com/rust-lang/rust/issues/81661).

With this change AST structures for `mod` items diverge even more for AST structure for the crate root, which previously used `ast::Mod`.
Therefore this PR removes `ast::Mod` from `ast::Crate` in the first commit, these two things are sufficiently different from each other, at least at syntactic level.
Customization points for visiting a "`mod` item or crate root" were also removed from AST visitors (`fn visit_mod`).
`ast::Mod` itself was refactored away in the second commit in favor of `ItemKind::Mod(Unsafe, ModKind)`.

3 years agolintcheck: parallelize
Matthias Krüger [Thu, 18 Feb 2021 18:09:12 +0000 (19:09 +0100)]
lintcheck: parallelize

Use rayon to figure out the threadcount and half that for core count.
For each core, create a target dir that is used.
Otherwise, when running multiple clippys with the same target-dir, cargo would lock the dir and prevent parallelism.
This way we can run multiple clippys at the same time (on root crates) but we sacrifice cache-hits (when we already cargo-checked crate-deps).

3 years agoAuto merge of #6665 - pag4k:unnecessary_wraps_bug_6640, r=camsteffen
bors [Thu, 18 Feb 2021 22:47:44 +0000 (22:47 +0000)]
Auto merge of #6665 - pag4k:unnecessary_wraps_bug_6640, r=camsteffen

Fix for issue 6640

*Please write a short comment explaining your change (or "none" for internal only changes)*
changelog: unnecessary_wraps will now suggest to remove unnecessary wrapped return unit type, like Option<()>
fixes #6640