Skip to content

Commit

Permalink
edition: manual changes
Browse files Browse the repository at this point in the history
This is mostly just about removing 'extern crate' everywhere and fixing
the fallout.
  • Loading branch information
BurntSushi committed Jun 2, 2021
1 parent af54069 commit e824531
Show file tree
Hide file tree
Showing 34 changed files with 93 additions and 182 deletions.
4 changes: 3 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions crates/cli/README.md
Expand Up @@ -29,9 +29,3 @@ Add this to your `Cargo.toml`:
[dependencies]
grep-cli = "0.1"
```

and this to your crate root:

```rust
extern crate grep_cli;
```
4 changes: 2 additions & 2 deletions crates/cli/src/decompress.rs
Expand Up @@ -230,7 +230,7 @@ impl DecompressionReaderBuilder {
match self.command_builder.build(&mut cmd) {
Ok(cmd_reader) => Ok(DecompressionReader { rdr: Ok(cmd_reader) }),
Err(err) => {
debug!(
log::debug!(
"{}: error spawning command '{:?}': {} \
(falling back to uncompressed reader)",
path.display(),
Expand Down Expand Up @@ -479,7 +479,7 @@ fn default_decompression_commands() -> Vec<DecompressionCommand> {
let bin = match resolve_binary(Path::new(args[0])) {
Ok(bin) => bin,
Err(err) => {
debug!("{}", err);
log::debug!("{}", err);
return;
}
};
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/human.rs
Expand Up @@ -88,7 +88,7 @@ impl From<ParseSizeError> for io::Error {
///
/// Additional suffixes may be added over time.
pub fn parse_human_readable_size(size: &str) -> Result<u64, ParseSizeError> {
lazy_static! {
lazy_static::lazy_static! {
// Normally I'd just parse something this simple by hand to avoid the
// regex dep, but we bring regex in any way for glob matching, so might
// as well use it.
Expand Down
7 changes: 0 additions & 7 deletions crates/cli/src/lib.rs
Expand Up @@ -158,13 +158,6 @@ error message is crafted that typically tells the user how to fix the problem.

#![deny(missing_docs)]

use atty;

#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate log;

mod decompress;
mod escape;
mod human;
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/process.rs
Expand Up @@ -254,7 +254,7 @@ impl CommandReader {
impl Drop for CommandReader {
fn drop(&mut self) {
if let Err(error) = self.close() {
warn!("{}", error);
log::warn!("{}", error);
}
}
}
Expand Down
6 changes: 0 additions & 6 deletions crates/globset/README.md
Expand Up @@ -22,12 +22,6 @@ Add this to your `Cargo.toml`:
globset = "0.3"
```

and this to your crate root:

```rust
extern crate globset;
```

### Features

* `serde1`: Enables implementing Serde traits on the `Glob` type.
Expand Down
3 changes: 0 additions & 3 deletions crates/globset/benches/bench.rs
Expand Up @@ -4,9 +4,6 @@ tool itself, see the benchsuite directory.
*/
#![feature(test)]

use glob;


extern crate test;

use globset::{Candidate, Glob, GlobMatcher, GlobSet, GlobSetBuilder};
Expand Down
62 changes: 42 additions & 20 deletions crates/globset/src/lib.rs
Expand Up @@ -103,16 +103,6 @@ or to enable case insensitive matching.

#![deny(missing_docs)]



use fnv;
#[macro_use]
extern crate log;
use regex;

#[cfg(feature = "serde1")]
extern crate serde;

use std::borrow::Cow;
use std::collections::{BTreeMap, HashMap};
use std::error::Error as StdError;
Expand Down Expand Up @@ -423,12 +413,12 @@ impl GlobSet {
required_exts.add(i, ext, p.regex().to_owned());
}
MatchStrategy::Regex => {
debug!("glob converted to regex: {:?}", p);
log::debug!("glob converted to regex: {:?}", p);
regexes.add(i, p.regex().to_owned());
}
}
}
debug!(
log::debug!(
"built glob set; {} literals, {} basenames, {} extensions, \
{} prefixes, {} suffixes, {} required extensions, {} regexes",
lits.0.len(),
Expand Down Expand Up @@ -556,7 +546,11 @@ 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::*;
match *self {
Literal(ref s) => s.matches_into(candidate, matches),
Expand Down Expand Up @@ -587,7 +581,11 @@ impl LiteralStrategy {
}

#[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()) {
matches.extend(hits);
}
Expand All @@ -614,7 +612,11 @@ impl BasenameLiteralStrategy {
}

#[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() {
return;
}
Expand Down Expand Up @@ -644,7 +646,11 @@ impl ExtensionStrategy {
}

#[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() {
return;
}
Expand Down Expand Up @@ -672,7 +678,11 @@ impl PrefixStrategy {
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);
for m in self.matcher.find_overlapping_iter(path) {
if m.start() == 0 {
Expand Down Expand Up @@ -700,7 +710,11 @@ impl SuffixStrategy {
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);
for m in self.matcher.find_overlapping_iter(path) {
if m.end() == path.len() {
Expand Down Expand Up @@ -732,7 +746,11 @@ impl RequiredExtensionStrategy {
}

#[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() {
return;
}
Expand All @@ -757,7 +775,11 @@ impl RegexSetStrategy {
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()) {
matches.push(self.map[i]);
}
Expand Down
6 changes: 0 additions & 6 deletions crates/grep/README.md
Expand Up @@ -26,12 +26,6 @@ Add this to your `Cargo.toml`:
grep = "0.2"
```

and this to your crate root:

```rust
extern crate grep;
```


### Features

Expand Down
6 changes: 0 additions & 6 deletions crates/ignore/README.md
Expand Up @@ -22,12 +22,6 @@ Add this to your `Cargo.toml`:
ignore = "0.4"
```

and this to your crate root:

```rust
extern crate ignore;
```

### Example

This example shows the most basic usage of this crate. This code will
Expand Down
6 changes: 1 addition & 5 deletions crates/ignore/examples/walk.rs
@@ -1,7 +1,3 @@
extern crate crossbeam_channel as channel;
use ignore;
use walkdir;

use std::env;
use std::io::{self, Write};
use std::path::Path;
Expand All @@ -14,7 +10,7 @@ fn main() {
let mut path = env::args().nth(1).unwrap();
let mut parallel = false;
let mut simple = false;
let (tx, rx) = channel::bounded::<DirEntry>(100);
let (tx, rx) = crossbeam_channel::bounded::<DirEntry>(100);
if path == "parallel" {
path = env::args().nth(2).unwrap();
parallel = true;
Expand Down
2 changes: 1 addition & 1 deletion crates/ignore/src/dir.rs
Expand Up @@ -581,7 +581,7 @@ impl IgnoreBuilder {
.unwrap();
let (gi, err) = builder.build_global();
if let Some(err) = err {
debug!("{}", err);
log::debug!("{}", err);
}
gi
};
Expand Down
2 changes: 1 addition & 1 deletion crates/ignore/src/gitignore.rs
Expand Up @@ -592,7 +592,7 @@ fn parse_excludes_file(data: &[u8]) -> Option<PathBuf> {
// N.B. This is the lazy approach, and isn't technically correct, but
// probably works in more circumstances. I guess we would ideally have
// a full INI parser. Yuck.
lazy_static! {
lazy_static::lazy_static! {
static ref RE: Regex =
Regex::new(r"(?im)^\s*excludesfile\s*=\s*(.+)\s*$").unwrap();
};
Expand Down
13 changes: 0 additions & 13 deletions crates/ignore/src/lib.rs
Expand Up @@ -46,19 +46,6 @@ See the documentation for `WalkBuilder` for many other options.

#![deny(missing_docs)]


#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate log;




use walkdir;
#[cfg(windows)]
extern crate winapi_util;

use std::error;
use std::fmt;
use std::io;
Expand Down
2 changes: 1 addition & 1 deletion crates/ignore/src/types.rs
Expand Up @@ -427,7 +427,7 @@ impl TypesBuilder {
/// If `name` is `all` or otherwise contains any character that is not a
/// Unicode letter or number, then an error is returned.
pub fn add(&mut self, name: &str, glob: &str) -> Result<(), Error> {
lazy_static! {
lazy_static::lazy_static! {
static ref RE: Regex = Regex::new(r"^[\pL\pN]+$").unwrap();
};
if name == "all" || !RE.is_match(name) {
Expand Down
6 changes: 3 additions & 3 deletions crates/ignore/src/walk.rs
Expand Up @@ -1725,7 +1725,7 @@ fn skip_filesize(

if let Some(fs) = filesize {
if fs > max_filesize {
debug!("ignoring {}: {} bytes", path.display(), fs);
log::debug!("ignoring {}: {} bytes", path.display(), fs);
true
} else {
false
Expand All @@ -1738,10 +1738,10 @@ fn skip_filesize(
fn should_skip_entry(ig: &Ignore, dent: &DirEntry) -> bool {
let m = ig.matched_dir_entry(dent);
if m.is_ignore() {
debug!("ignoring {}: {:?}", dent.path().display(), m);
log::debug!("ignoring {}: {:?}", dent.path().display(), m);
true
} else if m.is_whitelist() {
debug!("whitelisting {}: {:?}", dent.path().display(), m);
log::debug!("whitelisting {}: {:?}", dent.path().display(), m);
false
} else {
false
Expand Down
6 changes: 0 additions & 6 deletions crates/matcher/README.md
Expand Up @@ -27,9 +27,3 @@ Add this to your `Cargo.toml`:
[dependencies]
grep-matcher = "0.1"
```

and this to your crate root:

```rust
extern crate grep_matcher;
```
6 changes: 0 additions & 6 deletions crates/pcre2/README.md
Expand Up @@ -30,9 +30,3 @@ Add this to your `Cargo.toml`:
[dependencies]
grep-pcre2 = "0.1"
```

and this to your crate root:

```rust
extern crate grep_pcre2;
```
5 changes: 2 additions & 3 deletions crates/printer/Cargo.toml
Expand Up @@ -16,16 +16,15 @@ edition = "2018"

[features]
default = ["serde1"]
serde1 = ["base64", "serde", "serde_derive", "serde_json"]
serde1 = ["base64", "serde", "serde_json"]

[dependencies]
base64 = { version = "0.13.0", optional = true }
bstr = "0.2.0"
grep-matcher = { version = "0.1.2", path = "../matcher" }
grep-searcher = { version = "0.1.4", path = "../searcher" }
termcolor = "1.0.4"
serde = { version = "1.0.77", optional = true }
serde_derive = { version = "1.0.77", optional = true }
serde = { version = "1.0.77", optional = true, features = ["derive"] }
serde_json = { version = "1.0.27", optional = true }

[dev-dependencies]
Expand Down
6 changes: 0 additions & 6 deletions crates/printer/README.md
Expand Up @@ -26,9 +26,3 @@ Add this to your `Cargo.toml`:
[dependencies]
grep-printer = "0.1"
```

and this to your crate root:

```rust
extern crate grep_printer;
```

0 comments on commit e824531

Please sign in to comment.