mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-22 20:53:21 +00:00
Merge pull request #1477 from tomprince/support-exclusive-patterns
Fix #1476: Add support for exclusive pattern matches.
This commit is contained in:
commit
34399d4508
4 changed files with 8 additions and 5 deletions
|
@ -14,7 +14,6 @@
|
|||
#![allow(indexing_slicing, shadow_reuse, unknown_lints, missing_docs_in_private_items)]
|
||||
#![allow(needless_lifetimes)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate syntax;
|
||||
#[macro_use]
|
||||
extern crate rustc;
|
||||
|
|
|
@ -361,7 +361,7 @@ fn all_ranges(cx: &LateContext, arms: &[Arm]) -> Vec<SpannedRange<ConstVal>> {
|
|||
}
|
||||
.filter_map(|pat| {
|
||||
if_let_chain! {[
|
||||
let PatKind::Range(ref lhs, ref rhs) = pat.node,
|
||||
let PatKind::Range(ref lhs, ref rhs, _) = pat.node,
|
||||
let Ok(lhs) = constcx.eval(lhs, ExprTypeChecked),
|
||||
let Ok(rhs) = constcx.eval(rhs, ExprTypeChecked)
|
||||
], {
|
||||
|
|
|
@ -160,8 +160,8 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
|
|||
(&PatKind::Tuple(ref l, ls), &PatKind::Tuple(ref r, rs)) => {
|
||||
ls == rs && over(l, r, |l, r| self.eq_pat(l, r))
|
||||
},
|
||||
(&PatKind::Range(ref ls, ref le), &PatKind::Range(ref rs, ref re)) => {
|
||||
self.eq_expr(ls, rs) && self.eq_expr(le, re)
|
||||
(&PatKind::Range(ref ls, ref le, ref li), &PatKind::Range(ref rs, ref re, ref ri)) => {
|
||||
self.eq_expr(ls, rs) && self.eq_expr(le, re) && (*li == *ri)
|
||||
},
|
||||
(&PatKind::Ref(ref le, ref lm), &PatKind::Ref(ref re, ref rm)) => lm == rm && self.eq_pat(le, re),
|
||||
(&PatKind::Slice(ref ls, ref li, ref le), &PatKind::Slice(ref rs, ref ri, ref re)) => {
|
||||
|
|
|
@ -475,10 +475,14 @@ fn print_pat(cx: &LateContext, pat: &hir::Pat, indent: usize) {
|
|||
println!("{}Lit", ind);
|
||||
print_expr(cx, e, indent + 1);
|
||||
},
|
||||
hir::PatKind::Range(ref l, ref r) => {
|
||||
hir::PatKind::Range(ref l, ref r, ref range_end) => {
|
||||
println!("{}Range", ind);
|
||||
print_expr(cx, l, indent + 1);
|
||||
print_expr(cx, r, indent + 1);
|
||||
match *range_end {
|
||||
hir::RangeEnd::Included => println!("{} end included", ind),
|
||||
hir::RangeEnd::Excluded => println!("{} end excluded", ind),
|
||||
}
|
||||
},
|
||||
hir::PatKind::Slice(ref first_pats, ref range, ref last_pats) => {
|
||||
println!("{}Slice [a, b, ..i, y, z]", ind);
|
||||
|
|
Loading…
Reference in a new issue