edition: run 'cargo fix --edition --edition-idioms --all'

This commit is contained in:
Andrew Gallant 2021-06-01 19:47:46 -04:00
parent 77a9e99964
commit af54069c51
36 changed files with 107 additions and 137 deletions

View File

@ -52,7 +52,7 @@ impl error::Error for ParseSizeError {
} }
impl fmt::Display for ParseSizeError { impl fmt::Display for ParseSizeError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use self::ParseSizeErrorKind::*; use self::ParseSizeErrorKind::*;
match self.kind { match self.kind {

View File

@ -158,18 +158,12 @@ error message is crafted that typically tells the user how to fix the problem.
#![deny(missing_docs)] #![deny(missing_docs)]
extern crate atty; use atty;
extern crate bstr;
extern crate globset;
#[macro_use] #[macro_use]
extern crate lazy_static; extern crate lazy_static;
#[macro_use] #[macro_use]
extern crate log; extern crate log;
extern crate regex;
extern crate same_file;
extern crate termcolor;
#[cfg(windows)]
extern crate winapi_util;
mod decompress; mod decompress;
mod escape; mod escape;

View File

@ -35,7 +35,7 @@ impl error::Error for InvalidPatternError {
} }
impl fmt::Display for InvalidPatternError { impl fmt::Display for InvalidPatternError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!( write!(
f, f,
"found invalid UTF-8 in pattern at byte offset {}: {} \ "found invalid UTF-8 in pattern at byte offset {}: {} \

View File

@ -47,7 +47,7 @@ impl error::Error for CommandError {
} }
impl fmt::Display for CommandError { impl fmt::Display for CommandError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.kind { match self.kind {
CommandErrorKind::Io(ref e) => e.fmt(f), CommandErrorKind::Io(ref e) => e.fmt(f),
CommandErrorKind::Stderr(ref bytes) => { CommandErrorKind::Stderr(ref bytes) => {

View File

@ -1720,7 +1720,7 @@ impl ArgMatches {
self.0.value_of_os(name) self.0.value_of_os(name)
} }
fn values_of_os(&self, name: &str) -> Option<clap::OsValues> { fn values_of_os(&self, name: &str) -> Option<clap::OsValues<'_>> {
self.0.values_of_os(name) self.0.values_of_os(name)
} }
} }

View File

@ -24,13 +24,13 @@ impl Logger {
} }
impl Log for Logger { impl Log for Logger {
fn enabled(&self, _: &log::Metadata) -> bool { fn enabled(&self, _: &log::Metadata<'_>) -> bool {
// We set the log level via log::set_max_level, so we don't need to // We set the log level via log::set_max_level, so we don't need to
// implement filtering here. // implement filtering here.
true true
} }
fn log(&self, record: &log::Record) { fn log(&self, record: &log::Record<'_>) {
match (record.file(), record.line()) { match (record.file(), record.line()) {
(Some(file), Some(line)) => { (Some(file), Some(line)) => {
eprintln!( eprintln!(

View File

@ -4,9 +4,9 @@ tool itself, see the benchsuite directory.
*/ */
#![feature(test)] #![feature(test)]
extern crate glob; use glob;
extern crate globset;
extern crate regex;
extern crate test; extern crate test;
use globset::{Candidate, Glob, GlobMatcher, GlobSet, GlobSetBuilder}; use globset::{Candidate, Glob, GlobMatcher, GlobSet, GlobSetBuilder};

View File

@ -98,7 +98,7 @@ impl hash::Hash for Glob {
} }
impl fmt::Display for Glob { impl fmt::Display for Glob {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.glob.fmt(f) self.glob.fmt(f)
} }
} }
@ -127,7 +127,7 @@ impl GlobMatcher {
} }
/// Tests whether the given path matches this pattern or not. /// Tests whether the given path matches this pattern or not.
pub fn is_match_candidate(&self, path: &Candidate) -> bool { pub fn is_match_candidate(&self, path: &Candidate<'_>) -> bool {
self.re.is_match(&path.path) self.re.is_match(&path.path)
} }
@ -157,7 +157,7 @@ impl GlobStrategic {
} }
/// Tests whether the given path matches this pattern or not. /// Tests whether the given path matches this pattern or not.
fn is_match_candidate(&self, candidate: &Candidate) -> bool { fn is_match_candidate(&self, candidate: &Candidate<'_>) -> bool {
let byte_path = &*candidate.path; let byte_path = &*candidate.path;
match self.strategy { match self.strategy {

View File

@ -103,12 +103,12 @@ or to enable case insensitive matching.
#![deny(missing_docs)] #![deny(missing_docs)]
extern crate aho_corasick;
extern crate bstr;
extern crate fnv; use fnv;
#[macro_use] #[macro_use]
extern crate log; extern crate log;
extern crate regex; use regex;
#[cfg(feature = "serde1")] #[cfg(feature = "serde1")]
extern crate serde; extern crate serde;
@ -228,7 +228,7 @@ impl ErrorKind {
} }
impl fmt::Display 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.glob { match self.glob {
None => self.kind.fmt(f), None => self.kind.fmt(f),
Some(ref glob) => { Some(ref glob) => {
@ -239,7 +239,7 @@ impl fmt::Display for Error {
} }
impl fmt::Display for ErrorKind { impl fmt::Display for ErrorKind {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self { match *self {
ErrorKind::InvalidRecursive ErrorKind::InvalidRecursive
| ErrorKind::UnclosedClass | ErrorKind::UnclosedClass
@ -317,7 +317,7 @@ impl GlobSet {
/// ///
/// This takes a Candidate as input, which can be used to amortize the /// This takes a Candidate as input, which can be used to amortize the
/// cost of preparing a path for matching. /// cost of preparing a path for matching.
pub fn is_match_candidate(&self, path: &Candidate) -> bool { pub fn is_match_candidate(&self, path: &Candidate<'_>) -> bool {
if self.is_empty() { if self.is_empty() {
return false; return false;
} }
@ -340,7 +340,7 @@ impl GlobSet {
/// ///
/// This takes a Candidate as input, which can be used to amortize the /// This takes a Candidate as input, which can be used to amortize the
/// cost of preparing a path for matching. /// cost of preparing a path for matching.
pub fn matches_candidate(&self, path: &Candidate) -> Vec<usize> { pub fn matches_candidate(&self, path: &Candidate<'_>) -> Vec<usize> {
let mut into = vec![]; let mut into = vec![];
if self.is_empty() { if self.is_empty() {
return into; return into;
@ -374,7 +374,7 @@ impl GlobSet {
/// cost of preparing a path for matching. /// cost of preparing a path for matching.
pub fn matches_candidate_into( pub fn matches_candidate_into(
&self, &self,
path: &Candidate, path: &Candidate<'_>,
into: &mut Vec<usize>, into: &mut Vec<usize>,
) { ) {
into.clear(); into.clear();
@ -543,7 +543,7 @@ enum GlobSetMatchStrategy {
} }
impl GlobSetMatchStrategy { impl GlobSetMatchStrategy {
fn is_match(&self, candidate: &Candidate) -> bool { fn is_match(&self, candidate: &Candidate<'_>) -> bool {
use self::GlobSetMatchStrategy::*; use self::GlobSetMatchStrategy::*;
match *self { match *self {
Literal(ref s) => s.is_match(candidate), Literal(ref s) => s.is_match(candidate),
@ -556,7 +556,7 @@ impl GlobSetMatchStrategy {
} }
} }
fn matches_into(&self, candidate: &Candidate, matches: &mut Vec<usize>) { fn matches_into(&self, candidate: &Candidate<'_>, matches: &mut Vec<usize>) {
use self::GlobSetMatchStrategy::*; use self::GlobSetMatchStrategy::*;
match *self { match *self {
Literal(ref s) => s.matches_into(candidate, matches), Literal(ref s) => s.matches_into(candidate, matches),
@ -582,12 +582,12 @@ impl LiteralStrategy {
self.0.entry(lit.into_bytes()).or_insert(vec![]).push(global_index); self.0.entry(lit.into_bytes()).or_insert(vec![]).push(global_index);
} }
fn is_match(&self, candidate: &Candidate) -> bool { fn is_match(&self, candidate: &Candidate<'_>) -> bool {
self.0.contains_key(candidate.path.as_bytes()) self.0.contains_key(candidate.path.as_bytes())
} }
#[inline(never)] #[inline(never)]
fn matches_into(&self, candidate: &Candidate, matches: &mut Vec<usize>) { fn matches_into(&self, candidate: &Candidate<'_>, matches: &mut Vec<usize>) {
if let Some(hits) = self.0.get(candidate.path.as_bytes()) { if let Some(hits) = self.0.get(candidate.path.as_bytes()) {
matches.extend(hits); matches.extend(hits);
} }
@ -606,7 +606,7 @@ impl BasenameLiteralStrategy {
self.0.entry(lit.into_bytes()).or_insert(vec![]).push(global_index); self.0.entry(lit.into_bytes()).or_insert(vec![]).push(global_index);
} }
fn is_match(&self, candidate: &Candidate) -> bool { fn is_match(&self, candidate: &Candidate<'_>) -> bool {
if candidate.basename.is_empty() { if candidate.basename.is_empty() {
return false; return false;
} }
@ -614,7 +614,7 @@ impl BasenameLiteralStrategy {
} }
#[inline(never)] #[inline(never)]
fn matches_into(&self, candidate: &Candidate, matches: &mut Vec<usize>) { fn matches_into(&self, candidate: &Candidate<'_>, matches: &mut Vec<usize>) {
if candidate.basename.is_empty() { if candidate.basename.is_empty() {
return; return;
} }
@ -636,7 +636,7 @@ impl ExtensionStrategy {
self.0.entry(ext.into_bytes()).or_insert(vec![]).push(global_index); self.0.entry(ext.into_bytes()).or_insert(vec![]).push(global_index);
} }
fn is_match(&self, candidate: &Candidate) -> bool { fn is_match(&self, candidate: &Candidate<'_>) -> bool {
if candidate.ext.is_empty() { if candidate.ext.is_empty() {
return false; return false;
} }
@ -644,7 +644,7 @@ impl ExtensionStrategy {
} }
#[inline(never)] #[inline(never)]
fn matches_into(&self, candidate: &Candidate, matches: &mut Vec<usize>) { fn matches_into(&self, candidate: &Candidate<'_>, matches: &mut Vec<usize>) {
if candidate.ext.is_empty() { if candidate.ext.is_empty() {
return; return;
} }
@ -662,7 +662,7 @@ struct PrefixStrategy {
} }
impl PrefixStrategy { impl PrefixStrategy {
fn is_match(&self, candidate: &Candidate) -> bool { fn is_match(&self, candidate: &Candidate<'_>) -> bool {
let path = candidate.path_prefix(self.longest); let path = candidate.path_prefix(self.longest);
for m in self.matcher.find_overlapping_iter(path) { for m in self.matcher.find_overlapping_iter(path) {
if m.start() == 0 { if m.start() == 0 {
@ -672,7 +672,7 @@ impl PrefixStrategy {
false false
} }
fn matches_into(&self, candidate: &Candidate, matches: &mut Vec<usize>) { fn matches_into(&self, candidate: &Candidate<'_>, matches: &mut Vec<usize>) {
let path = candidate.path_prefix(self.longest); let path = candidate.path_prefix(self.longest);
for m in self.matcher.find_overlapping_iter(path) { for m in self.matcher.find_overlapping_iter(path) {
if m.start() == 0 { if m.start() == 0 {
@ -690,7 +690,7 @@ struct SuffixStrategy {
} }
impl SuffixStrategy { impl SuffixStrategy {
fn is_match(&self, candidate: &Candidate) -> bool { fn is_match(&self, candidate: &Candidate<'_>) -> bool {
let path = candidate.path_suffix(self.longest); let path = candidate.path_suffix(self.longest);
for m in self.matcher.find_overlapping_iter(path) { for m in self.matcher.find_overlapping_iter(path) {
if m.end() == path.len() { if m.end() == path.len() {
@ -700,7 +700,7 @@ impl SuffixStrategy {
false false
} }
fn matches_into(&self, candidate: &Candidate, matches: &mut Vec<usize>) { fn matches_into(&self, candidate: &Candidate<'_>, matches: &mut Vec<usize>) {
let path = candidate.path_suffix(self.longest); let path = candidate.path_suffix(self.longest);
for m in self.matcher.find_overlapping_iter(path) { for m in self.matcher.find_overlapping_iter(path) {
if m.end() == path.len() { if m.end() == path.len() {
@ -714,7 +714,7 @@ impl SuffixStrategy {
struct RequiredExtensionStrategy(HashMap<Vec<u8>, Vec<(usize, Regex)>, Fnv>); struct RequiredExtensionStrategy(HashMap<Vec<u8>, Vec<(usize, Regex)>, Fnv>);
impl RequiredExtensionStrategy { impl RequiredExtensionStrategy {
fn is_match(&self, candidate: &Candidate) -> bool { fn is_match(&self, candidate: &Candidate<'_>) -> bool {
if candidate.ext.is_empty() { if candidate.ext.is_empty() {
return false; return false;
} }
@ -732,7 +732,7 @@ impl RequiredExtensionStrategy {
} }
#[inline(never)] #[inline(never)]
fn matches_into(&self, candidate: &Candidate, matches: &mut Vec<usize>) { fn matches_into(&self, candidate: &Candidate<'_>, matches: &mut Vec<usize>) {
if candidate.ext.is_empty() { if candidate.ext.is_empty() {
return; return;
} }
@ -753,11 +753,11 @@ struct RegexSetStrategy {
} }
impl RegexSetStrategy { impl RegexSetStrategy {
fn is_match(&self, candidate: &Candidate) -> bool { fn is_match(&self, candidate: &Candidate<'_>) -> bool {
self.matcher.is_match(candidate.path.as_bytes()) self.matcher.is_match(candidate.path.as_bytes())
} }
fn matches_into(&self, candidate: &Candidate, matches: &mut Vec<usize>) { fn matches_into(&self, candidate: &Candidate<'_>, matches: &mut Vec<usize>) {
for i in self.matcher.matches(candidate.path.as_bytes()) { for i in self.matcher.matches(candidate.path.as_bytes()) {
matches.push(self.map[i]); matches.push(self.map[i]);
} }

View File

@ -60,7 +60,7 @@ pub fn file_name_ext<'a>(name: &Cow<'a, [u8]>) -> Option<Cow<'a, [u8]>> {
/// Normalizes a path to use `/` as a separator everywhere, even on platforms /// Normalizes a path to use `/` as a separator everywhere, even on platforms
/// that recognize other characters as separators. /// that recognize other characters as separators.
#[cfg(unix)] #[cfg(unix)]
pub fn normalize_path(path: Cow<[u8]>) -> Cow<[u8]> { pub fn normalize_path(path: Cow<'_, [u8]>) -> Cow<'_, [u8]> {
// UNIX only uses /, so we're good. // UNIX only uses /, so we're good.
path path
} }

View File

@ -1,7 +1,3 @@
extern crate grep;
extern crate termcolor;
extern crate walkdir;
use std::env; use std::env;
use std::error::Error; use std::error::Error;
use std::ffi::OsString; use std::ffi::OsString;

View File

@ -1,6 +1,6 @@
extern crate crossbeam_channel as channel; extern crate crossbeam_channel as channel;
extern crate ignore; use ignore;
extern crate walkdir; use walkdir;
use std::env; use std::env;
use std::io::{self, Write}; use std::io::{self, Write};

View File

@ -495,7 +495,7 @@ impl Ignore {
} }
/// Returns an iterator over parent ignore matchers, including this one. /// Returns an iterator over parent ignore matchers, including this one.
pub fn parents(&self) -> Parents { pub fn parents(&self) -> Parents<'_> {
Parents(Some(self)) Parents(Some(self))
} }

View File

@ -46,16 +46,16 @@ See the documentation for `WalkBuilder` for many other options.
#![deny(missing_docs)] #![deny(missing_docs)]
extern crate globset;
#[macro_use] #[macro_use]
extern crate lazy_static; extern crate lazy_static;
#[macro_use] #[macro_use]
extern crate log; extern crate log;
extern crate memchr;
extern crate regex;
extern crate same_file;
extern crate thread_local;
extern crate walkdir; use walkdir;
#[cfg(windows)] #[cfg(windows)]
extern crate winapi_util; extern crate winapi_util;
@ -334,7 +334,7 @@ impl error::Error for Error {
} }
impl fmt::Display 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 { match *self {
Error::Partial(ref errs) => { Error::Partial(ref errs) => {
let msgs: Vec<String> = let msgs: Vec<String> =

View File

@ -252,7 +252,7 @@ struct DirEntryRaw {
} }
impl fmt::Debug for DirEntryRaw { impl fmt::Debug for DirEntryRaw {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// Leaving out FileType because it doesn't have a debug impl // Leaving out FileType because it doesn't have a debug impl
// in Rust 1.9. We could add it if we really wanted to by manually // in Rust 1.9. We could add it if we really wanted to by manually
// querying each possibly file type. Meh. ---AG // querying each possibly file type. Meh. ---AG
@ -504,7 +504,7 @@ enum Sorter {
struct Filter(Arc<dyn Fn(&DirEntry) -> bool + Send + Sync + 'static>); struct Filter(Arc<dyn Fn(&DirEntry) -> bool + Send + Sync + 'static>);
impl fmt::Debug for WalkBuilder { impl fmt::Debug for WalkBuilder {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("WalkBuilder") f.debug_struct("WalkBuilder")
.field("paths", &self.paths) .field("paths", &self.paths)
.field("ig_builder", &self.ig_builder) .field("ig_builder", &self.ig_builder)
@ -1226,7 +1226,7 @@ impl WalkParallel {
/// visitor runs on only one thread, this build-up can be done without /// visitor runs on only one thread, this build-up can be done without
/// synchronization. Then, once traversal is complete, all of the results /// synchronization. Then, once traversal is complete, all of the results
/// can be merged together into a single data structure. /// can be merged together into a single data structure.
pub fn visit(mut self, builder: &mut dyn ParallelVisitorBuilder) { pub fn visit(mut self, builder: &mut dyn ParallelVisitorBuilder<'_>) {
let threads = self.threads(); let threads = self.threads();
let stack = Arc::new(Mutex::new(vec![])); let stack = Arc::new(Mutex::new(vec![]));
{ {

View File

@ -1,5 +1,3 @@
extern crate ignore;
use std::path::Path; use std::path::Path;
use ignore::gitignore::{Gitignore, GitignoreBuilder}; use ignore::gitignore::{Gitignore, GitignoreBuilder};

View File

@ -92,7 +92,7 @@ impl From<usize> for Ref<'static> {
/// starting at the beginning of `replacement`. /// starting at the beginning of `replacement`.
/// ///
/// If no such valid reference could be found, None is returned. /// If no such valid reference could be found, None is returned.
fn find_cap_ref(replacement: &[u8]) -> Option<CaptureRef> { fn find_cap_ref(replacement: &[u8]) -> Option<CaptureRef<'_>> {
let mut i = 0; let mut i = 0;
if replacement.len() <= 1 || replacement[0] != b'$' { if replacement.len() <= 1 || replacement[0] != b'$' {
return None; return None;

View File

@ -38,8 +38,6 @@ implementations.
#![deny(missing_docs)] #![deny(missing_docs)]
extern crate memchr;
use std::fmt; use std::fmt;
use std::io; use std::io;
use std::ops; use std::ops;
@ -304,7 +302,7 @@ pub struct ByteSet(BitSet);
struct BitSet([u64; 4]); struct BitSet([u64; 4]);
impl fmt::Debug for BitSet { impl fmt::Debug for BitSet {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut fmtd = f.debug_set(); let mut fmtd = f.debug_set();
for b in (0..256).map(|b| b as u8) { for b in (0..256).map(|b| b as u8) {
if ByteSet(*self).contains(b) { if ByteSet(*self).contains(b) {
@ -494,7 +492,7 @@ impl ::std::error::Error for NoError {
} }
impl fmt::Display for NoError { impl fmt::Display for NoError {
fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
panic!("BUG for NoError: an impossible error occurred") panic!("BUG for NoError: an impossible error occurred")
} }
} }

View File

@ -1,6 +1,3 @@
extern crate grep_matcher;
extern crate regex;
mod util; mod util;
mod test_matcher; mod test_matcher;

View File

@ -50,7 +50,7 @@ impl error::Error for Error {
} }
impl fmt::Display 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 { match self.kind {
ErrorKind::Regex(ref s) => write!(f, "{}", s), ErrorKind::Regex(ref s) => write!(f, "{}", s),
ErrorKind::__Nonexhaustive => unreachable!(), ErrorKind::__Nonexhaustive => unreachable!(),

View File

@ -5,9 +5,6 @@ An implementation of `grep-matcher`'s `Matcher` trait for
#![deny(missing_docs)] #![deny(missing_docs)]
extern crate grep_matcher;
extern crate pcre2;
pub use crate::error::{Error, ErrorKind}; pub use crate::error::{Error, ErrorKind};
pub use crate::matcher::{RegexCaptures, RegexMatcher, RegexMatcherBuilder}; pub use crate::matcher::{RegexCaptures, RegexMatcher, RegexMatcherBuilder};
pub use pcre2::{is_jit_available, version}; pub use pcre2::{is_jit_available, version};

View File

@ -60,7 +60,7 @@ impl ColorError {
} }
impl fmt::Display for ColorError { impl fmt::Display for ColorError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self { match *self {
ColorError::UnrecognizedOutType(ref name) => write!( ColorError::UnrecognizedOutType(ref name) => write!(
f, f,

View File

@ -507,7 +507,10 @@ impl<W: io::Write> JSON<W> {
/// Write the given message followed by a new line. The new line is /// Write the given message followed by a new line. The new line is
/// determined from the configuration of the given searcher. /// determined from the configuration of the given searcher.
fn write_message(&mut self, message: &jsont::Message) -> io::Result<()> { fn write_message(
&mut self,
message: &jsont::Message<'_>,
) -> io::Result<()> {
if self.config.pretty { if self.config.pretty {
json::to_writer_pretty(&mut self.wtr, message)?; json::to_writer_pretty(&mut self.wtr, message)?;
} else { } else {
@ -552,7 +555,7 @@ impl<W> JSON<W> {
/// * `W` refers to the underlying writer that this printer is writing its /// * `W` refers to the underlying writer that this printer is writing its
/// output to. /// output to.
#[derive(Debug)] #[derive(Debug)]
pub struct JSONSink<'p, 's, M: Matcher, W: 's> { pub struct JSONSink<'p, 's, M: Matcher, W> {
matcher: M, matcher: M,
json: &'s mut JSON<W>, json: &'s mut JSON<W>,
path: Option<&'p Path>, path: Option<&'p Path>,
@ -682,7 +685,7 @@ impl<'p, 's, M: Matcher, W: io::Write> Sink for JSONSink<'p, 's, M, W> {
fn matched( fn matched(
&mut self, &mut self,
searcher: &Searcher, searcher: &Searcher,
mat: &SinkMatch, mat: &SinkMatch<'_>,
) -> Result<bool, io::Error> { ) -> Result<bool, io::Error> {
self.write_begin_message()?; self.write_begin_message()?;
@ -724,7 +727,7 @@ impl<'p, 's, M: Matcher, W: io::Write> Sink for JSONSink<'p, 's, M, W> {
fn context( fn context(
&mut self, &mut self,
searcher: &Searcher, searcher: &Searcher,
ctx: &SinkContext, ctx: &SinkContext<'_>,
) -> Result<bool, io::Error> { ) -> Result<bool, io::Error> {
self.write_begin_message()?; self.write_begin_message()?;
self.json.matches.clear(); self.json.matches.clear();
@ -836,7 +839,7 @@ impl<'a> SubMatches<'a> {
} }
/// Return this set of match ranges as a slice. /// Return this set of match ranges as a slice.
fn as_slice(&self) -> &[jsont::SubMatch] { fn as_slice(&self) -> &[jsont::SubMatch<'_>] {
match *self { match *self {
SubMatches::Empty => &[], SubMatches::Empty => &[],
SubMatches::Small(ref x) => x, SubMatches::Small(ref x) => x,

View File

@ -90,7 +90,7 @@ enum Data<'a> {
} }
impl<'a> Data<'a> { impl<'a> Data<'a> {
fn from_bytes(bytes: &[u8]) -> Data { fn from_bytes(bytes: &[u8]) -> Data<'_> {
match str::from_utf8(bytes) { match str::from_utf8(bytes) {
Ok(text) => Data::Text { text: Cow::Borrowed(text) }, Ok(text) => Data::Text { text: Cow::Borrowed(text) },
Err(_) => Data::Bytes { bytes }, Err(_) => Data::Bytes { bytes },
@ -98,7 +98,7 @@ impl<'a> Data<'a> {
} }
#[cfg(unix)] #[cfg(unix)]
fn from_path(path: &Path) -> Data { fn from_path(path: &Path) -> Data<'_> {
use std::os::unix::ffi::OsStrExt; use std::os::unix::ffi::OsStrExt;
match path.to_str() { match path.to_str() {

View File

@ -70,19 +70,17 @@ fn example() -> Result<(), Box<Error>> {
#[cfg(feature = "serde1")] #[cfg(feature = "serde1")]
extern crate base64; extern crate base64;
extern crate bstr;
extern crate grep_matcher;
#[cfg(test)]
extern crate grep_regex;
extern crate grep_searcher;
#[cfg(feature = "serde1")]
extern crate serde;
#[cfg(feature = "serde1")] #[cfg(feature = "serde1")]
#[macro_use] #[macro_use]
extern crate serde_derive; extern crate serde_derive;
#[cfg(feature = "serde1")] #[cfg(feature = "serde1")]
extern crate serde_json; extern crate serde_json;
extern crate termcolor;
pub use crate::color::{ pub use crate::color::{
default_color_specs, ColorError, ColorSpecs, UserColorSpec, default_color_specs, ColorError, ColorSpecs, UserColorSpec,

View File

@ -625,7 +625,7 @@ impl<W> Standard<W> {
/// * `W` refers to the underlying writer that this printer is writing its /// * `W` refers to the underlying writer that this printer is writing its
/// output to. /// output to.
#[derive(Debug)] #[derive(Debug)]
pub struct StandardSink<'p, 's, M: Matcher, W: 's> { pub struct StandardSink<'p, 's, M: Matcher, W> {
matcher: M, matcher: M,
standard: &'s mut Standard<W>, standard: &'s mut Standard<W>,
replacer: Replacer<M>, replacer: Replacer<M>,
@ -784,7 +784,7 @@ impl<'p, 's, M: Matcher, W: WriteColor> Sink for StandardSink<'p, 's, M, W> {
fn matched( fn matched(
&mut self, &mut self,
searcher: &Searcher, searcher: &Searcher,
mat: &SinkMatch, mat: &SinkMatch<'_>,
) -> Result<bool, io::Error> { ) -> Result<bool, io::Error> {
self.match_count += 1; self.match_count += 1;
// When we've exceeded our match count, then the remaining context // When we've exceeded our match count, then the remaining context
@ -825,7 +825,7 @@ impl<'p, 's, M: Matcher, W: WriteColor> Sink for StandardSink<'p, 's, M, W> {
fn context( fn context(
&mut self, &mut self,
searcher: &Searcher, searcher: &Searcher,
ctx: &SinkContext, ctx: &SinkContext<'_>,
) -> Result<bool, io::Error> { ) -> Result<bool, io::Error> {
self.standard.matches.clear(); self.standard.matches.clear();
self.replacer.clear(); self.replacer.clear();
@ -904,7 +904,7 @@ impl<'p, 's, M: Matcher, W: WriteColor> Sink for StandardSink<'p, 's, M, W> {
/// A StandardImpl is initialized every time a match or a contextual line is /// A StandardImpl is initialized every time a match or a contextual line is
/// reported. /// reported.
#[derive(Debug)] #[derive(Debug)]
struct StandardImpl<'a, M: 'a + Matcher, W: 'a> { struct StandardImpl<'a, M: Matcher, W> {
searcher: &'a Searcher, searcher: &'a Searcher,
sink: &'a StandardSink<'a, 'a, M, W>, sink: &'a StandardSink<'a, 'a, M, W>,
sunk: Sunk<'a>, sunk: Sunk<'a>,
@ -916,7 +916,7 @@ impl<'a, M: Matcher, W: WriteColor> StandardImpl<'a, M, W> {
/// Bundle self with a searcher and return the core implementation of Sink. /// Bundle self with a searcher and return the core implementation of Sink.
fn new( fn new(
searcher: &'a Searcher, searcher: &'a Searcher,
sink: &'a StandardSink<M, W>, sink: &'a StandardSink<'_, '_, M, W>,
) -> StandardImpl<'a, M, W> { ) -> StandardImpl<'a, M, W> {
StandardImpl { StandardImpl {
searcher: searcher, searcher: searcher,
@ -930,7 +930,7 @@ impl<'a, M: Matcher, W: WriteColor> StandardImpl<'a, M, W> {
/// for use with handling matching lines. /// for use with handling matching lines.
fn from_match( fn from_match(
searcher: &'a Searcher, searcher: &'a Searcher,
sink: &'a StandardSink<M, W>, sink: &'a StandardSink<'_, '_, M, W>,
mat: &'a SinkMatch<'a>, mat: &'a SinkMatch<'a>,
) -> StandardImpl<'a, M, W> { ) -> StandardImpl<'a, M, W> {
let sunk = Sunk::from_sink_match( let sunk = Sunk::from_sink_match(
@ -945,7 +945,7 @@ impl<'a, M: Matcher, W: WriteColor> StandardImpl<'a, M, W> {
/// for use with handling contextual lines. /// for use with handling contextual lines.
fn from_context( fn from_context(
searcher: &'a Searcher, searcher: &'a Searcher,
sink: &'a StandardSink<M, W>, sink: &'a StandardSink<'_, '_, M, W>,
ctx: &'a SinkContext<'a>, ctx: &'a SinkContext<'a>,
) -> StandardImpl<'a, M, W> { ) -> StandardImpl<'a, M, W> {
let sunk = Sunk::from_sink_context( let sunk = Sunk::from_sink_context(

View File

@ -457,7 +457,7 @@ impl<W> Summary<W> {
/// * `W` refers to the underlying writer that this printer is writing its /// * `W` refers to the underlying writer that this printer is writing its
/// output to. /// output to.
#[derive(Debug)] #[derive(Debug)]
pub struct SummarySink<'p, 's, M: Matcher, W: 's> { pub struct SummarySink<'p, 's, M: Matcher, W> {
matcher: M, matcher: M,
summary: &'s mut Summary<W>, summary: &'s mut Summary<W>,
path: Option<PrinterPath<'p>>, path: Option<PrinterPath<'p>>,
@ -591,7 +591,7 @@ impl<'p, 's, M: Matcher, W: WriteColor> Sink for SummarySink<'p, 's, M, W> {
fn matched( fn matched(
&mut self, &mut self,
searcher: &Searcher, searcher: &Searcher,
mat: &SinkMatch, mat: &SinkMatch<'_>,
) -> Result<bool, io::Error> { ) -> Result<bool, io::Error> {
let is_multi_line = self.multi_line(searcher); let is_multi_line = self.multi_line(searcher);
let sink_match_count = if self.stats.is_none() && !is_multi_line { let sink_match_count = if self.stats.is_none() && !is_multi_line {

View File

@ -29,7 +29,7 @@ struct Space<M: Matcher> {
} }
impl<M: Matcher> fmt::Debug for Replacer<M> { impl<M: Matcher> fmt::Debug for Replacer<M> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let (dst, matches) = self.replacement().unwrap_or((&[], &[])); let (dst, matches) = self.replacement().unwrap_or((&[], &[]));
f.debug_struct("Replacer") f.debug_struct("Replacer")
.field("dst", &dst) .field("dst", &dst)
@ -330,7 +330,7 @@ impl<'a> PrinterPath<'a> {
pub struct NiceDuration(pub time::Duration); pub struct NiceDuration(pub time::Duration);
impl fmt::Display for NiceDuration { impl fmt::Display for NiceDuration {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:0.6}s", self.fractional_seconds()) write!(f, "{:0.6}s", self.fractional_seconds())
} }
} }

View File

@ -72,7 +72,7 @@ impl error::Error for Error {
} }
impl fmt::Display 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 { match self.kind {
ErrorKind::Regex(ref s) => write!(f, "{}", s), ErrorKind::Regex(ref s) => write!(f, "{}", s),
ErrorKind::NotAllowed(ref lit) => { ErrorKind::NotAllowed(ref lit) => {

View File

@ -4,14 +4,14 @@ An implementation of `grep-matcher`'s `Matcher` trait for Rust's regex engine.
#![deny(missing_docs)] #![deny(missing_docs)]
extern crate aho_corasick;
extern crate bstr;
extern crate grep_matcher;
#[macro_use] #[macro_use]
extern crate log; extern crate log;
extern crate regex;
extern crate regex_syntax;
extern crate thread_local;
pub use crate::error::{Error, ErrorKind}; pub use crate::error::{Error, ErrorKind};
pub use crate::matcher::{RegexCaptures, RegexMatcher, RegexMatcherBuilder}; pub use crate::matcher::{RegexCaptures, RegexMatcher, RegexMatcherBuilder};

View File

@ -1,6 +1,3 @@
extern crate grep_regex;
extern crate grep_searcher;
use std::env; use std::env;
use std::error::Error; use std::error::Error;
use std::io; use std::io;

View File

@ -99,16 +99,8 @@ searches stdin.
#![deny(missing_docs)] #![deny(missing_docs)]
extern crate bstr;
extern crate bytecount;
extern crate encoding_rs;
extern crate encoding_rs_io;
extern crate grep_matcher;
#[macro_use] #[macro_use]
extern crate log; extern crate log;
extern crate memmap;
#[cfg(test)]
extern crate regex;
pub use crate::lines::{LineIter, LineStep}; pub use crate::lines::{LineIter, LineStep};
pub use crate::searcher::{ pub use crate::searcher::{

View File

@ -10,7 +10,7 @@ use crate::searcher::core::Core;
use crate::searcher::{Config, Range, Searcher}; use crate::searcher::{Config, Range, Searcher};
#[derive(Debug)] #[derive(Debug)]
pub struct ReadByLine<'s, M: 's, R, S> { pub struct ReadByLine<'s, M, R, S> {
config: &'s Config, config: &'s Config,
core: Core<'s, M, S>, core: Core<'s, M, S>,
rdr: LineBufferReader<'s, R>, rdr: LineBufferReader<'s, R>,
@ -87,7 +87,7 @@ where
} }
#[derive(Debug)] #[derive(Debug)]
pub struct SliceByLine<'s, M: 's, S> { pub struct SliceByLine<'s, M, S> {
config: &'s Config, config: &'s Config,
core: Core<'s, M, S>, core: Core<'s, M, S>,
slice: &'s [u8], slice: &'s [u8],
@ -134,7 +134,7 @@ impl<'s, M: Matcher, S: Sink> SliceByLine<'s, M, S> {
} }
#[derive(Debug)] #[derive(Debug)]
pub struct MultiLine<'s, M: 's, S> { pub struct MultiLine<'s, M, S> {
config: &'s Config, config: &'s Config,
core: Core<'s, M, S>, core: Core<'s, M, S>,
slice: &'s [u8], slice: &'s [u8],

View File

@ -263,7 +263,7 @@ impl ::std::error::Error for ConfigError {
} }
impl fmt::Display for ConfigError { impl fmt::Display for ConfigError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self { match *self {
ConfigError::SearchUnavailable => { ConfigError::SearchUnavailable => {
write!(f, "grep config error: no available searchers") write!(f, "grep config error: no available searchers")

View File

@ -121,7 +121,7 @@ pub trait Sink {
fn matched( fn matched(
&mut self, &mut self,
_searcher: &Searcher, _searcher: &Searcher,
_mat: &SinkMatch, _mat: &SinkMatch<'_>,
) -> Result<bool, Self::Error>; ) -> Result<bool, Self::Error>;
/// This method is called whenever a context line is found, and is optional /// This method is called whenever a context line is found, and is optional
@ -140,7 +140,7 @@ pub trait Sink {
fn context( fn context(
&mut self, &mut self,
_searcher: &Searcher, _searcher: &Searcher,
_context: &SinkContext, _context: &SinkContext<'_>,
) -> Result<bool, Self::Error> { ) -> Result<bool, Self::Error> {
Ok(true) Ok(true)
} }
@ -226,7 +226,7 @@ impl<'a, S: Sink> Sink for &'a mut S {
fn matched( fn matched(
&mut self, &mut self,
searcher: &Searcher, searcher: &Searcher,
mat: &SinkMatch, mat: &SinkMatch<'_>,
) -> Result<bool, S::Error> { ) -> Result<bool, S::Error> {
(**self).matched(searcher, mat) (**self).matched(searcher, mat)
} }
@ -235,7 +235,7 @@ impl<'a, S: Sink> Sink for &'a mut S {
fn context( fn context(
&mut self, &mut self,
searcher: &Searcher, searcher: &Searcher,
context: &SinkContext, context: &SinkContext<'_>,
) -> Result<bool, S::Error> { ) -> Result<bool, S::Error> {
(**self).context(searcher, context) (**self).context(searcher, context)
} }
@ -279,7 +279,7 @@ impl<S: Sink + ?Sized> Sink for Box<S> {
fn matched( fn matched(
&mut self, &mut self,
searcher: &Searcher, searcher: &Searcher,
mat: &SinkMatch, mat: &SinkMatch<'_>,
) -> Result<bool, S::Error> { ) -> Result<bool, S::Error> {
(**self).matched(searcher, mat) (**self).matched(searcher, mat)
} }
@ -288,7 +288,7 @@ impl<S: Sink + ?Sized> Sink for Box<S> {
fn context( fn context(
&mut self, &mut self,
searcher: &Searcher, searcher: &Searcher,
context: &SinkContext, context: &SinkContext<'_>,
) -> Result<bool, S::Error> { ) -> Result<bool, S::Error> {
(**self).context(searcher, context) (**self).context(searcher, context)
} }
@ -545,7 +545,7 @@ pub mod sinks {
fn matched( fn matched(
&mut self, &mut self,
_searcher: &Searcher, _searcher: &Searcher,
mat: &SinkMatch, mat: &SinkMatch<'_>,
) -> Result<bool, io::Error> { ) -> Result<bool, io::Error> {
let matched = match str::from_utf8(mat.bytes()) { let matched = match str::from_utf8(mat.bytes()) {
Ok(matched) => matched, Ok(matched) => matched,
@ -593,7 +593,7 @@ pub mod sinks {
fn matched( fn matched(
&mut self, &mut self,
_searcher: &Searcher, _searcher: &Searcher,
mat: &SinkMatch, mat: &SinkMatch<'_>,
) -> Result<bool, io::Error> { ) -> Result<bool, io::Error> {
use std::borrow::Cow; use std::borrow::Cow;
@ -643,7 +643,7 @@ pub mod sinks {
fn matched( fn matched(
&mut self, &mut self,
_searcher: &Searcher, _searcher: &Searcher,
mat: &SinkMatch, mat: &SinkMatch<'_>,
) -> Result<bool, io::Error> { ) -> Result<bool, io::Error> {
let line_number = match mat.line_number() { let line_number = match mat.line_number() {
Some(line_number) => line_number, Some(line_number) => line_number,

View File

@ -129,7 +129,7 @@ impl Sink for KitchenSink {
fn matched( fn matched(
&mut self, &mut self,
_searcher: &Searcher, _searcher: &Searcher,
mat: &SinkMatch, mat: &SinkMatch<'_>,
) -> Result<bool, io::Error> { ) -> Result<bool, io::Error> {
assert!(!mat.bytes().is_empty()); assert!(!mat.bytes().is_empty());
assert!(mat.lines().count() >= 1); assert!(mat.lines().count() >= 1);
@ -152,7 +152,7 @@ impl Sink for KitchenSink {
fn context( fn context(
&mut self, &mut self,
_searcher: &Searcher, _searcher: &Searcher,
context: &SinkContext, context: &SinkContext<'_>,
) -> Result<bool, io::Error> { ) -> Result<bool, io::Error> {
assert!(!context.bytes().is_empty()); assert!(!context.bytes().is_empty());
assert!(context.lines().count() == 1); assert!(context.lines().count() == 1);