Skip to content

Commit

Permalink
Auto merge of #8232 - Jarcho:match_same_arm_860, r=xFrednet
Browse files Browse the repository at this point in the history
`match_same_arms` fix

fixes #860
fixes #1140

changelog: Don't lint `match_same_arms` when an interposing arm's pattern would overlap
  • Loading branch information
bors committed Mar 21, 2022
2 parents 4a07662 + 773d203 commit f07ee8a
Show file tree
Hide file tree
Showing 7 changed files with 618 additions and 249 deletions.
15 changes: 7 additions & 8 deletions clippy_lints/src/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,12 +637,6 @@ fn check_code(cx: &LateContext<'_>, text: &str, edition: Edition, span: Span) {
loop {
match parser.parse_item(ForceCollect::No) {
Ok(Some(item)) => match &item.kind {
// Tests with one of these items are ignored
ItemKind::Static(..)
| ItemKind::Const(..)
| ItemKind::ExternCrate(..)
| ItemKind::ForeignMod(..) => return false,
// We found a main function ...
ItemKind::Fn(box Fn {
sig, body: Some(block), ..
}) if item.ident.name == sym::main => {
Expand All @@ -661,8 +655,13 @@ fn check_code(cx: &LateContext<'_>, text: &str, edition: Edition, span: Span) {
return false;
}
},
// Another function was found; this case is ignored too
ItemKind::Fn(..) => return false,
// Tests with one of these items are ignored
ItemKind::Static(..)
| ItemKind::Const(..)
| ItemKind::ExternCrate(..)
| ItemKind::ForeignMod(..)
// Another function was found; this case is ignored
| ItemKind::Fn(..) => return false,
_ => {},
},
Ok(None) => break,
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

// FIXME: switch to something more ergonomic here, once available.
// (Currently there is no way to opt into sysroot crates without `extern crate`.)
extern crate rustc_arena;
extern crate rustc_ast;
extern crate rustc_ast_pretty;
extern crate rustc_attr;
Expand Down
Loading

0 comments on commit f07ee8a

Please sign in to comment.