Skip to content

rustdoc: fix diagnostic with mixed code block styles #64267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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