aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html14
-rw-r--r--crates/ide/src/syntax_highlighting/tests.rs12
-rw-r--r--crates/syntax/src/parsing/text_tree_sink.rs4
-rw-r--r--crates/syntax/test_data/parser/ok/0045_block_attrs.rast6
4 files changed, 30 insertions, 6 deletions
diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html b/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html
index 8d83ba206..921a956e6 100644
--- a/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html
+++ b/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html
@@ -37,13 +37,25 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
37 37
38.unresolved_reference { color: #FC5555; text-decoration: wavy underline; } 38.unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
39</style> 39</style>
40<pre><code><span class="comment documentation">/// ```</span> 40<pre><code><span class="comment documentation">//! This is a module to test doc injection.</span>
41<span class="comment documentation">//! ```</span>
42<span class="comment documentation">//! </span><span class="keyword injected">fn</span><span class="none injected"> </span><span class="function declaration injected">test</span><span class="parenthesis injected">(</span><span class="parenthesis injected">)</span><span class="none injected"> </span><span class="brace injected">{</span><span class="brace injected">}</span>
43<span class="comment documentation">//! ```</span>
44
45<span class="comment documentation">/// ```</span>
41<span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="none injected"> </span><span class="punctuation injected">_</span><span class="none injected"> </span><span class="operator injected">=</span><span class="none injected"> </span><span class="string_literal injected">"early doctests should not go boom"</span><span class="semicolon injected">;</span> 46<span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="none injected"> </span><span class="punctuation injected">_</span><span class="none injected"> </span><span class="operator injected">=</span><span class="none injected"> </span><span class="string_literal injected">"early doctests should not go boom"</span><span class="semicolon injected">;</span>
42<span class="comment documentation">/// ```</span> 47<span class="comment documentation">/// ```</span>
43<span class="keyword">struct</span> <span class="struct declaration">Foo</span> <span class="brace">{</span> 48<span class="keyword">struct</span> <span class="struct declaration">Foo</span> <span class="brace">{</span>
44 <span class="field declaration">bar</span><span class="colon">:</span> <span class="builtin_type">bool</span><span class="comma">,</span> 49 <span class="field declaration">bar</span><span class="colon">:</span> <span class="builtin_type">bool</span><span class="comma">,</span>
45<span class="brace">}</span> 50<span class="brace">}</span>
46 51
52<span class="comment documentation">/// This is an impl with a code block.</span>
53<span class="comment documentation">///</span>
54<span class="comment documentation">/// ```</span>
55<span class="comment documentation">/// </span><span class="keyword injected">fn</span><span class="none injected"> </span><span class="function declaration injected">foo</span><span class="parenthesis injected">(</span><span class="parenthesis injected">)</span><span class="none injected"> </span><span class="brace injected">{</span>
56<span class="comment documentation">///</span>
57<span class="comment documentation">/// </span><span class="brace injected">}</span>
58<span class="comment documentation">/// ```</span>
47<span class="keyword">impl</span> <span class="struct">Foo</span> <span class="brace">{</span> 59<span class="keyword">impl</span> <span class="struct">Foo</span> <span class="brace">{</span>
48 <span class="comment documentation">/// ```</span> 60 <span class="comment documentation">/// ```</span>
49 <span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="none injected"> </span><span class="punctuation injected">_</span><span class="none injected"> </span><span class="operator injected">=</span><span class="none injected"> </span><span class="string_literal injected">"Call me</span> 61 <span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="none injected"> </span><span class="punctuation injected">_</span><span class="none injected"> </span><span class="operator injected">=</span><span class="none injected"> </span><span class="string_literal injected">"Call me</span>
diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs
index 32f2d9038..95408dfb2 100644
--- a/crates/ide/src/syntax_highlighting/tests.rs
+++ b/crates/ide/src/syntax_highlighting/tests.rs
@@ -524,6 +524,11 @@ fn main() {
524fn test_highlight_doc_comment() { 524fn test_highlight_doc_comment() {
525 check_highlighting( 525 check_highlighting(
526 r#" 526 r#"
527//! This is a module to test doc injection.
528//! ```
529//! fn test() {}
530//! ```
531
527/// ``` 532/// ```
528/// let _ = "early doctests should not go boom"; 533/// let _ = "early doctests should not go boom";
529/// ``` 534/// ```
@@ -531,6 +536,13 @@ struct Foo {
531 bar: bool, 536 bar: bool,
532} 537}
533 538
539/// This is an impl with a code block.
540///
541/// ```
542/// fn foo() {
543///
544/// }
545/// ```
534impl Foo { 546impl Foo {
535 /// ``` 547 /// ```
536 /// let _ = "Call me 548 /// let _ = "Call me
diff --git a/crates/syntax/src/parsing/text_tree_sink.rs b/crates/syntax/src/parsing/text_tree_sink.rs
index 1934204ea..d63ec080b 100644
--- a/crates/syntax/src/parsing/text_tree_sink.rs
+++ b/crates/syntax/src/parsing/text_tree_sink.rs
@@ -147,8 +147,8 @@ fn n_attached_trivias<'a>(
147 trivias: impl Iterator<Item = (SyntaxKind, &'a str)>, 147 trivias: impl Iterator<Item = (SyntaxKind, &'a str)>,
148) -> usize { 148) -> usize {
149 match kind { 149 match kind {
150 MACRO_CALL | MACRO_RULES | MACRO_DEF | CONST | TYPE_ALIAS | STRUCT | UNION | ENUM 150 CONST | ENUM | FN | IMPL | MACRO_CALL | MACRO_DEF | MACRO_RULES | MODULE | RECORD_FIELD
151 | VARIANT | FN | TRAIT | MODULE | RECORD_FIELD | STATIC | USE => { 151 | STATIC | STRUCT | TRAIT | TUPLE_FIELD | TYPE_ALIAS | UNION | USE | VARIANT => {
152 let mut res = 0; 152 let mut res = 0;
153 let mut trivias = trivias.enumerate().peekable(); 153 let mut trivias = trivias.enumerate().peekable();
154 154
diff --git a/crates/syntax/test_data/parser/ok/0045_block_attrs.rast b/crates/syntax/test_data/parser/ok/0045_block_attrs.rast
index 50ab52d32..5e50b4e0b 100644
--- a/crates/syntax/test_data/parser/ok/0045_block_attrs.rast
+++ b/crates/syntax/test_data/parser/ok/0045_block_attrs.rast
@@ -127,9 +127,9 @@ [email protected]
127 [email protected] "\n" 127 [email protected] "\n"
128 [email protected] "}" 128 [email protected] "}"
129 [email protected] "\n\n" 129 [email protected] "\n\n"
130 COMMENT@541..601 "// https://github.com ..." 130 IMPL@541..763
131 WHITESPACE@601..602 "\n" 131 COMMENT@541..601 "// https://github.com ..."
132 IMPL@602..763 132 WHITESPACE@601..602 "\n"
133 [email protected] "impl" 133 [email protected] "impl"
134 [email protected] " " 134 [email protected] " "
135 [email protected] 135 [email protected]