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/ext | |
| 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/ext')
| -rw-r--r-- | src/libsyntax/ext/base.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/ext/quote.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax/ext/source_util.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_rules.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/transcribe.rs | 2 |
8 files changed, 22 insertions, 21 deletions
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 9d467b4095a..3ee25634207 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -13,8 +13,8 @@ pub use self::SyntaxExtension::*; use ast; use ast::{Name, PatKind}; use attr::HasAttrs; -use codemap; -use codemap::{CodeMap, Span, ExpnId, ExpnInfo, NO_EXPANSION}; +use codemap::{self, CodeMap, ExpnInfo}; +use syntax_pos::{Span, ExpnId, NO_EXPANSION}; use errors::DiagnosticBuilder; use ext; use ext::expand; diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 1d27cf5b0a1..fdf26263330 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -11,7 +11,8 @@ use abi::Abi; use ast::{self, Ident, Generics, Expr, BlockCheckMode, UnOp, PatKind}; use attr; -use codemap::{Span, respan, Spanned, DUMMY_SP, Pos}; +use syntax_pos::{Span, DUMMY_SP, Pos}; +use codemap::{respan, Spanned}; use ext::base::ExtCtxt; use parse::token::{self, keywords, InternedString}; use ptr::P; diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 126f39bcb0e..123d38c0006 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -18,8 +18,8 @@ use ext::mtwt; use ext::build::AstBuilder; use attr; use attr::{AttrMetaMethods, WithAttrs, ThinAttributesExt}; -use codemap; -use codemap::{Span, Spanned, ExpnInfo, ExpnId, NameAndSpan, MacroBang, MacroAttribute}; +use codemap::{Spanned, ExpnInfo, NameAndSpan, MacroBang, MacroAttribute}; +use syntax_pos::{self, Span, ExpnId}; use config::StripUnconfigured; use ext::base::*; use feature_gate::{self, Features}; @@ -1053,7 +1053,7 @@ impl<'a, 'b> Folder for MacroExpander<'a, 'b> { result = expand_item(item, self); self.pop_mod_path(); } else { - let filename = if inner != codemap::DUMMY_SP { + let filename = if inner != syntax_pos::DUMMY_SP { Some(self.cx.parse_sess.codemap().span_to_filename(inner)) } else { None }; let orig_filename = replace(&mut self.cx.filename, filename); @@ -1242,7 +1242,7 @@ mod tests { use super::{PatIdentFinder, IdentRenamer, PatIdentRenamer, ExpansionConfig}; use ast; use ast::Name; - use codemap; + use syntax_pos; use ext::base::{ExtCtxt, DummyMacroLoader}; use ext::mtwt; use fold::Folder; @@ -1284,7 +1284,7 @@ mod tests { } impl<'v> Visitor<'v> for IdentFinder { - fn visit_ident(&mut self, _: codemap::Span, id: ast::Ident){ + fn visit_ident(&mut self, _: syntax_pos::Span, id: ast::Ident){ self.ident_accumulator.push(id); } } diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 871b0d4b1c0..db22eb7901c 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -9,7 +9,7 @@ // except according to those terms. use ast::{self, Arg, Arm, Block, Expr, Item, Pat, Stmt, TokenTree, Ty}; -use codemap::Span; +use syntax_pos::Span; use ext::base::ExtCtxt; use ext::base; use ext::build::AstBuilder; @@ -36,7 +36,8 @@ pub mod rt { use ast::TokenTree; pub use parse::new_parser_from_tts; - pub use codemap::{BytePos, Span, dummy_spanned, DUMMY_SP}; + pub use syntax_pos::{BytePos, Span, DUMMY_SP}; + pub use codemap::{dummy_spanned}; pub trait ToTokens { fn to_tokens(&self, _cx: &ExtCtxt) -> Vec<TokenTree>; diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index fd229d77966..a9b90dcbb7c 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -9,8 +9,7 @@ // except according to those terms. use ast; -use codemap::{Pos, Span}; -use codemap; +use syntax_pos::{self, Pos, Span}; use ext::base::*; use ext::base; use ext::build::AstBuilder; @@ -194,7 +193,7 @@ pub fn expand_include_bytes(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) // resolve a file-system path to an absolute file-system path (if it // isn't already) -fn res_rel_file(cx: &mut ExtCtxt, sp: codemap::Span, arg: &Path) -> PathBuf { +fn res_rel_file(cx: &mut ExtCtxt, sp: syntax_pos::Span, arg: &Path) -> PathBuf { // NB: relative paths are resolved relative to the compilation unit if !arg.is_absolute() { let mut cu = PathBuf::from(&cx.codemap().span_to_filename(sp)); diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index ca5eb8f8003..2230da10552 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -80,8 +80,8 @@ use self::TokenTreeOrTokenTreeVec::*; use ast; use ast::{TokenTree, Name, Ident}; -use codemap::{BytePos, mk_sp, Span, Spanned}; -use codemap; +use syntax_pos::{self, BytePos, mk_sp, Span}; +use codemap::Spanned; use errors::FatalError; use parse::lexer::*; //resolve bug? use parse::ParseSess; @@ -196,7 +196,7 @@ pub fn initial_matcher_pos(ms: Rc<Vec<TokenTree>>, sep: Option<Token>, lo: ByteP /// token tree it was derived from. pub enum NamedMatch { - MatchedSeq(Vec<Rc<NamedMatch>>, codemap::Span), + MatchedSeq(Vec<Rc<NamedMatch>>, syntax_pos::Span), MatchedNonterminal(Nonterminal) } @@ -204,7 +204,7 @@ pub fn nameize(p_s: &ParseSess, ms: &[TokenTree], res: &[Rc<NamedMatch>]) -> ParseResult<HashMap<Name, Rc<NamedMatch>>> { fn n_rec(p_s: &ParseSess, m: &TokenTree, res: &[Rc<NamedMatch>], ret_val: &mut HashMap<Name, Rc<NamedMatch>>, idx: &mut usize) - -> Result<(), (codemap::Span, String)> { + -> Result<(), (syntax_pos::Span, String)> { match *m { TokenTree::Sequence(_, ref seq) => { for next_m in &seq.tts { @@ -251,9 +251,9 @@ pub fn nameize(p_s: &ParseSess, ms: &[TokenTree], res: &[Rc<NamedMatch>]) pub enum ParseResult<T> { Success(T), /// Arm failed to match - Failure(codemap::Span, String), + Failure(syntax_pos::Span, String), /// Fatal error (malformed macro?). Abort compilation. - Error(codemap::Span, String) + Error(syntax_pos::Span, String) } pub type NamedParseResult = ParseResult<HashMap<Name, Rc<NamedMatch>>>; diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index fe98394c3e4..850fbb5addf 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -9,7 +9,7 @@ // except according to those terms. use ast::{self, TokenTree}; -use codemap::{Span, DUMMY_SP}; +use syntax_pos::{Span, DUMMY_SP}; use ext::base::{DummyResult, ExtCtxt, MacResult, SyntaxExtension}; use ext::base::{NormalTT, TTMacroExpander}; use ext::tt::macro_parser::{Success, Error, Failure}; diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 6b3b5ce9de9..8b5ecd10fcb 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -11,7 +11,7 @@ use self::LockstepIterSize::*; use ast; use ast::{TokenTree, Ident, Name}; -use codemap::{Span, DUMMY_SP}; +use syntax_pos::{Span, DUMMY_SP}; use errors::{Handler, DiagnosticBuilder}; use ext::tt::macro_parser::{NamedMatch, MatchedSeq, MatchedNonterminal}; use parse::token::{DocComment, MatchNt, SubstNt}; |
