diff options
| author | bors <bors@rust-lang.org> | 2019-01-20 19:01:38 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-01-20 19:01:38 +0000 |
| commit | 846ea58cd5ae1c8d72e55dd6cf1ee35ffbca3d63 (patch) | |
| tree | 938807989fc06604c34778a763b976947a20a04b /src/libsyntax/parse | |
| parent | 794e22862c9fed17cdb8d4f3d650851c667bc78e (diff) | |
| parent | 8c93798e9f80d6d6ed9a2ab4b01af06a8fea23b7 (diff) | |
| download | rust-846ea58cd5ae1c8d72e55dd6cf1ee35ffbca3d63.tar.gz rust-846ea58cd5ae1c8d72e55dd6cf1ee35ffbca3d63.zip | |
Auto merge of #56884 - euclio:codeblock-diagnostics, r=QuietMisdreavus
rustdoc: overhaul code block lexing errors Fixes #53919. This PR moves the reporting of code block lexing errors from rendering time to an early pass, so we can use the compiler's error reporting mechanisms. This dramatically improves the diagnostics in this situation: we now de-emphasize the lexing errors as a note under a warning that has a span and suggestion instead of just emitting errors at the top level. Additionally, this PR generalizes the markdown -> source span calculation function, which should allow other rustdoc warnings to use better spans in the future. Last, the PR makes sure that the code block is always emitted in the docs, even if it fails to highlight correctly. Of note: - The new pass unfortunately adds another pass over the docs to gather the doc blocks for syntax-checking. I wonder if this could be combined with the pass that looks for testable blocks? I'm not familiar with that code, so I don't know how feasible that is. - `pulldown_cmark` doesn't make it easy to find the spans of the code blocks, so the code that calculates the spans is a little nasty. It works for all the test cases I threw at it, but I wouldn't be surprised if an edge case would break it. Should have a thorough review. - This PR worsens the state of #56885, since those certain fatal lexing errors are now emitted before docs get generated at all.
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/lexer/mod.rs | 13 |
1 files changed, 0 insertions, 13 deletions
diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index cf51d3ed58d..8827e04802c 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -238,19 +238,6 @@ impl<'a> StringReader<'a> { sr } - pub fn new_without_err(sess: &'a ParseSess, - source_file: Lrc<syntax_pos::SourceFile>, - 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(()); - } - Ok(sr) - } - pub fn new_or_buffered_errs(sess: &'a ParseSess, source_file: Lrc<syntax_pos::SourceFile>, override_span: Option<Span>) -> Result<Self, Vec<Diagnostic>> { |
