summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2019-06-16 18:37:51 -0400
committerAndrew Gallant <jamslam@gmail.com>2019-06-16 18:37:51 -0400
commit7b9972c30876797103d6b51c14dd8f9bf1001c92 (patch)
treefa4e1c6c75c23de5a5552470d173e02d78bd5575
parent9f000c29109cf369c4c28254f0cf9b9216a1950d (diff)
style: fix deprecations
Use `dyn` for trait objects and use `..=` for inclusive ranges.
-rw-r--r--grep-cli/src/escape.rs6
-rw-r--r--grep-matcher/src/interpolate.rs2
-rw-r--r--grep-searcher/src/sink.rs7
-rw-r--r--ignore/src/walk.rs8
-rw-r--r--src/config.rs4
-rw-r--r--src/main.rs3
6 files changed, 16 insertions, 14 deletions
diff --git a/grep-cli/src/escape.rs b/grep-cli/src/escape.rs
index 7ea96788..6b4d2d3c 100644
--- a/grep-cli/src/escape.rs
+++ b/grep-cli/src/escape.rs
@@ -111,7 +111,7 @@ pub fn unescape(s: &str) -> Vec<u8> {
}
HexFirst => {
match c {
- '0'...'9' | 'A'...'F' | 'a'...'f' => {
+ '0'..='9' | 'A'..='F' | 'a'..='f' => {
state = HexSecond(c);
}
c => {
@@ -122,7 +122,7 @@ pub fn unescape(s: &str) -> Vec<u8> {
}
HexSecond(first) => {
match c {
- '0'...'9' | 'A'...'F' | 'a'...'f' => {
+ '0'..='9' | 'A'..='F' | 'a'..='f' => {
let ordinal = format!("{}{}", first, c);
let byte = u8::from_str_radix(&ordinal, 16).unwrap();
bytes.push(byte);
@@ -174,7 +174,7 @@ fn escape_char(cp: char, into: &mut String) {
/// Adds the given byte to the given string, escaping it if necessary.
fn escape_byte(byte: u8, into: &mut String) {
match byte {
- 0x21...0x5B | 0x5D...0x7D => into.push(byte as char),
+ 0x21..=0x5B | 0x5D..=0x7D => into.push(byte as char),
b'\n' => into.push_str(r"\n"),
b'\r' => into.push_str(r"\r"),
b'\t' => into.push_str(r"\t"),
diff --git a/grep-matcher/src/interpolate.rs b/grep-matcher/src/interpolate.rs
index 168dd343..445518de 100644
--- a/grep-matcher/src/interpolate.rs
+++ b/grep-matcher/src/interpolate.rs
@@ -134,7 +134,7 @@ fn find_cap_ref(replacement: &[u8]) -> Option<CaptureRef> {
/// Returns true if and only if the given byte is allowed in a capture name.
fn is_valid_cap_letter(b: &u8) -> bool {
match *b {
- b'0' ... b'9' | b'a' ... b'z' | b'A' ... b'Z' | b'_' => true,
+ b'0' ..= b'9' | b'a' ..= b'z' | b'A' ..= b'Z' | b'_' => true,
_ => false,
}
}
diff --git a/grep-searcher/src/sink.rs b/grep-searcher/src/sink.rs
index 63a8ae24..74fba00b 100644
--- a/grep-searcher/src/sink.rs
+++ b/grep-searcher/src/sink.rs
@@ -1,3 +1,4 @@
+use std::error;
use std::fmt;
use std::io;
@@ -49,9 +50,9 @@ impl SinkError for io::Error {
/// A `Box<std::error::Error>` can be used as an error for `Sink`
/// implementations out of the box.
-impl SinkError for Box<::std::error::Error> {
- fn error_message<T: fmt::Display>(message: T) -> Box<::std::error::Error> {
- Box::<::std::error::Error>::from(message.to_string())
+impl SinkError for Box<dyn error::Error> {
+ fn error_message<T: fmt::Display>(message: T) -> Box<dyn error::Error> {
+ Box::<dyn error::Error>::from(message.to_string())
}
}
diff --git a/ignore/src/walk.rs b/ignore/src/walk.rs
index 72459220..57f795c1 100644
--- a/ignore/src/walk.rs
+++ b/ignore/src/walk.rs
@@ -481,8 +481,8 @@ pub struct WalkBuilder {
#[derive(Clone)]
enum Sorter {
- ByName(Arc<Fn(&OsStr, &OsStr) -> cmp::Ordering + Send + Sync + 'static>),
- ByPath(Arc<Fn(&Path, &Path) -> cmp::Ordering + Send + Sync + 'static>),
+ ByName(Arc<dyn Fn(&OsStr, &OsStr) -> cmp::Ordering + Send + Sync + 'static>),
+ ByPath(Arc<dyn Fn(&Path, &Path) -> cmp::Ordering + Send + Sync + 'static>),
}
impl fmt::Debug for WalkBuilder {
@@ -1075,7 +1075,7 @@ impl WalkParallel {
pub fn run<F>(
self,
mut mkf: F,
- ) where F: FnMut() -> Box<FnMut(Result<DirEntry, Error>) -> WalkState + Send + 'static> {
+ ) where F: FnMut() -> Box<dyn FnMut(Result<DirEntry, Error>) -> WalkState + Send + 'static> {
let mut f = mkf();
let threads = self.threads();
// TODO: Figure out how to use a bounded channel here. With an
@@ -1253,7 +1253,7 @@ impl Work {
/// Note that a worker is *both* a producer and a consumer.
struct Worker {
/// The caller's callback.
- f: Box<FnMut(Result<DirEntry, Error>) -> WalkState + Send + 'static>,
+ f: Box<dyn FnMut(Result<DirEntry, Error>) -> WalkState + Send + 'static>,
/// The push side of our mpmc queue.
tx: channel::Sender<Message>,
/// The receive side of our mpmc queue.
diff --git a/src/config.rs b/src/config.rs
index a5e492ec..f0f7929c 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -55,7 +55,7 @@ pub fn args() -> Vec<OsString> {
/// for each line in addition to successfully parsed arguments.
fn parse<P: AsRef<Path>>(
path: P,
-) -> Result<(Vec<OsString>, Vec<Box<Error>>)> {
+) -> Result<(Vec<OsString>, Vec<Box<dyn Error>>)> {
let path = path.as_ref();
match File::open(&path) {
Ok(file) => parse_reader(file),
@@ -76,7 +76,7 @@ fn parse<P: AsRef<Path>>(
/// in addition to successfully parsed arguments.
fn parse_reader<R: io::Read>(
rdr: R,
-) -> Result<(Vec<OsString>, Vec<Box<Error>>)> {
+) -> Result<(Vec<OsString>, Vec<Box<dyn Error>>)> {
let bufrdr = io::BufReader::new(rdr);
let (mut args, mut errs) = (vec![], vec![]);
let mut line_number = 0;
diff --git a/src/main.rs b/src/main.rs
index bed33296..6c8826b4 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,3 +1,4 @@
+use std::error;
use std::io::{self, Write};
use std::process;
use std::sync::{Arc, Mutex};
@@ -42,7 +43,7 @@ mod subject;
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
-type Result<T> = ::std::result::Result<T, Box<::std::error::Error>>;
+type Result<T> = ::std::result::Result<T, Box<dyn error::Error>>;
fn main() {
if let Err(err) = Args::parse().and_then(try_main) {