Skip to content

Commit

Permalink
Fix fallout in rustdoc.
Browse files Browse the repository at this point in the history
  • Loading branch information
jseyfried committed Jan 17, 2017
1 parent 4c98e1b commit 0b9e26f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
16 changes: 7 additions & 9 deletions src/librustdoc/html/highlight.rs
Expand Up @@ -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;
Expand All @@ -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!("<pre>{}</pre>", src);
}
Expand All @@ -63,8 +62,7 @@ pub fn render_inner_with_highlighting(src: &str) -> io::Result<String> {
let fm = sess.codemap().new_filemap("<stdin>".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())
Expand Down Expand Up @@ -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, ""));
}
};
Expand Down
6 changes: 3 additions & 3 deletions src/libsyntax/parse/lexer/mod.rs
Expand Up @@ -111,7 +111,7 @@ impl<'a> StringReader<'a> {
}
}
/// Return the next token. EFFECT: advances the string_reader.
fn try_next_token(&mut self) -> Result<TokenAndSpan, ()> {
pub fn try_next_token(&mut self) -> Result<TokenAndSpan, ()> {
assert!(self.fatal_errs.is_empty());
let ret_val = TokenAndSpan {
tok: replace(&mut self.peek_tok, token::Underscore),
Expand All @@ -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(),
Expand Down

0 comments on commit 0b9e26f

Please sign in to comment.