diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index a031be8b3c2be..0629e93e7ef5d 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -27,7 +27,7 @@ use std::io; use std::io::prelude::*; use syntax::codemap::CodeMap; -use syntax::parse::lexer::{self, Reader, TokenAndSpan}; +use syntax::parse::lexer::{self, TokenAndSpan}; use syntax::parse::token; use syntax::parse; use syntax_pos::Span; @@ -42,8 +42,7 @@ pub fn render_with_highlighting(src: &str, class: Option<&str>, id: Option<&str> let mut out = Vec::new(); write_header(class, id, &mut out).unwrap(); - let mut classifier = Classifier::new(lexer::StringReader::new(&sess.span_diagnostic, fm), - sess.codemap()); + let mut classifier = Classifier::new(lexer::StringReader::new(&sess, fm), sess.codemap()); if let Err(_) = classifier.write_source(&mut out) { return format!("
{}
", src); } @@ -63,8 +62,7 @@ pub fn render_inner_with_highlighting(src: &str) -> io::Result { let fm = sess.codemap().new_filemap("".to_string(), None, src.to_string()); let mut out = Vec::new(); - let mut classifier = Classifier::new(lexer::StringReader::new(&sess.span_diagnostic, fm), - sess.codemap()); + let mut classifier = Classifier::new(lexer::StringReader::new(&sess, fm), sess.codemap()); classifier.write_source(&mut out)?; Ok(String::from_utf8_lossy(&out).into_owned()) @@ -185,10 +183,10 @@ impl<'a> Classifier<'a> { Ok(tas) => tas, Err(_) => { self.lexer.emit_fatal_errors(); - self.lexer.span_diagnostic.struct_warn("Backing out of syntax highlighting") - .note("You probably did not intend to render this \ - as a rust code-block") - .emit(); + self.lexer.sess.span_diagnostic + .struct_warn("Backing out of syntax highlighting") + .note("You probably did not intend to render this as a rust code-block") + .emit(); return Err(io::Error::new(io::ErrorKind::Other, "")); } }; diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 12b9130c47439..6bc15115b09d3 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -111,7 +111,7 @@ impl<'a> StringReader<'a> { } } /// Return the next token. EFFECT: advances the string_reader. - fn try_next_token(&mut self) -> Result { + pub fn try_next_token(&mut self) -> Result { assert!(self.fatal_errs.is_empty()); let ret_val = TokenAndSpan { tok: replace(&mut self.peek_tok, token::Underscore), @@ -123,13 +123,13 @@ impl<'a> StringReader<'a> { fn fatal(&self, m: &str) -> FatalError { self.fatal_span(self.peek_span, m) } - fn emit_fatal_errors(&mut self) { + pub fn emit_fatal_errors(&mut self) { for err in &mut self.fatal_errs { err.emit(); } self.fatal_errs.clear(); } - fn peek(&self) -> TokenAndSpan { + pub fn peek(&self) -> TokenAndSpan { // FIXME(pcwalton): Bad copy! TokenAndSpan { tok: self.peek_tok.clone(),