Skip to content

Commit 1316702

Browse files
committed
Auto merge of #83480 - flip1995:clippyup, r=Dylan-DPC
Update Clippy Bi-weekly Clippy update. r? `@Manishearth`
2 parents 7637fd5 + 0f1ff45 commit 1316702

File tree

413 files changed

+5719
-2856
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

413 files changed

+5719
-2856
lines changed

Cargo.lock

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -557,18 +557,20 @@ dependencies = [
557557

558558
[[package]]
559559
name = "clippy"
560-
version = "0.1.52"
560+
version = "0.1.53"
561561
dependencies = [
562562
"cargo_metadata 0.12.0",
563563
"clippy-mini-macro-test",
564564
"clippy_lints",
565565
"compiletest_rs 0.6.0",
566566
"derive-new",
567+
"quote",
567568
"regex",
568569
"rustc-workspace-hack",
569570
"rustc_tools_util 0.2.0",
570571
"semver 0.11.0",
571572
"serde",
573+
"syn",
572574
"tempfile",
573575
"tester 0.9.0",
574576
]
@@ -579,37 +581,32 @@ version = "0.2.0"
579581

580582
[[package]]
581583
name = "clippy_lints"
582-
version = "0.1.52"
584+
version = "0.1.53"
583585
dependencies = [
584586
"cargo_metadata 0.12.0",
585587
"clippy_utils",
586588
"if_chain",
587589
"itertools 0.9.0",
588590
"pulldown-cmark 0.8.0",
589591
"quine-mc_cluskey",
590-
"quote",
591592
"regex-syntax",
592593
"rustc-semver",
593594
"semver 0.11.0",
594595
"serde",
595-
"smallvec 1.6.1",
596-
"syn",
597596
"toml",
598597
"unicode-normalization",
599598
"url 2.1.1",
600599
]
601600

602601
[[package]]
603602
name = "clippy_utils"
604-
version = "0.1.52"
603+
version = "0.1.53"
605604
dependencies = [
606605
"if_chain",
607606
"itertools 0.9.0",
608607
"regex-syntax",
609608
"rustc-semver",
610609
"serde",
611-
"smallvec 1.6.1",
612-
"toml",
613610
"unicode-normalization",
614611
]
615612

src/tools/clippy/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,6 +2103,7 @@ Released 2018-09-13
21032103
[`if_let_some_result`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_let_some_result
21042104
[`if_not_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_not_else
21052105
[`if_same_then_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else
2106+
[`if_then_some_else_none`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_then_some_else_none
21062107
[`ifs_same_cond`]: https://rust-lang.github.io/rust-clippy/master/index.html#ifs_same_cond
21072108
[`implicit_clone`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_clone
21082109
[`implicit_hasher`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_hasher

src/tools/clippy/CONTRIBUTING.md

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ All contributors are expected to follow the [Rust Code of Conduct].
1818
- [Finding something to fix/improve](#finding-something-to-fiximprove)
1919
- [Writing code](#writing-code)
2020
- [Getting code-completion for rustc internals to work](#getting-code-completion-for-rustc-internals-to-work)
21+
- [IntelliJ Rust](#intellij-rust)
22+
- [Rust Analyzer](#rust-analyzer)
2123
- [How Clippy works](#how-clippy-works)
22-
- [Syncing changes between Clippy and `rust-lang/rust`](#syncing-changes-between-clippy-and-rust-langrust)
24+
- [Syncing changes between Clippy and [`rust-lang/rust`]](#syncing-changes-between-clippy-and-rust-langrust)
2325
- [Patching git-subtree to work with big repos](#patching-git-subtree-to-work-with-big-repos)
24-
- [Performing the sync from `rust-lang/rust` to Clippy](#performing-the-sync-from-rust-langrust-to-clippy)
25-
- [Performing the sync from Clippy to `rust-lang/rust`](#performing-the-sync-from-clippy-to-rust-langrust)
26+
- [Performing the sync from [`rust-lang/rust`] to Clippy](#performing-the-sync-from-rust-langrust-to-clippy)
27+
- [Performing the sync from Clippy to [`rust-lang/rust`]](#performing-the-sync-from-clippy-to-rust-langrust)
2628
- [Defining remotes](#defining-remotes)
2729
- [Issue and PR triage](#issue-and-pr-triage)
2830
- [Bors and Homu](#bors-and-homu)
@@ -105,21 +107,41 @@ quick read.
105107

106108
## Getting code-completion for rustc internals to work
107109

108-
Unfortunately, [`rust-analyzer`][ra_homepage] does not (yet?) understand how Clippy uses compiler-internals
110+
### IntelliJ Rust
111+
Unfortunately, [`IntelliJ Rust`][IntelliJ_rust_homepage] does not (yet?) understand how Clippy uses compiler-internals
109112
using `extern crate` and it also needs to be able to read the source files of the rustc-compiler which are not
110113
available via a `rustup` component at the time of writing.
111114
To work around this, you need to have a copy of the [rustc-repo][rustc_repo] available which can be obtained via
112115
`git clone https://github.com/rust-lang/rust/`.
113116
Then you can run a `cargo dev` command to automatically make Clippy use the rustc-repo via path-dependencies
114-
which rust-analyzer will be able to understand.
115-
Run `cargo dev ra_setup --repo-path <repo-path>` where `<repo-path>` is an absolute path to the rustc repo
117+
which `IntelliJ Rust` will be able to understand.
118+
Run `cargo dev ide_setup --repo-path <repo-path>` where `<repo-path>` is a path to the rustc repo
116119
you just cloned.
117120
The command will add path-dependencies pointing towards rustc-crates inside the rustc repo to
118121
Clippys `Cargo.toml`s and should allow rust-analyzer to understand most of the types that Clippy uses.
119122
Just make sure to remove the dependencies again before finally making a pull request!
120123

121-
[ra_homepage]: https://rust-analyzer.github.io/
122124
[rustc_repo]: https://github.com/rust-lang/rust/
125+
[IntelliJ_rust_homepage]: https://intellij-rust.github.io/
126+
127+
### Rust Analyzer
128+
As of [#6869][6869], [`rust-analyzer`][ra_homepage] can understand that Clippy uses compiler-internals
129+
using `extern crate` when `package.metadata.rust-analyzer.rustc_private` is set to `true` in Clippys `Cargo.toml.`
130+
You will required a `nightly` toolchain with the `rustc-dev` component installed.
131+
Make sure that in the `rust-analyzer` configuration, you set
132+
```
133+
{ "rust-analyzer.rustcSource": "discover" }
134+
```
135+
and
136+
```
137+
{ "rust-analyzer.updates.channel": "nightly" }
138+
```
139+
You should be able to see information on things like `Expr` or `EarlyContext` now if you hover them, also
140+
a lot more type hints.
141+
This will work with `rust-analyzer 2021-03-15` shipped in nightly `1.52.0-nightly (107896c32 2021-03-15)` or later.
142+
143+
[ra_homepage]: https://rust-analyzer.github.io/
144+
[6869]: https://github.com/rust-lang/rust-clippy/pull/6869
123145

124146
## How Clippy works
125147

src/tools/clippy/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.1.52"
3+
version = "0.1.53"
44
authors = ["The Rust Clippy Developers"]
55
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
66
repository = "https://github.com/rust-lang/rust-clippy"
@@ -37,6 +37,8 @@ clippy-mini-macro-test = { version = "0.2", path = "mini-macro" }
3737
serde = { version = "1.0", features = ["derive"] }
3838
derive-new = "0.5"
3939
regex = "1.4"
40+
quote = "1"
41+
syn = { version = "1", features = ["full"] }
4042

4143
# A noop dependency that changes in the Rust repository, it's a bit of a hack.
4244
# See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust`

src/tools/clippy/clippy_dev/src/fmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub fn run(check: bool, verbose: bool) {
9090
},
9191
CliError::RaSetupActive => {
9292
eprintln!(
93-
"error: a local rustc repo is enabled as path dependency via `cargo dev ra_setup`.
93+
"error: a local rustc repo is enabled as path dependency via `cargo dev ide_setup`.
9494
Not formatting because that would format the local repo as well!
9595
Please revert the changes to Cargo.tomls first."
9696
);

src/tools/clippy/clippy_dev/src/ra_setup.rs renamed to src/tools/clippy/clippy_dev/src/ide_setup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn inject_deps_into_manifest(
5555
// do not inject deps if we have aleady done so
5656
if cargo_toml.contains("[target.'cfg(NOT_A_PLATFORM)'.dependencies]") {
5757
eprintln!(
58-
"cargo dev ra_setup: warning: deps already found inside {}, doing nothing.",
58+
"cargo dev ide_setup: warning: deps already found inside {}, doing nothing.",
5959
manifest_path
6060
);
6161
return Ok(());

src/tools/clippy/clippy_dev/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use walkdir::WalkDir;
1212

1313
pub mod bless;
1414
pub mod fmt;
15+
pub mod ide_setup;
1516
pub mod new_lint;
16-
pub mod ra_setup;
1717
pub mod serve;
1818
pub mod stderr_length_check;
1919
pub mod update_lints;

src/tools/clippy/clippy_dev/src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
22

33
use clap::{App, Arg, ArgMatches, SubCommand};
4-
use clippy_dev::{bless, fmt, new_lint, ra_setup, serve, stderr_length_check, update_lints};
4+
use clippy_dev::{bless, fmt, ide_setup, new_lint, serve, stderr_length_check, update_lints};
55
fn main() {
66
let matches = get_clap_config();
77

@@ -34,7 +34,7 @@ fn main() {
3434
("limit_stderr_length", _) => {
3535
stderr_length_check::check();
3636
},
37-
("ra_setup", Some(matches)) => ra_setup::run(matches.value_of("rustc-repo-path")),
37+
("ide_setup", Some(matches)) => ide_setup::run(matches.value_of("rustc-repo-path")),
3838
("serve", Some(matches)) => {
3939
let port = matches.value_of("port").unwrap().parse().unwrap();
4040
let lint = matches.value_of("lint");
@@ -138,8 +138,8 @@ fn get_clap_config<'a>() -> ArgMatches<'a> {
138138
.about("Ensures that stderr files do not grow longer than a certain amount of lines."),
139139
)
140140
.subcommand(
141-
SubCommand::with_name("ra_setup")
142-
.about("Alter dependencies so rust-analyzer can find rustc internals")
141+
SubCommand::with_name("ide_setup")
142+
.about("Alter dependencies so Intellij Rust can find rustc internals")
143143
.arg(
144144
Arg::with_name("rustc-repo-path")
145145
.long("repo-path")

src/tools/clippy/clippy_lints/Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "clippy_lints"
33
# begin automatic update
4-
version = "0.1.52"
4+
version = "0.1.53"
55
# end automatic update
66
authors = ["The Rust Clippy Developers"]
77
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
@@ -20,16 +20,13 @@ pulldown-cmark = { version = "0.8", default-features = false }
2020
quine-mc_cluskey = "0.2.2"
2121
regex-syntax = "0.6"
2222
serde = { version = "1.0", features = ["derive"] }
23-
smallvec = { version = "1", features = ["union"] }
2423
toml = "0.5.3"
2524
unicode-normalization = "0.1"
2625
semver = "0.11"
2726
rustc-semver = "1.1.0"
2827
# NOTE: cargo requires serde feat in its url dep
2928
# see <https://github.com/rust-lang/rust/pull/63587#issuecomment-522343864>
3029
url = { version = "2.1.0", features = ["serde"] }
31-
quote = "1"
32-
syn = { version = "1", features = ["full"] }
3330

3431
[features]
3532
deny-warnings = []

src/tools/clippy/clippy_lints/src/approx_const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::utils::span_lint;
1+
use clippy_utils::diagnostics::span_lint;
22
use rustc_ast::ast::{FloatTy, LitFloatType, LitKind};
33
use rustc_hir::{Expr, ExprKind};
44
use rustc_lint::{LateContext, LateLintPass};

0 commit comments

Comments
 (0)