diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-01-20 11:14:42 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-20 11:14:42 +0530 |
| commit | 0dc2557c1202a89f10eec424bb2625bd1615319d (patch) | |
| tree | d0a0e869d252f5c7d6379da8e42f8c043c17db80 /src/librustdoc/html | |
| parent | 29b854fb741809c29764e33fc17c32ba9c6523ba (diff) | |
| parent | 79061d0e02f70ecbf3333057eac36dcc6c4b1727 (diff) | |
| download | rust-0dc2557c1202a89f10eec424bb2625bd1615319d.tar.gz rust-0dc2557c1202a89f10eec424bb2625bd1615319d.zip | |
Rollup merge of #68326 - ollie27:rustdoc_hightlight_fatal_errors, r=GuillaumeGomez
rustdoc: Catch fatal errors when syntax highlighting For some errors the lexer will unwind so we need to handle that in addition to handling `token::Unknown`. Fixes #56885 r? @GuillaumeGomez
Diffstat (limited to 'src/librustdoc/html')
| -rw-r--r-- | src/librustdoc/html/highlight.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index aa52b769c38..5bea1b56141 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -41,7 +41,7 @@ pub fn render_with_highlighting( let fm = sess .source_map() .new_source_file(FileName::Custom(String::from("rustdoc-highlighting")), src.to_owned()); - let highlight_result = { + let highlight_result = rustc_driver::catch_fatal_errors(|| { let lexer = lexer::StringReader::new(&sess, fm, None); let mut classifier = Classifier::new(lexer, sess.source_map()); @@ -51,7 +51,8 @@ pub fn render_with_highlighting( } else { Ok(String::from_utf8_lossy(&highlighted_source).into_owned()) } - }; + }) + .unwrap_or(Err(())); match highlight_result { Ok(highlighted_source) => { |
