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`.
This commit is contained in:
Oliver Middleton 2020-01-17 23:44:44 +00:00
parent 689fca01c5
commit 79061d0e02
5 changed files with 34 additions and 4 deletions

View file

@ -93,3 +93,9 @@ pub fn empty_rust_with_whitespace() {}
///
pub fn indent_after_fenced() {}
//~^^^ WARNING could not parse code block as Rust code
/// ```
/// "invalid
/// ```
pub fn invalid() {}
//~^^^^ WARNING could not parse code block as Rust code

View file

@ -132,3 +132,18 @@ LL | /// \____/
|
= note: error from rustc: unknown start of token: \
warning: could not parse code block as Rust code
--> $DIR/invalid-syntax.rs:97:5
|
LL | /// ```
| _____^
LL | | /// "invalid
LL | | /// ```
| |_______^
|
= note: error from rustc: unterminated double quote string
help: mark blocks that do not contain Rust code as text
|
LL | /// ```text
| ^^^^^^^

View file

@ -33,3 +33,10 @@ pub fn ok() {}
/// <script>alert("not valid Rust");</script>
/// ```
pub fn escape() {}
// @has bad_codeblock_syntax/fn.unterminated.html
// @has - '//*[@class="docblock"]/pre/code' '"unterminated'
/// ```
/// "unterminated
/// ```
pub fn unterminated() {}