about summary refs log tree commit diff
path: root/clippy_utils/src/lib.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-03-04 18:23:39 +0000
committerbors <bors@rust-lang.org>2021-03-04 18:23:39 +0000
commit7be3a32f25f514fa376cfbdfd6e89d77d0dd350e (patch)
tree5afe82864bfe2ec03335611aa22b79e95553bb08 /clippy_utils/src/lib.rs
parent66807109613a233eb867651b32c4d36bee541c2c (diff)
parent39c5e863378270c25ef75f3ae53d908565bc2619 (diff)
Auto merge of #6843 - Jarcho:match_on_same_arms_macro, r=Manishearth
Compare empty blocks for equality based on tokens

fixes: #1390

This only considers empty blocks for now, though we should also catch something like this:

```rust
match 0 {
    0 => {
        do_something();
        trace!(0);
        0
    }
    1 => {
        do_something();
        trace!(1);
        1
    }
    x => x,
}
```

As far as I can tell there aren't any negative effects on other lints. These blocks only happen to be the same for a given compilation, not all compilations.

changelog: Fix `match_on_same_arms` and others. Only consider empty blocks equal if the tokens contained are the same.
Diffstat (limited to 'clippy_utils/src/lib.rs')
-rw-r--r--clippy_utils/src/lib.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs
index 00455d4102f..0395079901c 100644
--- a/clippy_utils/src/lib.rs
+++ b/clippy_utils/src/lib.rs
@@ -14,6 +14,7 @@ extern crate rustc_errors;
 extern crate rustc_hir;
 extern crate rustc_hir_pretty;
 extern crate rustc_infer;
+extern crate rustc_lexer;
 extern crate rustc_lint;
 extern crate rustc_middle;
 extern crate rustc_mir;