about summary refs log tree commit diff
path: root/src
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
parenta7a68370a72cc553c8ca983fe593062235360b9b (diff)
downloadrust-93b2bb01a961fdb61a4aeaf6bc6bdcab9ccedbe2.tar.gz
rust-93b2bb01a961fdb61a4aeaf6bc6bdcab9ccedbe2.zip
Remove dependency on `libsyntax`
Diffstat (limited to 'src')
-rw-r--r--src/Cargo.lock3
-rw-r--r--src/libfmt_macros/Cargo.toml3
-rw-r--r--src/libfmt_macros/lib.rs18
-rw-r--r--src/librustc/traits/on_unimplemented.rs6
-rw-r--r--src/libsyntax_ext/format.rs6
5 files changed, 13 insertions, 23 deletions
diff --git a/src/Cargo.lock b/src/Cargo.lock
index c59c1108495..8299dea1c4b 100644
--- a/src/Cargo.lock
+++ b/src/Cargo.lock
@@ -715,9 +715,6 @@ dependencies = [
 [[package]]
 name = "fmt_macros"
 version = "0.0.0"
-dependencies = [
- "syntax 0.0.0",
-]
 
 [[package]]
 name = "fnv"
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() {
diff --git a/src/librustc/traits/on_unimplemented.rs b/src/librustc/traits/on_unimplemented.rs
index 33d5502eba0..925d3504f75 100644
--- a/src/librustc/traits/on_unimplemented.rs
+++ b/src/librustc/traits/on_unimplemented.rs
@@ -15,7 +15,7 @@ use ty::{self, TyCtxt, GenericParamDefKind};
 use util::common::ErrorReported;
 use util::nodemap::FxHashMap;
 
-use syntax::ast::{self, MetaItem, NestedMetaItem};
+use syntax::ast::{MetaItem, NestedMetaItem};
 use syntax::attr;
 use syntax_pos::Span;
 use syntax_pos::symbol::LocalInternedString;
@@ -242,7 +242,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedFormatString {
     {
         let name = tcx.item_name(trait_def_id);
         let generics = tcx.generics_of(trait_def_id);
-        let parser = Parser::new(&self.0, ast::StrStyle::Cooked);
+        let parser = Parser::new(&self.0, None);
         let mut result = Ok(());
         for token in parser {
             match token {
@@ -298,7 +298,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedFormatString {
             Some((name, value))
         }).collect::<FxHashMap<String, String>>();
 
-        let parser = Parser::new(&self.0, ast::StrStyle::Cooked);
+        let parser = Parser::new(&self.0, None);
         parser.map(|p| {
             match p {
                 Piece::String(s) => s,
diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs
index 5b8f059fd14..c63cc3727ed 100644
--- a/src/libsyntax_ext/format.rs
+++ b/src/libsyntax_ext/format.rs
@@ -778,7 +778,11 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt,
     };
 
     let fmt_str = &*fmt.node.0.as_str();
-    let mut parser = parse::Parser::new(fmt_str, fmt.node.1);
+    let str_style = match fmt.node.1 {
+        ast::StrStyle::Cooked => None,
+        ast::StrStyle::Raw(raw) => Some(raw as usize),
+    };
+    let mut parser = parse::Parser::new(fmt_str, str_style);
     let mut pieces = vec![];
 
     while let Some(mut piece) = parser.next() {