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/parse/parser.rs | |
| parent | 4e2e31c11837f244e5039165b777ddedde5dc44d (diff) | |
| parent | bc1400600be083cfb39ffdc6f6b32153e585cd3c (diff) | |
| download | rust-d3ae56d755f912471e4c36982a069317842fa495.tar.gz rust-d3ae56d755f912471e4c36982a069317842fa495.zip | |
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/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index de41ab5e189..99eddce3645 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -40,7 +40,8 @@ use ast::{Visibility, WhereClause}; use attr::{ThinAttributes, ThinAttributesExt, AttributesExt}; use ast::{BinOpKind, UnOp}; use ast; -use codemap::{self, Span, BytePos, Spanned, spanned, mk_sp, CodeMap}; +use codemap::{self, CodeMap, Spanned, spanned}; +use syntax_pos::{self, Span, BytePos, mk_sp}; use errors::{self, DiagnosticBuilder}; use ext::tt::macro_parser; use parse; @@ -344,7 +345,7 @@ impl<'a> Parser<'a> { { let tok0 = rdr.real_token(); let span = tok0.sp; - let filename = if span != codemap::DUMMY_SP { + let filename = if span != syntax_pos::DUMMY_SP { Some(sess.codemap().span_to_filename(span)) } else { None }; let placeholder = TokenAndSpan { @@ -3525,7 +3526,7 @@ impl<'a> Parser<'a> { } /// Parse the fields of a struct-like pattern - fn parse_pat_fields(&mut self) -> PResult<'a, (Vec<codemap::Spanned<ast::FieldPat>> , bool)> { + fn parse_pat_fields(&mut self) -> PResult<'a, (Vec<codemap::Spanned<ast::FieldPat>>, bool)> { let mut fields = Vec::new(); let mut etc = false; let mut first = true; @@ -3595,9 +3596,9 @@ impl<'a> Parser<'a> { }; fields.push(codemap::Spanned { span: mk_sp(lo, hi), - node: ast::FieldPat { ident: fieldname, - pat: subpat, - is_shorthand: is_shorthand }}); + node: ast::FieldPat { ident: fieldname, + pat: subpat, + is_shorthand: is_shorthand }}); } return Ok((fields, etc)); } @@ -3688,7 +3689,7 @@ impl<'a> Parser<'a> { SeqSep::none(), |p| p.parse_token_tree())?; let mac = Mac_ { path: path, tts: tts, ctxt: EMPTY_CTXT }; pat = PatKind::Mac(codemap::Spanned {node: mac, - span: mk_sp(lo, self.last_span.hi)}); + span: mk_sp(lo, self.last_span.hi)}); } else { // Parse ident @ pat // This can give false positives and parse nullary enums, @@ -4935,8 +4936,8 @@ impl<'a> Parser<'a> { |p| p.parse_token_tree())?; let m_ = Mac_ { path: pth, tts: tts, ctxt: EMPTY_CTXT }; let m: ast::Mac = codemap::Spanned { node: m_, - span: mk_sp(lo, - self.last_span.hi) }; + span: mk_sp(lo, + self.last_span.hi) }; if delim != token::Brace { self.expect(&token::Semi)? } @@ -5274,7 +5275,7 @@ impl<'a> Parser<'a> { return Err(self.fatal(&format!("expected item, found `{}`", token_str))); } - let hi = if self.span == codemap::DUMMY_SP { + let hi = if self.span == syntax_pos::DUMMY_SP { inner_lo } else { self.last_span.hi @@ -6020,8 +6021,8 @@ impl<'a> Parser<'a> { // single-variant-enum... : let m = Mac_ { path: pth, tts: tts, ctxt: EMPTY_CTXT }; let m: ast::Mac = codemap::Spanned { node: m, - span: mk_sp(mac_lo, - self.last_span.hi) }; + span: mk_sp(mac_lo, + self.last_span.hi) }; if delim != token::Brace { if !self.eat(&token::Semi) { |
