diff options
author | Paul Daniel Faria <[email protected]> | 2020-08-07 02:15:31 +0100 |
---|---|---|
committer | Paul Daniel Faria <[email protected]> | 2020-08-07 02:15:31 +0100 |
commit | a6532905a983c4a3f035fde95ec288dc751f833a (patch) | |
tree | 395e6baa753f40267e639c5be56786c75312043c /crates/ra_ide/src/syntax_highlighting | |
parent | f1d507270c7d915ef0177feca7b6745d95169ac8 (diff) |
Add test for unsafe union field access highlighting
Diffstat (limited to 'crates/ra_ide/src/syntax_highlighting')
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting/tests.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index 2deee404c..a09422da3 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs | |||
@@ -275,6 +275,11 @@ fn test_unsafe_highlighting() { | |||
275 | r#" | 275 | r#" |
276 | unsafe fn unsafe_fn() {} | 276 | unsafe fn unsafe_fn() {} |
277 | 277 | ||
278 | union Union { | ||
279 | a: u32, | ||
280 | b: f32, | ||
281 | } | ||
282 | |||
278 | struct HasUnsafeFn; | 283 | struct HasUnsafeFn; |
279 | 284 | ||
280 | impl HasUnsafeFn { | 285 | impl HasUnsafeFn { |
@@ -283,8 +288,14 @@ impl HasUnsafeFn { | |||
283 | 288 | ||
284 | fn main() { | 289 | fn main() { |
285 | let x = &5 as *const usize; | 290 | let x = &5 as *const usize; |
291 | let u = Union { b: 0 }; | ||
286 | unsafe { | 292 | unsafe { |
287 | unsafe_fn(); | 293 | unsafe_fn(); |
294 | let b = u.b; | ||
295 | match u { | ||
296 | Union { b: 0 } => (), | ||
297 | Union { a } => (), | ||
298 | } | ||
288 | HasUnsafeFn.unsafe_method(); | 299 | HasUnsafeFn.unsafe_method(); |
289 | let y = *(x); | 300 | let y = *(x); |
290 | let z = -x; | 301 | let z = -x; |