Skip to content

Commit

Permalink
Add a sentence before rustc errors
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Sep 29, 2018
1 parent f7240e1 commit 322e469
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/librustdoc/html/highlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn render_with_highlighting(src: &str, class: Option<&str>,
}
write_header(class, &mut out).unwrap();

let lexer = match lexer::StringReader::new_without_err(&sess, fm, None) {
let lexer = match lexer::StringReader::new_without_err(&sess, fm, None, "Output from rustc:") {
Ok(l) => l,
Err(_) => {
let first_line = src.lines().next().unwrap_or_else(|| "");
Expand Down
4 changes: 3 additions & 1 deletion src/libsyntax/parse/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,11 @@ impl<'a> StringReader<'a> {

pub fn new_without_err(sess: &'a ParseSess,
source_file: Lrc<syntax_pos::SourceFile>,
override_span: Option<Span>) -> Result<Self, ()> {
override_span: Option<Span>,
prepend_error_text: &str) -> Result<Self, ()> {
let mut sr = StringReader::new_raw(sess, source_file, override_span);
if sr.advance_token().is_err() {
eprintln!("{}", prepend_error_text);
sr.emit_fatal_errors();
return Err(());
}
Expand Down
1 change: 1 addition & 0 deletions src/test/rustdoc-ui/invalid-syntax.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Output from rustc:
error: unknown start of token: /
--> <stdin>:1:1
|
Expand Down

0 comments on commit 322e469

Please sign in to comment.