aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Daniel Faria <[email protected]>2020-06-22 15:28:07 +0100
committerPaul Daniel Faria <[email protected]>2020-06-23 17:11:33 +0100
commitd8230acd84dc931f72b9dd32b8fbc2aa887d8b4b (patch)
tree29b4dea638978cd7043a7d6e5b0dbab3d7d84fdd
parente137d9accb0ad73e1794e55a76c18ed4c8ca85e9 (diff)
Add punctuation highlighting for highlighting punctuation in doctests, fix highlighting in doctests
-rw-r--r--crates/ra_ide/src/lib.rs4
-rw-r--r--crates/ra_ide/src/prime_caches.rs2
-rw-r--r--crates/ra_ide/src/snapshots/highlight_doctest.html84
-rw-r--r--crates/ra_ide/src/snapshots/highlight_injection.html22
-rw-r--r--crates/ra_ide/src/snapshots/highlight_strings.html106
-rw-r--r--crates/ra_ide/src/snapshots/highlight_unsafe.html30
-rw-r--r--crates/ra_ide/src/snapshots/highlighting.html142
-rw-r--r--crates/ra_ide/src/snapshots/rainbow_highlighting.html22
-rw-r--r--crates/ra_ide/src/syntax_highlighting.rs25
-rw-r--r--crates/ra_ide/src/syntax_highlighting/html.rs4
-rw-r--r--crates/ra_ide/src/syntax_highlighting/injection.rs4
-rw-r--r--crates/ra_ide/src/syntax_highlighting/tags.rs2
-rw-r--r--crates/rust-analyzer/src/semantic_tokens.rs5
-rw-r--r--crates/rust-analyzer/src/to_proto.rs1
14 files changed, 228 insertions, 225 deletions
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs
index 22203b4a3..31bd6cf03 100644
--- a/crates/ra_ide/src/lib.rs
+++ b/crates/ra_ide/src/lib.rs
@@ -443,13 +443,13 @@ impl Analysis {
443 443
444 /// Computes syntax highlighting for the given file 444 /// Computes syntax highlighting for the given file
445 pub fn highlight(&self, file_id: FileId) -> Cancelable<Vec<HighlightedRange>> { 445 pub fn highlight(&self, file_id: FileId) -> Cancelable<Vec<HighlightedRange>> {
446 self.with_db(|db| syntax_highlighting::highlight(db, file_id, None, false, None)) 446 self.with_db(|db| syntax_highlighting::highlight(db, file_id, None, false, false))
447 } 447 }
448 448
449 /// Computes syntax highlighting for the given file range. 449 /// Computes syntax highlighting for the given file range.
450 pub fn highlight_range(&self, frange: FileRange) -> Cancelable<Vec<HighlightedRange>> { 450 pub fn highlight_range(&self, frange: FileRange) -> Cancelable<Vec<HighlightedRange>> {
451 self.with_db(|db| { 451 self.with_db(|db| {
452 syntax_highlighting::highlight(db, frange.file_id, Some(frange.range), false, None) 452 syntax_highlighting::highlight(db, frange.file_id, Some(frange.range), false, false)
453 }) 453 })
454 } 454 }
455 455
diff --git a/crates/ra_ide/src/prime_caches.rs b/crates/ra_ide/src/prime_caches.rs
index dbed8a506..59386c5e6 100644
--- a/crates/ra_ide/src/prime_caches.rs
+++ b/crates/ra_ide/src/prime_caches.rs
@@ -7,6 +7,6 @@ use crate::{FileId, RootDatabase};
7 7
8pub(crate) fn prime_caches(db: &RootDatabase, files: Vec<FileId>) { 8pub(crate) fn prime_caches(db: &RootDatabase, files: Vec<FileId>) {
9 for file in files { 9 for file in files {
10 let _ = crate::syntax_highlighting::highlight(db, file, None, false, None); 10 let _ = crate::syntax_highlighting::highlight(db, file, None, false, false);
11 } 11 }
12} 12}
diff --git a/crates/ra_ide/src/snapshots/highlight_doctest.html b/crates/ra_ide/src/snapshots/highlight_doctest.html
index f9a11710e..95f3d2d1e 100644
--- a/crates/ra_ide/src/snapshots/highlight_doctest.html
+++ b/crates/ra_ide/src/snapshots/highlight_doctest.html
@@ -5,7 +5,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
5 5
6.lifetime { color: #DFAF8F; font-style: italic; } 6.lifetime { color: #DFAF8F; font-style: italic; }
7.comment { color: #7F9F7F; } 7.comment { color: #7F9F7F; }
8.documentation { color: #00CC00; } 8.documentation { color: #629755; }
9.injected { opacity: 0.65 ; } 9.injected { opacity: 0.65 ; }
10.struct, .enum { color: #7CB8BB; } 10.struct, .enum { color: #7CB8BB; }
11.enum_variant { color: #BDE0F3; } 11.enum_variant { color: #BDE0F3; }
@@ -35,67 +35,67 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
35.control { font-style: italic; } 35.control { font-style: italic; }
36</style> 36</style>
37<pre><code><span class="comment documentation">/// ```</span> 37<pre><code><span class="comment documentation">/// ```</span>
38<span class="comment documentation">/// </span><span class="keyword">let</span> _ = <span class="string_literal">"early doctests should not go boom"</span>; 38<span class="comment documentation">/// </span><span class="keyword injected">let</span> <span class="punctuation injected">_</span> <span class="punctuation injected">=</span> <span class="string_literal injected">"early doctests should not go boom"</span><span class="punctuation injected">;</span><span class="punctuation injected">
39<span class="comment documentation">/// ```</span> 39</span><span class="comment documentation">/// ```</span>
40<span class="keyword">struct</span> <span class="struct declaration">Foo</span> { 40<span class="keyword">struct</span> <span class="struct declaration">Foo</span> <span class="punctuation">{</span>
41 <span class="field declaration">bar</span>: <span class="builtin_type">bool</span>, 41 <span class="field declaration">bar</span><span class="punctuation">:</span> <span class="builtin_type">bool</span><span class="punctuation">,</span>
42} 42<span class="punctuation">}</span>
43 43
44<span class="keyword">impl</span> <span class="struct">Foo</span> { 44<span class="keyword">impl</span> <span class="struct">Foo</span> <span class="punctuation">{</span>
45 <span class="keyword">pub</span> <span class="keyword">const</span> <span class="constant declaration">bar</span>: <span class="builtin_type">bool</span> = <span class="bool_literal">true</span>; 45 <span class="keyword">pub</span> <span class="keyword">const</span> <span class="constant declaration">bar</span><span class="punctuation">:</span> <span class="builtin_type">bool</span> <span class="punctuation">=</span> <span class="bool_literal">true</span><span class="punctuation">;</span>
46 46
47 <span class="comment documentation">/// Constructs a new `Foo`.</span> 47 <span class="comment documentation">/// Constructs a new `Foo`.</span>
48 <span class="comment documentation">///</span> 48 <span class="comment documentation">///</span>
49 <span class="comment documentation">/// # Examples</span> 49 <span class="comment documentation">/// # Examples</span>
50 <span class="comment documentation">///</span> 50 <span class="comment documentation">///</span>
51 <span class="comment documentation">/// ```</span> 51 <span class="comment documentation">/// ```</span>
52 <span class="comment documentation">/// #</span> <span class="operator injected">#</span><span class="operator injected">!</span><span class="operator injected">[</span><span class="operator injected">allow</span><span class="operator injected">(</span><span class="operator injected">unused_mut</span><span class="operator injected">)</span><span class="operator injected">]</span><span class="operator injected"> 52 <span class="comment documentation">/// #</span> <span class="punctuation injected">#</span><span class="punctuation injected">!</span><span class="punctuation injected">[</span><span class="function attribute injected">allow</span><span class="punctuation injected">(</span><span class="attribute injected">unused_mut</span><span class="punctuation injected">)</span><span class="punctuation injected">]</span>
53</span> <span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="operator injected"> </span><span class="keyword injected">mut</span><span class="operator injected"> </span><span class="operator injected">foo</span><span class="operator injected">:</span><span class="operator injected"> </span><span class="operator injected">Foo</span><span class="operator injected"> </span><span class="operator injected">=</span><span class="operator injected"> </span><span class="operator injected">Foo</span><span class="operator injected">::</span><span class="operator injected">new</span><span class="operator injected">(</span><span class="operator injected">)</span><span class="operator injected">;</span><span class="operator injected"> 53 <span class="comment documentation">/// </span><span class="keyword injected">let</span> <span class="keyword injected">mut</span> <span class="variable declaration injected mutable">foo</span><span class="punctuation injected">:</span> <span class="struct injected">Foo</span> <span class="punctuation injected">=</span> <span class="struct injected">Foo</span><span class="punctuation injected">::</span><span class="function injected">new</span><span class="punctuation injected">(</span><span class="punctuation injected">)</span><span class="punctuation injected">;</span><span class="punctuation injected">
54</span><span class="operator injected"> </span> <span class="comment documentation">/// ```</span> 54</span> <span class="comment documentation">/// ```</span>
55 <span class="keyword">pub</span> <span class="keyword">const</span> <span class="keyword">fn</span> <span class="function declaration">new</span>() -&gt; <span class="struct">Foo</span> { 55 <span class="keyword">pub</span> <span class="keyword">const</span> <span class="keyword">fn</span> <span class="function declaration">new</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">-&gt;</span> <span class="struct">Foo</span> <span class="punctuation">{</span>
56 <span class="struct">Foo</span> { <span class="field">bar</span>: <span class="bool_literal">true</span> } 56 <span class="struct">Foo</span> <span class="punctuation">{</span> <span class="field">bar</span><span class="punctuation">:</span> <span class="bool_literal">true</span> <span class="punctuation">}</span>
57 } 57 <span class="punctuation">}</span>
58 58
59 <span class="comment documentation">/// `bar` method on `Foo`.</span> 59 <span class="comment documentation">/// `bar` method on `Foo`.</span>
60 <span class="comment documentation">///</span> 60 <span class="comment documentation">///</span>
61 <span class="comment documentation">/// # Examples</span> 61 <span class="comment documentation">/// # Examples</span>
62 <span class="comment documentation">///</span> 62 <span class="comment documentation">///</span>
63 <span class="comment documentation">/// ```</span> 63 <span class="comment documentation">/// ```</span>
64 <span class="comment documentation">/// </span><span class="keyword injected">use</span><span class="operator injected"> </span><span class="operator injected">x</span><span class="operator injected">::</span><span class="operator injected">y</span><span class="operator injected">;</span><span class="operator injected"> 64 <span class="comment documentation">/// </span><span class="keyword injected">use</span> <span class="module injected">x</span><span class="punctuation injected">::</span><span class="module injected">y</span><span class="punctuation injected">;</span>
65 </span><span class="comment documentation">///</span><span class="operator injected"> 65 <span class="comment documentation">///</span>
66</span> <span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="operator injected"> </span><span class="operator injected">foo</span><span class="operator injected"> </span><span class="operator injected">=</span><span class="operator injected"> </span><span class="operator injected">Foo</span><span class="operator injected">::</span><span class="operator injected">new</span><span class="operator injected">(</span><span class="operator injected">)</span><span class="operator injected">;</span><span class="operator injected"> 66 <span class="comment documentation">/// </span><span class="keyword injected">let</span> <span class="variable declaration injected">foo</span> <span class="punctuation injected">=</span> <span class="struct injected">Foo</span><span class="punctuation injected">::</span><span class="function injected">new</span><span class="punctuation injected">(</span><span class="punctuation injected">)</span><span class="punctuation injected">;</span>
67 </span><span class="comment documentation">///</span><span class="operator injected"> 67 <span class="comment documentation">///</span>
68</span> <span class="comment documentation">/// </span><span class="comment injected">// calls bar on foo</span><span class="operator injected"> 68 <span class="comment documentation">/// </span><span class="comment injected">// calls bar on foo</span>
69</span> <span class="comment documentation">/// </span><span class="macro injected">assert!</span><span class="operator injected">(</span><span class="operator injected">foo</span><span class="operator injected">.</span><span class="operator injected">bar</span><span class="operator injected">(</span><span class="operator injected">)</span><span class="operator injected">)</span><span class="operator injected">;</span><span class="operator injected"> 69 <span class="comment documentation">/// </span><span class="macro injected">assert!</span><span class="punctuation injected">(</span>foo<span class="punctuation injected">.</span>bar<span class="punctuation injected">(</span><span class="punctuation injected">)</span><span class="punctuation injected">)</span><span class="punctuation injected">;</span>
70 </span><span class="comment documentation">///</span><span class="operator injected"> 70 <span class="comment documentation">///</span>
71</span> <span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="operator injected"> </span><span class="operator injected">bar</span><span class="operator injected"> </span><span class="operator injected">=</span><span class="operator injected"> </span><span class="operator injected">foo</span><span class="operator injected">.</span><span class="operator injected">bar</span><span class="operator injected"> </span><span class="operator injected">||</span><span class="operator injected"> </span><span class="operator injected">Foo</span><span class="operator injected">::</span><span class="operator injected">bar</span><span class="operator injected">;</span><span class="operator injected"> 71 <span class="comment documentation">/// </span><span class="keyword injected">let</span> <span class="variable declaration injected">bar</span> <span class="punctuation injected">=</span> <span class="variable injected">foo</span><span class="punctuation injected">.</span><span class="field injected">bar</span> <span class="punctuation injected">||</span> <span class="struct injected">Foo</span><span class="punctuation injected">::</span><span class="constant injected">bar</span><span class="punctuation injected">;</span>
72 </span><span class="comment documentation">///</span><span class="operator injected"> 72 <span class="comment documentation">///</span>
73</span> <span class="comment documentation">/// </span><span class="comment injected">/* multi-line 73 <span class="comment documentation">/// </span><span class="comment injected">/* multi-line
74 </span><span class="comment documentation">/// </span><span class="comment injected"> comment */</span><span class="operator injected"> 74 </span><span class="comment documentation">/// </span><span class="comment injected"> comment */</span>
75 </span><span class="comment documentation">///</span><span class="operator injected"> 75 <span class="comment documentation">///</span>
76</span> <span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="operator injected"> </span><span class="operator injected">multi_line_string</span><span class="operator injected"> </span><span class="operator injected">=</span><span class="operator injected"> </span><span class="string_literal injected">"Foo 76 <span class="comment documentation">/// </span><span class="keyword injected">let</span> <span class="variable declaration injected">multi_line_string</span> <span class="punctuation injected">=</span> <span class="string_literal injected">"Foo
77 </span><span class="comment documentation">/// </span><span class="string_literal injected"> bar 77 </span><span class="comment documentation">/// </span><span class="string_literal injected"> bar
78 </span><span class="comment documentation">/// </span><span class="string_literal injected"> "</span><span class="operator injected">;</span><span class="operator injected"> 78 </span><span class="comment documentation">/// </span><span class="string_literal injected"> "</span><span class="punctuation injected">;</span>
79 </span><span class="comment documentation">///</span><span class="operator injected"> 79 <span class="comment documentation">///</span>
80</span> <span class="comment documentation">/// ```</span> 80 <span class="comment documentation">/// ```</span>
81 <span class="comment documentation">///</span> 81 <span class="comment documentation">///</span>
82 <span class="comment documentation">/// ```rust,no_run</span> 82 <span class="comment documentation">/// ```rust,no_run</span>
83 <span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="operator injected"> </span><span class="operator injected">foobar</span><span class="operator injected"> </span><span class="operator injected">=</span><span class="operator injected"> </span><span class="operator injected">Foo</span><span class="operator injected">::</span><span class="operator injected">new</span><span class="operator injected">(</span><span class="operator injected">)</span><span class="operator injected">.</span><span class="operator injected">bar</span><span class="operator injected">(</span><span class="operator injected">)</span><span class="operator injected">;</span><span class="operator injected"> 83 <span class="comment documentation">/// </span><span class="keyword injected">let</span> <span class="variable declaration injected">foobar</span> <span class="punctuation injected">=</span> <span class="struct injected">Foo</span><span class="punctuation injected">::</span><span class="function injected">new</span><span class="punctuation injected">(</span><span class="punctuation injected">)</span><span class="punctuation injected">.</span><span class="function injected">bar</span><span class="punctuation injected">(</span><span class="punctuation injected">)</span><span class="punctuation injected">;</span><span class="punctuation injected">
84</span><span class="operator injected"> </span> <span class="comment documentation">/// ```</span> 84</span> <span class="comment documentation">/// ```</span>
85 <span class="comment documentation">///</span> 85 <span class="comment documentation">///</span>
86 <span class="comment documentation">/// ```sh</span> 86 <span class="comment documentation">/// ```sh</span>
87 <span class="comment documentation">/// echo 1</span> 87 <span class="comment documentation">/// echo 1</span>
88 <span class="comment documentation">/// ```</span> 88 <span class="comment documentation">/// ```</span>
89 <span class="keyword">pub</span> <span class="keyword">fn</span> <span class="function declaration">foo</span>(&<span class="self_keyword">self</span>) -&gt; <span class="builtin_type">bool</span> { 89 <span class="keyword">pub</span> <span class="keyword">fn</span> <span class="function declaration">foo</span><span class="punctuation">(</span><span class="punctuation">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="punctuation">-&gt;</span> <span class="builtin_type">bool</span> <span class="punctuation">{</span>
90 <span class="bool_literal">true</span> 90 <span class="bool_literal">true</span>
91 } 91 <span class="punctuation">}</span>
92} 92<span class="punctuation">}</span>
93 93
94<span class="comment documentation">/// ```</span> 94<span class="comment documentation">/// ```</span>
95<span class="comment documentation">/// </span><span class="macro">noop!</span>(<span class="numeric_literal">1</span>); 95<span class="comment documentation">/// </span><span class="macro injected">noop!</span><span class="punctuation injected">(</span><span class="numeric_literal injected">1</span><span class="punctuation injected">)</span><span class="punctuation injected">;</span><span class="punctuation injected">
96<span class="comment documentation">/// ```</span> 96</span><span class="comment documentation">/// ```</span>
97<span class="macro">macro_rules!</span> <span class="macro declaration">noop</span> { 97<span class="macro">macro_rules!</span> <span class="macro declaration">noop</span> <span class="punctuation">{</span>
98 ($expr:expr) =&gt; { 98 <span class="punctuation">(</span><span class="punctuation">$</span>expr<span class="punctuation">:</span>expr<span class="punctuation">)</span> <span class="punctuation">=</span><span class="punctuation">&gt;</span> <span class="punctuation">{</span>
99 $expr 99 <span class="punctuation">$</span>expr
100 } 100 <span class="punctuation">}</span>
101}</code></pre> \ No newline at end of file 101<span class="punctuation">}</span></code></pre> \ No newline at end of file
diff --git a/crates/ra_ide/src/snapshots/highlight_injection.html b/crates/ra_ide/src/snapshots/highlight_injection.html
index 4c3fa2a7b..bc19313d8 100644
--- a/crates/ra_ide/src/snapshots/highlight_injection.html
+++ b/crates/ra_ide/src/snapshots/highlight_injection.html
@@ -5,7 +5,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
5 5
6.lifetime { color: #DFAF8F; font-style: italic; } 6.lifetime { color: #DFAF8F; font-style: italic; }
7.comment { color: #7F9F7F; } 7.comment { color: #7F9F7F; }
8.documentation { color: #00CC00; } 8.documentation { color: #629755; }
9.injected { opacity: 0.65 ; } 9.injected { opacity: 0.65 ; }
10.struct, .enum { color: #7CB8BB; } 10.struct, .enum { color: #7CB8BB; }
11.enum_variant { color: #BDE0F3; } 11.enum_variant { color: #BDE0F3; }
@@ -34,14 +34,14 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
34.keyword.unsafe { color: #BC8383; font-weight: bold; } 34.keyword.unsafe { color: #BC8383; font-weight: bold; }
35.control { font-style: italic; } 35.control { font-style: italic; }
36</style> 36</style>
37<pre><code><span class="keyword">fn</span> <span class="function declaration">fixture</span>(<span class="variable declaration">ra_fixture</span>: &<span class="builtin_type">str</span>) {} 37<pre><code><span class="keyword">fn</span> <span class="function declaration">fixture</span><span class="punctuation">(</span><span class="variable declaration">ra_fixture</span><span class="punctuation">:</span> <span class="punctuation">&</span><span class="builtin_type">str</span><span class="punctuation">)</span> <span class="punctuation">{</span><span class="punctuation">}</span>
38 38
39<span class="keyword">fn</span> <span class="function declaration">main</span>() { 39<span class="keyword">fn</span> <span class="function declaration">main</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span>
40 <span class="function">fixture</span>(<span class="string_literal">r#"</span> 40 <span class="function">fixture</span><span class="punctuation">(</span><span class="string_literal">r#"</span>
41 <span class="keyword">trait</span> <span class="trait declaration">Foo</span> { 41 <span class="keyword">trait</span> <span class="trait declaration">Foo</span> <span class="punctuation">{</span>
42 <span class="keyword">fn</span> <span class="function declaration">foo</span>() { 42 <span class="keyword">fn</span> <span class="function declaration">foo</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span>
43 <span class="macro">println!</span>(<span class="string_literal">"2 + 2 = {}"</span>, <span class="numeric_literal">4</span>); 43 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"2 + 2 = {}"</span><span class="punctuation">,</span> <span class="numeric_literal">4</span><span class="punctuation">)</span><span class="punctuation">;</span>
44 } 44 <span class="punctuation">}</span>
45 }<span class="string_literal">"#</span> 45 <span class="punctuation">}</span><span class="string_literal">"#</span>
46 ); 46 <span class="punctuation">)</span><span class="punctuation">;</span>
47}</code></pre> \ No newline at end of file 47<span class="punctuation">}</span></code></pre> \ No newline at end of file
diff --git a/crates/ra_ide/src/snapshots/highlight_strings.html b/crates/ra_ide/src/snapshots/highlight_strings.html
index 245c425f5..910b2978d 100644
--- a/crates/ra_ide/src/snapshots/highlight_strings.html
+++ b/crates/ra_ide/src/snapshots/highlight_strings.html
@@ -5,7 +5,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
5 5
6.lifetime { color: #DFAF8F; font-style: italic; } 6.lifetime { color: #DFAF8F; font-style: italic; }
7.comment { color: #7F9F7F; } 7.comment { color: #7F9F7F; }
8.documentation { color: #00CC00; } 8.documentation { color: #629755; }
9.injected { opacity: 0.65 ; } 9.injected { opacity: 0.65 ; }
10.struct, .enum { color: #7CB8BB; } 10.struct, .enum { color: #7CB8BB; }
11.enum_variant { color: #BDE0F3; } 11.enum_variant { color: #BDE0F3; }
@@ -34,62 +34,62 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
34.keyword.unsafe { color: #BC8383; font-weight: bold; } 34.keyword.unsafe { color: #BC8383; font-weight: bold; }
35.control { font-style: italic; } 35.control { font-style: italic; }
36</style> 36</style>
37<pre><code><span class="macro">macro_rules!</span> <span class="macro declaration">println</span> { 37<pre><code><span class="macro">macro_rules!</span> <span class="macro declaration">println</span> <span class="punctuation">{</span>
38 ($($arg:tt)*) =&gt; ({ 38 <span class="punctuation">(</span><span class="punctuation">$</span><span class="punctuation">(</span><span class="punctuation">$</span>arg<span class="punctuation">:</span>tt<span class="punctuation">)</span>*<span class="punctuation">)</span> <span class="punctuation">=</span><span class="punctuation">&gt;</span> <span class="punctuation">(</span><span class="punctuation">{</span>
39 $<span class="keyword">crate</span>::io::_print($<span class="keyword">crate</span>::format_args_nl!($($arg)*)); 39 <span class="punctuation">$</span><span class="keyword">crate</span><span class="punctuation">:</span><span class="punctuation">:</span>io<span class="punctuation">:</span><span class="punctuation">:</span>_print<span class="punctuation">(</span><span class="punctuation">$</span><span class="keyword">crate</span><span class="punctuation">:</span><span class="punctuation">:</span>format_args_nl<span class="punctuation">!</span><span class="punctuation">(</span><span class="punctuation">$</span><span class="punctuation">(</span><span class="punctuation">$</span>arg<span class="punctuation">)</span>*<span class="punctuation">)</span><span class="punctuation">)</span><span class="punctuation">;</span>
40 }) 40 <span class="punctuation">}</span><span class="punctuation">)</span>
41} 41<span class="punctuation">}</span>
42#[rustc_builtin_macro] 42#[rustc_builtin_macro]
43<span class="macro">macro_rules!</span> <span class="macro declaration">format_args_nl</span> { 43<span class="macro">macro_rules!</span> <span class="macro declaration">format_args_nl</span> <span class="punctuation">{</span>
44 ($fmt:expr) =&gt; {{ <span class="comment">/* compiler built-in */</span> }}; 44 <span class="punctuation">(</span><span class="punctuation">$</span>fmt<span class="punctuation">:</span>expr<span class="punctuation">)</span> <span class="punctuation">=</span><span class="punctuation">&gt;</span> <span class="punctuation">{</span><span class="punctuation">{</span> <span class="comment">/* compiler built-in */</span> <span class="punctuation">}</span><span class="punctuation">}</span><span class="punctuation">;</span>
45 ($fmt:expr, $($args:tt)*) =&gt; {{ <span class="comment">/* compiler built-in */</span> }}; 45 <span class="punctuation">(</span><span class="punctuation">$</span>fmt<span class="punctuation">:</span>expr<span class="punctuation">,</span> <span class="punctuation">$</span><span class="punctuation">(</span><span class="punctuation">$</span>args<span class="punctuation">:</span>tt<span class="punctuation">)</span>*<span class="punctuation">)</span> <span class="punctuation">=</span><span class="punctuation">&gt;</span> <span class="punctuation">{</span><span class="punctuation">{</span> <span class="comment">/* compiler built-in */</span> <span class="punctuation">}</span><span class="punctuation">}</span><span class="punctuation">;</span>
46} 46<span class="punctuation">}</span>
47 47
48<span class="keyword">fn</span> <span class="function declaration">main</span>() { 48<span class="keyword">fn</span> <span class="function declaration">main</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span>
49 <span class="comment">// from https://doc.rust-lang.org/std/fmt/index.html</span> 49 <span class="comment">// from https://doc.rust-lang.org/std/fmt/index.html</span>
50 <span class="macro">println!</span>(<span class="string_literal">"Hello"</span>); <span class="comment">// =&gt; "Hello"</span> 50 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"Hello"</span><span class="punctuation">)</span><span class="punctuation">;</span> <span class="comment">// =&gt; "Hello"</span>
51 <span class="macro">println!</span>(<span class="string_literal">"Hello, </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">!"</span>, <span class="string_literal">"world"</span>); <span class="comment">// =&gt; "Hello, world!"</span> 51 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"Hello, </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="punctuation">,</span> <span class="string_literal">"world"</span><span class="punctuation">)</span><span class="punctuation">;</span> <span class="comment">// =&gt; "Hello, world!"</span>
52 <span class="macro">println!</span>(<span class="string_literal">"The number is </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">"</span>, <span class="numeric_literal">1</span>); <span class="comment">// =&gt; "The number is 1"</span> 52 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"The number is </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="punctuation">,</span> <span class="numeric_literal">1</span><span class="punctuation">)</span><span class="punctuation">;</span> <span class="comment">// =&gt; "The number is 1"</span>
53 <span class="macro">println!</span>(<span class="string_literal">"</span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">?</span><span class="format_specifier">}</span><span class="string_literal">"</span>, (<span class="numeric_literal">3</span>, <span class="numeric_literal">4</span>)); <span class="comment">// =&gt; "(3, 4)"</span> 53 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">?</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="punctuation">,</span> <span class="punctuation">(</span><span class="numeric_literal">3</span><span class="punctuation">,</span> <span class="numeric_literal">4</span><span class="punctuation">)</span><span class="punctuation">)</span><span class="punctuation">;</span> <span class="comment">// =&gt; "(3, 4)"</span>
54 <span class="macro">println!</span>(<span class="string_literal">"</span><span class="format_specifier">{</span><span class="variable">value</span><span class="format_specifier">}</span><span class="string_literal">"</span>, value=<span class="numeric_literal">4</span>); <span class="comment">// =&gt; "4"</span> 54 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="variable">value</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="punctuation">,</span> value<span class="punctuation">=</span><span class="numeric_literal">4</span><span class="punctuation">)</span><span class="punctuation">;</span> <span class="comment">// =&gt; "4"</span>
55 <span class="macro">println!</span>(<span class="string_literal">"</span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal"> </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">"</span>, <span class="numeric_literal">1</span>, <span class="numeric_literal">2</span>); <span class="comment">// =&gt; "1 2"</span> 55 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal"> </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="punctuation">,</span> <span class="numeric_literal">1</span><span class="punctuation">,</span> <span class="numeric_literal">2</span><span class="punctuation">)</span><span class="punctuation">;</span> <span class="comment">// =&gt; "1 2"</span>
56 <span class="macro">println!</span>(<span class="string_literal">"</span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="numeric_literal">0</span><span class="numeric_literal">4</span><span class="format_specifier">}</span><span class="string_literal">"</span>, <span class="numeric_literal">42</span>); <span class="comment">// =&gt; "0042" with leading zerosV</span> 56 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="numeric_literal">0</span><span class="numeric_literal">4</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="punctuation">,</span> <span class="numeric_literal">42</span><span class="punctuation">)</span><span class="punctuation">;</span> <span class="comment">// =&gt; "0042" with leading zerosV</span>
57 <span class="macro">println!</span>(<span class="string_literal">"</span><span class="format_specifier">{</span><span class="numeric_literal">1</span><span class="format_specifier">}</span><span class="string_literal"> </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal"> </span><span class="format_specifier">{</span><span class="numeric_literal">0</span><span class="format_specifier">}</span><span class="string_literal"> </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">"</span>, <span class="numeric_literal">1</span>, <span class="numeric_literal">2</span>); <span class="comment">// =&gt; "2 1 1 2"</span> 57 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="numeric_literal">1</span><span class="format_specifier">}</span><span class="string_literal"> </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal"> </span><span class="format_specifier">{</span><span class="numeric_literal">0</span><span class="format_specifier">}</span><span class="string_literal"> </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="punctuation">,</span> <span class="numeric_literal">1</span><span class="punctuation">,</span> <span class="numeric_literal">2</span><span class="punctuation">)</span><span class="punctuation">;</span> <span class="comment">// =&gt; "2 1 1 2"</span>
58 <span class="macro">println!</span>(<span class="string_literal">"</span><span class="format_specifier">{</span><span class="variable">argument</span><span class="format_specifier">}</span><span class="string_literal">"</span>, argument = <span class="string_literal">"test"</span>); <span class="comment">// =&gt; "test"</span> 58 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="variable">argument</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="punctuation">,</span> argument <span class="punctuation">=</span> <span class="string_literal">"test"</span><span class="punctuation">)</span><span class="punctuation">;</span> <span class="comment">// =&gt; "test"</span>
59 <span class="macro">println!</span>(<span class="string_literal">"</span><span class="format_specifier">{</span><span class="variable">name</span><span class="format_specifier">}</span><span class="string_literal"> </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">"</span>, <span class="numeric_literal">1</span>, name = <span class="numeric_literal">2</span>); <span class="comment">// =&gt; "2 1"</span> 59 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="variable">name</span><span class="format_specifier">}</span><span class="string_literal"> </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="punctuation">,</span> <span class="numeric_literal">1</span><span class="punctuation">,</span> name <span class="punctuation">=</span> <span class="numeric_literal">2</span><span class="punctuation">)</span><span class="punctuation">;</span> <span class="comment">// =&gt; "2 1"</span>
60 <span class="macro">println!</span>(<span class="string_literal">"</span><span class="format_specifier">{</span><span class="variable">a</span><span class="format_specifier">}</span><span class="string_literal"> </span><span class="format_specifier">{</span><span class="variable">c</span><span class="format_specifier">}</span><span class="string_literal"> </span><span class="format_specifier">{</span><span class="variable">b</span><span class="format_specifier">}</span><span class="string_literal">"</span>, a=<span class="string_literal">"a"</span>, b=<span class="char_literal">'b'</span>, c=<span class="numeric_literal">3</span>); <span class="comment">// =&gt; "a 3 b"</span> 60 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="variable">a</span><span class="format_specifier">}</span><span class="string_literal"> </span><span class="format_specifier">{</span><span class="variable">c</span><span class="format_specifier">}</span><span class="string_literal"> </span><span class="format_specifier">{</span><span class="variable">b</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="punctuation">,</span> a<span class="punctuation">=</span><span class="string_literal">"a"</span><span class="punctuation">,</span> b<span class="punctuation">=</span><span class="char_literal">'b'</span><span class="punctuation">,</span> c<span class="punctuation">=</span><span class="numeric_literal">3</span><span class="punctuation">)</span><span class="punctuation">;</span> <span class="comment">// =&gt; "a 3 b"</span>
61 <span class="macro">println!</span>(<span class="string_literal">"{{</span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">}}"</span>, <span class="numeric_literal">2</span>); <span class="comment">// =&gt; "{2}"</span> 61 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"{{</span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">}}"</span><span class="punctuation">,</span> <span class="numeric_literal">2</span><span class="punctuation">)</span><span class="punctuation">;</span> <span class="comment">// =&gt; "{2}"</span>
62 <span class="macro">println!</span>(<span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="numeric_literal">5</span><span class="format_specifier">}</span><span class="string_literal">!"</span>, <span class="string_literal">"x"</span>); 62 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="numeric_literal">5</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="punctuation">,</span> <span class="string_literal">"x"</span><span class="punctuation">)</span><span class="punctuation">;</span>
63 <span class="macro">println!</span>(<span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="numeric_literal">1</span><span class="format_specifier">$</span><span class="format_specifier">}</span><span class="string_literal">!"</span>, <span class="string_literal">"x"</span>, <span class="numeric_literal">5</span>); 63 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="numeric_literal">1</span><span class="format_specifier">$</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="punctuation">,</span> <span class="string_literal">"x"</span><span class="punctuation">,</span> <span class="numeric_literal">5</span><span class="punctuation">)</span><span class="punctuation">;</span>
64 <span class="macro">println!</span>(<span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="numeric_literal">1</span><span class="format_specifier">:</span><span class="numeric_literal">0</span><span class="format_specifier">$</span><span class="format_specifier">}</span><span class="string_literal">!"</span>, <span class="numeric_literal">5</span>, <span class="string_literal">"x"</span>); 64 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="numeric_literal">1</span><span class="format_specifier">:</span><span class="numeric_literal">0</span><span class="format_specifier">$</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="punctuation">,</span> <span class="numeric_literal">5</span><span class="punctuation">,</span> <span class="string_literal">"x"</span><span class="punctuation">)</span><span class="punctuation">;</span>
65 <span class="macro">println!</span>(<span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="variable">width</span><span class="format_specifier">$</span><span class="format_specifier">}</span><span class="string_literal">!"</span>, <span class="string_literal">"x"</span>, width = <span class="numeric_literal">5</span>); 65 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="variable">width</span><span class="format_specifier">$</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="punctuation">,</span> <span class="string_literal">"x"</span><span class="punctuation">,</span> width <span class="punctuation">=</span> <span class="numeric_literal">5</span><span class="punctuation">)</span><span class="punctuation">;</span>
66 <span class="macro">println!</span>(<span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">&lt;</span><span class="numeric_literal">5</span><span class="format_specifier">}</span><span class="string_literal">!"</span>, <span class="string_literal">"x"</span>); 66 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">&lt;</span><span class="numeric_literal">5</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="punctuation">,</span> <span class="string_literal">"x"</span><span class="punctuation">)</span><span class="punctuation">;</span>
67 <span class="macro">println!</span>(<span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">-</span><span class="format_specifier">&lt;</span><span class="numeric_literal">5</span><span class="format_specifier">}</span><span class="string_literal">!"</span>, <span class="string_literal">"x"</span>); 67 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">-</span><span class="format_specifier">&lt;</span><span class="numeric_literal">5</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="punctuation">,</span> <span class="string_literal">"x"</span><span class="punctuation">)</span><span class="punctuation">;</span>
68 <span class="macro">println!</span>(<span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">^</span><span class="numeric_literal">5</span><span class="format_specifier">}</span><span class="string_literal">!"</span>, <span class="string_literal">"x"</span>); 68 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">^</span><span class="numeric_literal">5</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="punctuation">,</span> <span class="string_literal">"x"</span><span class="punctuation">)</span><span class="punctuation">;</span>
69 <span class="macro">println!</span>(<span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">&gt;</span><span class="numeric_literal">5</span><span class="format_specifier">}</span><span class="string_literal">!"</span>, <span class="string_literal">"x"</span>); 69 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">&gt;</span><span class="numeric_literal">5</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="punctuation">,</span> <span class="string_literal">"x"</span><span class="punctuation">)</span><span class="punctuation">;</span>
70 <span class="macro">println!</span>(<span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">+</span><span class="format_specifier">}</span><span class="string_literal">!"</span>, <span class="numeric_literal">5</span>); 70 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">+</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="punctuation">,</span> <span class="numeric_literal">5</span><span class="punctuation">)</span><span class="punctuation">;</span>
71 <span class="macro">println!</span>(<span class="string_literal">"</span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">#</span><span class="variable">x</span><span class="format_specifier">}</span><span class="string_literal">!"</span>, <span class="numeric_literal">27</span>); 71 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">#</span><span class="variable">x</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="punctuation">,</span> <span class="numeric_literal">27</span><span class="punctuation">)</span><span class="punctuation">;</span>
72 <span class="macro">println!</span>(<span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="numeric_literal">0</span><span class="numeric_literal">5</span><span class="format_specifier">}</span><span class="string_literal">!"</span>, <span class="numeric_literal">5</span>); 72 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="numeric_literal">0</span><span class="numeric_literal">5</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="punctuation">,</span> <span class="numeric_literal">5</span><span class="punctuation">)</span><span class="punctuation">;</span>
73 <span class="macro">println!</span>(<span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="numeric_literal">0</span><span class="numeric_literal">5</span><span class="format_specifier">}</span><span class="string_literal">!"</span>, -<span class="numeric_literal">5</span>); 73 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="numeric_literal">0</span><span class="numeric_literal">5</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="punctuation">,</span> <span class="punctuation">-</span><span class="numeric_literal">5</span><span class="punctuation">)</span><span class="punctuation">;</span>
74 <span class="macro">println!</span>(<span class="string_literal">"</span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">#</span><span class="numeric_literal">0</span><span class="numeric_literal">10</span><span class="variable">x</span><span class="format_specifier">}</span><span class="string_literal">!"</span>, <span class="numeric_literal">27</span>); 74 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">#</span><span class="numeric_literal">0</span><span class="numeric_literal">10</span><span class="variable">x</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="punctuation">,</span> <span class="numeric_literal">27</span><span class="punctuation">)</span><span class="punctuation">;</span>
75 <span class="macro">println!</span>(<span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="numeric_literal">0</span><span class="format_specifier">}</span><span class="string_literal"> is </span><span class="format_specifier">{</span><span class="numeric_literal">1</span><span class="format_specifier">:</span><span class="format_specifier">.</span><span class="numeric_literal">5</span><span class="format_specifier">}</span><span class="string_literal">"</span>, <span class="string_literal">"x"</span>, <span class="numeric_literal">0.01</span>); 75 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="numeric_literal">0</span><span class="format_specifier">}</span><span class="string_literal"> is </span><span class="format_specifier">{</span><span class="numeric_literal">1</span><span class="format_specifier">:</span><span class="format_specifier">.</span><span class="numeric_literal">5</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="punctuation">,</span> <span class="string_literal">"x"</span><span class="punctuation">,</span> <span class="numeric_literal">0.01</span><span class="punctuation">)</span><span class="punctuation">;</span>
76 <span class="macro">println!</span>(<span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="numeric_literal">1</span><span class="format_specifier">}</span><span class="string_literal"> is </span><span class="format_specifier">{</span><span class="numeric_literal">2</span><span class="format_specifier">:</span><span class="format_specifier">.</span><span class="numeric_literal">0</span><span class="format_specifier">$</span><span class="format_specifier">}</span><span class="string_literal">"</span>, <span class="numeric_literal">5</span>, <span class="string_literal">"x"</span>, <span class="numeric_literal">0.01</span>); 76 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="numeric_literal">1</span><span class="format_specifier">}</span><span class="string_literal"> is </span><span class="format_specifier">{</span><span class="numeric_literal">2</span><span class="format_specifier">:</span><span class="format_specifier">.</span><span class="numeric_literal">0</span><span class="format_specifier">$</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="punctuation">,</span> <span class="numeric_literal">5</span><span class="punctuation">,</span> <span class="string_literal">"x"</span><span class="punctuation">,</span> <span class="numeric_literal">0.01</span><span class="punctuation">)</span><span class="punctuation">;</span>
77 <span class="macro">println!</span>(<span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="numeric_literal">0</span><span class="format_specifier">}</span><span class="string_literal"> is </span><span class="format_specifier">{</span><span class="numeric_literal">2</span><span class="format_specifier">:</span><span class="format_specifier">.</span><span class="numeric_literal">1</span><span class="format_specifier">$</span><span class="format_specifier">}</span><span class="string_literal">"</span>, <span class="string_literal">"x"</span>, <span class="numeric_literal">5</span>, <span class="numeric_literal">0.01</span>); 77 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="numeric_literal">0</span><span class="format_specifier">}</span><span class="string_literal"> is </span><span class="format_specifier">{</span><span class="numeric_literal">2</span><span class="format_specifier">:</span><span class="format_specifier">.</span><span class="numeric_literal">1</span><span class="format_specifier">$</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="punctuation">,</span> <span class="string_literal">"x"</span><span class="punctuation">,</span> <span class="numeric_literal">5</span><span class="punctuation">,</span> <span class="numeric_literal">0.01</span><span class="punctuation">)</span><span class="punctuation">;</span>
78 <span class="macro">println!</span>(<span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal"> is </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">.</span><span class="format_specifier">*</span><span class="format_specifier">}</span><span class="string_literal">"</span>, <span class="string_literal">"x"</span>, <span class="numeric_literal">5</span>, <span class="numeric_literal">0.01</span>); 78 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal"> is </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">.</span><span class="format_specifier">*</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="punctuation">,</span> <span class="string_literal">"x"</span><span class="punctuation">,</span> <span class="numeric_literal">5</span><span class="punctuation">,</span> <span class="numeric_literal">0.01</span><span class="punctuation">)</span><span class="punctuation">;</span>
79 <span class="macro">println!</span>(<span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal"> is </span><span class="format_specifier">{</span><span class="numeric_literal">2</span><span class="format_specifier">:</span><span class="format_specifier">.</span><span class="format_specifier">*</span><span class="format_specifier">}</span><span class="string_literal">"</span>, <span class="string_literal">"x"</span>, <span class="numeric_literal">5</span>, <span class="numeric_literal">0.01</span>); 79 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal"> is </span><span class="format_specifier">{</span><span class="numeric_literal">2</span><span class="format_specifier">:</span><span class="format_specifier">.</span><span class="format_specifier">*</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="punctuation">,</span> <span class="string_literal">"x"</span><span class="punctuation">,</span> <span class="numeric_literal">5</span><span class="punctuation">,</span> <span class="numeric_literal">0.01</span><span class="punctuation">)</span><span class="punctuation">;</span>
80 <span class="macro">println!</span>(<span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal"> is </span><span class="format_specifier">{</span><span class="variable">number</span><span class="format_specifier">:</span><span class="format_specifier">.</span><span class="variable">prec</span><span class="format_specifier">$</span><span class="format_specifier">}</span><span class="string_literal">"</span>, <span class="string_literal">"x"</span>, prec = <span class="numeric_literal">5</span>, number = <span class="numeric_literal">0.01</span>); 80 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal"> is </span><span class="format_specifier">{</span><span class="variable">number</span><span class="format_specifier">:</span><span class="format_specifier">.</span><span class="variable">prec</span><span class="format_specifier">$</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="punctuation">,</span> <span class="string_literal">"x"</span><span class="punctuation">,</span> prec <span class="punctuation">=</span> <span class="numeric_literal">5</span><span class="punctuation">,</span> number <span class="punctuation">=</span> <span class="numeric_literal">0.01</span><span class="punctuation">)</span><span class="punctuation">;</span>
81 <span class="macro">println!</span>(<span class="string_literal">"</span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">, `</span><span class="format_specifier">{</span><span class="variable">name</span><span class="format_specifier">:</span><span class="format_specifier">.</span><span class="format_specifier">*</span><span class="format_specifier">}</span><span class="string_literal">` has 3 fractional digits"</span>, <span class="string_literal">"Hello"</span>, <span class="numeric_literal">3</span>, name=<span class="numeric_literal">1234.56</span>); 81 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">, `</span><span class="format_specifier">{</span><span class="variable">name</span><span class="format_specifier">:</span><span class="format_specifier">.</span><span class="format_specifier">*</span><span class="format_specifier">}</span><span class="string_literal">` has 3 fractional digits"</span><span class="punctuation">,</span> <span class="string_literal">"Hello"</span><span class="punctuation">,</span> <span class="numeric_literal">3</span><span class="punctuation">,</span> name<span class="punctuation">=</span><span class="numeric_literal">1234.56</span><span class="punctuation">)</span><span class="punctuation">;</span>
82 <span class="macro">println!</span>(<span class="string_literal">"</span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">, `</span><span class="format_specifier">{</span><span class="variable">name</span><span class="format_specifier">:</span><span class="format_specifier">.</span><span class="format_specifier">*</span><span class="format_specifier">}</span><span class="string_literal">` has 3 characters"</span>, <span class="string_literal">"Hello"</span>, <span class="numeric_literal">3</span>, name=<span class="string_literal">"1234.56"</span>); 82 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">, `</span><span class="format_specifier">{</span><span class="variable">name</span><span class="format_specifier">:</span><span class="format_specifier">.</span><span class="format_specifier">*</span><span class="format_specifier">}</span><span class="string_literal">` has 3 characters"</span><span class="punctuation">,</span> <span class="string_literal">"Hello"</span><span class="punctuation">,</span> <span class="numeric_literal">3</span><span class="punctuation">,</span> name<span class="punctuation">=</span><span class="string_literal">"1234.56"</span><span class="punctuation">)</span><span class="punctuation">;</span>
83 <span class="macro">println!</span>(<span class="string_literal">"</span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">, `</span><span class="format_specifier">{</span><span class="variable">name</span><span class="format_specifier">:</span><span class="format_specifier">&gt;</span><span class="numeric_literal">8</span><span class="format_specifier">.</span><span class="format_specifier">*</span><span class="format_specifier">}</span><span class="string_literal">` has 3 right-aligned characters"</span>, <span class="string_literal">"Hello"</span>, <span class="numeric_literal">3</span>, name=<span class="string_literal">"1234.56"</span>); 83 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">, `</span><span class="format_specifier">{</span><span class="variable">name</span><span class="format_specifier">:</span><span class="format_specifier">&gt;</span><span class="numeric_literal">8</span><span class="format_specifier">.</span><span class="format_specifier">*</span><span class="format_specifier">}</span><span class="string_literal">` has 3 right-aligned characters"</span><span class="punctuation">,</span> <span class="string_literal">"Hello"</span><span class="punctuation">,</span> <span class="numeric_literal">3</span><span class="punctuation">,</span> name<span class="punctuation">=</span><span class="string_literal">"1234.56"</span><span class="punctuation">)</span><span class="punctuation">;</span>
84 <span class="macro">println!</span>(<span class="string_literal">"Hello {{}}"</span>); 84 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"Hello {{}}"</span><span class="punctuation">)</span><span class="punctuation">;</span>
85 <span class="macro">println!</span>(<span class="string_literal">"{{ Hello"</span>); 85 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"{{ Hello"</span><span class="punctuation">)</span><span class="punctuation">;</span>
86 86
87 <span class="macro">println!</span>(<span class="string_literal">r"Hello, </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">!"</span>, <span class="string_literal">"world"</span>); 87 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">r"Hello, </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="punctuation">,</span> <span class="string_literal">"world"</span><span class="punctuation">)</span><span class="punctuation">;</span>
88 88
89 <span class="comment">// escape sequences</span> 89 <span class="comment">// escape sequences</span>
90 <span class="macro">println!</span>(<span class="string_literal">"Hello</span><span class="escape_sequence">\n</span><span class="string_literal">World"</span>); 90 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"Hello</span><span class="escape_sequence">\n</span><span class="string_literal">World"</span><span class="punctuation">)</span><span class="punctuation">;</span>
91 <span class="macro">println!</span>(<span class="string_literal">"</span><span class="escape_sequence">\u{48}</span><span class="escape_sequence">\x65</span><span class="escape_sequence">\x6C</span><span class="escape_sequence">\x6C</span><span class="escape_sequence">\x6F</span><span class="string_literal"> World"</span>); 91 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"</span><span class="escape_sequence">\u{48}</span><span class="escape_sequence">\x65</span><span class="escape_sequence">\x6C</span><span class="escape_sequence">\x6C</span><span class="escape_sequence">\x6F</span><span class="string_literal"> World"</span><span class="punctuation">)</span><span class="punctuation">;</span>
92 92
93 <span class="macro">println!</span>(<span class="string_literal">"</span><span class="format_specifier">{</span><span class="escape_sequence">\x41</span><span class="format_specifier">}</span><span class="string_literal">"</span>, A = <span class="numeric_literal">92</span>); 93 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="escape_sequence">\x41</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="punctuation">,</span> A <span class="punctuation">=</span> <span class="numeric_literal">92</span><span class="punctuation">)</span><span class="punctuation">;</span>
94 <span class="macro">println!</span>(<span class="string_literal">"</span><span class="format_specifier">{</span><span class="variable">ничоси</span><span class="format_specifier">}</span><span class="string_literal">"</span>, ничоси = <span class="numeric_literal">92</span>); 94 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="variable">ничоси</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="punctuation">,</span> ничоси <span class="punctuation">=</span> <span class="numeric_literal">92</span><span class="punctuation">)</span><span class="punctuation">;</span>
95}</code></pre> \ No newline at end of file 95<span class="punctuation">}</span></code></pre> \ No newline at end of file
diff --git a/crates/ra_ide/src/snapshots/highlight_unsafe.html b/crates/ra_ide/src/snapshots/highlight_unsafe.html
index fe986b98c..fa986a3bc 100644
--- a/crates/ra_ide/src/snapshots/highlight_unsafe.html
+++ b/crates/ra_ide/src/snapshots/highlight_unsafe.html
@@ -5,7 +5,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
5 5
6.lifetime { color: #DFAF8F; font-style: italic; } 6.lifetime { color: #DFAF8F; font-style: italic; }
7.comment { color: #7F9F7F; } 7.comment { color: #7F9F7F; }
8.documentation { color: #00CC00; } 8.documentation { color: #629755; }
9.injected { opacity: 0.65 ; } 9.injected { opacity: 0.65 ; }
10.struct, .enum { color: #7CB8BB; } 10.struct, .enum { color: #7CB8BB; }
11.enum_variant { color: #BDE0F3; } 11.enum_variant { color: #BDE0F3; }
@@ -34,20 +34,20 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
34.keyword.unsafe { color: #BC8383; font-weight: bold; } 34.keyword.unsafe { color: #BC8383; font-weight: bold; }
35.control { font-style: italic; } 35.control { font-style: italic; }
36</style> 36</style>
37<pre><code><span class="keyword unsafe">unsafe</span> <span class="keyword">fn</span> <span class="function declaration unsafe">unsafe_fn</span>() {} 37<pre><code><span class="keyword unsafe">unsafe</span> <span class="keyword">fn</span> <span class="function declaration unsafe">unsafe_fn</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span><span class="punctuation">}</span>
38 38
39<span class="keyword">struct</span> <span class="struct declaration">HasUnsafeFn</span>; 39<span class="keyword">struct</span> <span class="struct declaration">HasUnsafeFn</span><span class="punctuation">;</span>
40 40
41<span class="keyword">impl</span> <span class="struct">HasUnsafeFn</span> { 41<span class="keyword">impl</span> <span class="struct">HasUnsafeFn</span> <span class="punctuation">{</span>
42 <span class="keyword unsafe">unsafe</span> <span class="keyword">fn</span> <span class="function declaration unsafe">unsafe_method</span>(&<span class="self_keyword">self</span>) {} 42 <span class="keyword unsafe">unsafe</span> <span class="keyword">fn</span> <span class="function declaration unsafe">unsafe_method</span><span class="punctuation">(</span><span class="punctuation">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="punctuation">{</span><span class="punctuation">}</span>
43} 43<span class="punctuation">}</span>
44 44
45<span class="keyword">fn</span> <span class="function declaration">main</span>() { 45<span class="keyword">fn</span> <span class="function declaration">main</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span>
46 <span class="keyword">let</span> <span class="variable declaration">x</span> = &<span class="numeric_literal">5</span> <span class="keyword">as</span> *<span class="keyword">const</span> <span class="builtin_type">usize</span>; 46 <span class="keyword">let</span> <span class="variable declaration">x</span> <span class="punctuation">=</span> <span class="punctuation">&</span><span class="numeric_literal">5</span> <span class="keyword">as</span> *<span class="keyword">const</span> <span class="builtin_type">usize</span><span class="punctuation">;</span>
47 <span class="keyword unsafe">unsafe</span> { 47 <span class="keyword unsafe">unsafe</span> <span class="punctuation">{</span>
48 <span class="function unsafe">unsafe_fn</span>(); 48 <span class="function unsafe">unsafe_fn</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
49 <span class="struct">HasUnsafeFn</span>.<span class="function unsafe">unsafe_method</span>(); 49 <span class="struct">HasUnsafeFn</span><span class="punctuation">.</span><span class="function unsafe">unsafe_method</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
50 <span class="keyword">let</span> <span class="variable declaration">y</span> = <span class="operator unsafe">*</span>(<span class="variable">x</span>); 50 <span class="keyword">let</span> <span class="variable declaration">y</span> <span class="punctuation">=</span> <span class="operator unsafe">*</span><span class="punctuation">(</span><span class="variable">x</span><span class="punctuation">)</span><span class="punctuation">;</span>
51 <span class="keyword">let</span> <span class="variable declaration">z</span> = -<span class="variable">x</span>; 51 <span class="keyword">let</span> <span class="variable declaration">z</span> <span class="punctuation">=</span> <span class="punctuation">-</span><span class="variable">x</span><span class="punctuation">;</span>
52 } 52 <span class="punctuation">}</span>
53}</code></pre> \ No newline at end of file 53<span class="punctuation">}</span></code></pre> \ No newline at end of file
diff --git a/crates/ra_ide/src/snapshots/highlighting.html b/crates/ra_ide/src/snapshots/highlighting.html
index c101af8ea..e1852c409 100644
--- a/crates/ra_ide/src/snapshots/highlighting.html
+++ b/crates/ra_ide/src/snapshots/highlighting.html
@@ -5,7 +5,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
5 5
6.lifetime { color: #DFAF8F; font-style: italic; } 6.lifetime { color: #DFAF8F; font-style: italic; }
7.comment { color: #7F9F7F; } 7.comment { color: #7F9F7F; }
8.documentation { color: #00CC00; } 8.documentation { color: #629755; }
9.injected { opacity: 0.65 ; } 9.injected { opacity: 0.65 ; }
10.struct, .enum { color: #7CB8BB; } 10.struct, .enum { color: #7CB8BB; }
11.enum_variant { color: #BDE0F3; } 11.enum_variant { color: #BDE0F3; }
@@ -34,84 +34,84 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
34.keyword.unsafe { color: #BC8383; font-weight: bold; } 34.keyword.unsafe { color: #BC8383; font-weight: bold; }
35.control { font-style: italic; } 35.control { font-style: italic; }
36</style> 36</style>
37<pre><code><span class="attribute">#[</span><span class="function attribute">derive</span><span class="attribute">(Clone, Debug)]</span> 37<pre><code><span class="punctuation">#</span><span class="punctuation">[</span><span class="function attribute">derive</span><span class="punctuation">(</span><span class="attribute">Clone</span><span class="punctuation">,</span><span class="attribute"> Debug</span><span class="punctuation">)</span><span class="punctuation">]</span>
38<span class="keyword">struct</span> <span class="struct declaration">Foo</span> { 38<span class="keyword">struct</span> <span class="struct declaration">Foo</span> <span class="punctuation">{</span>
39 <span class="keyword">pub</span> <span class="field declaration">x</span>: <span class="builtin_type">i32</span>, 39 <span class="keyword">pub</span> <span class="field declaration">x</span><span class="punctuation">:</span> <span class="builtin_type">i32</span><span class="punctuation">,</span>
40 <span class="keyword">pub</span> <span class="field declaration">y</span>: <span class="builtin_type">i32</span>, 40 <span class="keyword">pub</span> <span class="field declaration">y</span><span class="punctuation">:</span> <span class="builtin_type">i32</span><span class="punctuation">,</span>
41} 41<span class="punctuation">}</span>
42 42
43<span class="keyword">trait</span> <span class="trait declaration">Bar</span> { 43<span class="keyword">trait</span> <span class="trait declaration">Bar</span> <span class="punctuation">{</span>
44 <span class="keyword">fn</span> <span class="function declaration">bar</span>(&<span class="self_keyword">self</span>) -&gt; <span class="builtin_type">i32</span>; 44 <span class="keyword">fn</span> <span class="function declaration">bar</span><span class="punctuation">(</span><span class="punctuation">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="punctuation">-&gt;</span> <span class="builtin_type">i32</span><span class="punctuation">;</span>
45} 45<span class="punctuation">}</span>
46 46
47<span class="keyword">impl</span> <span class="trait">Bar</span> <span class="keyword">for</span> <span class="struct">Foo</span> { 47<span class="keyword">impl</span> <span class="trait">Bar</span> <span class="keyword">for</span> <span class="struct">Foo</span> <span class="punctuation">{</span>
48 <span class="keyword">fn</span> <span class="function declaration">bar</span>(&<span class="self_keyword">self</span>) -&gt; <span class="builtin_type">i32</span> { 48 <span class="keyword">fn</span> <span class="function declaration">bar</span><span class="punctuation">(</span><span class="punctuation">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="punctuation">-&gt;</span> <span class="builtin_type">i32</span> <span class="punctuation">{</span>
49 <span class="self_keyword">self</span>.<span class="field">x</span> 49 <span class="self_keyword">self</span><span class="punctuation">.</span><span class="field">x</span>
50 } 50 <span class="punctuation">}</span>
51} 51<span class="punctuation">}</span>
52 52
53<span class="keyword">static</span> <span class="keyword">mut</span> <span class="static declaration mutable">STATIC_MUT</span>: <span class="builtin_type">i32</span> = <span class="numeric_literal">0</span>; 53<span class="keyword">static</span> <span class="keyword">mut</span> <span class="static declaration mutable">STATIC_MUT</span><span class="punctuation">:</span> <span class="builtin_type">i32</span> <span class="punctuation">=</span> <span class="numeric_literal">0</span><span class="punctuation">;</span>
54 54
55<span class="keyword">fn</span> <span class="function declaration">foo</span>&lt;<span class="lifetime declaration">'a</span>, <span class="type_param declaration">T</span>&gt;() -&gt; <span class="type_param">T</span> { 55<span class="keyword">fn</span> <span class="function declaration">foo</span><span class="punctuation">&lt;</span><span class="lifetime declaration">'a</span><span class="punctuation">,</span> <span class="type_param declaration">T</span><span class="punctuation">&gt;</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">-&gt;</span> <span class="type_param">T</span> <span class="punctuation">{</span>
56 <span class="function">foo</span>::&lt;<span class="lifetime">'a</span>, <span class="builtin_type">i32</span>&gt;() 56 <span class="function">foo</span><span class="punctuation">::</span><span class="punctuation">&lt;</span><span class="lifetime">'a</span><span class="punctuation">,</span> <span class="builtin_type">i32</span><span class="punctuation">&gt;</span><span class="punctuation">(</span><span class="punctuation">)</span>
57} 57<span class="punctuation">}</span>
58 58
59<span class="macro">macro_rules!</span> <span class="macro declaration">def_fn</span> { 59<span class="macro">macro_rules!</span> <span class="macro declaration">def_fn</span> <span class="punctuation">{</span>
60 ($($tt:tt)*) =&gt; {$($tt)*} 60 <span class="punctuation">(</span><span class="punctuation">$</span><span class="punctuation">(</span><span class="punctuation">$</span>tt<span class="punctuation">:</span>tt<span class="punctuation">)</span>*<span class="punctuation">)</span> <span class="punctuation">=</span><span class="punctuation">&gt;</span> <span class="punctuation">{</span><span class="punctuation">$</span><span class="punctuation">(</span><span class="punctuation">$</span>tt<span class="punctuation">)</span>*<span class="punctuation">}</span>
61} 61<span class="punctuation">}</span>
62 62
63<span class="macro">def_fn!</span> { 63<span class="macro">def_fn!</span> <span class="punctuation">{</span>
64 <span class="keyword">fn</span> <span class="function declaration">bar</span>() -&gt; <span class="builtin_type">u32</span> { 64 <span class="keyword">fn</span> <span class="function declaration">bar</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">-</span><span class="punctuation">&gt;</span> <span class="builtin_type">u32</span> <span class="punctuation">{</span>
65 <span class="numeric_literal">100</span> 65 <span class="numeric_literal">100</span>
66 } 66 <span class="punctuation">}</span>
67} 67<span class="punctuation">}</span>
68 68
69<span class="macro">macro_rules!</span> <span class="macro declaration">noop</span> { 69<span class="macro">macro_rules!</span> <span class="macro declaration">noop</span> <span class="punctuation">{</span>
70 ($expr:expr) =&gt; { 70 <span class="punctuation">(</span><span class="punctuation">$</span>expr<span class="punctuation">:</span>expr<span class="punctuation">)</span> <span class="punctuation">=</span><span class="punctuation">&gt;</span> <span class="punctuation">{</span>
71 $expr 71 <span class="punctuation">$</span>expr
72 } 72 <span class="punctuation">}</span>
73} 73<span class="punctuation">}</span>
74 74
75<span class="comment">// comment</span> 75<span class="comment">// comment</span>
76<span class="keyword">fn</span> <span class="function declaration">main</span>() { 76<span class="keyword">fn</span> <span class="function declaration">main</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span>
77 <span class="macro">println!</span>(<span class="string_literal">"Hello, {}!"</span>, <span class="numeric_literal">92</span>); 77 <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"Hello, {}!"</span><span class="punctuation">,</span> <span class="numeric_literal">92</span><span class="punctuation">)</span><span class="punctuation">;</span>
78 78
79 <span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable">vec</span> = <span class="unresolved_reference">Vec</span>::<span class="unresolved_reference">new</span>(); 79 <span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable">vec</span> <span class="punctuation">=</span> <span class="unresolved_reference">Vec</span><span class="punctuation">::</span><span class="unresolved_reference">new</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
80 <span class="keyword control">if</span> <span class="bool_literal">true</span> { 80 <span class="keyword control">if</span> <span class="bool_literal">true</span> <span class="punctuation">{</span>
81 <span class="keyword">let</span> <span class="variable declaration">x</span> = <span class="numeric_literal">92</span>; 81 <span class="keyword">let</span> <span class="variable declaration">x</span> <span class="punctuation">=</span> <span class="numeric_literal">92</span><span class="punctuation">;</span>
82 <span class="variable mutable">vec</span>.<span class="unresolved_reference">push</span>(<span class="struct">Foo</span> { <span class="field">x</span>, <span class="field">y</span>: <span class="numeric_literal">1</span> }); 82 <span class="variable mutable">vec</span><span class="punctuation">.</span><span class="unresolved_reference">push</span><span class="punctuation">(</span><span class="struct">Foo</span> <span class="punctuation">{</span> <span class="field">x</span><span class="punctuation">,</span> <span class="field">y</span><span class="punctuation">:</span> <span class="numeric_literal">1</span> <span class="punctuation">}</span><span class="punctuation">)</span><span class="punctuation">;</span>
83 } 83 <span class="punctuation">}</span>
84 <span class="keyword unsafe">unsafe</span> { 84 <span class="keyword unsafe">unsafe</span> <span class="punctuation">{</span>
85 <span class="variable mutable">vec</span>.<span class="unresolved_reference">set_len</span>(<span class="numeric_literal">0</span>); 85 <span class="variable mutable">vec</span><span class="punctuation">.</span><span class="unresolved_reference">set_len</span><span class="punctuation">(</span><span class="numeric_literal">0</span><span class="punctuation">)</span><span class="punctuation">;</span>
86 <span class="static mutable">STATIC_MUT</span> = <span class="numeric_literal">1</span>; 86 <span class="static mutable">STATIC_MUT</span> <span class="punctuation">=</span> <span class="numeric_literal">1</span><span class="punctuation">;</span>
87 } 87 <span class="punctuation">}</span>
88 88
89 <span class="keyword control">for</span> <span class="variable declaration">e</span> <span class="keyword control">in</span> <span class="variable mutable">vec</span> { 89 <span class="keyword control">for</span> <span class="variable declaration">e</span> <span class="keyword control">in</span> <span class="variable mutable">vec</span> <span class="punctuation">{</span>
90 <span class="comment">// Do nothing</span> 90 <span class="comment">// Do nothing</span>
91 } 91 <span class="punctuation">}</span>
92 92
93 <span class="macro">noop!</span>(<span class="macro">noop</span><span class="macro">!</span>(<span class="numeric_literal">1</span>)); 93 <span class="macro">noop!</span><span class="punctuation">(</span><span class="macro">noop</span><span class="macro">!</span><span class="punctuation">(</span><span class="numeric_literal">1</span><span class="punctuation">)</span><span class="punctuation">)</span><span class="punctuation">;</span>
94 94
95 <span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable">x</span> = <span class="numeric_literal">42</span>; 95 <span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable">x</span> <span class="punctuation">=</span> <span class="numeric_literal">42</span><span class="punctuation">;</span>
96 <span class="keyword">let</span> <span class="variable declaration mutable">y</span> = &<span class="keyword">mut</span> <span class="variable mutable">x</span>; 96 <span class="keyword">let</span> <span class="variable declaration mutable">y</span> <span class="punctuation">=</span> <span class="punctuation">&</span><span class="keyword">mut</span> <span class="variable mutable">x</span><span class="punctuation">;</span>
97 <span class="keyword">let</span> <span class="variable declaration">z</span> = &<span class="variable mutable">y</span>; 97 <span class="keyword">let</span> <span class="variable declaration">z</span> <span class="punctuation">=</span> <span class="punctuation">&</span><span class="variable mutable">y</span><span class="punctuation">;</span>
98 98
99 <span class="keyword">let</span> <span class="struct">Foo</span> { <span class="field">x</span>: <span class="variable declaration">z</span>, <span class="field">y</span> } = <span class="struct">Foo</span> { <span class="field">x</span>: <span class="variable">z</span>, <span class="field">y</span> }; 99 <span class="keyword">let</span> <span class="struct">Foo</span> <span class="punctuation">{</span> <span class="field">x</span><span class="punctuation">:</span> <span class="variable declaration">z</span><span class="punctuation">,</span> <span class="field">y</span> <span class="punctuation">}</span> <span class="punctuation">=</span> <span class="struct">Foo</span> <span class="punctuation">{</span> <span class="field">x</span><span class="punctuation">:</span> <span class="variable">z</span><span class="punctuation">,</span> <span class="field">y</span> <span class="punctuation">}</span><span class="punctuation">;</span>
100 100
101 <span class="variable">y</span>; 101 <span class="variable">y</span><span class="punctuation">;</span>
102} 102<span class="punctuation">}</span>
103 103
104<span class="keyword">enum</span> <span class="enum declaration">Option</span>&lt;<span class="type_param declaration">T</span>&gt; { 104<span class="keyword">enum</span> <span class="enum declaration">Option</span><span class="punctuation">&lt;</span><span class="type_param declaration">T</span><span class="punctuation">&gt;</span> <span class="punctuation">{</span>
105 <span class="enum_variant declaration">Some</span>(<span class="type_param">T</span>), 105 <span class="enum_variant declaration">Some</span><span class="punctuation">(</span><span class="type_param">T</span><span class="punctuation">)</span><span class="punctuation">,</span>
106 <span class="enum_variant declaration">None</span>, 106 <span class="enum_variant declaration">None</span><span class="punctuation">,</span>
107} 107<span class="punctuation">}</span>
108<span class="keyword">use</span> <span class="enum">Option</span>::*; 108<span class="keyword">use</span> <span class="enum">Option</span><span class="punctuation">::</span>*<span class="punctuation">;</span>
109 109
110<span class="keyword">impl</span>&lt;<span class="type_param declaration">T</span>&gt; <span class="enum">Option</span>&lt;<span class="type_param">T</span>&gt; { 110<span class="keyword">impl</span><span class="punctuation">&lt;</span><span class="type_param declaration">T</span><span class="punctuation">&gt;</span> <span class="enum">Option</span><span class="punctuation">&lt;</span><span class="type_param">T</span><span class="punctuation">&gt;</span> <span class="punctuation">{</span>
111 <span class="keyword">fn</span> <span class="function declaration">and</span>&lt;<span class="type_param declaration">U</span>&gt;(<span class="self_keyword">self</span>, <span class="variable declaration">other</span>: <span class="enum">Option</span>&lt;<span class="type_param">U</span>&gt;) -&gt; <span class="enum">Option</span>&lt;(<span class="type_param">T</span>, <span class="type_param">U</span>)&gt; { 111 <span class="keyword">fn</span> <span class="function declaration">and</span><span class="punctuation">&lt;</span><span class="type_param declaration">U</span><span class="punctuation">&gt;</span><span class="punctuation">(</span><span class="self_keyword">self</span><span class="punctuation">,</span> <span class="variable declaration">other</span><span class="punctuation">:</span> <span class="enum">Option</span><span class="punctuation">&lt;</span><span class="type_param">U</span><span class="punctuation">&gt;</span><span class="punctuation">)</span> <span class="punctuation">-&gt;</span> <span class="enum">Option</span><span class="punctuation">&lt;</span><span class="punctuation">(</span><span class="type_param">T</span><span class="punctuation">,</span> <span class="type_param">U</span><span class="punctuation">)</span><span class="punctuation">&gt;</span> <span class="punctuation">{</span>
112 <span class="keyword control">match</span> <span class="variable">other</span> { 112 <span class="keyword control">match</span> <span class="variable">other</span> <span class="punctuation">{</span>
113 <span class="enum_variant">None</span> =&gt; <span class="macro">unimplemented!</span>(), 113 <span class="enum_variant">None</span> <span class="punctuation">=&gt;</span> <span class="macro">unimplemented!</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">,</span>
114 <span class="variable declaration">Nope</span> =&gt; <span class="variable">Nope</span>, 114 <span class="variable declaration">Nope</span> <span class="punctuation">=&gt;</span> <span class="variable">Nope</span><span class="punctuation">,</span>
115 } 115 <span class="punctuation">}</span>
116 } 116 <span class="punctuation">}</span>
117}</code></pre> \ No newline at end of file 117<span class="punctuation">}</span></code></pre> \ No newline at end of file
diff --git a/crates/ra_ide/src/snapshots/rainbow_highlighting.html b/crates/ra_ide/src/snapshots/rainbow_highlighting.html
index 97b296d72..d05a56cf2 100644
--- a/crates/ra_ide/src/snapshots/rainbow_highlighting.html
+++ b/crates/ra_ide/src/snapshots/rainbow_highlighting.html
@@ -5,7 +5,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
5 5
6.lifetime { color: #DFAF8F; font-style: italic; } 6.lifetime { color: #DFAF8F; font-style: italic; }
7.comment { color: #7F9F7F; } 7.comment { color: #7F9F7F; }
8.documentation { color: #00CC00; } 8.documentation { color: #629755; }
9.injected { opacity: 0.65 ; } 9.injected { opacity: 0.65 ; }
10.struct, .enum { color: #7CB8BB; } 10.struct, .enum { color: #7CB8BB; }
11.enum_variant { color: #BDE0F3; } 11.enum_variant { color: #BDE0F3; }
@@ -34,15 +34,15 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
34.keyword.unsafe { color: #BC8383; font-weight: bold; } 34.keyword.unsafe { color: #BC8383; font-weight: bold; }
35.control { font-style: italic; } 35.control { font-style: italic; }
36</style> 36</style>
37<pre><code><span class="keyword">fn</span> <span class="function declaration">main</span>() { 37<pre><code><span class="keyword">fn</span> <span class="function declaration">main</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span>
38 <span class="keyword">let</span> <span class="variable declaration" data-binding-hash="8121853618659664005" style="color: hsl(261,57%,61%);">hello</span> = <span class="string_literal">"hello"</span>; 38 <span class="keyword">let</span> <span class="variable declaration" data-binding-hash="8121853618659664005" style="color: hsl(261,57%,61%);">hello</span> <span class="punctuation">=</span> <span class="string_literal">"hello"</span><span class="punctuation">;</span>
39 <span class="keyword">let</span> <span class="variable declaration" data-binding-hash="2705725358298919760" style="color: hsl(17,51%,74%);">x</span> = <span class="variable" data-binding-hash="8121853618659664005" style="color: hsl(261,57%,61%);">hello</span>.<span class="unresolved_reference">to_string</span>(); 39 <span class="keyword">let</span> <span class="variable declaration" data-binding-hash="2705725358298919760" style="color: hsl(17,51%,74%);">x</span> <span class="punctuation">=</span> <span class="variable" data-binding-hash="8121853618659664005" style="color: hsl(261,57%,61%);">hello</span><span class="punctuation">.</span><span class="unresolved_reference">to_string</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
40 <span class="keyword">let</span> <span class="variable declaration" data-binding-hash="3365759661443752373" style="color: hsl(127,76%,66%);">y</span> = <span class="variable" data-binding-hash="8121853618659664005" style="color: hsl(261,57%,61%);">hello</span>.<span class="unresolved_reference">to_string</span>(); 40 <span class="keyword">let</span> <span class="variable declaration" data-binding-hash="3365759661443752373" style="color: hsl(127,76%,66%);">y</span> <span class="punctuation">=</span> <span class="variable" data-binding-hash="8121853618659664005" style="color: hsl(261,57%,61%);">hello</span><span class="punctuation">.</span><span class="unresolved_reference">to_string</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
41 41
42 <span class="keyword">let</span> <span class="variable declaration" data-binding-hash="794745962933817518" style="color: hsl(19,74%,76%);">x</span> = <span class="string_literal">"other color please!"</span>; 42 <span class="keyword">let</span> <span class="variable declaration" data-binding-hash="794745962933817518" style="color: hsl(19,74%,76%);">x</span> <span class="punctuation">=</span> <span class="string_literal">"other color please!"</span><span class="punctuation">;</span>
43 <span class="keyword">let</span> <span class="variable declaration" data-binding-hash="6717528807933952652" style="color: hsl(85,49%,84%);">y</span> = <span class="variable" data-binding-hash="794745962933817518" style="color: hsl(19,74%,76%);">x</span>.<span class="unresolved_reference">to_string</span>(); 43 <span class="keyword">let</span> <span class="variable declaration" data-binding-hash="6717528807933952652" style="color: hsl(85,49%,84%);">y</span> <span class="punctuation">=</span> <span class="variable" data-binding-hash="794745962933817518" style="color: hsl(19,74%,76%);">x</span><span class="punctuation">.</span><span class="unresolved_reference">to_string</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
44} 44<span class="punctuation">}</span>
45 45
46<span class="keyword">fn</span> <span class="function declaration">bar</span>() { 46<span class="keyword">fn</span> <span class="function declaration">bar</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span>
47 <span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable" data-binding-hash="8121853618659664005" style="color: hsl(261,57%,61%);">hello</span> = <span class="string_literal">"hello"</span>; 47 <span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable" data-binding-hash="8121853618659664005" style="color: hsl(261,57%,61%);">hello</span> <span class="punctuation">=</span> <span class="string_literal">"hello"</span><span class="punctuation">;</span>
48}</code></pre> \ No newline at end of file 48<span class="punctuation">}</span></code></pre> \ No newline at end of file
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index b4dcdba39..8e714a999 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -45,7 +45,7 @@ pub(crate) fn highlight(
45 file_id: FileId, 45 file_id: FileId,
46 range_to_highlight: Option<TextRange>, 46 range_to_highlight: Option<TextRange>,
47 syntactic_name_ref_highlighting: bool, 47 syntactic_name_ref_highlighting: bool,
48 default_tag: Option<HighlightTag>, 48 should_highlight_punctuation: bool,
49) -> Vec<HighlightedRange> { 49) -> Vec<HighlightedRange> {
50 let _p = profile("highlight"); 50 let _p = profile("highlight");
51 let sema = Semantics::new(db); 51 let sema = Semantics::new(db);
@@ -108,7 +108,7 @@ pub(crate) fn highlight(
108 &mut bindings_shadow_count, 108 &mut bindings_shadow_count,
109 syntactic_name_ref_highlighting, 109 syntactic_name_ref_highlighting,
110 name.syntax().clone().into(), 110 name.syntax().clone().into(),
111 default_tag, 111 should_highlight_punctuation,
112 ) { 112 ) {
113 stack.add(HighlightedRange { 113 stack.add(HighlightedRange {
114 range: name.syntax().text_range(), 114 range: name.syntax().text_range(),
@@ -208,7 +208,7 @@ pub(crate) fn highlight(
208 &mut bindings_shadow_count, 208 &mut bindings_shadow_count,
209 syntactic_name_ref_highlighting, 209 syntactic_name_ref_highlighting,
210 element_to_highlight.clone(), 210 element_to_highlight.clone(),
211 default_tag, 211 true,
212 ) { 212 ) {
213 stack.add(HighlightedRange { range, highlight, binding_hash }); 213 stack.add(HighlightedRange { range, highlight, binding_hash });
214 if let Some(string) = 214 if let Some(string) =
@@ -331,12 +331,12 @@ impl HighlightedRangeStack {
331 /// can only modify the last range currently on the stack. 331 /// can only modify the last range currently on the stack.
332 /// Can be used to do injections that span multiple ranges, like the 332 /// Can be used to do injections that span multiple ranges, like the
333 /// doctest injection below. 333 /// doctest injection below.
334 /// If `delete` is set to true, the parent range is deleted instead of 334 /// If `inject` is set to true, the parent range is deleted instead of
335 /// intersected. 335 /// intersected.
336 /// 336 ///
337 /// Note that `pop` can be simulated by `pop_and_inject(false)` but the 337 /// Note that `pop` can be simulated by `pop_and_inject(false)` but the
338 /// latter is computationally more expensive. 338 /// latter is computationally more expensive.
339 fn pop_and_inject(&mut self, delete: bool) { 339 fn pop_and_inject(&mut self, inject: bool) {
340 let mut children = self.stack.pop().unwrap(); 340 let mut children = self.stack.pop().unwrap();
341 let prev = self.stack.last_mut().unwrap(); 341 let prev = self.stack.last_mut().unwrap();
342 children.sort_by_key(|range| range.range.start()); 342 children.sort_by_key(|range| range.range.start());
@@ -347,14 +347,14 @@ impl HighlightedRangeStack {
347 prev.iter().position(|parent| parent.range.contains_range(child.range)) 347 prev.iter().position(|parent| parent.range.contains_range(child.range))
348 { 348 {
349 let cloned = Self::intersect(&mut prev[idx], &child); 349 let cloned = Self::intersect(&mut prev[idx], &child);
350 let insert_idx = if delete || prev[idx].range.is_empty() { 350 let insert_idx = if inject || prev[idx].range.is_empty() {
351 prev.remove(idx); 351 prev.remove(idx);
352 idx 352 idx
353 } else { 353 } else {
354 idx + 1 354 idx + 1
355 }; 355 };
356 prev.insert(insert_idx, child); 356 prev.insert(insert_idx, child);
357 if !delete && !cloned.range.is_empty() { 357 if !inject && !cloned.range.is_empty() {
358 prev.insert(insert_idx + 1, cloned); 358 prev.insert(insert_idx + 1, cloned);
359 } 359 }
360 } else if let Some(_idx) = 360 } else if let Some(_idx) =
@@ -433,14 +433,14 @@ fn highlight_element(
433 bindings_shadow_count: &mut FxHashMap<Name, u32>, 433 bindings_shadow_count: &mut FxHashMap<Name, u32>,
434 syntactic_name_ref_highlighting: bool, 434 syntactic_name_ref_highlighting: bool,
435 element: SyntaxElement, 435 element: SyntaxElement,
436 default_tag: Option<HighlightTag>, 436 should_highlight_punctuation: bool,
437) -> Option<(Highlight, Option<u64>)> { 437) -> Option<(Highlight, Option<u64>)> {
438 let db = sema.db; 438 let db = sema.db;
439 let mut binding_hash = None; 439 let mut binding_hash = None;
440 let highlight: Highlight = match element.kind() { 440 let highlight: Highlight = match element.kind() {
441 FN_DEF => { 441 FN_DEF => {
442 bindings_shadow_count.clear(); 442 bindings_shadow_count.clear();
443 default_tag?.into() 443 return None;
444 } 444 }
445 445
446 // Highlight definitions depending on the "type" of the definition. 446 // Highlight definitions depending on the "type" of the definition.
@@ -518,10 +518,10 @@ fn highlight_element(
518 518
519 let expr = prefix_expr.expr()?; 519 let expr = prefix_expr.expr()?;
520 let ty = sema.type_of_expr(&expr)?; 520 let ty = sema.type_of_expr(&expr)?;
521 let mut h = HighlightTag::Operator.into();
521 if !ty.is_raw_ptr() { 522 if !ty.is_raw_ptr() {
522 default_tag?.into() 523 h
523 } else { 524 } else {
524 let mut h = Highlight::new(HighlightTag::Operator);
525 h |= HighlightModifier::Unsafe; 525 h |= HighlightModifier::Unsafe;
526 h 526 h
527 } 527 }
@@ -550,7 +550,8 @@ fn highlight_element(
550 } 550 }
551 } 551 }
552 552
553 _ => default_tag?.into(), 553 p if should_highlight_punctuation && p.is_punct() => HighlightTag::Punctuation.into(),
554 _ => return None,
554 }; 555 };
555 556
556 return Some((highlight, binding_hash)); 557 return Some((highlight, binding_hash));
diff --git a/crates/ra_ide/src/syntax_highlighting/html.rs b/crates/ra_ide/src/syntax_highlighting/html.rs
index 191c586a3..2a27c81dd 100644
--- a/crates/ra_ide/src/syntax_highlighting/html.rs
+++ b/crates/ra_ide/src/syntax_highlighting/html.rs
@@ -19,7 +19,7 @@ pub(crate) fn highlight_as_html(db: &RootDatabase, file_id: FileId, rainbow: boo
19 ) 19 )
20 } 20 }
21 21
22 let ranges = highlight(db, file_id, None, false, None); 22 let ranges = highlight(db, file_id, None, false, false);
23 let text = parse.tree().syntax().to_string(); 23 let text = parse.tree().syntax().to_string();
24 let mut prev_pos = TextSize::from(0); 24 let mut prev_pos = TextSize::from(0);
25 let mut buf = String::new(); 25 let mut buf = String::new();
@@ -64,7 +64,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
64 64
65.lifetime { color: #DFAF8F; font-style: italic; } 65.lifetime { color: #DFAF8F; font-style: italic; }
66.comment { color: #7F9F7F; } 66.comment { color: #7F9F7F; }
67.documentation { color: #00CC00; } 67.documentation { color: #629755; }
68.injected { opacity: 0.65 ; } 68.injected { opacity: 0.65 ; }
69.struct, .enum { color: #7CB8BB; } 69.struct, .enum { color: #7CB8BB; }
70.enum_variant { color: #BDE0F3; } 70.enum_variant { color: #BDE0F3; }
diff --git a/crates/ra_ide/src/syntax_highlighting/injection.rs b/crates/ra_ide/src/syntax_highlighting/injection.rs
index bd38cdb6f..8c724af5b 100644
--- a/crates/ra_ide/src/syntax_highlighting/injection.rs
+++ b/crates/ra_ide/src/syntax_highlighting/injection.rs
@@ -150,9 +150,7 @@ pub(super) fn highlight_doc_comment(
150 let (analysis, tmp_file_id) = Analysis::from_single_file(text); 150 let (analysis, tmp_file_id) = Analysis::from_single_file(text);
151 151
152 stack.push(); 152 stack.push();
153 for mut h in analysis 153 for mut h in analysis.with_db(|db| super::highlight(db, tmp_file_id, None, true, true)).unwrap()
154 .with_db(|db| super::highlight(db, tmp_file_id, None, true, Some(HighlightTag::Operator)))
155 .unwrap()
156 { 154 {
157 // Determine start offset and end offset in case of multi-line ranges 155 // Determine start offset and end offset in case of multi-line ranges
158 let mut start_offset = None; 156 let mut start_offset = None;
diff --git a/crates/ra_ide/src/syntax_highlighting/tags.rs b/crates/ra_ide/src/syntax_highlighting/tags.rs
index f5ab73865..7f8e91e8d 100644
--- a/crates/ra_ide/src/syntax_highlighting/tags.rs
+++ b/crates/ra_ide/src/syntax_highlighting/tags.rs
@@ -33,6 +33,7 @@ pub enum HighlightTag {
33 Module, 33 Module,
34 NumericLiteral, 34 NumericLiteral,
35 Operator, 35 Operator,
36 Punctuation,
36 SelfKeyword, 37 SelfKeyword,
37 SelfType, 38 SelfType,
38 Static, 39 Static,
@@ -84,6 +85,7 @@ impl HighlightTag {
84 HighlightTag::Module => "module", 85 HighlightTag::Module => "module",
85 HighlightTag::NumericLiteral => "numeric_literal", 86 HighlightTag::NumericLiteral => "numeric_literal",
86 HighlightTag::Operator => "operator", 87 HighlightTag::Operator => "operator",
88 HighlightTag::Punctuation => "punctuation",
87 HighlightTag::SelfKeyword => "self_keyword", 89 HighlightTag::SelfKeyword => "self_keyword",
88 HighlightTag::SelfType => "self_type", 90 HighlightTag::SelfType => "self_type",
89 HighlightTag::Static => "static", 91 HighlightTag::Static => "static",
diff --git a/crates/rust-analyzer/src/semantic_tokens.rs b/crates/rust-analyzer/src/semantic_tokens.rs
index 6f43667a3..30f25250f 100644
--- a/crates/rust-analyzer/src/semantic_tokens.rs
+++ b/crates/rust-analyzer/src/semantic_tokens.rs
@@ -39,13 +39,14 @@ define_semantic_token_types![
39 (BOOLEAN, "boolean"), 39 (BOOLEAN, "boolean"),
40 (BUILTIN_TYPE, "builtinType"), 40 (BUILTIN_TYPE, "builtinType"),
41 (ENUM_MEMBER, "enumMember"), 41 (ENUM_MEMBER, "enumMember"),
42 (ESCAPE_SEQUENCE, "escapeSequence"),
43 (FORMAT_SPECIFIER, "formatSpecifier"),
42 (LIFETIME, "lifetime"), 44 (LIFETIME, "lifetime"),
45 (PUNCTUATION, "punctuation"),
43 (SELF_KEYWORD, "selfKeyword"), 46 (SELF_KEYWORD, "selfKeyword"),
44 (TYPE_ALIAS, "typeAlias"), 47 (TYPE_ALIAS, "typeAlias"),
45 (UNION, "union"), 48 (UNION, "union"),
46 (UNRESOLVED_REFERENCE, "unresolvedReference"), 49 (UNRESOLVED_REFERENCE, "unresolvedReference"),
47 (FORMAT_SPECIFIER, "formatSpecifier"),
48 (ESCAPE_SEQUENCE, "escapeSequence"),
49]; 50];
50 51
51macro_rules! define_semantic_token_modifiers { 52macro_rules! define_semantic_token_modifiers {
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs
index dee5d7859..efc452347 100644
--- a/crates/rust-analyzer/src/to_proto.rs
+++ b/crates/rust-analyzer/src/to_proto.rs
@@ -323,6 +323,7 @@ fn semantic_token_type_and_modifiers(
323 HighlightTag::UnresolvedReference => semantic_tokens::UNRESOLVED_REFERENCE, 323 HighlightTag::UnresolvedReference => semantic_tokens::UNRESOLVED_REFERENCE,
324 HighlightTag::FormatSpecifier => semantic_tokens::FORMAT_SPECIFIER, 324 HighlightTag::FormatSpecifier => semantic_tokens::FORMAT_SPECIFIER,
325 HighlightTag::Operator => lsp_types::SemanticTokenType::OPERATOR, 325 HighlightTag::Operator => lsp_types::SemanticTokenType::OPERATOR,
326 HighlightTag::Punctuation => semantic_tokens::PUNCTUATION,
326 HighlightTag::EscapeSequence => semantic_tokens::ESCAPE_SEQUENCE, 327 HighlightTag::EscapeSequence => semantic_tokens::ESCAPE_SEQUENCE,
327 }; 328 };
328 329