aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/syntax_highlighting/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src/syntax_highlighting/tests.rs')
-rw-r--r--crates/ra_ide/src/syntax_highlighting/tests.rs31
1 files changed, 16 insertions, 15 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs
index a7f5ad862..a8087635a 100644
--- a/crates/ra_ide/src/syntax_highlighting/tests.rs
+++ b/crates/ra_ide/src/syntax_highlighting/tests.rs
@@ -301,16 +301,7 @@ trait DoTheAutoref {
301 fn calls_autoref(&self); 301 fn calls_autoref(&self);
302} 302}
303 303
304struct NeedsAlign { 304impl DoTheAutoref for u16 {
305 a: u16
306}
307
308#[repr(packed)]
309struct HasAligned {
310 a: NeedsAlign
311}
312
313impl DoTheAutoref for NeedsAlign {
314 fn calls_autoref(&self) {} 305 fn calls_autoref(&self) {}
315} 306}
316 307
@@ -318,6 +309,7 @@ fn main() {
318 let x = &5 as *const _ as *const usize; 309 let x = &5 as *const _ as *const usize;
319 let u = Union { b: 0 }; 310 let u = Union { b: 0 };
320 unsafe { 311 unsafe {
312 // unsafe fn and method calls
321 unsafe_fn(); 313 unsafe_fn();
322 let b = u.b; 314 let b = u.b;
323 match u { 315 match u {
@@ -325,13 +317,22 @@ fn main() {
325 Union { a } => (), 317 Union { a } => (),
326 } 318 }
327 HasUnsafeFn.unsafe_method(); 319 HasUnsafeFn.unsafe_method();
328 let _y = *(x); 320
329 let z = -x; 321 // unsafe deref
322 let y = *x;
323
324 // unsafe access to a static mut
330 let a = global_mut.a; 325 let a = global_mut.a;
326
327 // unsafe ref of packed fields
331 let packed = Packed { a: 0 }; 328 let packed = Packed { a: 0 };
332 let _a = &packed.a; 329 let a = &packed.a;
333 let h = HasAligned{ a: NeedsAlign { a: 1 } }; 330 let ref a = packed.a;
334 h.a.calls_autoref(); 331 let Packed { ref a } = packed;
332 let Packed { a: ref _a } = packed;
333
334 // unsafe auto ref of packed field
335 packed.a.calls_autoref();
335 } 336 }
336} 337}
337"# 338"#