aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/syntax_highlighting/tests.rs
diff options
context:
space:
mode:
authorPaul Daniel Faria <[email protected]>2020-06-04 04:38:25 +0100
committerPaul Daniel Faria <[email protected]>2020-08-10 13:44:54 +0100
commit263f9a7f231a474dd56d02adbcd7c57d079e88fd (patch)
tree125391657a69cb05ac14fadee37e6138dc0daae7 /crates/ra_ide/src/syntax_highlighting/tests.rs
parentf3336509e52187a7a70a8043557a7317872e3a2f (diff)
Add tracking of packed repr, use it to highlight unsafe refs
Taking a reference to a misaligned field on a packed struct is an unsafe operation. Highlight that behavior. Currently, the misaligned part isn't tracked, so this highlight is a bit too aggressive.
Diffstat (limited to 'crates/ra_ide/src/syntax_highlighting/tests.rs')
-rw-r--r--crates/ra_ide/src/syntax_highlighting/tests.rs11
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 09062c38e..f2c078d34 100644
--- a/crates/ra_ide/src/syntax_highlighting/tests.rs
+++ b/crates/ra_ide/src/syntax_highlighting/tests.rs
@@ -292,6 +292,13 @@ struct TypeForStaticMut {
292 292
293static mut global_mut: TypeForStaticMut = TypeForStaticMut { a: 0 }; 293static mut global_mut: TypeForStaticMut = TypeForStaticMut { a: 0 };
294 294
295#[repr(packed)]
296struct Packed {
297 a: u16,
298 b: u8,
299 c: u32,
300}
301
295fn main() { 302fn main() {
296 let x = &5 as *const usize; 303 let x = &5 as *const usize;
297 let u = Union { b: 0 }; 304 let u = Union { b: 0 };
@@ -306,6 +313,10 @@ fn main() {
306 let y = *(x); 313 let y = *(x);
307 let z = -x; 314 let z = -x;
308 let a = global_mut.a; 315 let a = global_mut.a;
316 let packed = Packed { a: 0, b: 0, c: 0 };
317 let a = &packed.a;
318 let b = &packed.b;
319 let c = &packed.c;
309 } 320 }
310} 321}
311"# 322"#