summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2019-01-19 10:15:56 -0500
committerAndrew Gallant <jamslam@gmail.com>2019-01-19 10:44:30 -0500
commit7a6a40bae18f89bcfc6997479d7202d2c098e964 (patch)
tree2d75e646bd424e858570e728d370f26af6c0d6a6
parent1e9ee2cc85da6f18b72ea554010810c317c31031 (diff)
edition: move core ripgrep to Rust 2018
-rw-r--r--Cargo.toml1
-rw-r--r--src/app.rs3
-rw-r--r--src/args.rs24
-rw-r--r--src/config.rs6
-rw-r--r--src/main.rs14
-rw-r--r--src/messages.rs4
-rw-r--r--src/search.rs3
-rw-r--r--src/subject.rs3
-rw-r--r--tests/feature.rs4
-rw-r--r--tests/json.rs5
-rw-r--r--tests/macros.rs4
-rw-r--r--tests/misc.rs4
-rw-r--r--tests/multiline.rs4
-rw-r--r--tests/regression.rs4
-rw-r--r--tests/tests.rs5
15 files changed, 40 insertions, 48 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 9d7e42d7..d28758f4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,6 +17,7 @@ license = "Unlicense OR MIT"
exclude = ["HomebrewFormula"]
build = "build.rs"
autotests = false
+edition = "2018"
[badges]
travis-ci = { repository = "BurntSushi/ripgrep" }
diff --git a/src/app.rs b/src/app.rs
index 8d8cdad2..5b25b72f 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -9,7 +9,8 @@
// is where we read clap's configuration from the end user's arguments and turn
// it into a ripgrep-specific configuration type that is not coupled with clap.
-use clap::{self, App, AppSettings};
+use clap::{self, App, AppSettings, crate_authors, crate_version};
+use lazy_static::lazy_static;
const ABOUT: &str = "
ripgrep (rg) recursively searches your current directory for a regex pattern.
diff --git a/src/args.rs b/src/args.rs
index 623a230c..70af9df1 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -34,20 +34,22 @@ use ignore::types::{FileTypeDef, Types, TypesBuilder};
use ignore::{Walk, WalkBuilder, WalkParallel};
use log;
use num_cpus;
-use path_printer::{PathPrinter, PathPrinterBuilder};
use regex;
use termcolor::{
WriteColor,
BufferWriter, ColorChoice,
};
-use app;
-use config;
-use logger::Logger;
-use messages::{set_messages, set_ignore_messages};
-use search::{PatternMatcher, Printer, SearchWorker, SearchWorkerBuilder};
-use subject::SubjectBuilder;
-use Result;
+use crate::app;
+use crate::config;
+use crate::logger::Logger;
+use crate::messages::{set_messages, set_ignore_messages};
+use crate::path_printer::{PathPrinter, PathPrinterBuilder};
+use crate::search::{
+ PatternMatcher, Printer, SearchWorker, SearchWorkerBuilder,
+};
+use crate::subject::SubjectBuilder;
+use crate::Result;
/// The command that ripgrep should execute based on the command line
/// configuration.
@@ -491,7 +493,9 @@ impl ArgMatches {
fn reconfigure(self) -> ArgMatches {
// If the end user says no config, then respect it.
if self.is_present("no-config") {
- debug!("not reading config files because --no-config is present");
+ log::debug!(
+ "not reading config files because --no-config is present"
+ );
return self;
}
// If the user wants ripgrep to use a config file, then parse args
@@ -505,7 +509,7 @@ impl ArgMatches {
args.insert(0, bin);
}
args.extend(cliargs);
- debug!("final argv: {:?}", args);
+ log::debug!("final argv: {:?}", args);
ArgMatches::new(app::app().get_matches_from(args))
}
diff --git a/src/config.rs b/src/config.rs
index eade0cca..f10c5a86 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -9,7 +9,9 @@ use std::io::{self, BufRead};
use std::ffi::OsString;
use std::path::{Path, PathBuf};
-use Result;
+use log;
+
+use crate::Result;
/// Return a sequence of arguments derived from ripgrep rc configuration files.
pub fn args() -> Vec<OsString> {
@@ -34,7 +36,7 @@ pub fn args() -> Vec<OsString> {
message!("{}:{}", config_path.display(), err);
}
}
- debug!(
+ log::debug!(
"{}: arguments loaded from config file: {:?}",
config_path.display(),
args
diff --git a/src/main.rs b/src/main.rs
index bcadc8a1..274a1fe2 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,17 +1,3 @@
-#[macro_use]
-extern crate clap;
-extern crate grep;
-extern crate ignore;
-#[macro_use]
-extern crate lazy_static;
-#[macro_use]
-extern crate log;
-extern crate num_cpus;
-extern crate regex;
-#[macro_use]
-extern crate serde_json;
-extern crate termcolor;
-
use std::io::{self, Write};
use std::process;
use std::sync::{Arc, Mutex};
diff --git a/src/messages.rs b/src/messages.rs
index 2016ff64..21ca109d 100644
--- a/src/messages.rs
+++ b/src/messages.rs
@@ -6,7 +6,7 @@ static IGNORE_MESSAGES: AtomicBool = ATOMIC_BOOL_INIT;
#[macro_export]
macro_rules! message {
($($tt:tt)*) => {
- if ::messages::messages() {
+ if crate::messages::messages() {
eprintln!($($tt)*);
}
}
@@ -15,7 +15,7 @@ macro_rules! message {
#[macro_export]
macro_rules! ignore_message {
($($tt:tt)*) => {
- if ::messages::messages() && ::messages::ignore_messages() {
+ if crate::messages::messages() && crate::messages::ignore_messages() {
eprintln!($($tt)*);
}
}
diff --git a/src/search.rs b/src/search.rs
index 9baf513f..048f882b 100644
--- a/src/search.rs
+++ b/src/search.rs
@@ -13,9 +13,10 @@ use grep::regex::{RegexMatcher as RustRegexMatcher};
use grep::searcher::Searcher;
use ignore::overrides::Override;
use serde_json as json;
+use serde_json::json;
use termcolor::WriteColor;
-use subject::Subject;
+use crate::subject::Subject;
/// The configuration for the search worker. Among a few other things, the
/// configuration primarily controls the way we show search results to users
diff --git a/src/subject.rs b/src/subject.rs
index f323ef08..82cddbd9 100644
--- a/src/subject.rs
+++ b/src/subject.rs
@@ -1,6 +1,7 @@
use std::path::Path;
use ignore::{self, DirEntry};
+use log;
/// A configuration for describing how subjects should be built.
#[derive(Clone, Debug)]
@@ -79,7 +80,7 @@ impl SubjectBuilder {
// directory. Otherwise, emitting messages for directories is just
// noisy.
if !subj.is_dir() {
- debug!(
+ log::debug!(
"ignoring {}: failed to pass subject filter: \
file type: {:?}, metadata: {:?}",
subj.dent.path().display(),
diff --git a/tests/feature.rs b/tests/feature.rs
index 5b14a0d2..d27fbf2f 100644
--- a/tests/feature.rs
+++ b/tests/feature.rs
@@ -1,5 +1,5 @@
-use hay::{SHERLOCK, SHERLOCK_CRLF};
-use util::{Dir, TestCommand, sort_lines};
+use crate::hay::{SHERLOCK, SHERLOCK_CRLF};
+use crate::util::{Dir, TestCommand, sort_lines};
// See: https://github.com/BurntSushi/ripgrep/issues/1
rgtest!(f1_sjis, |dir: Dir, mut cmd: TestCommand| {
diff --git a/tests/json.rs b/tests/json.rs
index 7a7bd4d0..c0b064b1 100644
--- a/tests/json.rs
+++ b/tests/json.rs
@@ -1,9 +1,10 @@
use std::time;
+use serde_derive::Deserialize;
use serde_json as json;
-use hay::{SHERLOCK, SHERLOCK_CRLF};
-use util::{Dir, TestCommand};
+use crate::hay::{SHERLOCK, SHERLOCK_CRLF};
+use crate::util::{Dir, TestCommand};
#[derive(Clone, Debug, Deserialize, PartialEq, Eq)]
#[serde(tag = "type", content = "data")]
diff --git a/tests/macros.rs b/tests/macros.rs
index 24bf13f8..28b799d9 100644
--- a/tests/macros.rs
+++ b/tests/macros.rs
@@ -3,11 +3,11 @@ macro_rules! rgtest {
($name:ident, $fun:expr) => {
#[test]
fn $name() {
- let (dir, cmd) = ::util::setup(stringify!($name));
+ let (dir, cmd) = crate::util::setup(stringify!($name));
$fun(dir, cmd);
if cfg!(feature = "pcre2") {
- let (dir, cmd) = ::util::setup_pcre2(stringify!($name));
+ let (dir, cmd) = crate::util::setup_pcre2(stringify!($name));
$fun(dir, cmd);
}
}
diff --git a/tests/misc.rs b/tests/misc.rs
index 9b5a7a75..31662871 100644
--- a/tests/misc.rs
+++ b/tests/misc.rs
@@ -1,5 +1,5 @@
-use hay::SHERLOCK;
-use util::{Dir, TestCommand, cmd_exists, sort_lines};
+use crate::hay::SHERLOCK;
+use crate::util::{Dir, TestCommand, cmd_exists, sort_lines};
// This file contains "miscellaneous" tests that were either written before
// features were tracked more explicitly, or were simply written without
diff --git a/tests/multiline.rs b/tests/multiline.rs
index 5a569358..41b4d3ad 100644
--- a/tests/multiline.rs
+++ b/tests/multiline.rs
@@ -1,5 +1,5 @@
-use hay::SHERLOCK;
-use util::{Dir, TestCommand};
+use crate::hay::SHERLOCK;
+use crate::util::{Dir, TestCommand};
// This tests that multiline matches that span multiple lines, but where
// multiple matches may begin and end on the same line work correctly.
diff --git a/tests/regression.rs b/tests/regression.rs
index abf29bdd..4ee3ab53 100644
--- a/tests/regression.rs
+++ b/tests/regression.rs
@@ -1,5 +1,5 @@
-use hay::SHERLOCK;
-use util::{Dir, TestCommand, sort_lines};
+use crate::hay::SHERLOCK;
+use crate::util::{Dir, TestCommand, sort_lines};
// See: https://github.com/BurntSushi/ripgrep/issues/16
rgtest!(r16, |dir: Dir, mut cmd: TestCommand| {
diff --git a/tests/tests.rs b/tests/tests.rs
index ceff7bc2..29cc5824 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -1,8 +1,3 @@
-extern crate serde;
-#[macro_use]
-extern crate serde_derive;
-extern crate serde_json;
-
// Macros useful for testing.
#[macro_use]
mod macros;