diff options
| author | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2016-06-25 22:27:27 +0000 |
|---|---|---|
| committer | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2016-06-25 22:35:09 +0000 |
| commit | d3ae56d755f912471e4c36982a069317842fa495 (patch) | |
| tree | b2056ff0adb5634e0793e94b98af46cd19709390 /src/libsyntax/print | |
| parent | 4e2e31c11837f244e5039165b777ddedde5dc44d (diff) | |
| parent | bc1400600be083cfb39ffdc6f6b32153e585cd3c (diff) | |
Rollup merge of #34403 - jonathandturner:move_liberror, r=alexcrichton
This PR refactors the 'errors' part of libsyntax into its own crate (librustc_errors). This is the first part of a few refactorings to simplify error reporting and potentially support more output formats (like a standardized JSON output and possibly an --explain mode that can work with the user's code), though this PR stands on its own and doesn't assume further changes. As part of separating out the errors crate, I have also refactored the code position portion of codemap into its own crate (libsyntax_pos). While it's helpful to have the common code positions in a separate crate for the new errors crate, this may also enable further simplifications in the future.
Diffstat (limited to 'src/libsyntax/print')
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 1fefc53af63..9fc5e1089c0 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -18,7 +18,8 @@ use attr::ThinAttributesExt; use util::parser::AssocOp; use attr; use attr::{AttrMetaMethods, AttributeMethods}; -use codemap::{self, CodeMap, BytePos}; +use codemap::{self, CodeMap}; +use syntax_pos::{self, BytePos}; use errors; use parse::token::{self, keywords, BinOpToken, Token, InternedString}; use parse::lexer::comments; @@ -842,11 +843,11 @@ impl<'a> State<'a> { self.end() // close the head-box } - pub fn bclose_(&mut self, span: codemap::Span, + pub fn bclose_(&mut self, span: syntax_pos::Span, indented: usize) -> io::Result<()> { self.bclose_maybe_open(span, indented, true) } - pub fn bclose_maybe_open(&mut self, span: codemap::Span, + pub fn bclose_maybe_open(&mut self, span: syntax_pos::Span, indented: usize, close_box: bool) -> io::Result<()> { try!(self.maybe_print_comment(span.hi)); try!(self.break_offset_if_not_bol(1, -(indented as isize))); @@ -856,7 +857,7 @@ impl<'a> State<'a> { } Ok(()) } - pub fn bclose(&mut self, span: codemap::Span) -> io::Result<()> { + pub fn bclose(&mut self, span: syntax_pos::Span) -> io::Result<()> { self.bclose_(span, INDENT_UNIT) } @@ -900,7 +901,7 @@ impl<'a> State<'a> { mut op: F, mut get_span: G) -> io::Result<()> where F: FnMut(&mut State, &T) -> io::Result<()>, - G: FnMut(&T) -> codemap::Span, + G: FnMut(&T) -> syntax_pos::Span, { try!(self.rbox(0, b)); let len = elts.len(); @@ -1352,7 +1353,7 @@ impl<'a> State<'a> { pub fn print_enum_def(&mut self, enum_definition: &ast::EnumDef, generics: &ast::Generics, ident: ast::Ident, - span: codemap::Span, + span: syntax_pos::Span, visibility: &ast::Visibility) -> io::Result<()> { try!(self.head(&visibility_qualified(visibility, "enum"))); try!(self.print_ident(ident)); @@ -1364,7 +1365,7 @@ impl<'a> State<'a> { pub fn print_variants(&mut self, variants: &[ast::Variant], - span: codemap::Span) -> io::Result<()> { + span: syntax_pos::Span) -> io::Result<()> { try!(self.bopen()); for v in variants { try!(self.space_if_not_bol()); @@ -1393,7 +1394,7 @@ impl<'a> State<'a> { struct_def: &ast::VariantData, generics: &ast::Generics, ident: ast::Ident, - span: codemap::Span, + span: syntax_pos::Span, print_finalizer: bool) -> io::Result<()> { try!(self.print_ident(ident)); try!(self.print_generics(generics)); @@ -3010,7 +3011,7 @@ impl<'a> State<'a> { self.end() } - pub fn maybe_print_trailing_comment(&mut self, span: codemap::Span, + pub fn maybe_print_trailing_comment(&mut self, span: syntax_pos::Span, next_pos: Option<BytePos>) -> io::Result<()> { let cm = match self.cm { @@ -3115,6 +3116,7 @@ mod tests { use ast; use codemap; use parse::token; + use syntax_pos; #[test] fn test_fun_to_string() { @@ -3122,7 +3124,7 @@ mod tests { let decl = ast::FnDecl { inputs: Vec::new(), - output: ast::FunctionRetTy::Default(codemap::DUMMY_SP), + output: ast::FunctionRetTy::Default(syntax_pos::DUMMY_SP), variadic: false }; let generics = ast::Generics::default(); @@ -3136,7 +3138,7 @@ mod tests { fn test_variant_to_string() { let ident = token::str_to_ident("principal_skinner"); - let var = codemap::respan(codemap::DUMMY_SP, ast::Variant_ { + let var = codemap::respan(syntax_pos::DUMMY_SP, ast::Variant_ { name: ident, attrs: Vec::new(), // making this up as I go.... ? |
