Commit Graph

10980 Commits

Author SHA1 Message Date
Yoshitomo Nakanishi
d23038944a New lint: inconsistent_struct_constructor 2021-02-21 05:05:11 +09:00
ThibsG
5af6f96c8f Fix camel case postfix for enum_variant_names lint 2021-02-20 19:48:04 +01:00
bors
67087a1b4e 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.
2021-02-20 09:33:11 +00:00
bors
2746632917 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
2021-02-20 00:36:53 +00:00
bors
23de8013a6 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
2021-02-20 00:25:10 +00:00
Matthias Krüger
8499a32859 lintcheck: add -j <N> option to configure threads.
defaults to 1
-j 0 choses the number of threads automtically (= number of physical cores)
2021-02-19 23:20:05 +01:00
Matthias Krüger
22aeec09e4 lintcheck: sort crates before linting 2021-02-19 22:16:53 +01:00
Matthias Krüger
4974734a24 lintcheck: show progress percentage in the "Linting..." message 2021-02-19 22:06:50 +01:00
Matthias Krüger
d198551311 lintheck: show output (and compiler errors!) when compiling clippy for lintcheck 2021-02-19 21:52:34 +01:00
Matthias Krüger
bb5f9d18a0 lintcheck: tweak some comments 2021-02-19 21:48:52 +01:00
bool
c4b8d87ab9 Fixed the known problems section 2021-02-19 22:00:23 +02:00
bool
bf55aee7b1 Updated from_str_radix_10 sugg to be slightly smarter and ran bless 2021-02-19 21:56:21 +02:00
Camille GILLOT
4334f57feb Move try_print_query_stack to rustc_interface. 2021-02-19 17:51:55 +01:00
Matthias Krüger
1f4153aa1e collapsible_match: fix lint message capitalization
(see https://rustc-dev-guide.rust-lang.org/diagnostics.html for details)
2021-02-19 10:02:17 +01:00
Cameron Steffen
46c91db1e1 Change known problems 2021-02-18 20:23:49 -06:00
Cameron Steffen
54c6054ec7 Change unnecessary_wraps to pedantic 2021-02-18 20:03:13 -06:00
Dylan DPC
2c302b246e 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)`.
2021-02-19 02:49:08 +01:00
Matthias Krüger
90d3275b45 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).
2021-02-19 00:14:43 +01:00
bors
0f70e88137 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
2021-02-18 22:47:44 +00:00
Pierre-Andre Gagnon
a78271b861 Changed fn body suggestion msg 2021-02-18 17:32:55 -05:00
bors
2f815ecd00 Auto merge of #6763 - flip1995:fix_lintcheck, r=matthiaskrgr
Fix lintcheck by excluding checked crates from workspace

r? `@matthiaskrgr`  cc `@camsteffen`

So `exclude` doesn't work with glob patterns, but it turns out that it works with `starts_with`.

changelog: none
2021-02-18 22:15:42 +00:00
flip1995
aea55d2c62
Fix lintcheck by excluding checked crates from workspace 2021-02-18 23:07:19 +01:00
bors
7d535f6a91 Auto merge of #6759 - Y-Nak:fix-fp-of-result_unit_err, r=llogiq
Fix FP of result_unit_err when using type aliases

fixes #6546

changelog: none
2021-02-18 21:39:29 +00:00
Dylan DPC
6e12a2f9e2 Rollup merge of #82215 - TaKO8Ki:replace-if-let-while-let, r=varkor
Replace if-let and while-let with `if let` and `while let`

This pull request replaces if-let and while-let with `if let` and `while let`.

closes https://github.com/rust-lang/rust/issues/82205
2021-02-18 16:57:37 +01:00
Vadim Petrochenkov
b185fa3ae2 ast: Keep expansion status for out-of-line module items
Also remove `ast::Mod` which is mostly redundant now
2021-02-18 13:07:49 +03:00
Yoshitomo Nakanishi
a87fa0e350 Fix FP of result_unit_err when using type aliases 2021-02-18 18:49:26 +09:00
bors
a149f61244 Auto merge of #81993 - flip1995:clippyup, r=Manishearth
Update Clippy

Biweekly Clippy update

r? `@Manishearth`
2021-02-17 22:37:42 +00:00
Pierre-Andre Gagnon
6165cccf7e Added detailled suggs for new case 2021-02-17 16:41:50 -05:00
Cameron Steffen
9ad6e263c9 Fix match_same_arms with SpanlessEq changes 2021-02-17 10:47:26 -06:00
Cameron Steffen
742922a41a Make expr_fallback FnMut 2021-02-17 10:47:26 -06:00
Cameron Steffen
4ac14f9e63 Teach SpanlessEq binding IDs 2021-02-17 10:47:26 -06:00
bors
ddeea97714 Auto merge of #6750 - flip1995:lintcheck_options, r=matthiaskrgr
Lintcheck and an options for command line options

Make it possible to add command line options to the clippy invocation of the lintcheck-tool

changelog: none

r? `@matthiaskrgr`

I found that this will be really helpful if we use a separate repository and want to maintain a all-lints-passing list of crates. See my early experimentation here: https://github.com/flip1995/clippy-lintcheck

```
git submodule update --init
cargo run -- --mode=all
```

Will run the lintcheck tool on all the specified crates in `config/` in that repository.
2021-02-17 12:53:31 +00:00
Takayuki Maeda
2d60a6113d replace if-let and while-let with if let and while let 2021-02-17 19:26:38 +09:00
flip1995
79d7f4ccb3
lintcheck: Add a note that -Wclippy::all is enabled by default 2021-02-17 08:35:57 +01:00
flip1995
e3f584665a
Reformat clippy_dev README 2021-02-16 18:09:34 +01:00
bors
877be189ad Auto merge of #6749 - camsteffen:test-all, r=Manishearth
Test workspace at once

changelog: none

Follow-up to #6733
2021-02-16 17:03:03 +00:00
Cameron Steffen
e355652fec Test workspace at once 2021-02-16 10:50:43 -06:00
Cameron Steffen
9bcb257985 Add workspace to manifest 2021-02-16 10:14:40 -06:00
flip1995
dd5c9b7dda
lintcheck: Slight improvements to the error reporting 2021-02-16 16:58:00 +01:00
flip1995
2a28ea0bea
Add command line options option to lintcheck crates config 2021-02-16 16:57:30 +01:00
bors
e2753f9a7b Auto merge of #6662 - Y-Nak:default-numeric-fallback, r=flip1995
New lint: default_numeric_fallback

fixes #6064
r? `@flip1995`

As we discussed in [here](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Issue.20.236064/near/224647188) and [here](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Issue.20clippy.236064/near/224746333),   I start implementing this lint from the strictest version.
In this PR, I'll allow the below two cases to pass the lint to reduce FPs.

1. Appearances of unsuffixed numeric literals in `Local` if `Local` has a type annotation, for example:
```rust
// Good.
let x: i32 = 1;

// Also good.
let x: (i32, i32) = if cond {
   (1, 2)
} else {
   (2, 3)
};
```

2. Appearances of unsuffixed numeric literals in args of `Call` or `MethodCall`  if corresponding arguments of their signature have concrete types, for example:
```rust
fn foo_mono(x: i32) -> i32 {
    x
}

fn foo_poly<T>(t: T) -> t {
    t
}

// Good.
let x = foo_mono(13);

// Still bad.
let x: i32 = foo_poly(13);
```

changelog: Added restriction lint: `default_numeric_fallback`
2021-02-16 09:58:49 +00:00
Yoshitomo Nakanishi
9b0c1ebc18 Change to span_lint_and_sugg from span_lint_and_help 2021-02-16 18:07:09 +09:00
bors
f28c54cd08 Auto merge of #6744 - matthiaskrgr:lintcheck, r=flip1995
more lintcheck updates

* do some refactoring and renaming here and there
* add comments to functions
* fix bug where git repos would not get checked out to the proper commits (cmd was not actually run in repo directory 😅 )
* print warnings if we can't clone or check out a git repo
* filter out noise from cargo-metadata errors and lint messages that contained absolute file paths (these would change with every pinned-nightly bump, polluting the logs)

changelog: more lintcheck refactoring and fixes for git crates
2021-02-16 08:20:17 +00:00
Yoshitomo Nakanishi
1f8ee3cc19 Handle struct ctor case 2021-02-16 11:20:51 +09:00
Matthias Krüger
a95c250372 lintcheck: update logs 2021-02-15 23:38:51 +01:00
Matthias Krüger
028692b46a lintcheck: filter out messages that come from cargo-metadata errors or contain absolute paths to rustc source files
The latter is especially annoying because the paths would change every time we bumped the pinned nightly version.
2021-02-15 23:38:50 +01:00
Matthias Krüger
8f1cceb6ff lintcheck: print warnings if we can't check out or clone a git repo 2021-02-15 22:48:33 +01:00
Matthias Krüger
f8dbcae9f4 lintcheck: fix bug in downloade_and_extract() for git sources: we need to execute "git checkout xy" inside the repo dir! 2021-02-15 22:48:32 +01:00
Matthias Krüger
214d821268 lintcheck: put some code into a gather_stats() function 2021-02-15 22:13:17 +01:00
Matthias Krüger
4856e5f8fc lintcheck: rename a few symbols, add documentation to functions 2021-02-15 22:13:17 +01:00