Improve error display for codeblocks in rustdoc

This commit is contained in:
Guillaume Gomez
2018-09-03 22:24:11 +02:00
parent 20dc0c5070
commit f7240e1c74
4 changed files with 55 additions and 7 deletions

View File

@@ -238,6 +238,17 @@ impl<'a> StringReader<'a> {
sr
}
pub fn new_without_err(sess: &'a ParseSess,
source_file: Lrc<syntax_pos::SourceFile>,
override_span: Option<Span>) -> Result<Self, ()> {
let mut sr = StringReader::new_raw(sess, source_file, override_span);
if sr.advance_token().is_err() {
sr.emit_fatal_errors();
return Err(());
}
Ok(sr)
}
pub fn retokenize(sess: &'a ParseSess, mut span: Span) -> Self {
let begin = sess.source_map().lookup_byte_offset(span.lo());
let end = sess.source_map().lookup_byte_offset(span.hi());