diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index 88b1685f52f2..6973a3743c7c 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -33,7 +33,6 @@ use rustc_span::source_map::{Span, Spanned}; use rustc_span::sym; use std::cmp::Ordering; use std::collections::hash_map::Entry; -use std::ops::Bound; declare_clippy_lint! { /// ### What it does @@ -1596,7 +1595,7 @@ fn opt_parent_let<'a>(cx: &LateContext<'a>, ex: &Expr<'a>) -> Option<&'a Local<' None } -/// Gets all arms that are unbounded `PatRange`s. +/// Gets the ranges for each range pattern arm. Applies `ty` bounds for open ranges. fn all_ranges<'tcx>(cx: &LateContext<'tcx>, arms: &'tcx [Arm<'_>], ty: Ty<'tcx>) -> Vec> { arms.iter() .filter_map(|arm| { @@ -1637,6 +1636,12 @@ fn all_ranges<'tcx>(cx: &LateContext<'tcx>, arms: &'tcx [Arm<'_>], ty: Ty<'tcx>) .collect() } +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +pub enum Bound { + Included(T), + Excluded(T), +} + #[derive(Debug, Eq, PartialEq)] pub struct SpannedRange { pub span: Span, @@ -1730,8 +1735,6 @@ where value_cmp } }, - // Range patterns cannot be unbounded (yet) - (Bound::Unbounded, _) | (_, Bound::Unbounded) => unimplemented!(), (Bound::Included(a), Bound::Excluded(b)) => match a.cmp(&b) { Ordering::Equal => Ordering::Greater, other => other,