Skip to content

Commit

Permalink
Rollup merge of #64267 - ehuss:rustdoc-fix-mixed-code-block, r=Guilla…
Browse files Browse the repository at this point in the history
…umeGomez

rustdoc: fix diagnostic with mixed code block styles

This fixes a relatively obscure issue where the diagnostic (emitted [here](https://github.com/rust-lang/rust/blame/ef54f57c5b9d894a38179d09b00610c1b337b086/src/librustdoc/passes/check_code_block_syntax.rs#L69)) would get confused since the "is_fenced" flag wasn't reset properly.
  • Loading branch information
Centril authored Sep 8, 2019
2 parents 3a32803 + fb38708 commit 832b47a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,10 @@ crate fn rust_code_blocks(md: &str) -> Vec<RustCodeBlock> {
is_fenced = true;
previous_offset + fence_idx
}
None => offset,
None => {
is_fenced = false;
offset
}
};
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/test/rustdoc-ui/invalid-syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,11 @@ pub fn empty_rust() {}
///
/// ```
pub fn empty_rust_with_whitespace() {}

/// ```
/// let x = 1;
/// ```
///
/// \____/
///
pub fn indent_after_fenced() {}
18 changes: 18 additions & 0 deletions src/test/rustdoc-ui/invalid-syntax.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,24 @@ help: mark blocks that do not contain Rust code as text
LL | /// ```text
| ^^^^^^^

error: unknown start of token: \
--> <doctest>:1:1
|
1 | \____/
| ^

warning: could not parse code block as Rust code
--> $DIR/invalid-syntax.rs:82:9
|
LL | /// \____/
| ^^^^^^

error: unknown start of token: \
--> <rustdoc-highlighting>:1:1
|
1 | \____/
| ^

error: unknown start of token: \
--> <rustdoc-highlighting>:1:1
|
Expand Down

0 comments on commit 832b47a

Please sign in to comment.