about summary refs log tree commit diff
path: root/src/libfmt_macros
diff options
context:
space:
mode:
authorEsteban Küber <esteban@commure.com>2018-07-21 16:18:06 -0700
committerEsteban Küber <esteban@commure.com>2018-07-21 16:18:06 -0700
commit93b2bb01a961fdb61a4aeaf6bc6bdcab9ccedbe2 (patch)
tree9a3888c5613db82e46511a9c81602fb13229646e /src/libfmt_macros
parenta7a68370a72cc553c8ca983fe593062235360b9b (diff)
downloadrust-93b2bb01a961fdb61a4aeaf6bc6bdcab9ccedbe2.tar.gz
rust-93b2bb01a961fdb61a4aeaf6bc6bdcab9ccedbe2.zip
Remove dependency on `libsyntax`
Diffstat (limited to 'src/libfmt_macros')
-rw-r--r--src/libfmt_macros/Cargo.toml3
-rw-r--r--src/libfmt_macros/lib.rs18
2 files changed, 5 insertions, 16 deletions
diff --git a/src/libfmt_macros/Cargo.toml b/src/libfmt_macros/Cargo.toml
index 6e6af9c2ff5..b3f4d2deae2 100644
--- a/src/libfmt_macros/Cargo.toml
+++ b/src/libfmt_macros/Cargo.toml
@@ -7,6 +7,3 @@ version = "0.0.0"
 name = "fmt_macros"
 path = "lib.rs"
 crate-type = ["dylib"]
-
-[dependencies]
-syntax = { path = "../libsyntax" }
diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs
index 52223b2343c..3d17ccec121 100644
--- a/src/libfmt_macros/lib.rs
+++ b/src/libfmt_macros/lib.rs
@@ -28,8 +28,6 @@ pub use self::Alignment::*;
 pub use self::Flag::*;
 pub use self::Count::*;
 
-extern crate syntax;
-
 use std::str;
 use std::string;
 use std::iter;
@@ -152,8 +150,8 @@ pub struct Parser<'a> {
     pub errors: Vec<ParseError>,
     /// Current position of implicit positional argument pointer
     curarg: usize,
-    /// The style of the string (raw or not), used to position spans correctly
-    style: syntax::ast::StrStyle,
+    /// `Some(raw count)` when the string is "raw", used to position spans correctly
+    style: Option<usize>,
     /// How many newlines have been seen in the string so far, to adjust the error spans
     seen_newlines: usize,
 }
@@ -162,10 +160,7 @@ impl<'a> Iterator for Parser<'a> {
     type Item = Piece<'a>;
 
     fn next(&mut self) -> Option<Piece<'a>> {
-        let raw = match self.style {
-            syntax::ast::StrStyle::Raw(raw) => raw as usize + self.seen_newlines,
-            _ => 0,
-        };
+        let raw = self.style.map(|raw| raw + self.seen_newlines).unwrap_or(0);
         if let Some(&(pos, c)) = self.cur.peek() {
             match c {
                 '{' => {
@@ -208,7 +203,7 @@ impl<'a> Iterator for Parser<'a> {
 
 impl<'a> Parser<'a> {
     /// Creates a new parser for the given format string
-    pub fn new(s: &'a str, style: syntax::ast::StrStyle) -> Parser<'a> {
+    pub fn new(s: &'a str, style: Option<usize>) -> Parser<'a> {
         Parser {
             input: s,
             cur: s.char_indices().peekable(),
@@ -278,10 +273,7 @@ impl<'a> Parser<'a> {
     /// found, an error is emitted.
     fn must_consume(&mut self, c: char) {
         self.ws();
-        let raw = match self.style {
-            syntax::ast::StrStyle::Raw(raw) => raw as usize,
-            _ => 0,
-        };
+        let raw = self.style.unwrap_or(0);
 
         let padding = raw + self.seen_newlines;
         if let Some(&(pos, maybe)) = self.cur.peek() {