diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2015-12-14 11:17:55 +1300 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2015-12-17 09:35:50 +1300 |
| commit | 6309b0f5bb558b844f45b2d313d2078fd7b7614c (patch) | |
| tree | 3666b39af4692755af1cdac1bde215bbb2842f02 /src/libsyntax/parse/lexer | |
| parent | 073b0f9b852fa8b14ea4ab8c5a724043eb39fce5 (diff) | |
| download | rust-6309b0f5bb558b844f45b2d313d2078fd7b7614c.tar.gz rust-6309b0f5bb558b844f45b2d313d2078fd7b7614c.zip | |
move error handling from libsyntax/diagnostics.rs to libsyntax/errors/*
Also split out emitters into their own module.
Diffstat (limited to 'src/libsyntax/parse/lexer')
| -rw-r--r-- | src/libsyntax/parse/lexer/comments.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer/mod.rs | 17 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/libsyntax/parse/lexer/comments.rs b/src/libsyntax/parse/lexer/comments.rs index e5e2c3a986d..d2156d7cb68 100644 --- a/src/libsyntax/parse/lexer/comments.rs +++ b/src/libsyntax/parse/lexer/comments.rs @@ -12,7 +12,7 @@ pub use self::CommentStyle::*; use ast; use codemap::{BytePos, CharPos, CodeMap, Pos}; -use diagnostic; +use errors; use parse::lexer::is_block_doc_comment; use parse::lexer::{StringReader, TokenAndSpan}; use parse::lexer::{is_whitespace, Reader}; @@ -334,7 +334,7 @@ pub struct Literal { // it appears this function is called only from pprust... that's // probably not a good thing. -pub fn gather_comments_and_literals(span_diagnostic: &diagnostic::SpanHandler, +pub fn gather_comments_and_literals(span_diagnostic: &errors::Handler, path: String, srdr: &mut Read) -> (Vec<Comment>, Vec<Literal>) { diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index cb2181a0831..570e0882a85 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -11,8 +11,7 @@ use ast; use codemap::{BytePos, CharPos, CodeMap, Pos, Span}; use codemap; -use diagnostic::FatalError; -use diagnostic::SpanHandler; +use errors::{FatalError, Handler}; use ext::tt::transcribe::tt_next_token; use parse::token::str_to_ident; use parse::token; @@ -58,7 +57,7 @@ pub struct TokenAndSpan { } pub struct StringReader<'a> { - pub span_diagnostic: &'a SpanHandler, + pub span_diagnostic: &'a Handler, /// The absolute offset within the codemap of the next character to read pub pos: BytePos, /// The absolute offset within the codemap of the last character read(curr) @@ -128,10 +127,10 @@ impl<'a> Reader for TtReader<'a> { impl<'a> StringReader<'a> { /// For comments.rs, which hackily pokes into pos and curr - pub fn new_raw<'b>(span_diagnostic: &'b SpanHandler, + pub fn new_raw<'b>(span_diagnostic: &'b Handler, filemap: Rc<codemap::FileMap>) -> StringReader<'b> { if filemap.src.is_none() { - span_diagnostic.handler.bug(&format!("Cannot lex filemap without source: {}", + span_diagnostic.bug(&format!("Cannot lex filemap without source: {}", filemap.name)[..]); } @@ -153,7 +152,7 @@ impl<'a> StringReader<'a> { sr } - pub fn new<'b>(span_diagnostic: &'b SpanHandler, + pub fn new<'b>(span_diagnostic: &'b Handler, filemap: Rc<codemap::FileMap>) -> StringReader<'b> { let mut sr = StringReader::new_raw(span_diagnostic, filemap); sr.advance_token(); @@ -1428,15 +1427,15 @@ mod tests { use parse::token::{str_to_ident}; use std::io; - fn mk_sh() -> diagnostic::SpanHandler { + fn mk_sh() -> diagnostic::Handler { // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let emitter = diagnostic::EmitterWriter::new(Box::new(io::sink()), None); let handler = diagnostic::Handler::with_emitter(true, Box::new(emitter)); - diagnostic::SpanHandler::new(handler, CodeMap::new()) + diagnostic::Handler::new(handler, CodeMap::new()) } // open a string reader for the given string - fn setup<'a>(span_handler: &'a diagnostic::SpanHandler, + fn setup<'a>(span_handler: &'a diagnostic::Handler, teststr: String) -> StringReader<'a> { let fm = span_handler.cm.new_filemap("zebra.rs".to_string(), teststr); StringReader::new(span_handler, fm) |
