diff options
author | Lukas Wirth <[email protected]> | 2021-04-19 10:41:45 +0100 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-04-19 10:41:45 +0100 |
commit | 8a959497b1fab35294d8ccfa5e51c80a3551a224 (patch) | |
tree | 81e8006553622c11e1299fbfa9ca98a5755099f4 | |
parent | 75bf8328994e0966d381061647ac7dbbce374b39 (diff) |
Don't require all doc fences to be valid for identifying rust code
-rw-r--r-- | crates/ide/src/syntax_highlighting/inject.rs | 4 | ||||
-rw-r--r-- | crates/rust-analyzer/src/markdown.rs | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/crates/ide/src/syntax_highlighting/inject.rs b/crates/ide/src/syntax_highlighting/inject.rs index 855c7fba8..6b1037870 100644 --- a/crates/ide/src/syntax_highlighting/inject.rs +++ b/crates/ide/src/syntax_highlighting/inject.rs | |||
@@ -85,6 +85,8 @@ const RUSTDOC_FENCE_TOKENS: &[&'static str] = &[ | |||
85 | "ignore", | 85 | "ignore", |
86 | "no_run", | 86 | "no_run", |
87 | "compile_fail", | 87 | "compile_fail", |
88 | "allow_fail", | ||
89 | "test_harness", | ||
88 | "edition2015", | 90 | "edition2015", |
89 | "edition2018", | 91 | "edition2018", |
90 | "edition2021", | 92 | "edition2021", |
@@ -181,7 +183,7 @@ pub(super) fn doc_comment( | |||
181 | is_codeblock = !is_codeblock; | 183 | is_codeblock = !is_codeblock; |
182 | // Check whether code is rust by inspecting fence guards | 184 | // Check whether code is rust by inspecting fence guards |
183 | let guards = &line[idx + RUSTDOC_FENCE.len()..]; | 185 | 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())); |
185 | is_doctest = is_codeblock && is_rust; | 187 | is_doctest = is_codeblock && is_rust; |
186 | continue; | 188 | continue; |
187 | } | 189 | } |
diff --git a/crates/rust-analyzer/src/markdown.rs b/crates/rust-analyzer/src/markdown.rs index a51ff89e4..8932faaa8 100644 --- a/crates/rust-analyzer/src/markdown.rs +++ b/crates/rust-analyzer/src/markdown.rs | |||
@@ -8,6 +8,8 @@ const RUSTDOC_CODE_BLOCK_ATTRIBUTES_RUST_SPECIFIC: &[&str] = &[ | |||
8 | "ignore", | 8 | "ignore", |
9 | "no_run", | 9 | "no_run", |
10 | "compile_fail", | 10 | "compile_fail", |
11 | "allow_fail", | ||
12 | "test_harness", | ||
11 | "edition2015", | 13 | "edition2015", |
12 | "edition2018", | 14 | "edition2018", |
13 | "edition2021", | 15 | "edition2021", |
@@ -28,7 +30,7 @@ pub(crate) fn format_docs(src: &str) -> String { | |||
28 | 30 | ||
29 | if in_code_block { | 31 | if in_code_block { |
30 | is_rust = | 32 | 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())); |
32 | 34 | ||
33 | if is_rust { | 35 | if is_rust { |
34 | line = "```rust"; | 36 | line = "```rust"; |