diff options
Diffstat (limited to 'vendor/regex-syntax/src/hir')
-rw-r--r-- | vendor/regex-syntax/src/hir/interval.rs | 4 | ||||
-rw-r--r-- | vendor/regex-syntax/src/hir/literal/mod.rs | 28 | ||||
-rw-r--r-- | vendor/regex-syntax/src/hir/mod.rs | 18 | ||||
-rw-r--r-- | vendor/regex-syntax/src/hir/translate.rs | 20 |
4 files changed, 31 insertions, 39 deletions
diff --git a/vendor/regex-syntax/src/hir/interval.rs b/vendor/regex-syntax/src/hir/interval.rs index cfaa2cb45..56698c53a 100644 --- a/vendor/regex-syntax/src/hir/interval.rs +++ b/vendor/regex-syntax/src/hir/interval.rs @@ -114,8 +114,8 @@ impl<I: Interval> IntervalSet<I> { // we're done. let drain_end = self.ranges.len(); - let mut ita = (0..drain_end).into_iter(); - let mut itb = (0..other.ranges.len()).into_iter(); + let mut ita = 0..drain_end; + let mut itb = 0..other.ranges.len(); let mut a = ita.next().unwrap(); let mut b = itb.next().unwrap(); loop { diff --git a/vendor/regex-syntax/src/hir/literal/mod.rs b/vendor/regex-syntax/src/hir/literal/mod.rs index 1e66d2cc3..fbc5d3c97 100644 --- a/vendor/regex-syntax/src/hir/literal/mod.rs +++ b/vendor/regex-syntax/src/hir/literal/mod.rs @@ -225,7 +225,7 @@ impl Literals { if self.lits.is_empty() { return self.to_empty(); } - let mut old: Vec<Literal> = self.lits.iter().cloned().collect(); + let mut old = self.lits.to_vec(); let mut new = self.to_empty(); 'OUTER: while let Some(mut candidate) = old.pop() { if candidate.is_empty() { @@ -256,15 +256,13 @@ impl Literals { old.push(lit3); lit2.clear(); } - } else { - if let Some(i) = position(&lit2, &candidate) { - lit2.cut(); - let mut new_candidate = candidate.clone(); - new_candidate.truncate(i); - new_candidate.cut(); - old.push(new_candidate); - candidate.clear(); - } + } else if let Some(i) = position(&lit2, &candidate) { + lit2.cut(); + let mut new_candidate = candidate.clone(); + new_candidate.truncate(i); + new_candidate.cut(); + old.push(new_candidate); + candidate.clear(); } // Oops, the candidate is already represented in the set. if candidate.is_empty() { @@ -793,7 +791,7 @@ fn repeat_range_literals<F: FnMut(&Hir, &mut Literals)>( f( &Hir::repetition(hir::Repetition { kind: hir::RepetitionKind::ZeroOrMore, - greedy: greedy, + greedy, hir: Box::new(e.clone()), }), lits, @@ -932,12 +930,10 @@ fn escape_unicode(bytes: &[u8]) -> String { if c.is_whitespace() { let escaped = if c as u32 <= 0x7F { escape_byte(c as u8) + } else if c as u32 <= 0xFFFF { + format!(r"\u{{{:04x}}}", c as u32) } else { - if c as u32 <= 0xFFFF { - format!(r"\u{{{:04x}}}", c as u32) - } else { - format!(r"\U{{{:08x}}}", c as u32) - } + format!(r"\U{{{:08x}}}", c as u32) }; space_escaped.push_str(&escaped); } else { diff --git a/vendor/regex-syntax/src/hir/mod.rs b/vendor/regex-syntax/src/hir/mod.rs index f5cf992e5..1096e9f05 100644 --- a/vendor/regex-syntax/src/hir/mod.rs +++ b/vendor/regex-syntax/src/hir/mod.rs @@ -243,7 +243,7 @@ impl Hir { info.set_match_empty(true); info.set_literal(false); info.set_alternation_literal(false); - Hir { kind: HirKind::Empty, info: info } + Hir { kind: HirKind::Empty, info } } /// Creates a literal HIR expression. @@ -268,7 +268,7 @@ impl Hir { info.set_match_empty(false); info.set_literal(true); info.set_alternation_literal(true); - Hir { kind: HirKind::Literal(lit), info: info } + Hir { kind: HirKind::Literal(lit), info } } /// Creates a class HIR expression. @@ -285,7 +285,7 @@ impl Hir { info.set_match_empty(false); info.set_literal(false); info.set_alternation_literal(false); - Hir { kind: HirKind::Class(class), info: info } + Hir { kind: HirKind::Class(class), info } } /// Creates an anchor assertion HIR expression. @@ -318,7 +318,7 @@ impl Hir { if let Anchor::EndLine = anchor { info.set_line_anchored_end(true); } - Hir { kind: HirKind::Anchor(anchor), info: info } + Hir { kind: HirKind::Anchor(anchor), info } } /// Creates a word boundary assertion HIR expression. @@ -345,7 +345,7 @@ impl Hir { if let WordBoundary::AsciiNegate = word_boundary { info.set_always_utf8(false); } - Hir { kind: HirKind::WordBoundary(word_boundary), info: info } + Hir { kind: HirKind::WordBoundary(word_boundary), info } } /// Creates a repetition HIR expression. @@ -372,7 +372,7 @@ impl Hir { info.set_match_empty(rep.is_match_empty() || rep.hir.is_match_empty()); info.set_literal(false); info.set_alternation_literal(false); - Hir { kind: HirKind::Repetition(rep), info: info } + Hir { kind: HirKind::Repetition(rep), info } } /// Creates a group HIR expression. @@ -389,7 +389,7 @@ impl Hir { info.set_match_empty(group.hir.is_match_empty()); info.set_literal(false); info.set_alternation_literal(false); - Hir { kind: HirKind::Group(group), info: info } + Hir { kind: HirKind::Group(group), info } } /// Returns the concatenation of the given expressions. @@ -480,7 +480,7 @@ impl Hir { }) .any(|e| e.is_line_anchored_end()), ); - Hir { kind: HirKind::Concat(exprs), info: info } + Hir { kind: HirKind::Concat(exprs), info } } } } @@ -542,7 +542,7 @@ impl Hir { let x = info.is_alternation_literal() && e.is_literal(); info.set_alternation_literal(x); } - Hir { kind: HirKind::Alternation(exprs), info: info } + Hir { kind: HirKind::Alternation(exprs), info } } } } diff --git a/vendor/regex-syntax/src/hir/translate.rs b/vendor/regex-syntax/src/hir/translate.rs index 56afbbed8..890e1608b 100644 --- a/vendor/regex-syntax/src/hir/translate.rs +++ b/vendor/regex-syntax/src/hir/translate.rs @@ -589,7 +589,7 @@ struct TranslatorI<'t, 'p> { impl<'t, 'p> TranslatorI<'t, 'p> { /// Build a new internal translator. fn new(trans: &'t Translator, pattern: &'p str) -> TranslatorI<'t, 'p> { - TranslatorI { trans: trans, pattern: pattern } + TranslatorI { trans, pattern } } /// Return a reference to the underlying translator. @@ -609,7 +609,7 @@ impl<'t, 'p> TranslatorI<'t, 'p> { /// Create a new error with the given span and error type. fn error(&self, span: Span, kind: ErrorKind) -> Error { - Error { kind: kind, pattern: self.pattern.to_string(), span: span } + Error { kind, pattern: self.pattern.to_string(), span } } /// Return a copy of the active flags. @@ -779,7 +779,7 @@ impl<'t, 'p> TranslatorI<'t, 'p> { } ast::GroupKind::NonCapturing(_) => hir::GroupKind::NonCapturing, }; - Hir::group(hir::Group { kind: kind, hir: Box::new(expr) }) + Hir::group(hir::Group { kind, hir: Box::new(expr) }) } fn hir_repetition(&self, rep: &ast::Repetition, expr: Hir) -> Hir { @@ -802,11 +802,7 @@ impl<'t, 'p> TranslatorI<'t, 'p> { }; let greedy = if self.flags().swap_greed() { !rep.greedy } else { rep.greedy }; - Hir::repetition(hir::Repetition { - kind: kind, - greedy: greedy, - hir: Box::new(expr), - }) + Hir::repetition(hir::Repetition { kind, greedy, hir: Box::new(expr) }) } fn hir_unicode_class( @@ -1238,7 +1234,7 @@ mod tests { fn hir_quest(greedy: bool, expr: Hir) -> Hir { Hir::repetition(hir::Repetition { kind: hir::RepetitionKind::ZeroOrOne, - greedy: greedy, + greedy, hir: Box::new(expr), }) } @@ -1246,7 +1242,7 @@ mod tests { fn hir_star(greedy: bool, expr: Hir) -> Hir { Hir::repetition(hir::Repetition { kind: hir::RepetitionKind::ZeroOrMore, - greedy: greedy, + greedy, hir: Box::new(expr), }) } @@ -1254,7 +1250,7 @@ mod tests { fn hir_plus(greedy: bool, expr: Hir) -> Hir { Hir::repetition(hir::Repetition { kind: hir::RepetitionKind::OneOrMore, - greedy: greedy, + greedy, hir: Box::new(expr), }) } @@ -1262,7 +1258,7 @@ mod tests { fn hir_range(greedy: bool, range: hir::RepetitionRange, expr: Hir) -> Hir { Hir::repetition(hir::Repetition { kind: hir::RepetitionKind::Range(range), - greedy: greedy, + greedy, hir: Box::new(expr), }) } |