diff options
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | .github/workflows/ci.yml | 2 | ||||
-rw-r--r-- | Android.bp | 37 | ||||
-rw-r--r-- | Cargo.toml | 11 | ||||
-rw-r--r-- | Cargo.toml.orig | 18 | ||||
-rw-r--r-- | METADATA | 10 | ||||
-rw-r--r-- | README.md | 8 | ||||
-rw-r--r-- | TEST_MAPPING | 50 | ||||
-rw-r--r-- | cargo2android.json | 11 | ||||
-rw-r--r-- | src/ahocorasick.rs | 48 | ||||
-rw-r--r-- | src/automaton.rs | 8 | ||||
-rw-r--r-- | src/classes.rs | 4 | ||||
-rw-r--r-- | src/dfa.rs | 16 | ||||
-rw-r--r-- | src/error.rs | 2 | ||||
-rw-r--r-- | src/lib.rs | 7 | ||||
-rw-r--r-- | src/nfa.rs | 20 | ||||
-rw-r--r-- | src/packed/api.rs | 8 | ||||
-rw-r--r-- | src/packed/mod.rs | 2 | ||||
-rw-r--r-- | src/packed/pattern.rs | 10 | ||||
-rw-r--r-- | src/packed/rabinkarp.rs | 4 | ||||
-rw-r--r-- | src/packed/teddy/compile.rs | 10 | ||||
-rw-r--r-- | src/packed/teddy/mod.rs | 12 | ||||
-rw-r--r-- | src/packed/teddy/runtime.rs | 8 | ||||
-rw-r--r-- | src/packed/tests.rs | 4 | ||||
-rw-r--r-- | src/prefilter.rs | 12 | ||||
-rw-r--r-- | src/state_id.rs | 2 | ||||
-rw-r--r-- | src/tests.rs | 18 |
27 files changed, 212 insertions, 132 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index ae0871a..f618c96 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "3852632f10587db0ff72ef29e88d58bf305a0946" + "sha1": "1b116376d6a8f920adf5add27a689b2134eec8d0" } } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34ef326..82f1216 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: include: - build: pinned os: ubuntu-18.04 - rust: 1.28.0 + rust: 1.41.1 - build: stable os: ubuntu-18.04 rust: stable @@ -1,4 +1,5 @@ -// This file is generated by cargo2android.py --run --dependencies --device. +// This file is generated by cargo2android.py --config cargo2android.json. +// Do not modify this file as changes will be overridden on upgrade. package { default_applicable_licenses: ["external_rust_crates_aho-corasick_license"], @@ -37,12 +38,36 @@ license { ], } +rust_test { + name: "aho-corasick_test_src_lib", + host_supported: true, + crate_name: "aho_corasick", + cargo_env_compat: true, + cargo_pkg_version: "0.7.18", + srcs: ["src/lib.rs"], + test_suites: ["general-tests"], + auto_gen_config: true, + test_options: { + unit_test: true, + }, + edition: "2018", + features: [ + "default", + "std", + ], + rustlibs: [ + "libmemchr", + ], +} + rust_library { name: "libaho_corasick", host_supported: true, crate_name: "aho_corasick", + cargo_env_compat: true, + cargo_pkg_version: "0.7.18", srcs: ["src/lib.rs"], - edition: "2015", + edition: "2018", features: [ "default", "std", @@ -50,7 +75,9 @@ rust_library { rustlibs: [ "libmemchr", ], + apex_available: [ + "//apex_available:platform", + "com.android.compos", + "com.android.virt", + ], } - -// dependent_library ["feature_list"] -// memchr-2.3.4 "std,use_std" @@ -11,8 +11,9 @@ # will likely look very different (and much more reasonable) [package] +edition = "2018" name = "aho-corasick" -version = "0.7.15" +version = "0.7.18" authors = ["Andrew Gallant <jamslam@gmail.com>"] exclude = ["/aho-corasick-debug", "/ci/*", "/.travis.yml", "/appveyor.yml"] autotests = false @@ -32,11 +33,11 @@ debug = true [lib] name = "aho_corasick" [dependencies.memchr] -version = "2.2.0" +version = "2.4.0" default-features = false -[dev-dependencies.doc-comment] -version = "0.3.1" + +[dev-dependencies] [features] default = ["std"] -std = ["memchr/use_std"] +std = ["memchr/std"] diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 37a6852..06a91f1 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "aho-corasick" -version = "0.7.15" #:version +version = "0.7.18" #:version authors = ["Andrew Gallant <jamslam@gmail.com>"] description = "Fast multiple substring searching." homepage = "https://github.com/BurntSushi/aho-corasick" @@ -13,31 +13,25 @@ autotests = false exclude = [ "/aho-corasick-debug", "/ci/*", "/.travis.yml", "/appveyor.yml", ] +edition = "2018" [workspace] -members = ["bench"] -# We'd ideally not do this, but since the debug tool uses Rust 2018, older -# versions of Rust (such as 1.28) fail to parse the manifest because it treats -# `edition = "2018"` as an unstable feature. -# -# When we move our MSRV to Rust 2018, then we should be able to add this back -# to the workspace. -exclude = ["aho-corasick-debug"] +members = ["aho-corasick-debug", "bench"] [lib] name = "aho_corasick" [features] default = ["std"] -std = ["memchr/use_std"] +std = ["memchr/std"] [dependencies] -memchr = { version = "2.2.0", default-features = false } +memchr = { version = "2.4.0", default-features = false } [dev-dependencies] # TODO: Re-enable this once the MSRV is 1.43 or greater. # See: https://github.com/BurntSushi/aho-corasick/issues/62 -doc-comment = "0.3.1" +# doc-comment = "0.3.1" [profile.release] debug = true @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/aho-corasick/aho-corasick-0.7.15.crate" + value: "https://static.crates.io/crates/aho-corasick/aho-corasick-0.7.18.crate" } - version: "0.7.15" + version: "0.7.18" license_type: NOTICE last_upgrade_date { - year: 2020 - month: 11 - day: 4 + year: 2021 + month: 5 + day: 19 } } @@ -28,12 +28,6 @@ Add this to your `Cargo.toml`: aho-corasick = "0.7" ``` -and this to your crate root (if you're using Rust 2015): - -```rust -extern crate aho_corasick; -``` - ### Example: basic searching @@ -162,7 +156,7 @@ expression alternation. See `MatchKind` in the docs for more details. ### Minimum Rust version policy -This crate's minimum supported `rustc` version is `1.28.0`. +This crate's minimum supported `rustc` version is `1.41.1`. The current policy is that the minimum Rust version required to use this crate can be increased in minor version updates. For example, if `crate 1.0` requires diff --git a/TEST_MAPPING b/TEST_MAPPING index 6716814..6a2d8bc 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -1,8 +1,54 @@ -// Generated by cargo2android.py for tests in Android.bp +// Generated by update_crate_tests.py for tests that depend on this crate. { + "imports": [ + { + "path": "external/rust/crates/base64" + }, + { + "path": "external/rust/crates/libsqlite3-sys" + }, + { + "path": "external/rust/crates/once_cell" + }, + { + "path": "external/rust/crates/regex" + }, + { + "path": "external/rust/crates/tinytemplate" + }, + { + "path": "external/rust/crates/tinyvec" + }, + { + "path": "external/rust/crates/unicode-xid" + } + ], "presubmit": [ { - "name": "libsqlite3-sys_device_test_src_lib" + "name": "aho-corasick_test_src_lib" + }, + { + "name": "keystore2_test" + }, + { + "name": "legacykeystore_test" + }, + { + "name": "virtualizationservice_device_test" + } + ], + "presubmit-rust": [ + { + "name": "aho-corasick_test_src_lib" + }, + { + "name": "keystore2_test" + }, + { + "name": "legacykeystore_test" + }, + { + "name": "virtualizationservice_device_test" } ] } diff --git a/cargo2android.json b/cargo2android.json new file mode 100644 index 0000000..0e54308 --- /dev/null +++ b/cargo2android.json @@ -0,0 +1,11 @@ +{ + "apex-available": [ + "//apex_available:platform", + "com.android.compos", + "com.android.virt" + ], + "dependencies": true, + "device": true, + "run": true, + "tests": true +} diff --git a/src/ahocorasick.rs b/src/ahocorasick.rs index 9069396..2b1aa5c 100644 --- a/src/ahocorasick.rs +++ b/src/ahocorasick.rs @@ -1,14 +1,14 @@ use std::io; -use automaton::Automaton; -use buffer::Buffer; -use dfa::{self, DFA}; -use error::Result; -use nfa::{self, NFA}; -use packed; -use prefilter::{Prefilter, PrefilterState}; -use state_id::StateID; -use Match; +use crate::automaton::Automaton; +use crate::buffer::Buffer; +use crate::dfa::{self, DFA}; +use crate::error::Result; +use crate::nfa::{self, NFA}; +use crate::packed; +use crate::prefilter::{Prefilter, PrefilterState}; +use crate::state_id::StateID; +use crate::Match; /// An automaton for searching multiple strings in linear time. /// @@ -1005,18 +1005,6 @@ impl<S: StateID> AhoCorasick<S> { /// /// let ac = AhoCorasickBuilder::new() /// .dfa(true) - /// .byte_classes(false) - /// .build(&["foo", "bar", "baz"]); - /// assert_eq!(20_768, ac.heap_bytes()); - /// - /// let ac = AhoCorasickBuilder::new() - /// .dfa(true) - /// .byte_classes(true) // default - /// .build(&["foo", "bar", "baz"]); - /// assert_eq!(1_248, ac.heap_bytes()); - /// - /// let ac = AhoCorasickBuilder::new() - /// .dfa(true) /// .ascii_case_insensitive(true) /// .build(&["foo", "bar", "baz"]); /// assert_eq!(1_248, ac.heap_bytes()); @@ -1169,7 +1157,7 @@ impl<S: StateID> Imp<S> { /// /// The lifetime `'b` refers to the lifetime of the haystack being searched. #[derive(Debug)] -pub struct FindIter<'a, 'b, S: 'a + StateID> { +pub struct FindIter<'a, 'b, S: StateID> { fsm: &'a Imp<S>, prestate: PrefilterState, haystack: &'b [u8], @@ -1226,7 +1214,7 @@ impl<'a, 'b, S: StateID> Iterator for FindIter<'a, 'b, S> { /// /// The lifetime `'b` refers to the lifetime of the haystack being searched. #[derive(Debug)] -pub struct FindOverlappingIter<'a, 'b, S: 'a + StateID> { +pub struct FindOverlappingIter<'a, 'b, S: StateID> { fsm: &'a Imp<S>, prestate: PrefilterState, haystack: &'b [u8], @@ -1297,7 +1285,7 @@ impl<'a, 'b, S: StateID> Iterator for FindOverlappingIter<'a, 'b, S> { /// /// The lifetime `'a` refers to the lifetime of the `AhoCorasick` automaton. #[derive(Debug)] -pub struct StreamFindIter<'a, R, S: 'a + StateID> { +pub struct StreamFindIter<'a, R, S: StateID> { it: StreamChunkIter<'a, R, S>, } @@ -1332,7 +1320,7 @@ impl<'a, R: io::Read, S: StateID> Iterator for StreamFindIter<'a, R, S> { /// N.B. This does not actually implement Iterator because we need to borrow /// from the underlying reader. But conceptually, it's still an iterator. #[derive(Debug)] -struct StreamChunkIter<'a, R, S: 'a + StateID> { +struct StreamChunkIter<'a, R, S: StateID> { /// The AC automaton. fsm: &'a Imp<S>, /// State associated with this automaton's prefilter. It is a heuristic @@ -1681,7 +1669,7 @@ impl AhoCorasickBuilder { // N.B. Using byte classes can actually be faster by improving // locality, but this only really applies for multi-megabyte // automata (i.e., automata that don't fit in your CPU's cache). - self.dfa(true).byte_classes(false); + self.dfa(true); } else if patterns.len() <= 5000 { self.dfa(true); } @@ -1928,6 +1916,10 @@ impl AhoCorasickBuilder { /// overall performance. /// /// This option is enabled by default. + #[deprecated( + since = "0.7.16", + note = "not carrying its weight, will be always enabled, see: https://github.com/BurntSushi/aho-corasick/issues/57" + )] pub fn byte_classes(&mut self, yes: bool) -> &mut AhoCorasickBuilder { self.dfa_builder.byte_classes(yes); self @@ -1956,6 +1948,10 @@ impl AhoCorasickBuilder { /// non-premultiplied form only requires 8 bits. /// /// This option is enabled by default. + #[deprecated( + since = "0.7.16", + note = "not carrying its weight, will be always enabled, see: https://github.com/BurntSushi/aho-corasick/issues/57" + )] pub fn premultiply(&mut self, yes: bool) -> &mut AhoCorasickBuilder { self.dfa_builder.premultiply(yes); self diff --git a/src/automaton.rs b/src/automaton.rs index 2ada1a0..b971bf3 100644 --- a/src/automaton.rs +++ b/src/automaton.rs @@ -1,7 +1,7 @@ -use ahocorasick::MatchKind; -use prefilter::{self, Candidate, Prefilter, PrefilterState}; -use state_id::{dead_id, fail_id, StateID}; -use Match; +use crate::ahocorasick::MatchKind; +use crate::prefilter::{self, Candidate, Prefilter, PrefilterState}; +use crate::state_id::{dead_id, fail_id, StateID}; +use crate::Match; // NOTE: This trait essentially started as a copy of the same trait from from // regex-automata, with some wording changed since we use this trait for diff --git a/src/classes.rs b/src/classes.rs index 1fba7ea..f84ae21 100644 --- a/src/classes.rs +++ b/src/classes.rs @@ -64,7 +64,7 @@ impl ByteClasses { /// hasn't been converted to equivalence classes yet. Picking an arbitrary /// byte from each equivalence class then permits a full exploration of /// the NFA instead of using every possible byte value. - pub fn representatives(&self) -> ByteClassRepresentatives { + pub fn representatives(&self) -> ByteClassRepresentatives<'_> { ByteClassRepresentatives { classes: self, byte: 0, last_class: None } } @@ -85,7 +85,7 @@ impl ByteClasses { } impl fmt::Debug for ByteClasses { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if self.is_singleton() { write!(f, "ByteClasses({{singletons}})") } else { @@ -1,13 +1,13 @@ use std::mem::size_of; -use ahocorasick::MatchKind; -use automaton::Automaton; -use classes::ByteClasses; -use error::Result; -use nfa::{PatternID, PatternLength, NFA}; -use prefilter::{Prefilter, PrefilterObj, PrefilterState}; -use state_id::{dead_id, fail_id, premultiply_overflow_error, StateID}; -use Match; +use crate::ahocorasick::MatchKind; +use crate::automaton::Automaton; +use crate::classes::ByteClasses; +use crate::error::Result; +use crate::nfa::{PatternID, PatternLength, NFA}; +use crate::prefilter::{Prefilter, PrefilterObj, PrefilterState}; +use crate::state_id::{dead_id, fail_id, premultiply_overflow_error, StateID}; +use crate::Match; #[derive(Clone, Debug)] pub enum DFA<S> { diff --git a/src/error.rs b/src/error.rs index 7dace63..a57a777 100644 --- a/src/error.rs +++ b/src/error.rs @@ -68,7 +68,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.kind { ErrorKind::StateIDOverflow { max } => write!( f, @@ -186,7 +186,6 @@ disabled via #[cfg(not(feature = "std"))] compile_error!("`std` feature is currently required to build this crate"); -extern crate memchr; // #[cfg(doctest)] // #[macro_use] // extern crate doc_comment; @@ -194,12 +193,12 @@ extern crate memchr; // #[cfg(doctest)] // doctest!("../README.md"); -pub use ahocorasick::{ +pub use crate::ahocorasick::{ AhoCorasick, AhoCorasickBuilder, FindIter, FindOverlappingIter, MatchKind, StreamFindIter, }; -pub use error::{Error, ErrorKind}; -pub use state_id::StateID; +pub use crate::error::{Error, ErrorKind}; +pub use crate::state_id::StateID; mod ahocorasick; mod automaton; @@ -4,13 +4,13 @@ use std::fmt; use std::mem::size_of; use std::ops::{Index, IndexMut}; -use ahocorasick::MatchKind; -use automaton::Automaton; -use classes::{ByteClassBuilder, ByteClasses}; -use error::Result; -use prefilter::{self, opposite_ascii_case, Prefilter, PrefilterObj}; -use state_id::{dead_id, fail_id, usize_to_state_id, StateID}; -use Match; +use crate::ahocorasick::MatchKind; +use crate::automaton::Automaton; +use crate::classes::{ByteClassBuilder, ByteClasses}; +use crate::error::Result; +use crate::prefilter::{self, opposite_ascii_case, Prefilter, PrefilterObj}; +use crate::state_id::{dead_id, fail_id, usize_to_state_id, StateID}; +use crate::Match; /// The identifier for a pattern, which is simply the position of the pattern /// in the sequence of patterns given by the caller. @@ -172,7 +172,7 @@ impl<S: StateID> NFA<S> { self.state_mut(id) } - fn iter_transitions_mut(&mut self, id: S) -> IterTransitionsMut<S> { + fn iter_transitions_mut(&mut self, id: S) -> IterTransitionsMut<'_, S> { IterTransitionsMut::new(self, id) } @@ -497,7 +497,7 @@ impl<S: StateID> Transitions<S> { /// is iterating over transitions, the caller can still mutate the NFA. This /// is useful when creating failure transitions. #[derive(Debug)] -struct IterTransitionsMut<'a, S: StateID + 'a> { +struct IterTransitionsMut<'a, S: StateID> { nfa: &'a mut NFA<S>, state_id: S, cur: usize, @@ -1274,7 +1274,7 @@ impl Iterator for AllBytesIter { } impl<S: StateID> fmt::Debug for NFA<S> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { writeln!(f, "NFA(")?; writeln!(f, "match_kind: {:?}", self.match_kind)?; writeln!(f, "prefilter: {:?}", self.prefilter)?; diff --git a/src/packed/api.rs b/src/packed/api.rs index 3a316b5..c15ae3f 100644 --- a/src/packed/api.rs +++ b/src/packed/api.rs @@ -1,9 +1,9 @@ use std::u16; -use packed::pattern::Patterns; -use packed::rabinkarp::RabinKarp; -use packed::teddy::{self, Teddy}; -use Match; +use crate::packed::pattern::Patterns; +use crate::packed::rabinkarp::RabinKarp; +use crate::packed::teddy::{self, Teddy}; +use crate::Match; /// This is a limit placed on the total number of patterns we're willing to try /// and match at once. As more sophisticated algorithms are added, this number diff --git a/src/packed/mod.rs b/src/packed/mod.rs index 5a3aa2e..25a7966 100644 --- a/src/packed/mod.rs +++ b/src/packed/mod.rs @@ -105,7 +105,7 @@ common reasons: no searcher is built. */ -pub use packed::api::{Builder, Config, FindIter, MatchKind, Searcher}; +pub use crate::packed::api::{Builder, Config, FindIter, MatchKind, Searcher}; mod api; mod pattern; diff --git a/src/packed/pattern.rs b/src/packed/pattern.rs index dfb07e9..f4c6756 100644 --- a/src/packed/pattern.rs +++ b/src/packed/pattern.rs @@ -4,7 +4,7 @@ use std::mem; use std::u16; use std::usize; -use packed::api::MatchKind; +use crate::packed::api::MatchKind; /// The type used for representing a pattern identifier. /// @@ -155,7 +155,7 @@ impl Patterns { /// Return the pattern with the given identifier. If such a pattern does /// not exist, then this panics. - pub fn get(&self, id: PatternID) -> Pattern { + pub fn get(&self, id: PatternID) -> Pattern<'_> { Pattern(&self.by_id[id as usize]) } @@ -167,7 +167,7 @@ impl Patterns { /// Callers must ensure that a pattern with the given identifier exists /// before using this method. #[cfg(target_arch = "x86_64")] - pub unsafe fn get_unchecked(&self, id: PatternID) -> Pattern { + pub unsafe fn get_unchecked(&self, id: PatternID) -> Pattern<'_> { Pattern(self.by_id.get_unchecked(id as usize)) } @@ -189,7 +189,7 @@ impl Patterns { /// the order provided by this iterator, then the result is guaranteed /// to satisfy the correct match semantics. (Either leftmost-first or /// leftmost-longest.) - pub fn iter(&self) -> PatternIter { + pub fn iter(&self) -> PatternIter<'_> { PatternIter { patterns: self, i: 0 } } } @@ -226,7 +226,7 @@ impl<'p> Iterator for PatternIter<'p> { pub struct Pattern<'a>(&'a [u8]); impl<'a> fmt::Debug for Pattern<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Pattern") .field("lit", &String::from_utf8_lossy(&self.0)) .finish() diff --git a/src/packed/rabinkarp.rs b/src/packed/rabinkarp.rs index 3992296..fa6b1e3 100644 --- a/src/packed/rabinkarp.rs +++ b/src/packed/rabinkarp.rs @@ -1,7 +1,7 @@ use std::mem; -use packed::pattern::{PatternID, Patterns}; -use Match; +use crate::packed::pattern::{PatternID, Patterns}; +use crate::Match; /// The type of the rolling hash used in the Rabin-Karp algorithm. type Hash = usize; diff --git a/src/packed/teddy/compile.rs b/src/packed/teddy/compile.rs index a7a48b7..741cb69 100644 --- a/src/packed/teddy/compile.rs +++ b/src/packed/teddy/compile.rs @@ -4,8 +4,8 @@ use std::cmp; use std::collections::BTreeMap; use std::fmt; -use packed::pattern::{PatternID, Patterns}; -use packed::teddy::Teddy; +use crate::packed::pattern::{PatternID, Patterns}; +use crate::packed::teddy::Teddy; /// A builder for constructing a Teddy matcher. /// @@ -73,7 +73,7 @@ impl Builder { } fn build_imp(&self, patterns: &Patterns) -> Option<Teddy> { - use packed::teddy::runtime; + use crate::packed::teddy::runtime; // Most of the logic here is just about selecting the optimal settings, // or perhaps even rejecting construction altogether. The choices @@ -296,7 +296,7 @@ impl<'p> Compiler<'p> { } impl<'p> fmt::Debug for Compiler<'p> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut buckets = vec![vec![]; self.buckets.len()]; for (i, bucket) in self.buckets.iter().enumerate() { for &patid in bucket { @@ -400,7 +400,7 @@ impl Mask { } impl fmt::Debug for Mask { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let (mut parts_lo, mut parts_hi) = (vec![], vec![]); for i in 0..32 { parts_lo.push(format!("{:02}: {:08b}", i, self.lo[i])); diff --git a/src/packed/teddy/mod.rs b/src/packed/teddy/mod.rs index b896023..3268cdf 100644 --- a/src/packed/teddy/mod.rs +++ b/src/packed/teddy/mod.rs @@ -1,11 +1,11 @@ #[cfg(target_arch = "x86_64")] -pub use packed::teddy::compile::Builder; +pub use crate::packed::teddy::compile::Builder; #[cfg(not(target_arch = "x86_64"))] -pub use packed::teddy::fallback::Builder; +pub use crate::packed::teddy::fallback::Builder; #[cfg(not(target_arch = "x86_64"))] -pub use packed::teddy::fallback::Teddy; +pub use crate::packed::teddy::fallback::Teddy; #[cfg(target_arch = "x86_64")] -pub use packed::teddy::runtime::Teddy; +pub use crate::packed::teddy::runtime::Teddy; #[cfg(target_arch = "x86_64")] mod compile; @@ -14,8 +14,8 @@ mod runtime; #[cfg(not(target_arch = "x86_64"))] mod fallback { - use packed::pattern::Patterns; - use Match; + use crate::packed::pattern::Patterns; + use crate::Match; #[derive(Clone, Debug, Default)] pub struct Builder(()); diff --git a/src/packed/teddy/runtime.rs b/src/packed/teddy/runtime.rs index a736948..0d96913 100644 --- a/src/packed/teddy/runtime.rs +++ b/src/packed/teddy/runtime.rs @@ -51,10 +51,10 @@ use std::arch::x86_64::*; use std::mem; -use packed::pattern::{PatternID, Patterns}; -use packed::teddy::compile; -use packed::vector::*; -use Match; +use crate::packed::pattern::{PatternID, Patterns}; +use crate::packed::teddy::compile; +use crate::packed::vector::*; +use crate::Match; /// The Teddy runtime. /// diff --git a/src/packed/tests.rs b/src/packed/tests.rs index a384396..91410cb 100644 --- a/src/packed/tests.rs +++ b/src/packed/tests.rs @@ -1,8 +1,8 @@ use std::collections::HashMap; use std::usize; -use packed::{Config, MatchKind}; -use Match; +use crate::packed::{Config, MatchKind}; +use crate::Match; /// A description of a single test against a multi-pattern searcher. /// diff --git a/src/prefilter.rs b/src/prefilter.rs index 05fa46d..ef81411 100644 --- a/src/prefilter.rs +++ b/src/prefilter.rs @@ -5,9 +5,9 @@ use std::u8; use memchr::{memchr, memchr2, memchr3}; -use ahocorasick::MatchKind; -use packed; -use Match; +use crate::ahocorasick::MatchKind; +use crate::packed; +use crate::Match; /// A candidate is the result of running a prefilter on a haystack at a /// particular position. The result is either no match, a confirmed match or @@ -435,7 +435,7 @@ impl ByteSet { } impl fmt::Debug for ByteSet { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut bytes = vec![]; for b in 0..=255 { if self.contains(b) { @@ -471,7 +471,7 @@ impl RareByteOffsets { } impl fmt::Debug for RareByteOffsets { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut offsets = vec![]; for off in self.set.iter() { if off.max > 0 { @@ -1032,7 +1032,7 @@ pub fn opposite_ascii_case(b: u8) -> u8 { /// Return the frequency rank of the given byte. The higher the rank, the more /// common the byte (heuristically speaking). fn freq_rank(b: u8) -> u8 { - use byte_frequencies::BYTE_FREQUENCIES; + use crate::byte_frequencies::BYTE_FREQUENCIES; BYTE_FREQUENCIES[b as usize] } diff --git a/src/state_id.rs b/src/state_id.rs index 22f6be2..8973806 100644 --- a/src/state_id.rs +++ b/src/state_id.rs @@ -1,7 +1,7 @@ use std::fmt::Debug; use std::hash::Hash; -use error::{Error, Result}; +use crate::error::{Error, Result}; // NOTE: Most of this code was copied from regex-automata, but without the // (de)serialization specific stuff. diff --git a/src/tests.rs b/src/tests.rs index 668fbbf..25c0d5f 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use std::io; use std::usize; -use {AhoCorasickBuilder, Match, MatchKind}; +use crate::{AhoCorasickBuilder, Match, MatchKind}; /// A description of a single test against an Aho-Corasick automaton. /// @@ -739,6 +739,8 @@ macro_rules! testcombo { $collection, $kind, |b: &mut AhoCorasickBuilder| { + // TODO: remove tests when option is removed. + #[allow(deprecated)] b.dfa(true).byte_classes(false); } ); @@ -747,6 +749,8 @@ macro_rules! testcombo { $collection, $kind, |b: &mut AhoCorasickBuilder| { + // TODO: remove tests when option is removed. + #[allow(deprecated)] b.dfa(true).premultiply(false); } ); @@ -755,6 +759,8 @@ macro_rules! testcombo { $collection, $kind, |b: &mut AhoCorasickBuilder| { + // TODO: remove tests when options are removed. + #[allow(deprecated)] b.dfa(true).byte_classes(false).premultiply(false); } ); @@ -830,6 +836,8 @@ testconfig!( AC_STANDARD_OVERLAPPING, Standard, |b: &mut AhoCorasickBuilder| { + // TODO: remove tests when option is removed. + #[allow(deprecated)] b.dfa(true).byte_classes(false); } ); @@ -839,6 +847,8 @@ testconfig!( AC_STANDARD_OVERLAPPING, Standard, |b: &mut AhoCorasickBuilder| { + // TODO: remove tests when option is removed. + #[allow(deprecated)] b.dfa(true).premultiply(false); } ); @@ -848,6 +858,8 @@ testconfig!( AC_STANDARD_OVERLAPPING, Standard, |b: &mut AhoCorasickBuilder| { + // TODO: remove tests when options are removed. + #[allow(deprecated)] b.dfa(true).byte_classes(false).premultiply(false); } ); @@ -1129,7 +1141,7 @@ fn regression_ascii_case_insensitive_no_exponential() { // was incorrect, leading to a false negative. #[test] fn regression_rare_byte_prefilter() { - use AhoCorasick; + use crate::AhoCorasick; let ac = AhoCorasick::new_auto_configured(&["ab/j/", "x/"]); assert!(ac.is_match("ab/j/")); @@ -1137,7 +1149,7 @@ fn regression_rare_byte_prefilter() { #[test] fn regression_case_insensitive_prefilter() { - use AhoCorasickBuilder; + use crate::AhoCorasickBuilder; for c in b'a'..b'z' { for c2 in b'a'..b'z' { |