From 4a4b1f48efeff4ebe578eb92b7bb8338d0181a83 Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Mon, 15 Jun 2020 07:41:13 -0400 Subject: Limit scope of unsafe to & instead of all ref exprs, add test showing missing support for autoref behavior --- crates/ra_ide/src/syntax_highlighting/tests.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'crates/ra_ide/src/syntax_highlighting') diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index f2c078d34..c40805850 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs @@ -299,6 +299,23 @@ struct Packed { c: u32, } +trait DoTheAutoref { + fn calls_autoref(&self); +} + +struct NeedsAlign { + a: u16 +} + +#[repr(packed)] +struct HasAligned { + a: NeedsAlign +} + +impl DoTheAutoref for NeedsAlign { + fn calls_autored(&self) {} +} + fn main() { let x = &5 as *const usize; let u = Union { b: 0 }; @@ -317,6 +334,8 @@ fn main() { let a = &packed.a; let b = &packed.b; let c = &packed.c; + let h = HasAligned{ a: NeedsAlign { a: 1 } }; + h.a.calls_autoref(); } } "# -- cgit v1.2.3