Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Clippy #73660

Merged
merged 66 commits into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
a4b8bb8
warn on macro_use attr
DevinR528 Feb 26, 2020
ede366b
collected all the imports and names
DevinR528 Mar 4, 2020
8ffbf6f
use hashset not map for keeping track of seen macro refs
DevinR528 Mar 13, 2020
1d9e80a
remove session
DevinR528 Mar 24, 2020
8bc106b
fix some of the review, rename, fmt, refactor
DevinR528 May 10, 2020
451363d
still working on displaying nested imports
DevinR528 May 14, 2020
d4f60b5
wip: of handling nested import paths for multi-macro paths
DevinR528 May 15, 2020
8c5a5a9
cleaned up import suggestion formatter, look into code reuse with wil…
DevinR528 May 26, 2020
288df59
Fix suggestion output, add run-rustfix to test file, stop sorting imp…
DevinR528 Jun 7, 2020
8db2484
Merge commit 'ff0993c5e9162ddaea78e83d0f0161e68bd4ea73' into clippy
tesuji Jun 9, 2020
e521a4e
Add enough attrs to the test file so the fix compiles with no errors,…
DevinR528 Jun 7, 2020
f065d4b
Auto merge of #5279 - DevinR528:macro-use-sugg, r=flip1995
bors Jun 9, 2020
a083b84
if_same_then_else: don't assume multiplication is always commutative
ebroto Jun 9, 2020
2f74283
Add a comment linking to the issue
ebroto Jun 9, 2020
7427065
Auto merge of #5702 - ebroto:5698_mul_not_comm, r=matthiaskrgr
bors Jun 9, 2020
c9bd35c
Migrate to numeric associated consts
tesuji Jun 2, 2020
6b3ee8f
Update Clippy for MethodCall changes
Aaron1011 Jun 9, 2020
e2e2a0f
Clippy fixes
Aaron1011 Jun 10, 2020
56f25e3
Downgrade unnested_or_patterns to pedantic
dtolnay Jun 11, 2020
840786a
clippy-driver: pass all args after "--rustc" to rustc.
matthiaskrgr May 31, 2020
88ab104
add test and remove debug print
matthiaskrgr Jun 2, 2020
f1d5cd5
add test for compiler output when compiling with rustc/clippy-driver
matthiaskrgr Jun 7, 2020
7a62380
clippy-driver: fix test and add --rustc to --help output
matthiaskrgr Jun 9, 2020
857ea16
Remove associated opaque types
matthewjasper May 10, 2020
af9b092
Remove ImplItemKind::OpaqueTy from clippy
matthewjasper May 10, 2020
7c15f30
Rollup merge of #72906 - lzutao:migrate-numeric-assoc-consts, r=dtolnay
Dylan-DPC Jun 12, 2020
b21ef2b
Fix ICE in consts::binop
ebroto Jun 12, 2020
994a839
Stabilize Option::zip
tesuji Jun 13, 2020
dee794f
typo
lcnr Jun 13, 2020
f663a21
Remove `bar` from blacklisted names
Jun 13, 2020
c020e45
Update stderr to match, and reinforce comments
Jun 14, 2020
454ed47
Update comment in conf.rs
Jun 14, 2020
8a6f42a
Fix typo in wildcard_imports
bugadani Jun 14, 2020
9217ef2
Auto merge of #72080 - matthewjasper:uniform-impl-trait, r=nikomatsakis
bors Jun 15, 2020
93696f4
Rollup merge of #72938 - lzutao:stabilize_option_zip, r=dtolnay
RalfJung Jun 15, 2020
8c1ee06
mem_replace_with_uninit: suggest std::ptr::read
esamudera Jun 7, 2020
a7743e9
redundant_pattern_matching: avoid non-const fn in const context
ebroto Jun 16, 2020
f3a40f5
Fix typo
sozysozbot Jun 17, 2020
922ff8e
Refactor hir::Place
arora-aman Jun 17, 2020
b92602b
Make is_freeze and is_copy_modulo_regions take TyCtxtAt
RalfJung Jun 21, 2020
e11b873
Stop using old version of `syn` in `rustc-workspace-hack`
Aaron1011 Jun 22, 2020
018440c
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Jun 23, 2020
51592f8
Fix sync fallout
flip1995 Jun 23, 2020
fa0f6a8
Auto merge of #5711 - flip1995:rustup, r=flip1995
bors Jun 23, 2020
1d077f6
Rollup merge of #73578 - RalfJung:ty-ctxt-at, r=jonas-schievink
Dylan-DPC Jun 23, 2020
c56c7e2
Auto merge of #5695 - esamudera:lint_mem_uninitialized, r=phansch,oli…
bors Jun 23, 2020
52c4864
Improve end of expression check in for loop lints
Jun 11, 2020
51c3b42
Add more specific GitHub issue templates
tesuji Jun 23, 2020
4cc2fa9
Auto merge of #5739 - flip1995:rustup, r=flip1995
bors Jun 23, 2020
ed083cc
Use lints in Clippy that are enabled in rustc bootstrap
flip1995 Jun 13, 2020
b886c06
Fix fallout
flip1995 Jun 13, 2020
7c61be6
Rollup merge of #5178 - matthiaskrgr:rustc_arg_pass, r=flip1995
flip1995 Jun 23, 2020
1f39eeb
Rollup merge of #5705 - dtolnay:orpat, r=flip1995
flip1995 Jun 23, 2020
9505919
Rollup merge of #5709 - ebroto:5389_ice, r=Manishearth
flip1995 Jun 23, 2020
24b77ea
Rollup merge of #5710 - lcnr:patch-1, r=flip1995
flip1995 Jun 23, 2020
0799be7
Rollup merge of #5712 - ijijn:master, r=flip1995
flip1995 Jun 23, 2020
598a79f
Rollup merge of #5713 - flip1995:more_lints, r=Manishearth
flip1995 Jun 23, 2020
68c0b24
Rollup merge of #5716 - bugadani:patch-1, r=matthiaskrgr
flip1995 Jun 23, 2020
f562117
Rollup merge of #5724 - ebroto:5697_const_result_option, r=Manishearth
flip1995 Jun 23, 2020
e4cbd1d
Rollup merge of #5726 - sozysozbot:patch-1, r=flip1995
flip1995 Jun 23, 2020
b452ad3
Auto merge of #5741 - flip1995:rollup-8chbwhy, r=flip1995
bors Jun 23, 2020
9504efc
Auto merge of #5735 - lzutao:issue-temp, r=flip1995
bors Jun 23, 2020
7374185
Remove unused allowed unused attributes
tesuji Jun 23, 2020
c420382
Auto merge of #5738 - mikerite:loops-20200623-2, r=matthiaskrgr
bors Jun 23, 2020
c2c07fa
Auto merge of #5740 - lzutao:unused-unused, r=flip1995
bors Jun 23, 2020
a2c0499
Merge commit 'c2c07fa9d095931eb5684a42942a7b573a0c5238' into clippyup
flip1995 Jun 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/tools/clippy/.github/ISSUE_TEMPLATE.md

This file was deleted.

4 changes: 4 additions & 0 deletions src/tools/clippy/.github/ISSUE_TEMPLATE/blank_issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
name: Blank Issue
about: Create a blank issue.
---
47 changes: 47 additions & 0 deletions src/tools/clippy/.github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: Bug Report
about: Create a bug report for Clippy
labels: L-bug
---
<!--
Thank you for filing a bug report! 🐛 Please provide a short summary of the bug,
along with any information you feel relevant to replicating the bug.
-->

I tried this code:

```rust
<code>
```

I expected to see this happen: *explanation*

Instead, this happened: *explanation*

### Meta

- `cargo clippy -V`: e.g. clippy 0.0.212 (f455e46 2020-06-20)
- `rustc -Vv`:
```
rustc 1.46.0-nightly (f455e46ea 2020-06-20)
binary: rustc
commit-hash: f455e46eae1a227d735091091144601b467e1565
commit-date: 2020-06-20
host: x86_64-unknown-linux-gnu
release: 1.46.0-nightly
LLVM version: 10.0
```

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo clippy`.
-->
<details><summary>Backtrace</summary>
<p>

```
<backtrace>
```

</p>
</details>
5 changes: 5 additions & 0 deletions src/tools/clippy/.github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: Rust Programming Language Forum
url: https://users.rust-lang.org
about: Please ask and answer questions about Rust here.
53 changes: 53 additions & 0 deletions src/tools/clippy/.github/ISSUE_TEMPLATE/ice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
name: Internal Compiler Error
about: Create a report for an internal compiler error in Clippy.
labels: L-bug, L-crash
---
<!--
Thank you for finding an Internal Compiler Error! 🧊 If possible, try to provide
a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for
how to create smaller examples.

http://blog.pnkfx.org/blog/2019/11/18/rust-bug-minimization-patterns/

-->

### Code

```rust
<code>
```

### Meta

- `cargo clippy -V`: e.g. clippy 0.0.212 (f455e46 2020-06-20)
- `rustc -Vv`:
```
rustc 1.46.0-nightly (f455e46ea 2020-06-20)
binary: rustc
commit-hash: f455e46eae1a227d735091091144601b467e1565
commit-date: 2020-06-20
host: x86_64-unknown-linux-gnu
release: 1.46.0-nightly
LLVM version: 10.0
```

### Error output

```
<output>
```

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo clippy`.
-->
<details><summary>Backtrace</summary>
<p>

```
<backtrace>
```

</p>
</details>
35 changes: 35 additions & 0 deletions src/tools/clippy/.github/ISSUE_TEMPLATE/new_lint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: New lint suggestion
about: Suggest a new Clippy lint.
labels: L-lint
---

### What it does

*What does this lint do?*

### Categories (optional)

- Kind: *See <https://github.com/rust-lang/rust-clippy/blob/master/README.md#clippy> for list of lint kinds*

*What benefit of this lint over old code?*

For example:
- Remove bounce checking inserted by ...
- Remove the need to duplicating/storing/typo ...

### Drawbacks

None.

### Example

```rust
<code>
```

Could be written as:

```rust
<code>
```
1 change: 1 addition & 0 deletions src/tools/clippy/.github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ Delete this line and everything above before opening your PR.

---

*Please keep the line below*
changelog: none
12 changes: 12 additions & 0 deletions src/tools/clippy/.github/driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,16 @@ unset CARGO_MANIFEST_DIR
sed -e "s,tests/ui,\$DIR," -e "/= help/d" cstring.stderr > normalized.stderr
diff normalized.stderr tests/ui/cstring.stderr


# make sure "clippy-driver --rustc --arg" and "rustc --arg" behave the same
SYSROOT=`rustc --print sysroot`
diff <(LD_LIBRARY_PATH=${SYSROOT}/lib ./target/debug/clippy-driver --rustc --version --verbose) <(rustc --version --verbose)


echo "fn main() {}" > target/driver_test.rs
# we can't run 2 rustcs on the same file at the same time
CLIPPY=`LD_LIBRARY_PATH=${SYSROOT}/lib ./target/debug/clippy-driver ./target/driver_test.rs --rustc`
RUSTC=`rustc ./target/driver_test.rs`
diff <($CLIPPY) <($RUSTC)

# TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
let l = self.expr(left)?;
let r = self.expr(right);
match (l, r) {
(Constant::Int(l), Some(Constant::Int(r))) => match self.tables.expr_ty(left).kind {
(Constant::Int(l), Some(Constant::Int(r))) => match self.tables.expr_ty_opt(left)?.kind {
ty::Int(ity) => {
let l = sext(self.lcx.tcx, l, ity);
let r = sext(self.lcx.tcx, r, ity);
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustc_middle::ty::{self, Ty};
use rustc_session::{declare_tool_lint, impl_lint_pass};
use rustc_span::source_map::Span;
use rustc_target::abi::LayoutOf;
use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, PlaceWithHirId, PlaceBase};
use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};

use crate::utils::span_lint;

Expand Down
3 changes: 2 additions & 1 deletion src/tools/clippy/clippy_lints/src/len_zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ fn check_impl_items(cx: &LateContext<'_, '_>, item: &Item<'_>, impl_items: &[Imp
}

fn check_cmp(cx: &LateContext<'_, '_>, span: Span, method: &Expr<'_>, lit: &Expr<'_>, op: &str, compare_to: u32) {
if let (&ExprKind::MethodCall(ref method_path, _, ref args, _), &ExprKind::Lit(ref lit)) = (&method.kind, &lit.kind) {
if let (&ExprKind::MethodCall(ref method_path, _, ref args, _), &ExprKind::Lit(ref lit)) = (&method.kind, &lit.kind)
{
// check if we are in an is_empty() method
if let Some(name) = get_item_name(cx, method) {
if name.as_str() == "is_empty" {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/let_underscore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ declare_clippy_lint! {
/// **What it does:** Checks for `let _ = sync_lock`
///
/// **Why is this bad?** This statement immediately drops the lock instead of
/// extending it's lifetime to the end of the scope, which is often not intended.
/// extending its lifetime to the end of the scope, which is often not intended.
/// To extend lock lifetime to the end of the scope, use an underscore-prefixed
/// name instead (i.e. _lock). If you want to explicitly drop the lock,
/// `std::mem::drop` conveys your intention better and is less error-prone.
Expand Down
54 changes: 15 additions & 39 deletions src/tools/clippy/clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,63 +1,44 @@
// error-pattern:cargo-clippy

#![feature(bindings_after_at)]
#![feature(box_syntax)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(concat_idents)]
#![feature(crate_visibility_modifier)]
#![feature(drain_filter)]
#![feature(or_patterns)]
#![feature(rustc_private)]
#![feature(stmt_expr_attributes)]
#![allow(clippy::missing_docs_in_private_items, clippy::must_use_candidate)]
#![recursion_limit = "512"]
#![warn(rust_2018_idioms, trivial_casts, trivial_numeric_casts)]
#![deny(rustc::internal)]
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
#![feature(crate_visibility_modifier)]
#![feature(concat_idents)]
#![feature(drain_filter)]
#![allow(clippy::missing_docs_in_private_items, clippy::must_use_candidate)]
#![warn(trivial_casts, trivial_numeric_casts)]
// warn on lints, that are included in `rust-lang/rust`s bootstrap
#![warn(rust_2018_idioms, unused_lifetimes)]
// warn on rustc internal lints
#![deny(rustc::internal)]

// FIXME: switch to something more ergonomic here, once available.
// (Currently there is no way to opt into sysroot crates without `extern crate`.)
#[allow(unused_extern_crates)]
extern crate rustc_ast;
#[allow(unused_extern_crates)]
extern crate rustc_ast_pretty;
#[allow(unused_extern_crates)]
extern crate rustc_attr;
#[allow(unused_extern_crates)]
extern crate rustc_data_structures;
#[allow(unused_extern_crates)]
extern crate rustc_driver;
#[allow(unused_extern_crates)]
extern crate rustc_errors;
#[allow(unused_extern_crates)]
extern crate rustc_hir;
#[allow(unused_extern_crates)]
extern crate rustc_hir_pretty;
#[allow(unused_extern_crates)]
extern crate rustc_index;
#[allow(unused_extern_crates)]
extern crate rustc_infer;
#[allow(unused_extern_crates)]
extern crate rustc_lexer;
#[allow(unused_extern_crates)]
extern crate rustc_lint;
#[allow(unused_extern_crates)]
extern crate rustc_middle;
#[allow(unused_extern_crates)]
extern crate rustc_mir;
#[allow(unused_extern_crates)]
extern crate rustc_parse;
#[allow(unused_extern_crates)]
extern crate rustc_parse_format;
#[allow(unused_extern_crates)]
extern crate rustc_session;
#[allow(unused_extern_crates)]
extern crate rustc_span;
#[allow(unused_extern_crates)]
extern crate rustc_target;
#[allow(unused_extern_crates)]
extern crate rustc_trait_selection;
#[allow(unused_extern_crates)]
extern crate rustc_typeck;

use rustc_data_structures::fx::FxHashSet;
Expand All @@ -82,14 +63,10 @@ use rustc_session::Session;
/// # Example
///
/// ```
/// # #![feature(rustc_private)]
/// # #[allow(unused_extern_crates)]
/// # extern crate rustc_middle;
/// # #[allow(unused_extern_crates)]
/// # extern crate rustc_session;
/// # #[macro_use]
/// # use clippy_lints::declare_clippy_lint;
/// #![feature(rustc_private)]
/// extern crate rustc_session;
/// use rustc_session::declare_tool_lint;
/// use clippy_lints::declare_clippy_lint;
///
/// declare_clippy_lint! {
/// /// **What it does:** Checks for ... (describe what the lint matches).
Expand Down Expand Up @@ -1062,7 +1039,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
store.register_early_pass(|| box option_env_unwrap::OptionEnvUnwrap);
let warn_on_all_wildcard_imports = conf.warn_on_all_wildcard_imports;
store.register_late_pass(move || box wildcard_imports::WildcardImports::new(warn_on_all_wildcard_imports));
store.register_early_pass(|| box macro_use::MacroUseImports);
store.register_late_pass(|| box verbose_file_reads::VerboseFileReads);
store.register_late_pass(|| box redundant_pub_crate::RedundantPubCrate::default());
store.register_late_pass(|| box unnamed_address::UnnamedAddress);
Expand All @@ -1080,6 +1056,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
single_char_binding_names_threshold,
});
store.register_early_pass(|| box unnested_or_patterns::UnnestedOrPatterns);
store.register_late_pass(|| box macro_use::MacroUseImports::default());

store.register_group(true, "clippy::restriction", Some("clippy_restriction"), vec![
LintId::of(&arithmetic::FLOAT_ARITHMETIC),
Expand Down Expand Up @@ -1187,6 +1164,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&types::OPTION_OPTION),
LintId::of(&unicode::NON_ASCII_LITERAL),
LintId::of(&unicode::UNICODE_NOT_NFC),
LintId::of(&unnested_or_patterns::UNNESTED_OR_PATTERNS),
LintId::of(&unused_self::UNUSED_SELF),
LintId::of(&wildcard_imports::ENUM_GLOB_USE),
LintId::of(&wildcard_imports::WILDCARD_IMPORTS),
Expand Down Expand Up @@ -1440,7 +1418,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&unnamed_address::FN_ADDRESS_COMPARISONS),
LintId::of(&unnamed_address::VTABLE_ADDRESS_COMPARISONS),
LintId::of(&unnecessary_sort_by::UNNECESSARY_SORT_BY),
LintId::of(&unnested_or_patterns::UNNESTED_OR_PATTERNS),
LintId::of(&unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME),
LintId::of(&unused_io_amount::UNUSED_IO_AMOUNT),
LintId::of(&unwrap::PANICKING_UNWRAP),
Expand Down Expand Up @@ -1624,7 +1601,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&types::UNNECESSARY_CAST),
LintId::of(&types::VEC_BOX),
LintId::of(&unnecessary_sort_by::UNNECESSARY_SORT_BY),
LintId::of(&unnested_or_patterns::UNNESTED_OR_PATTERNS),
LintId::of(&unwrap::UNNECESSARY_UNWRAP),
LintId::of(&useless_conversion::USELESS_CONVERSION),
LintId::of(&zero_div_zero::ZERO_DIVIDED_BY_ZERO),
Expand Down
Loading