Skip to content

Commit 94ce242

Browse files
committed
edition: more 2018 migration (idioms)
1 parent cb108b7 commit 94ce242

30 files changed

+106
-108
lines changed

examples/shootout-regex-dna-bytes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// contributed by TeXitoi
66
// contributed by BurntSushi
77

8-
extern crate regex;
8+
99

1010
use std::io::{self, Read};
1111
use std::sync::Arc;

examples/shootout-regex-dna-cheat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// replacing them with a single linear scan. i.e., it re-implements
1111
// `replace_all`. As a result, this is around 25% faster. ---AG
1212

13-
extern crate regex;
13+
1414

1515
use std::io::{self, Read};
1616
use std::sync::Arc;

examples/shootout-regex-dna-replace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
extern crate regex;
1+
22

33
use std::io::{self, Read};
44

examples/shootout-regex-dna-single-cheat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// contributed by TeXitoi
66
// contributed by BurntSushi
77

8-
extern crate regex;
8+
99

1010
use std::io::{self, Read};
1111

examples/shootout-regex-dna-single.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// contributed by TeXitoi
66
// contributed by BurntSushi
77

8-
extern crate regex;
8+
99

1010
use std::io::{self, Read};
1111

examples/shootout-regex-dna.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// contributed by TeXitoi
66
// contributed by BurntSushi
77

8-
extern crate regex;
8+
99

1010
use std::io::{self, Read};
1111
use std::sync::Arc;

src/dfa.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ impl State {
306306
StateFlags(self.data[0])
307307
}
308308

309-
fn inst_ptrs(&self) -> InstPtrs {
309+
fn inst_ptrs(&self) -> InstPtrs<'_> {
310310
InstPtrs { base: 0, data: &self.data[1..] }
311311
}
312312
}
@@ -1754,7 +1754,7 @@ impl Byte {
17541754
}
17551755

17561756
impl fmt::Debug for State {
1757-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1757+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17581758
let ips: Vec<usize> = self.inst_ptrs().collect();
17591759
f.debug_struct("State")
17601760
.field("flags", &self.flags())
@@ -1764,7 +1764,7 @@ impl fmt::Debug for State {
17641764
}
17651765

17661766
impl fmt::Debug for Transitions {
1767-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1767+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17681768
let mut fmtd = f.debug_map();
17691769
for si in 0..self.num_states() {
17701770
let s = si * self.num_byte_classes;
@@ -1778,7 +1778,7 @@ impl fmt::Debug for Transitions {
17781778
struct TransitionsRow<'a>(&'a [StatePtr]);
17791779

17801780
impl<'a> fmt::Debug for TransitionsRow<'a> {
1781-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1781+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17821782
let mut fmtd = f.debug_map();
17831783
for (b, si) in self.0.iter().enumerate() {
17841784
match *si {
@@ -1796,7 +1796,7 @@ impl<'a> fmt::Debug for TransitionsRow<'a> {
17961796
}
17971797

17981798
impl fmt::Debug for StateFlags {
1799-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1799+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18001800
f.debug_struct("StateFlags")
18011801
.field("is_match", &self.is_match())
18021802
.field("is_word", &self.is_word())
@@ -1889,7 +1889,7 @@ fn read_varu32(data: &[u8]) -> (u32, usize) {
18891889

18901890
#[cfg(test)]
18911891
mod tests {
1892-
extern crate rand;
1892+
18931893

18941894
use super::{
18951895
push_inst_ptr, read_vari32, read_varu32, write_vari32, write_varu32,

src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl ::std::error::Error for Error {
3131
}
3232

3333
impl fmt::Display for Error {
34-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
34+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3535
match *self {
3636
Error::Syntax(ref err) => err.fmt(f),
3737
Error::CompiledTooBig(limit) => write!(
@@ -49,7 +49,7 @@ impl fmt::Display for Error {
4949
// but the `Syntax` variant is already storing a `String` anyway, so we might
5050
// as well format it nicely.
5151
impl fmt::Debug for Error {
52-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
52+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
5353
match *self {
5454
Error::Syntax(ref err) => {
5555
let hr: String = repeat('~').take(79).collect();

src/exec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,7 @@ impl<'c> ExecNoSyncStr<'c> {
12631263
impl Exec {
12641264
/// Get a searcher that isn't Sync.
12651265
#[cfg_attr(feature = "perf-inline", inline(always))]
1266-
pub fn searcher(&self) -> ExecNoSync {
1266+
pub fn searcher(&self) -> ExecNoSync<'_> {
12671267
ExecNoSync {
12681268
ro: &self.ro, // a clone is too expensive here! (and not needed)
12691269
cache: self.pool.get(),
@@ -1272,7 +1272,7 @@ impl Exec {
12721272

12731273
/// Get a searcher that isn't Sync and can match on &str.
12741274
#[cfg_attr(feature = "perf-inline", inline(always))]
1275-
pub fn searcher_str(&self) -> ExecNoSyncStr {
1275+
pub fn searcher_str(&self) -> ExecNoSyncStr<'_> {
12761276
ExecNoSyncStr(self.searcher())
12771277
}
12781278

src/expand.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::re_bytes;
66
use crate::re_unicode;
77

88
pub fn expand_str(
9-
caps: &re_unicode::Captures,
9+
caps: &re_unicode::Captures<'_>,
1010
mut replacement: &str,
1111
dst: &mut String,
1212
) {
@@ -48,7 +48,7 @@ pub fn expand_str(
4848
}
4949

5050
pub fn expand_bytes(
51-
caps: &re_bytes::Captures,
51+
caps: &re_bytes::Captures<'_>,
5252
mut replacement: &[u8],
5353
dst: &mut Vec<u8>,
5454
) {
@@ -125,7 +125,7 @@ impl From<usize> for Ref<'static> {
125125
/// starting at the beginning of `replacement`.
126126
///
127127
/// If no such valid reference could be found, None is returned.
128-
fn find_cap_ref(replacement: &[u8]) -> Option<CaptureRef> {
128+
fn find_cap_ref(replacement: &[u8]) -> Option<CaptureRef<'_>> {
129129
let mut i = 0;
130130
let rep: &[u8] = replacement.as_ref();
131131
if rep.len() <= 1 || rep[0] != b'$' {
@@ -157,7 +157,7 @@ fn find_cap_ref(replacement: &[u8]) -> Option<CaptureRef> {
157157
})
158158
}
159159

160-
fn find_cap_ref_braced(rep: &[u8], mut i: usize) -> Option<CaptureRef> {
160+
fn find_cap_ref_braced(rep: &[u8], mut i: usize) -> Option<CaptureRef<'_>> {
161161
let start = i;
162162
while rep.get(i).map_or(false, |&b| b != b'}') {
163163
i += 1;

src/input.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ impl<'t> Input for ByteInput<'t> {
348348
pub struct Char(u32);
349349

350350
impl fmt::Debug for Char {
351-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
351+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
352352
match char::from_u32(self.0) {
353353
None => write!(f, "Empty"),
354354
Some(c) => write!(f, "{:?}", c),

src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -622,10 +622,8 @@ compile_error!("`std` feature is currently required to build this crate");
622622

623623
#[cfg(feature = "perf-literal")]
624624
extern crate aho_corasick;
625-
#[cfg(feature = "perf-literal")]
626-
extern crate memchr;
627-
#[cfg(test)]
628-
extern crate quickcheck;
625+
626+
629627
extern crate regex_syntax as syntax;
630628

631629
// #[cfg(doctest)]

src/literal/imp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl LiteralSearcher {
119119
}
120120

121121
/// Returns an iterator over all literals to be matched.
122-
pub fn iter(&self) -> LiteralIter {
122+
pub fn iter(&self) -> LiteralIter<'_> {
123123
match self.matcher {
124124
Matcher::Empty => LiteralIter::Empty,
125125
Matcher::Bytes(ref sset) => LiteralIter::Bytes(&sset.dense),

src/pool.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ pub struct Pool<T> {
154154
unsafe impl<T: Send> Sync for Pool<T> {}
155155

156156
impl<T: ::std::fmt::Debug> ::std::fmt::Debug for Pool<T> {
157-
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
157+
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
158158
f.debug_struct("Pool")
159159
.field("stack", &self.stack)
160160
.field("owner", &self.owner)
@@ -168,7 +168,7 @@ impl<T: ::std::fmt::Debug> ::std::fmt::Debug for Pool<T> {
168168
/// The purpose of the guard is to use RAII to automatically put the value back
169169
/// in the pool once it's dropped.
170170
#[derive(Debug)]
171-
pub struct PoolGuard<'a, T: 'a + Send> {
171+
pub struct PoolGuard<'a, T: Send> {
172172
/// The pool that this guard is attached to.
173173
pool: &'a Pool<T>,
174174
/// This is None when the guard represents the special "owned" value. In
@@ -193,7 +193,7 @@ impl<T: Send> Pool<T> {
193193
/// the value to go back into the pool) and then calling get again is NOT
194194
/// guaranteed to return the same value received in the first get call.
195195
#[cfg_attr(feature = "perf-inline", inline(always))]
196-
pub fn get(&self) -> PoolGuard<T> {
196+
pub fn get(&self) -> PoolGuard<'_, T> {
197197
// Our fast path checks if the caller is the thread that "owns" this
198198
// pool. Or stated differently, whether it is the first thread that
199199
// tried to extract a value from the pool. If it is, then we can return
@@ -217,7 +217,7 @@ impl<T: Send> Pool<T> {
217217
///
218218
/// If the pool has no owner, then this will set the owner.
219219
#[cold]
220-
fn get_slow(&self, caller: usize, owner: usize) -> PoolGuard<T> {
220+
fn get_slow(&self, caller: usize, owner: usize) -> PoolGuard<'_, T> {
221221
use std::sync::atomic::Ordering::Relaxed;
222222

223223
if owner == 0 {

src/prog.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl Deref for Program {
168168
}
169169

170170
impl fmt::Debug for Program {
171-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
171+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
172172
use self::Inst::*;
173173

174174
fn with_goto(cur: usize, goto: usize, fmtd: String) -> String {

0 commit comments

Comments
 (0)