Skip to content

Commit 8a95949

Browse files
committed
Don't require all doc fences to be valid for identifying rust code
1 parent 75bf832 commit 8a95949

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

crates/ide/src/syntax_highlighting/inject.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ const RUSTDOC_FENCE_TOKENS: &[&'static str] = &[
8585
"ignore",
8686
"no_run",
8787
"compile_fail",
88+
"allow_fail",
89+
"test_harness",
8890
"edition2015",
8991
"edition2018",
9092
"edition2021",
@@ -181,7 +183,7 @@ pub(super) fn doc_comment(
181183
is_codeblock = !is_codeblock;
182184
// Check whether code is rust by inspecting fence guards
183185
let guards = &line[idx + RUSTDOC_FENCE.len()..];
184-
let is_rust = guards.split(',').all(|sub| is_rustdoc_fence_token(sub.trim()));
186+
let is_rust = guards.split(',').any(|sub| is_rustdoc_fence_token(sub.trim()));
185187
is_doctest = is_codeblock && is_rust;
186188
continue;
187189
}

crates/rust-analyzer/src/markdown.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const RUSTDOC_CODE_BLOCK_ATTRIBUTES_RUST_SPECIFIC: &[&str] = &[
88
"ignore",
99
"no_run",
1010
"compile_fail",
11+
"allow_fail",
12+
"test_harness",
1113
"edition2015",
1214
"edition2018",
1315
"edition2021",
@@ -28,7 +30,7 @@ pub(crate) fn format_docs(src: &str) -> String {
2830

2931
if in_code_block {
3032
is_rust =
31-
header.split(',').all(|sub| is_rust_specific_code_block_attribute(sub.trim()));
33+
header.split(',').any(|sub| is_rust_specific_code_block_attribute(sub.trim()));
3234

3335
if is_rust {
3436
line = "```rust";

0 commit comments

Comments
 (0)