diff options
author | Joel Galenson <jgalenson@google.com> | 2021-06-09 19:51:38 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-06-09 19:51:38 +0000 |
commit | 3b80d632b3ddbf2602e90d47bd6832e81f04fa75 (patch) | |
tree | c87d3b69913b6ba520beb4da61426189f261255d | |
parent | 9680965206267ba3d96ade6922ffc95c31aaff12 (diff) | |
parent | fa30359d0447d0675f831619efa17ec7ec7b7f26 (diff) | |
download | regex-syntax-3b80d632b3ddbf2602e90d47bd6832e81f04fa75.tar.gz |
Upgrade rust/crates/regex-syntax to 0.6.25 am: 59bc14ef6a am: fa30359d04
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/regex-syntax/+/1713168
Change-Id: Iaa8e977daba897d30d60078fcdc68b80be6ef13f
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 4 | ||||
-rw-r--r-- | Cargo.toml | 3 | ||||
-rw-r--r-- | Cargo.toml.orig | 3 | ||||
-rw-r--r-- | METADATA | 8 | ||||
-rw-r--r-- | TEST_MAPPING | 6 | ||||
-rw-r--r-- | benches/bench.rs | 1 | ||||
-rw-r--r-- | src/ast/mod.rs | 16 | ||||
-rw-r--r-- | src/ast/parse.rs | 27 | ||||
-rw-r--r-- | src/ast/print.rs | 32 | ||||
-rw-r--r-- | src/ast/visitor.rs | 6 | ||||
-rw-r--r-- | src/error.rs | 12 | ||||
-rw-r--r-- | src/hir/interval.rs | 6 | ||||
-rw-r--r-- | src/hir/literal/mod.rs | 12 | ||||
-rw-r--r-- | src/hir/mod.rs | 28 | ||||
-rw-r--r-- | src/hir/print.rs | 8 | ||||
-rw-r--r-- | src/hir/translate.rs | 30 | ||||
-rw-r--r-- | src/hir/visitor.rs | 2 | ||||
-rw-r--r-- | src/lib.rs | 6 | ||||
-rw-r--r-- | src/parser.rs | 6 | ||||
-rw-r--r-- | src/unicode.rs | 46 | ||||
-rw-r--r-- | src/utf8.rs | 12 | ||||
-rwxr-xr-x | test | 2 |
23 files changed, 142 insertions, 136 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index b83ed4c..3d660d5 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "5a3570163b7e998b62ee9315522c37465b3cd12b" + "sha1": "3ea9e3eca7b762c30fbc09205522e3935cd70052" } } @@ -43,7 +43,7 @@ rust_library { host_supported: true, crate_name: "regex_syntax", srcs: ["src/lib.rs"], - edition: "2015", + edition: "2018", features: [ "default", "unicode", @@ -63,7 +63,7 @@ rust_defaults { srcs: ["src/lib.rs"], test_suites: ["general-tests"], auto_gen_config: true, - edition: "2015", + edition: "2018", features: [ "default", "unicode", @@ -11,8 +11,9 @@ # will likely look very different (and much more reasonable) [package] +edition = "2018" name = "regex-syntax" -version = "0.6.23" +version = "0.6.25" authors = ["The Rust Project Developers"] description = "A regular expression parser." homepage = "https://github.com/rust-lang/regex" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 8461178..1359aa1 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "regex-syntax" -version = "0.6.23" #:version +version = "0.6.25" #:version authors = ["The Rust Project Developers"] license = "MIT/Apache-2.0" repository = "https://github.com/rust-lang/regex" @@ -8,6 +8,7 @@ documentation = "https://docs.rs/regex-syntax" homepage = "https://github.com/rust-lang/regex" description = "A regular expression parser." workspace = ".." +edition = "2018" # Features are documented in the "Crate features" section of the crate docs: # https://docs.rs/regex-syntax/*/#crate-features @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/regex-syntax/regex-syntax-0.6.23.crate" + value: "https://static.crates.io/crates/regex-syntax/regex-syntax-0.6.25.crate" } - version: "0.6.23" + version: "0.6.25" license_type: NOTICE last_upgrade_date { year: 2021 - month: 4 - day: 1 + month: 5 + day: 19 } } diff --git a/TEST_MAPPING b/TEST_MAPPING index 695cd9b..3625313 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -2,16 +2,16 @@ { "presubmit": [ { - "name": "regex-syntax_device_test_src_lib" + "name": "keystore2_test" }, { "name": "libsqlite3-sys_device_test_src_lib" }, { - "name": "vpnprofilestore_test" + "name": "regex-syntax_device_test_src_lib" }, { - "name": "keystore2_test" + "name": "vpnprofilestore_test" } ] } diff --git a/benches/bench.rs b/benches/bench.rs index ba7f81c..d4703d4 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -1,6 +1,5 @@ #![feature(test)] -extern crate regex_syntax; extern crate test; use regex_syntax::Parser; diff --git a/src/ast/mod.rs b/src/ast/mod.rs index 7179f2d..9b9127b 100644 --- a/src/ast/mod.rs +++ b/src/ast/mod.rs @@ -6,7 +6,7 @@ use std::cmp::Ordering; use std::error; use std::fmt; -pub use ast::visitor::{visit, Visitor}; +pub use crate::ast::visitor::{visit, Visitor}; pub mod parse; pub mod print; @@ -220,13 +220,13 @@ impl error::Error for Error { } impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - ::error::Formatter::from(self).fmt(f) + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + crate::error::Formatter::from(self).fmt(f) } } impl fmt::Display for ErrorKind { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use self::ErrorKind::*; match *self { CaptureLimitExceeded => write!( @@ -328,7 +328,7 @@ pub struct Span { } impl fmt::Debug for Span { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "Span({:?}, {:?})", self.start, self.end) } } @@ -361,7 +361,7 @@ pub struct Position { } impl fmt::Debug for Position { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!( f, "Position(o: {:?}, l: {:?}, c: {:?})", @@ -542,8 +542,8 @@ impl Ast { /// This implementation uses constant stack space and heap space proportional /// to the size of the `Ast`. impl fmt::Display for Ast { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use ast::print::Printer; + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + use crate::ast::print::Printer; Printer::new().print(self, f) } } diff --git a/src/ast/parse.rs b/src/ast/parse.rs index 55c5f79..e62a7c2 100644 --- a/src/ast/parse.rs +++ b/src/ast/parse.rs @@ -7,10 +7,10 @@ use std::cell::{Cell, RefCell}; use std::mem; use std::result; -use ast::{self, Ast, Position, Span}; -use either::Either; +use crate::ast::{self, Ast, Position, Span}; +use crate::either::Either; -use is_meta_character; +use crate::is_meta_character; type Result<T> = result::Result<T, ast::Error>; @@ -58,10 +58,10 @@ impl Primitive { /// then return an error. fn into_class_set_item<P: Borrow<Parser>>( self, - p: &ParserI<P>, + p: &ParserI<'_, P>, ) -> Result<ast::ClassSetItem> { use self::Primitive::*; - use ast::ClassSetItem; + use crate::ast::ClassSetItem; match self { Literal(lit) => Ok(ClassSetItem::Literal(lit)), @@ -79,7 +79,7 @@ impl Primitive { /// dot), then return an error. fn into_class_literal<P: Borrow<Parser>>( self, - p: &ParserI<P>, + p: &ParserI<'_, P>, ) -> Result<ast::Literal> { use self::Primitive::*; @@ -2137,7 +2137,7 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> { /// A type that traverses a fully parsed Ast and checks whether its depth /// exceeds the specified nesting limit. If it does, then an error is returned. #[derive(Debug)] -struct NestLimiter<'p, 's: 'p, P: 'p + 's> { +struct NestLimiter<'p, 's, P> { /// The parser that is checking the nest limit. p: &'p ParserI<'s, P>, /// The current depth while walking an Ast. @@ -2312,7 +2312,7 @@ mod tests { use std::ops::Range; use super::{Parser, ParserBuilder, ParserI, Primitive}; - use ast::{self, Ast, Position, Span}; + use crate::ast::{self, Ast, Position, Span}; // Our own assert_eq, which has slightly better formatting (but honestly // still kind of crappy). @@ -2357,21 +2357,24 @@ mod tests { str.to_string() } - fn parser(pattern: &str) -> ParserI<Parser> { + fn parser(pattern: &str) -> ParserI<'_, Parser> { ParserI::new(Parser::new(), pattern) } - fn parser_octal(pattern: &str) -> ParserI<Parser> { + fn parser_octal(pattern: &str) -> ParserI<'_, Parser> { let parser = ParserBuilder::new().octal(true).build(); ParserI::new(parser, pattern) } - fn parser_nest_limit(pattern: &str, nest_limit: u32) -> ParserI<Parser> { + fn parser_nest_limit( + pattern: &str, + nest_limit: u32, + ) -> ParserI<'_, Parser> { let p = ParserBuilder::new().nest_limit(nest_limit).build(); ParserI::new(p, pattern) } - fn parser_ignore_whitespace(pattern: &str) -> ParserI<Parser> { + fn parser_ignore_whitespace(pattern: &str) -> ParserI<'_, Parser> { let p = ParserBuilder::new().ignore_whitespace(true).build(); ParserI::new(p, pattern) } diff --git a/src/ast/print.rs b/src/ast/print.rs index 1b9bc41..283ce4c 100644 --- a/src/ast/print.rs +++ b/src/ast/print.rs @@ -4,8 +4,8 @@ This module provides a regular expression printer for `Ast`. use std::fmt; -use ast::visitor::{self, Visitor}; -use ast::{self, Ast}; +use crate::ast::visitor::{self, Visitor}; +use crate::ast::{self, Ast}; /// A builder for constructing a printer. /// @@ -86,7 +86,7 @@ impl<'p, W: fmt::Write> Visitor for Writer<'p, W> { } fn visit_post(&mut self, ast: &Ast) -> fmt::Result { - use ast::Class; + use crate::ast::Class; match *ast { Ast::Empty(_) => Ok(()), @@ -126,7 +126,7 @@ impl<'p, W: fmt::Write> Visitor for Writer<'p, W> { &mut self, ast: &ast::ClassSetItem, ) -> Result<(), Self::Err> { - use ast::ClassSetItem::*; + use crate::ast::ClassSetItem::*; match *ast { Empty(_) => Ok(()), @@ -155,7 +155,7 @@ impl<'p, W: fmt::Write> Visitor for Writer<'p, W> { impl<'p, W: fmt::Write> Writer<'p, W> { fn fmt_group_pre(&mut self, ast: &ast::Group) -> fmt::Result { - use ast::GroupKind::*; + use crate::ast::GroupKind::*; match ast.kind { CaptureIndex(_) => self.wtr.write_str("("), CaptureName(ref x) => { @@ -178,7 +178,7 @@ impl<'p, W: fmt::Write> Writer<'p, W> { } fn fmt_repetition(&mut self, ast: &ast::Repetition) -> fmt::Result { - use ast::RepetitionKind::*; + use crate::ast::RepetitionKind::*; match ast.op.kind { ZeroOrOne if ast.greedy => self.wtr.write_str("?"), ZeroOrOne => self.wtr.write_str("??"), @@ -200,7 +200,7 @@ impl<'p, W: fmt::Write> Writer<'p, W> { &mut self, ast: &ast::RepetitionRange, ) -> fmt::Result { - use ast::RepetitionRange::*; + use crate::ast::RepetitionRange::*; match *ast { Exactly(x) => write!(self.wtr, "{{{}}}", x), AtLeast(x) => write!(self.wtr, "{{{},}}", x), @@ -209,7 +209,7 @@ impl<'p, W: fmt::Write> Writer<'p, W> { } fn fmt_literal(&mut self, ast: &ast::Literal) -> fmt::Result { - use ast::LiteralKind::*; + use crate::ast::LiteralKind::*; match ast.kind { Verbatim => self.wtr.write_char(ast.c), @@ -256,7 +256,7 @@ impl<'p, W: fmt::Write> Writer<'p, W> { } fn fmt_assertion(&mut self, ast: &ast::Assertion) -> fmt::Result { - use ast::AssertionKind::*; + use crate::ast::AssertionKind::*; match ast.kind { StartLine => self.wtr.write_str("^"), EndLine => self.wtr.write_str("$"), @@ -275,7 +275,7 @@ impl<'p, W: fmt::Write> Writer<'p, W> { } fn fmt_flags(&mut self, ast: &ast::Flags) -> fmt::Result { - use ast::{Flag, FlagsItemKind}; + use crate::ast::{Flag, FlagsItemKind}; for item in &ast.items { match item.kind { @@ -315,7 +315,7 @@ impl<'p, W: fmt::Write> Writer<'p, W> { &mut self, ast: &ast::ClassSetBinaryOpKind, ) -> fmt::Result { - use ast::ClassSetBinaryOpKind::*; + use crate::ast::ClassSetBinaryOpKind::*; match *ast { Intersection => self.wtr.write_str("&&"), Difference => self.wtr.write_str("--"), @@ -324,7 +324,7 @@ impl<'p, W: fmt::Write> Writer<'p, W> { } fn fmt_class_perl(&mut self, ast: &ast::ClassPerl) -> fmt::Result { - use ast::ClassPerlKind::*; + use crate::ast::ClassPerlKind::*; match ast.kind { Digit if ast.negated => self.wtr.write_str(r"\D"), Digit => self.wtr.write_str(r"\d"), @@ -336,7 +336,7 @@ impl<'p, W: fmt::Write> Writer<'p, W> { } fn fmt_class_ascii(&mut self, ast: &ast::ClassAscii) -> fmt::Result { - use ast::ClassAsciiKind::*; + use crate::ast::ClassAsciiKind::*; match ast.kind { Alnum if ast.negated => self.wtr.write_str("[:^alnum:]"), Alnum => self.wtr.write_str("[:alnum:]"), @@ -370,8 +370,8 @@ impl<'p, W: fmt::Write> Writer<'p, W> { } fn fmt_class_unicode(&mut self, ast: &ast::ClassUnicode) -> fmt::Result { - use ast::ClassUnicodeKind::*; - use ast::ClassUnicodeOpKind::*; + use crate::ast::ClassUnicodeKind::*; + use crate::ast::ClassUnicodeOpKind::*; if ast.negated { self.wtr.write_str(r"\P")?; @@ -397,7 +397,7 @@ impl<'p, W: fmt::Write> Writer<'p, W> { #[cfg(test)] mod tests { use super::Printer; - use ast::parse::ParserBuilder; + use crate::ast::parse::ParserBuilder; fn roundtrip(given: &str) { roundtrip_with(|b| b, given); diff --git a/src/ast/visitor.rs b/src/ast/visitor.rs index 3eaa4b0..a0d1e7d 100644 --- a/src/ast/visitor.rs +++ b/src/ast/visitor.rs @@ -1,6 +1,6 @@ use std::fmt; -use ast::{self, Ast}; +use crate::ast::{self, Ast}; /// A trait for visiting an abstract syntax tree (AST) in depth first order. /// @@ -478,7 +478,7 @@ impl<'a> ClassInduct<'a> { } impl<'a> fmt::Debug for ClassFrame<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let x = match *self { ClassFrame::Union { .. } => "Union", ClassFrame::Binary { .. } => "Binary", @@ -490,7 +490,7 @@ impl<'a> fmt::Debug for ClassFrame<'a> { } impl<'a> fmt::Debug for ClassInduct<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let x = match *self { ClassInduct::Item(it) => match *it { ast::ClassSetItem::Empty(_) => "Item(Empty)", diff --git a/src/error.rs b/src/error.rs index 93c2b0d..71cfa42 100644 --- a/src/error.rs +++ b/src/error.rs @@ -3,8 +3,8 @@ use std::error; use std::fmt; use std::result; -use ast; -use hir; +use crate::ast; +use crate::hir; /// A type alias for dealing with errors returned by this crate. pub type Result<T> = result::Result<T, Error>; @@ -52,7 +52,7 @@ impl error::Error for Error { } impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Error::Parse(ref x) => x.fmt(f), Error::Translate(ref x) => x.fmt(f), @@ -67,7 +67,7 @@ impl fmt::Display for Error { /// readable format. Most of its complexity is from interspersing notational /// markers pointing out the position where an error occurred. #[derive(Debug)] -pub struct Formatter<'e, E: 'e> { +pub struct Formatter<'e, E> { /// The original regex pattern in which the error occurred. pattern: &'e str, /// The error kind. It must impl fmt::Display. @@ -102,7 +102,7 @@ impl<'e> From<&'e hir::Error> for Formatter<'e, hir::ErrorKind> { } impl<'e, E: fmt::Display> fmt::Display for Formatter<'e, E> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let spans = Spans::from_formatter(self); if self.pattern.contains('\n') { let divider = repeat_char('~', 79); @@ -286,7 +286,7 @@ fn repeat_char(c: char, count: usize) -> String { #[cfg(test)] mod tests { - use ast::parse::Parser; + use crate::ast::parse::Parser; fn assert_panic_message(pattern: &str, expected_msg: &str) -> () { let result = Parser::new().parse(pattern); diff --git a/src/hir/interval.rs b/src/hir/interval.rs index 51eed52..cfaa2cb 100644 --- a/src/hir/interval.rs +++ b/src/hir/interval.rs @@ -4,7 +4,7 @@ use std::fmt::Debug; use std::slice; use std::u8; -use unicode; +use crate::unicode; // This module contains an *internal* implementation of interval sets. // @@ -60,7 +60,7 @@ impl<I: Interval> IntervalSet<I> { /// Return an iterator over all intervals in this set. /// /// The iterator yields intervals in ascending order. - pub fn iter(&self) -> IntervalSetIter<I> { + pub fn iter(&self) -> IntervalSetIter<'_, I> { IntervalSetIter(self.ranges.iter()) } @@ -322,7 +322,7 @@ impl<I: Interval> IntervalSet<I> { /// An iterator over intervals. #[derive(Debug)] -pub struct IntervalSetIter<'a, I: 'a>(slice::Iter<'a, I>); +pub struct IntervalSetIter<'a, I>(slice::Iter<'a, I>); impl<'a, I> Iterator for IntervalSetIter<'a, I> { type Item = &'a I; diff --git a/src/hir/literal/mod.rs b/src/hir/literal/mod.rs index 3ba225c..25ee88b 100644 --- a/src/hir/literal/mod.rs +++ b/src/hir/literal/mod.rs @@ -8,7 +8,7 @@ use std::iter; use std::mem; use std::ops; -use hir::{self, Hir, HirKind}; +use crate::hir::{self, Hir, HirKind}; /// A set of literal byte strings extracted from a regular expression. /// @@ -838,7 +838,7 @@ fn alternate_literals<F: FnMut(&Hir, &mut Literals)>( } impl fmt::Debug for Literals { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Literals") .field("lits", &self.lits) .field("limit_size", &self.limit_size) @@ -882,7 +882,7 @@ impl PartialOrd for Literal { } impl fmt::Debug for Literal { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if self.is_cut() { write!(f, "Cut({})", escape_unicode(&self.v)) } else { @@ -977,8 +977,8 @@ mod tests { use std::fmt; use super::{escape_bytes, Literal, Literals}; - use hir::Hir; - use ParserBuilder; + use crate::hir::Hir; + use crate::ParserBuilder; // To make test failures easier to read. #[derive(Debug, Eq, PartialEq)] @@ -1017,7 +1017,7 @@ mod tests { } impl fmt::Debug for ULiteral { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if self.is_cut() { write!(f, "Cut({})", self.v) } else { diff --git a/src/hir/mod.rs b/src/hir/mod.rs index 53d90b8..4969f12 100644 --- a/src/hir/mod.rs +++ b/src/hir/mod.rs @@ -8,12 +8,12 @@ use std::fmt; use std::result; use std::u8; -use ast::Span; -use hir::interval::{Interval, IntervalSet, IntervalSetIter}; -use unicode; +use crate::ast::Span; +use crate::hir::interval::{Interval, IntervalSet, IntervalSetIter}; +use crate::unicode; -pub use hir::visitor::{visit, Visitor}; -pub use unicode::CaseFoldError; +pub use crate::hir::visitor::{visit, Visitor}; +pub use crate::unicode::CaseFoldError; mod interval; pub mod literal; @@ -123,13 +123,13 @@ impl error::Error for Error { } impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - ::error::Formatter::from(self).fmt(f) + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + crate::error::Formatter::from(self).fmt(f) } } impl fmt::Display for ErrorKind { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // TODO: Remove this on the next breaking semver release. #[allow(deprecated)] f.write_str(self.description()) @@ -727,8 +727,8 @@ impl HirKind { /// This implementation uses constant stack space and heap space proportional /// to the size of the `Hir`. impl fmt::Display for Hir { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use hir::print::Printer; + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + use crate::hir::print::Printer; Printer::new().print(self, f) } } @@ -859,7 +859,7 @@ impl ClassUnicode { /// Return an iterator over all ranges in this class. /// /// The iterator yields ranges in ascending order. - pub fn iter(&self) -> ClassUnicodeIter { + pub fn iter(&self) -> ClassUnicodeIter<'_> { ClassUnicodeIter(self.set.iter()) } @@ -972,7 +972,7 @@ pub struct ClassUnicodeRange { } impl fmt::Debug for ClassUnicodeRange { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let start = if !self.start.is_whitespace() && !self.start.is_control() { self.start.to_string() @@ -1102,7 +1102,7 @@ impl ClassBytes { /// Return an iterator over all ranges in this class. /// /// The iterator yields ranges in ascending order. - pub fn iter(&self) -> ClassBytesIter { + pub fn iter(&self) -> ClassBytesIter<'_> { ClassBytesIter(self.set.iter()) } @@ -1258,7 +1258,7 @@ impl ClassBytesRange { } impl fmt::Debug for ClassBytesRange { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut debug = f.debug_struct("ClassBytesRange"); if self.start <= 0x7F { debug.field("start", &(self.start as char)); diff --git a/src/hir/print.rs b/src/hir/print.rs index eb44b93..ff18c6e 100644 --- a/src/hir/print.rs +++ b/src/hir/print.rs @@ -4,9 +4,9 @@ This module provides a regular expression printer for `Hir`. use std::fmt; -use hir::visitor::{self, Visitor}; -use hir::{self, Hir, HirKind}; -use is_meta_character; +use crate::hir::visitor::{self, Visitor}; +use crate::hir::{self, Hir, HirKind}; +use crate::is_meta_character; /// A builder for constructing a printer. /// @@ -239,7 +239,7 @@ impl<'p, W: fmt::Write> Writer<'p, W> { #[cfg(test)] mod tests { use super::Printer; - use ParserBuilder; + use crate::ParserBuilder; fn roundtrip(given: &str, expected: &str) { roundtrip_with(|b| b, given, expected); diff --git a/src/hir/translate.rs b/src/hir/translate.rs index 44d2813..99c9493 100644 --- a/src/hir/translate.rs +++ b/src/hir/translate.rs @@ -5,9 +5,9 @@ Defines a translator that converts an `Ast` to an `Hir`. use std::cell::{Cell, RefCell}; use std::result; -use ast::{self, Ast, Span, Visitor}; -use hir::{self, Error, ErrorKind, Hir}; -use unicode::{self, ClassQuery}; +use crate::ast::{self, Ast, Span, Visitor}; +use crate::hir::{self, Error, ErrorKind, Hir}; +use crate::unicode::{self, ClassQuery}; type Result<T> = result::Result<T, Error>; @@ -533,7 +533,7 @@ impl<'t, 'p> Visitor for TranslatorI<'t, 'p> { &mut self, op: &ast::ClassSetBinaryOp, ) -> Result<()> { - use ast::ClassSetBinaryOpKind::*; + use crate::ast::ClassSetBinaryOpKind::*; if self.flags().unicode() { let mut rhs = self.pop().unwrap().unwrap_class_unicode(); @@ -819,7 +819,7 @@ impl<'t, 'p> TranslatorI<'t, 'p> { &self, ast_class: &ast::ClassUnicode, ) -> Result<hir::ClassUnicode> { - use ast::ClassUnicodeKind::*; + use crate::ast::ClassUnicodeKind::*; if !self.flags().unicode() { return Err( @@ -857,7 +857,7 @@ impl<'t, 'p> TranslatorI<'t, 'p> { &self, ast_class: &ast::ClassPerl, ) -> Result<hir::ClassUnicode> { - use ast::ClassPerlKind::*; + use crate::ast::ClassPerlKind::*; assert!(self.flags().unicode()); let result = match ast_class.kind { @@ -879,7 +879,7 @@ impl<'t, 'p> TranslatorI<'t, 'p> { &self, ast_class: &ast::ClassPerl, ) -> hir::ClassBytes { - use ast::ClassPerlKind::*; + use crate::ast::ClassPerlKind::*; assert!(!self.flags().unicode()); let mut class = match ast_class.kind { @@ -1077,7 +1077,7 @@ fn hir_ascii_class_bytes(kind: &ast::ClassAsciiKind) -> hir::ClassBytes { } fn ascii_class(kind: &ast::ClassAsciiKind) -> &'static [(char, char)] { - use ast::ClassAsciiKind::*; + use crate::ast::ClassAsciiKind::*; match *kind { Alnum => &[('0', '9'), ('A', 'Z'), ('a', 'z')], Alpha => &[('A', 'Z'), ('a', 'z')], @@ -1105,10 +1105,10 @@ fn ascii_class(kind: &ast::ClassAsciiKind) -> &'static [(char, char)] { #[cfg(test)] mod tests { - use ast::parse::ParserBuilder; - use ast::{self, Ast, Position, Span}; - use hir::{self, Hir, HirKind}; - use unicode::{self, ClassQuery}; + use crate::ast::parse::ParserBuilder; + use crate::ast::{self, Ast, Position, Span}; + use crate::hir::{self, Hir, HirKind}; + use crate::unicode::{self, ClassQuery}; use super::{ascii_class, TranslatorBuilder}; @@ -1256,7 +1256,7 @@ mod tests { } #[allow(dead_code)] - fn hir_uclass_query(query: ClassQuery) -> Hir { + fn hir_uclass_query(query: ClassQuery<'_>) -> Hir { Hir::class(hir::Class::Unicode(unicode::class(query).unwrap())) } @@ -1315,7 +1315,7 @@ mod tests { #[allow(dead_code)] fn hir_union(expr1: Hir, expr2: Hir) -> Hir { - use hir::Class::{Bytes, Unicode}; + use crate::hir::Class::{Bytes, Unicode}; match (expr1.into_kind(), expr2.into_kind()) { (HirKind::Class(Unicode(mut c1)), HirKind::Class(Unicode(c2))) => { @@ -1332,7 +1332,7 @@ mod tests { #[allow(dead_code)] fn hir_difference(expr1: Hir, expr2: Hir) -> Hir { - use hir::Class::{Bytes, Unicode}; + use crate::hir::Class::{Bytes, Unicode}; match (expr1.into_kind(), expr2.into_kind()) { (HirKind::Class(Unicode(mut c1)), HirKind::Class(Unicode(c2))) => { diff --git a/src/hir/visitor.rs b/src/hir/visitor.rs index 81a9e98..4f5a709 100644 --- a/src/hir/visitor.rs +++ b/src/hir/visitor.rs @@ -1,4 +1,4 @@ -use hir::{self, Hir, HirKind}; +use crate::hir::{self, Hir, HirKind}; /// A trait for visiting the high-level IR (HIR) in depth first order. /// @@ -158,9 +158,9 @@ The following features are available: #![warn(missing_debug_implementations)] #![forbid(unsafe_code)] -pub use error::{Error, Result}; -pub use parser::{Parser, ParserBuilder}; -pub use unicode::UnicodeWordError; +pub use crate::error::{Error, Result}; +pub use crate::parser::{Parser, ParserBuilder}; +pub use crate::unicode::UnicodeWordError; pub mod ast; mod either; diff --git a/src/parser.rs b/src/parser.rs index 00f1391..eb363ca 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -1,7 +1,7 @@ -use ast; -use hir; +use crate::ast; +use crate::hir; -use Result; +use crate::Result; /// A builder for a regular expression parser. /// diff --git a/src/unicode.rs b/src/unicode.rs index 73df698..b894c7d 100644 --- a/src/unicode.rs +++ b/src/unicode.rs @@ -2,7 +2,7 @@ use std::error; use std::fmt; use std::result; -use hir; +use crate::hir; /// A type alias for errors specific to Unicode handling of classes. pub type Result<T> = result::Result<T, Error>; @@ -38,7 +38,7 @@ pub struct CaseFoldError(()); impl error::Error for CaseFoldError {} impl fmt::Display for CaseFoldError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!( f, "Unicode-aware case folding is not available \ @@ -58,7 +58,7 @@ pub struct UnicodeWordError(()); impl error::Error for UnicodeWordError {} impl fmt::Display for UnicodeWordError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!( f, "Unicode-aware \\w class is not available \ @@ -95,7 +95,7 @@ pub fn simple_fold( c: char, ) -> FoldResult<result::Result<impl Iterator<Item = char>, Option<char>>> { - use unicode_tables::case_folding_simple::CASE_FOLDING_SIMPLE; + use crate::unicode_tables::case_folding_simple::CASE_FOLDING_SIMPLE; Ok(CASE_FOLDING_SIMPLE .binary_search_by_key(&c, |&(c1, _)| c1) @@ -130,8 +130,8 @@ pub fn contains_simple_case_mapping( #[cfg(feature = "unicode-case")] fn imp(start: char, end: char) -> FoldResult<bool> { + use crate::unicode_tables::case_folding_simple::CASE_FOLDING_SIMPLE; use std::cmp::Ordering; - use unicode_tables::case_folding_simple::CASE_FOLDING_SIMPLE; assert!(start <= end); Ok(CASE_FOLDING_SIMPLE @@ -285,7 +285,7 @@ enum CanonicalClassQuery { /// Looks up a Unicode class given a query. If one doesn't exist, then /// `None` is returned. -pub fn class(query: ClassQuery) -> Result<hir::ClassUnicode> { +pub fn class(query: ClassQuery<'_>) -> Result<hir::ClassUnicode> { use self::CanonicalClassQuery::*; match query.canonicalize()? { @@ -330,7 +330,7 @@ pub fn perl_word() -> Result<hir::ClassUnicode> { #[cfg(feature = "unicode-perl")] fn imp() -> Result<hir::ClassUnicode> { - use unicode_tables::perl_word::PERL_WORD; + use crate::unicode_tables::perl_word::PERL_WORD; Ok(hir_class(PERL_WORD)) } @@ -348,13 +348,13 @@ pub fn perl_space() -> Result<hir::ClassUnicode> { #[cfg(all(feature = "unicode-perl", not(feature = "unicode-bool")))] fn imp() -> Result<hir::ClassUnicode> { - use unicode_tables::perl_space::WHITE_SPACE; + use crate::unicode_tables::perl_space::WHITE_SPACE; Ok(hir_class(WHITE_SPACE)) } #[cfg(feature = "unicode-bool")] fn imp() -> Result<hir::ClassUnicode> { - use unicode_tables::property_bool::WHITE_SPACE; + use crate::unicode_tables::property_bool::WHITE_SPACE; Ok(hir_class(WHITE_SPACE)) } @@ -372,13 +372,13 @@ pub fn perl_digit() -> Result<hir::ClassUnicode> { #[cfg(all(feature = "unicode-perl", not(feature = "unicode-gencat")))] fn imp() -> Result<hir::ClassUnicode> { - use unicode_tables::perl_decimal::DECIMAL_NUMBER; + use crate::unicode_tables::perl_decimal::DECIMAL_NUMBER; Ok(hir_class(DECIMAL_NUMBER)) } #[cfg(feature = "unicode-gencat")] fn imp() -> Result<hir::ClassUnicode> { - use unicode_tables::general_category::DECIMAL_NUMBER; + use crate::unicode_tables::general_category::DECIMAL_NUMBER; Ok(hir_class(DECIMAL_NUMBER)) } @@ -405,9 +405,9 @@ pub fn is_word_character(c: char) -> result::Result<bool, UnicodeWordError> { #[cfg(feature = "unicode-perl")] fn imp(c: char) -> result::Result<bool, UnicodeWordError> { - use is_word_byte; + use crate::is_word_byte; + use crate::unicode_tables::perl_word::PERL_WORD; use std::cmp::Ordering; - use unicode_tables::perl_word::PERL_WORD; if c <= 0x7F as char && is_word_byte(c as u8) { return Ok(true); @@ -482,7 +482,7 @@ fn canonical_prop(normalized_name: &str) -> Result<Option<&'static str>> { feature = "unicode-segment", ))] fn imp(name: &str) -> Result<Option<&'static str>> { - use unicode_tables::property_names::PROPERTY_NAMES; + use crate::unicode_tables::property_names::PROPERTY_NAMES; Ok(PROPERTY_NAMES .binary_search_by_key(&name, |&(n, _)| n) @@ -539,7 +539,7 @@ fn property_values( feature = "unicode-segment", ))] fn imp(name: &'static str) -> Result<Option<PropertyValues>> { - use unicode_tables::property_values::PROPERTY_VALUES; + use crate::unicode_tables::property_values::PROPERTY_VALUES; Ok(PROPERTY_VALUES .binary_search_by_key(&name, |&(n, _)| n) @@ -578,7 +578,7 @@ fn ages(canonical_age: &str) -> Result<impl Iterator<Item = Range>> { #[cfg(feature = "unicode-age")] fn imp(canonical_age: &str) -> Result<impl Iterator<Item = Range>> { - use unicode_tables::age; + use crate::unicode_tables::age; const AGES: &'static [(&'static str, Range)] = &[ ("V1_1", age::V1_1), @@ -631,7 +631,7 @@ fn gencat(canonical_name: &'static str) -> Result<hir::ClassUnicode> { #[cfg(feature = "unicode-gencat")] fn imp(name: &'static str) -> Result<hir::ClassUnicode> { - use unicode_tables::general_category::BY_NAME; + use crate::unicode_tables::general_category::BY_NAME; match name { "ASCII" => Ok(hir_class(&[('\0', '\x7F')])), "Any" => Ok(hir_class(&[('\0', '\u{10FFFF}')])), @@ -666,7 +666,7 @@ fn script(canonical_name: &'static str) -> Result<hir::ClassUnicode> { #[cfg(feature = "unicode-script")] fn imp(name: &'static str) -> Result<hir::ClassUnicode> { - use unicode_tables::script::BY_NAME; + use crate::unicode_tables::script::BY_NAME; property_set(BY_NAME, name) .map(hir_class) .ok_or(Error::PropertyValueNotFound) @@ -691,7 +691,7 @@ fn script_extension( #[cfg(feature = "unicode-script")] fn imp(name: &'static str) -> Result<hir::ClassUnicode> { - use unicode_tables::script_extension::BY_NAME; + use crate::unicode_tables::script_extension::BY_NAME; property_set(BY_NAME, name) .map(hir_class) .ok_or(Error::PropertyValueNotFound) @@ -715,7 +715,7 @@ fn bool_property(canonical_name: &'static str) -> Result<hir::ClassUnicode> { #[cfg(feature = "unicode-bool")] fn imp(name: &'static str) -> Result<hir::ClassUnicode> { - use unicode_tables::property_bool::BY_NAME; + use crate::unicode_tables::property_bool::BY_NAME; property_set(BY_NAME, name) .map(hir_class) .ok_or(Error::PropertyNotFound) @@ -743,7 +743,7 @@ fn gcb(canonical_name: &'static str) -> Result<hir::ClassUnicode> { #[cfg(feature = "unicode-segment")] fn imp(name: &'static str) -> Result<hir::ClassUnicode> { - use unicode_tables::grapheme_cluster_break::BY_NAME; + use crate::unicode_tables::grapheme_cluster_break::BY_NAME; property_set(BY_NAME, name) .map(hir_class) .ok_or(Error::PropertyValueNotFound) @@ -767,7 +767,7 @@ fn wb(canonical_name: &'static str) -> Result<hir::ClassUnicode> { #[cfg(feature = "unicode-segment")] fn imp(name: &'static str) -> Result<hir::ClassUnicode> { - use unicode_tables::word_break::BY_NAME; + use crate::unicode_tables::word_break::BY_NAME; property_set(BY_NAME, name) .map(hir_class) .ok_or(Error::PropertyValueNotFound) @@ -791,7 +791,7 @@ fn sb(canonical_name: &'static str) -> Result<hir::ClassUnicode> { #[cfg(feature = "unicode-segment")] fn imp(name: &'static str) -> Result<hir::ClassUnicode> { - use unicode_tables::sentence_break::BY_NAME; + use crate::unicode_tables::sentence_break::BY_NAME; property_set(BY_NAME, name) .map(hir_class) .ok_or(Error::PropertyValueNotFound) diff --git a/src/utf8.rs b/src/utf8.rs index 947ba7c..dc05503 100644 --- a/src/utf8.rs +++ b/src/utf8.rs @@ -203,7 +203,7 @@ impl<'a> IntoIterator for &'a Utf8Sequence { } impl fmt::Debug for Utf8Sequence { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use self::Utf8Sequence::*; match *self { One(ref r) => write!(f, "{:?}", r), @@ -237,7 +237,7 @@ impl Utf8Range { } impl fmt::Debug for Utf8Range { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if self.start == self.end { write!(f, "[{:X}]", self.start) } else { @@ -331,7 +331,7 @@ struct ScalarRange { } impl fmt::Debug for ScalarRange { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "ScalarRange({:X}, {:X})", self.start, self.end) } } @@ -457,7 +457,7 @@ fn max_scalar_value(nbytes: usize) -> u32 { mod tests { use std::char; - use utf8::{Utf8Range, Utf8Sequences}; + use crate::utf8::{Utf8Range, Utf8Sequences}; fn rutf8(s: u8, e: u8) -> Utf8Range { Utf8Range::new(s, e) @@ -504,7 +504,7 @@ mod tests { #[test] fn bmp() { - use utf8::Utf8Sequence::*; + use crate::utf8::Utf8Sequence::*; let seqs = Utf8Sequences::new('\u{0}', '\u{FFFF}').collect::<Vec<_>>(); assert_eq!( @@ -538,7 +538,7 @@ mod tests { #[test] fn reverse() { - use utf8::Utf8Sequence::*; + use crate::utf8::Utf8Sequence::*; let mut s = One(rutf8(0xA, 0xB)); s.reverse(); @@ -1,5 +1,7 @@ #!/bin/bash +set -e + # This is a convenience script for running a broad swath of the syntax tests. echo "===== DEFAULT FEATURES ===" cargo test |