aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide/src')
-rw-r--r--crates/ide/src/syntax_highlighting/test_data/highlighting.html18
-rw-r--r--crates/ide/src/syntax_highlighting/tests.rs38
2 files changed, 55 insertions, 1 deletions
diff --git a/crates/ide/src/syntax_highlighting/test_data/highlighting.html b/crates/ide/src/syntax_highlighting/test_data/highlighting.html
index 878431b56..e65dd3ff9 100644
--- a/crates/ide/src/syntax_highlighting/test_data/highlighting.html
+++ b/crates/ide/src/syntax_highlighting/test_data/highlighting.html
@@ -248,4 +248,20 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
248<span class="brace">}</span> 248<span class="brace">}</span>
249 249
250<span class="keyword unsafe">unsafe</span> <span class="keyword">trait</span> <span class="trait declaration unsafe">Dangerous</span> <span class="brace">{</span><span class="brace">}</span> 250<span class="keyword unsafe">unsafe</span> <span class="keyword">trait</span> <span class="trait declaration unsafe">Dangerous</span> <span class="brace">{</span><span class="brace">}</span>
251<span class="keyword">impl</span> <span class="trait unsafe">Dangerous</span> <span class="keyword">for</span> <span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span></code></pre> \ No newline at end of file 251<span class="keyword">impl</span> <span class="trait unsafe">Dangerous</span> <span class="keyword">for</span> <span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span>
252
253<span class="keyword">fn</span> <span class="function declaration">use_foo_items</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span>
254 <span class="keyword">let</span> <span class="variable declaration">bob</span> <span class="operator">=</span> <span class="module foreign">foo</span><span class="operator">::</span><span class="struct foreign">Person</span> <span class="brace">{</span>
255 <span class="field foreign">name</span><span class="colon">:</span> <span class="string_literal">"Bob"</span><span class="comma">,</span>
256 <span class="field foreign">age</span><span class="colon">:</span> <span class="module foreign">foo</span><span class="operator">::</span><span class="module foreign">consts</span><span class="operator">::</span><span class="constant foreign">NUMBER</span><span class="comma">,</span>
257 <span class="brace">}</span><span class="semicolon">;</span>
258
259 <span class="keyword">let</span> <span class="variable declaration">control_flow</span> <span class="operator">=</span> <span class="module foreign">foo</span><span class="operator">::</span><span class="function foreign">identity</span><span class="parenthesis">(</span><span class="module foreign">foo</span><span class="operator">::</span><span class="enum foreign">ControlFlow</span><span class="operator">::</span><span class="enum_variant foreign">Continue</span><span class="parenthesis">)</span><span class="semicolon">;</span>
260
261 <span class="keyword control">if</span> <span class="keyword">let</span> <span class="module foreign">foo</span><span class="operator">::</span><span class="enum foreign">ControlFlow</span><span class="operator">::</span><span class="enum_variant foreign">Die</span> <span class="operator">=</span> <span class="variable">control_flow</span> <span class="brace">{</span>
262 foo::<span class="macro">die!</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span>
263 <span class="brace">}</span>
264<span class="brace">}</span>
265
266
267</code></pre> \ No newline at end of file
diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs
index 9ce26e930..be4447ebb 100644
--- a/crates/ide/src/syntax_highlighting/tests.rs
+++ b/crates/ide/src/syntax_highlighting/tests.rs
@@ -10,6 +10,7 @@ use crate::{fixture, FileRange, HlTag, TextRange};
10fn test_highlighting() { 10fn test_highlighting() {
11 check_highlighting( 11 check_highlighting(
12 r#" 12 r#"
13//- /main.rs crate:main deps:foo
13use inner::{self as inner_mod}; 14use inner::{self as inner_mod};
14mod inner {} 15mod inner {}
15 16
@@ -222,6 +223,43 @@ async fn async_main() {
222 223
223unsafe trait Dangerous {} 224unsafe trait Dangerous {}
224impl Dangerous for () {} 225impl Dangerous for () {}
226
227fn use_foo_items() {
228 let bob = foo::Person {
229 name: "Bob",
230 age: foo::consts::NUMBER,
231 };
232
233 let control_flow = foo::identity(foo::ControlFlow::Continue);
234
235 if let foo::ControlFlow::Die = control_flow {
236 foo::die!();
237 }
238}
239
240
241//- /foo.rs crate:foo
242pub struct Person {
243 pub name: &'static str,
244 pub age: u8,
245}
246
247pub enum ControlFlow {
248 Continue,
249 Die,
250}
251
252pub fn identity<T>(x: T) -> T { x }
253
254pub mod consts {
255 pub const NUMBER: i64 = 92;
256}
257
258macro_rules! die {
259 () => {
260 panic!();
261 };
262}
225"# 263"#
226 .trim(), 264 .trim(),
227 expect_file!["./test_data/highlighting.html"], 265 expect_file!["./test_data/highlighting.html"],