aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2020-10-26 21:27:28 +0000
committerLukas Wirth <[email protected]>2020-10-26 21:27:30 +0000
commit269e67312d30e8e5a5c38cec3f12c52ba0d6d9b6 (patch)
treea5ef81d58d5862984274f699fc72e0228f6ada46
parentdb2c379baeeb2f676540368f89d77390c967541f (diff)
Highlight never type as BuiltinType
-rw-r--r--crates/ide/src/syntax_highlighting.rs3
-rw-r--r--crates/ide/src/syntax_highlighting/test_data/highlighting.html6
-rw-r--r--crates/ide/src/syntax_highlighting/tests.rs6
3 files changed, 15 insertions, 0 deletions
diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs
index 9f864179e..624a63075 100644
--- a/crates/ide/src/syntax_highlighting.rs
+++ b/crates/ide/src/syntax_highlighting.rs
@@ -562,6 +562,9 @@ fn highlight_element(
562 T![!] if element.parent().and_then(ast::MacroCall::cast).is_some() => { 562 T![!] if element.parent().and_then(ast::MacroCall::cast).is_some() => {
563 HighlightTag::Macro.into() 563 HighlightTag::Macro.into()
564 } 564 }
565 T![!] if element.parent().and_then(ast::NeverType::cast).is_some() => {
566 HighlightTag::BuiltinType.into()
567 }
565 T![*] if element.parent().and_then(ast::PtrType::cast).is_some() => { 568 T![*] if element.parent().and_then(ast::PtrType::cast).is_some() => {
566 HighlightTag::Keyword.into() 569 HighlightTag::Keyword.into()
567 } 570 }
diff --git a/crates/ide/src/syntax_highlighting/test_data/highlighting.html b/crates/ide/src/syntax_highlighting/test_data/highlighting.html
index c6b4f5a00..b0e547d57 100644
--- a/crates/ide/src/syntax_highlighting/test_data/highlighting.html
+++ b/crates/ide/src/syntax_highlighting/test_data/highlighting.html
@@ -110,6 +110,10 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
110 <span class="function">foo</span><span class="operator">::</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> 110 <span class="function">foo</span><span class="operator">::</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>
111<span class="punctuation">}</span> 111<span class="punctuation">}</span>
112 112
113<span class="keyword">fn</span> <span class="function declaration">never</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="operator">-&gt;</span> <span class="builtin_type">!</span> <span class="punctuation">{</span>
114 <span class="keyword control">loop</span> <span class="punctuation">{</span><span class="punctuation">}</span>
115<span class="punctuation">}</span>
116
113<span class="keyword">use</span> <span class="module">ops</span><span class="operator">::</span><span class="trait">Fn</span><span class="punctuation">;</span> 117<span class="keyword">use</span> <span class="module">ops</span><span class="operator">::</span><span class="trait">Fn</span><span class="punctuation">;</span>
114<span class="keyword">fn</span> <span class="function declaration">baz</span><span class="punctuation">&lt;</span><span class="type_param declaration">F</span><span class="punctuation">:</span> <span class="trait">Fn</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="operator">-&gt;</span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">&gt;</span><span class="punctuation">(</span><span class="value_param declaration callable">f</span><span class="punctuation">:</span> <span class="type_param">F</span><span class="punctuation">)</span> <span class="punctuation">{</span> 118<span class="keyword">fn</span> <span class="function declaration">baz</span><span class="punctuation">&lt;</span><span class="type_param declaration">F</span><span class="punctuation">:</span> <span class="trait">Fn</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="operator">-&gt;</span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">&gt;</span><span class="punctuation">(</span><span class="value_param declaration callable">f</span><span class="punctuation">:</span> <span class="type_param">F</span><span class="punctuation">)</span> <span class="punctuation">{</span>
115 <span class="value_param callable">f</span><span class="punctuation">(</span><span class="punctuation">)</span> 119 <span class="value_param callable">f</span><span class="punctuation">(</span><span class="punctuation">)</span>
@@ -179,6 +183,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
179 183
180 <span class="keyword">let</span> <span class="variable declaration">baz</span> <span class="operator">=</span> <span class="numeric_literal">-</span><span class="numeric_literal">42</span><span class="punctuation">;</span> 184 <span class="keyword">let</span> <span class="variable declaration">baz</span> <span class="operator">=</span> <span class="numeric_literal">-</span><span class="numeric_literal">42</span><span class="punctuation">;</span>
181 <span class="keyword">let</span> <span class="variable declaration">baz</span> <span class="operator">=</span> <span class="operator">-</span><span class="variable">baz</span><span class="punctuation">;</span> 185 <span class="keyword">let</span> <span class="variable declaration">baz</span> <span class="operator">=</span> <span class="operator">-</span><span class="variable">baz</span><span class="punctuation">;</span>
186
187 <span class="keyword">let</span> <span class="punctuation">_</span> <span class="operator">=</span> <span class="operator">!</span><span class="bool_literal">true</span><span class="punctuation">;</span>
182<span class="punctuation">}</span> 188<span class="punctuation">}</span>
183 189
184<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> 190<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>
diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs
index dd43f9dd9..f13cf3ef3 100644
--- a/crates/ide/src/syntax_highlighting/tests.rs
+++ b/crates/ide/src/syntax_highlighting/tests.rs
@@ -84,6 +84,10 @@ fn foo<'a, T>() -> T {
84 foo::<'a, i32>() 84 foo::<'a, i32>()
85} 85}
86 86
87fn never() -> ! {
88 loop {}
89}
90
87use ops::Fn; 91use ops::Fn;
88fn baz<F: Fn() -> ()>(f: F) { 92fn baz<F: Fn() -> ()>(f: F) {
89 f() 93 f()
@@ -153,6 +157,8 @@ fn main() {
153 157
154 let baz = -42; 158 let baz = -42;
155 let baz = -baz; 159 let baz = -baz;
160
161 let _ = !true;
156} 162}
157 163
158enum Option<T> { 164enum Option<T> {