Skip to content

Commit cb108b7

Browse files
committed
edition: initial migration to Rust 2018
1 parent ccdcf27 commit cb108b7

34 files changed

+204
-204
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ finite automata and guarantees linear time matching on all inputs.
1414
categories = ["text-processing"]
1515
autotests = false
1616
exclude = ["/scripts/*", "/.github/*"]
17+
edition = "2018"
1718

1819
[workspace]
1920
members = [

regex-capi/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ mod macros;
66
mod error;
77
mod rure;
88

9-
pub use error::*;
10-
pub use rure::*;
9+
pub use crate::error::*;
10+
pub use crate::rure::*;

regex-capi/src/rure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::str;
88
use libc::{c_char, size_t};
99
use regex::bytes;
1010

11-
use error::{Error, ErrorKind};
11+
use crate::error::{Error, ErrorKind};
1212

1313
const RURE_FLAG_CASEI: u32 = 1 << 0;
1414
const RURE_FLAG_MULTI: u32 = 1 << 1;

regex-debug/src/main.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use std::result;
1212

1313
use docopt::Docopt;
1414
use regex::internal::{Compiler, LiteralSearcher};
15-
use syntax::hir::literal::Literals;
16-
use syntax::hir::Hir;
15+
use crate::syntax::hir::literal::Literals;
16+
use crate::syntax::hir::Hir;
1717

1818
const USAGE: &'static str = "
1919
Usage:
@@ -127,7 +127,7 @@ fn run(args: &Args) -> Result<()> {
127127
}
128128

129129
fn cmd_ast(args: &Args) -> Result<()> {
130-
use syntax::ast::parse::Parser;
130+
use crate::syntax::ast::parse::Parser;
131131

132132
let mut parser = Parser::new();
133133
let ast = parser.parse(&args.arg_pattern)?;
@@ -136,7 +136,7 @@ fn cmd_ast(args: &Args) -> Result<()> {
136136
}
137137

138138
fn cmd_hir(args: &Args) -> Result<()> {
139-
use syntax::ParserBuilder;
139+
use crate::syntax::ParserBuilder;
140140

141141
let mut parser = ParserBuilder::new().allow_invalid_utf8(false).build();
142142
let hir = parser.parse(&args.arg_pattern)?;
@@ -225,9 +225,9 @@ fn cmd_compile(args: &Args) -> Result<()> {
225225
}
226226

227227
fn cmd_utf8_ranges(args: &Args) -> Result<()> {
228-
use syntax::hir::{self, HirKind};
229-
use syntax::utf8::Utf8Sequences;
230-
use syntax::ParserBuilder;
228+
use crate::syntax::hir::{self, HirKind};
229+
use crate::syntax::utf8::Utf8Sequences;
230+
use crate::syntax::ParserBuilder;
231231

232232
let hir = ParserBuilder::new()
233233
.build()
@@ -258,9 +258,9 @@ fn cmd_utf8_ranges(args: &Args) -> Result<()> {
258258
}
259259

260260
fn cmd_utf8_ranges_rev(args: &Args) -> Result<()> {
261-
use syntax::hir::{self, HirKind};
262-
use syntax::utf8::Utf8Sequences;
263-
use syntax::ParserBuilder;
261+
use crate::syntax::hir::{self, HirKind};
262+
use crate::syntax::utf8::Utf8Sequences;
263+
use crate::syntax::ParserBuilder;
264264

265265
let hir = ParserBuilder::new()
266266
.build()
@@ -334,7 +334,7 @@ impl Args {
334334
}
335335

336336
fn parse(re: &str) -> Result<Hir> {
337-
use syntax::ParserBuilder;
337+
use crate::syntax::ParserBuilder;
338338
ParserBuilder::new()
339339
.allow_invalid_utf8(true)
340340
.build()

regex-syntax/src/ast/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::cmp::Ordering;
66
use std::error;
77
use std::fmt;
88

9-
pub use ast::visitor::{visit, Visitor};
9+
pub use crate::ast::visitor::{visit, Visitor};
1010

1111
pub mod parse;
1212
pub mod print;
@@ -221,7 +221,7 @@ impl error::Error for Error {
221221

222222
impl fmt::Display for Error {
223223
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
224-
::error::Formatter::from(self).fmt(f)
224+
crate::error::Formatter::from(self).fmt(f)
225225
}
226226
}
227227

@@ -543,7 +543,7 @@ impl Ast {
543543
/// to the size of the `Ast`.
544544
impl fmt::Display for Ast {
545545
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
546-
use ast::print::Printer;
546+
use crate::ast::print::Printer;
547547
Printer::new().print(self, f)
548548
}
549549
}

regex-syntax/src/ast/parse.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ use std::cell::{Cell, RefCell};
77
use std::mem;
88
use std::result;
99

10-
use ast::{self, Ast, Position, Span};
11-
use either::Either;
10+
use crate::ast::{self, Ast, Position, Span};
11+
use crate::either::Either;
1212

13-
use is_meta_character;
13+
use crate::is_meta_character;
1414

1515
type Result<T> = result::Result<T, ast::Error>;
1616

@@ -61,7 +61,7 @@ impl Primitive {
6161
p: &ParserI<P>,
6262
) -> Result<ast::ClassSetItem> {
6363
use self::Primitive::*;
64-
use ast::ClassSetItem;
64+
use crate::ast::ClassSetItem;
6565

6666
match self {
6767
Literal(lit) => Ok(ClassSetItem::Literal(lit)),
@@ -2312,7 +2312,7 @@ mod tests {
23122312
use std::ops::Range;
23132313

23142314
use super::{Parser, ParserBuilder, ParserI, Primitive};
2315-
use ast::{self, Ast, Position, Span};
2315+
use crate::ast::{self, Ast, Position, Span};
23162316

23172317
// Our own assert_eq, which has slightly better formatting (but honestly
23182318
// still kind of crappy).

regex-syntax/src/ast/print.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ This module provides a regular expression printer for `Ast`.
44

55
use std::fmt;
66

7-
use ast::visitor::{self, Visitor};
8-
use ast::{self, Ast};
7+
use crate::ast::visitor::{self, Visitor};
8+
use crate::ast::{self, Ast};
99

1010
/// A builder for constructing a printer.
1111
///
@@ -86,7 +86,7 @@ impl<'p, W: fmt::Write> Visitor for Writer<'p, W> {
8686
}
8787

8888
fn visit_post(&mut self, ast: &Ast) -> fmt::Result {
89-
use ast::Class;
89+
use crate::ast::Class;
9090

9191
match *ast {
9292
Ast::Empty(_) => Ok(()),
@@ -126,7 +126,7 @@ impl<'p, W: fmt::Write> Visitor for Writer<'p, W> {
126126
&mut self,
127127
ast: &ast::ClassSetItem,
128128
) -> Result<(), Self::Err> {
129-
use ast::ClassSetItem::*;
129+
use crate::ast::ClassSetItem::*;
130130

131131
match *ast {
132132
Empty(_) => Ok(()),
@@ -155,7 +155,7 @@ impl<'p, W: fmt::Write> Visitor for Writer<'p, W> {
155155

156156
impl<'p, W: fmt::Write> Writer<'p, W> {
157157
fn fmt_group_pre(&mut self, ast: &ast::Group) -> fmt::Result {
158-
use ast::GroupKind::*;
158+
use crate::ast::GroupKind::*;
159159
match ast.kind {
160160
CaptureIndex(_) => self.wtr.write_str("("),
161161
CaptureName(ref x) => {
@@ -178,7 +178,7 @@ impl<'p, W: fmt::Write> Writer<'p, W> {
178178
}
179179

180180
fn fmt_repetition(&mut self, ast: &ast::Repetition) -> fmt::Result {
181-
use ast::RepetitionKind::*;
181+
use crate::ast::RepetitionKind::*;
182182
match ast.op.kind {
183183
ZeroOrOne if ast.greedy => self.wtr.write_str("?"),
184184
ZeroOrOne => self.wtr.write_str("??"),
@@ -200,7 +200,7 @@ impl<'p, W: fmt::Write> Writer<'p, W> {
200200
&mut self,
201201
ast: &ast::RepetitionRange,
202202
) -> fmt::Result {
203-
use ast::RepetitionRange::*;
203+
use crate::ast::RepetitionRange::*;
204204
match *ast {
205205
Exactly(x) => write!(self.wtr, "{{{}}}", x),
206206
AtLeast(x) => write!(self.wtr, "{{{},}}", x),
@@ -209,7 +209,7 @@ impl<'p, W: fmt::Write> Writer<'p, W> {
209209
}
210210

211211
fn fmt_literal(&mut self, ast: &ast::Literal) -> fmt::Result {
212-
use ast::LiteralKind::*;
212+
use crate::ast::LiteralKind::*;
213213

214214
match ast.kind {
215215
Verbatim => self.wtr.write_char(ast.c),
@@ -256,7 +256,7 @@ impl<'p, W: fmt::Write> Writer<'p, W> {
256256
}
257257

258258
fn fmt_assertion(&mut self, ast: &ast::Assertion) -> fmt::Result {
259-
use ast::AssertionKind::*;
259+
use crate::ast::AssertionKind::*;
260260
match ast.kind {
261261
StartLine => self.wtr.write_str("^"),
262262
EndLine => self.wtr.write_str("$"),
@@ -275,7 +275,7 @@ impl<'p, W: fmt::Write> Writer<'p, W> {
275275
}
276276

277277
fn fmt_flags(&mut self, ast: &ast::Flags) -> fmt::Result {
278-
use ast::{Flag, FlagsItemKind};
278+
use crate::ast::{Flag, FlagsItemKind};
279279

280280
for item in &ast.items {
281281
match item.kind {
@@ -315,7 +315,7 @@ impl<'p, W: fmt::Write> Writer<'p, W> {
315315
&mut self,
316316
ast: &ast::ClassSetBinaryOpKind,
317317
) -> fmt::Result {
318-
use ast::ClassSetBinaryOpKind::*;
318+
use crate::ast::ClassSetBinaryOpKind::*;
319319
match *ast {
320320
Intersection => self.wtr.write_str("&&"),
321321
Difference => self.wtr.write_str("--"),
@@ -324,7 +324,7 @@ impl<'p, W: fmt::Write> Writer<'p, W> {
324324
}
325325

326326
fn fmt_class_perl(&mut self, ast: &ast::ClassPerl) -> fmt::Result {
327-
use ast::ClassPerlKind::*;
327+
use crate::ast::ClassPerlKind::*;
328328
match ast.kind {
329329
Digit if ast.negated => self.wtr.write_str(r"\D"),
330330
Digit => self.wtr.write_str(r"\d"),
@@ -336,7 +336,7 @@ impl<'p, W: fmt::Write> Writer<'p, W> {
336336
}
337337

338338
fn fmt_class_ascii(&mut self, ast: &ast::ClassAscii) -> fmt::Result {
339-
use ast::ClassAsciiKind::*;
339+
use crate::ast::ClassAsciiKind::*;
340340
match ast.kind {
341341
Alnum if ast.negated => self.wtr.write_str("[:^alnum:]"),
342342
Alnum => self.wtr.write_str("[:alnum:]"),
@@ -370,8 +370,8 @@ impl<'p, W: fmt::Write> Writer<'p, W> {
370370
}
371371

372372
fn fmt_class_unicode(&mut self, ast: &ast::ClassUnicode) -> fmt::Result {
373-
use ast::ClassUnicodeKind::*;
374-
use ast::ClassUnicodeOpKind::*;
373+
use crate::ast::ClassUnicodeKind::*;
374+
use crate::ast::ClassUnicodeOpKind::*;
375375

376376
if ast.negated {
377377
self.wtr.write_str(r"\P")?;
@@ -397,7 +397,7 @@ impl<'p, W: fmt::Write> Writer<'p, W> {
397397
#[cfg(test)]
398398
mod tests {
399399
use super::Printer;
400-
use ast::parse::ParserBuilder;
400+
use crate::ast::parse::ParserBuilder;
401401

402402
fn roundtrip(given: &str) {
403403
roundtrip_with(|b| b, given);

regex-syntax/src/ast/visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::fmt;
22

3-
use ast::{self, Ast};
3+
use crate::ast::{self, Ast};
44

55
/// A trait for visiting an abstract syntax tree (AST) in depth first order.
66
///

regex-syntax/src/error.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use std::error;
33
use std::fmt;
44
use std::result;
55

6-
use ast;
7-
use hir;
6+
use crate::ast;
7+
use crate::hir;
88

99
/// A type alias for dealing with errors returned by this crate.
1010
pub type Result<T> = result::Result<T, Error>;
@@ -286,7 +286,7 @@ fn repeat_char(c: char, count: usize) -> String {
286286

287287
#[cfg(test)]
288288
mod tests {
289-
use ast::parse::Parser;
289+
use crate::ast::parse::Parser;
290290

291291
fn assert_panic_message(pattern: &str, expected_msg: &str) -> () {
292292
let result = Parser::new().parse(pattern);

regex-syntax/src/hir/interval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::fmt::Debug;
44
use std::slice;
55
use std::u8;
66

7-
use unicode;
7+
use crate::unicode;
88

99
// This module contains an *internal* implementation of interval sets.
1010
//

regex-syntax/src/hir/literal/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::iter;
88
use std::mem;
99
use std::ops;
1010

11-
use hir::{self, Hir, HirKind};
11+
use crate::hir::{self, Hir, HirKind};
1212

1313
/// A set of literal byte strings extracted from a regular expression.
1414
///
@@ -977,8 +977,8 @@ mod tests {
977977
use std::fmt;
978978

979979
use super::{escape_bytes, Literal, Literals};
980-
use hir::Hir;
981-
use ParserBuilder;
980+
use crate::hir::Hir;
981+
use crate::ParserBuilder;
982982

983983
// To make test failures easier to read.
984984
#[derive(Debug, Eq, PartialEq)]

regex-syntax/src/hir/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ use std::fmt;
88
use std::result;
99
use std::u8;
1010

11-
use ast::Span;
12-
use hir::interval::{Interval, IntervalSet, IntervalSetIter};
13-
use unicode;
11+
use crate::ast::Span;
12+
use crate::hir::interval::{Interval, IntervalSet, IntervalSetIter};
13+
use crate::unicode;
1414

15-
pub use hir::visitor::{visit, Visitor};
16-
pub use unicode::CaseFoldError;
15+
pub use crate::hir::visitor::{visit, Visitor};
16+
pub use crate::unicode::CaseFoldError;
1717

1818
mod interval;
1919
pub mod literal;
@@ -124,7 +124,7 @@ impl error::Error for Error {
124124

125125
impl fmt::Display for Error {
126126
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
127-
::error::Formatter::from(self).fmt(f)
127+
crate::error::Formatter::from(self).fmt(f)
128128
}
129129
}
130130

@@ -728,7 +728,7 @@ impl HirKind {
728728
/// to the size of the `Hir`.
729729
impl fmt::Display for Hir {
730730
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
731-
use hir::print::Printer;
731+
use crate::hir::print::Printer;
732732
Printer::new().print(self, f)
733733
}
734734
}

regex-syntax/src/hir/print.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ This module provides a regular expression printer for `Hir`.
44

55
use std::fmt;
66

7-
use hir::visitor::{self, Visitor};
8-
use hir::{self, Hir, HirKind};
9-
use is_meta_character;
7+
use crate::hir::visitor::{self, Visitor};
8+
use crate::hir::{self, Hir, HirKind};
9+
use crate::is_meta_character;
1010

1111
/// A builder for constructing a printer.
1212
///
@@ -239,7 +239,7 @@ impl<'p, W: fmt::Write> Writer<'p, W> {
239239
#[cfg(test)]
240240
mod tests {
241241
use super::Printer;
242-
use ParserBuilder;
242+
use crate::ParserBuilder;
243243

244244
fn roundtrip(given: &str, expected: &str) {
245245
roundtrip_with(|b| b, given, expected);

0 commit comments

Comments
 (0)