From 6be528da0de45606498a9755ad2c54f3bc41dc6c Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Thu, 6 Aug 2020 19:58:37 -0400 Subject: Add test for accessing static mut --- crates/ra_ide/test_data/highlight_unsafe.html | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'crates/ra_ide/test_data/highlight_unsafe.html') diff --git a/crates/ra_ide/test_data/highlight_unsafe.html b/crates/ra_ide/test_data/highlight_unsafe.html index b81b6f1c3..7c519ef5e 100644 --- a/crates/ra_ide/test_data/highlight_unsafe.html +++ b/crates/ra_ide/test_data/highlight_unsafe.html @@ -43,6 +43,12 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd unsafe fn unsafe_method(&self) {} } +struct TypeForStaticMut { + a: u8 +} + +static mut global_mut: TypeForStaticMut = TypeForStaticMut { a: 0 }; + fn main() { let x = &5 as *const usize; unsafe { @@ -50,5 +56,6 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd HasUnsafeFn.unsafe_method(); let y = *(x); let z = -x; + let a = global_mut.a; } } \ No newline at end of file -- cgit v1.2.3 From 8e657f663d519771ac8ffcd4b52ded8cb381b918 Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Thu, 6 Aug 2020 20:07:42 -0400 Subject: Mark static mutable names as unsafe --- crates/ra_ide/test_data/highlight_unsafe.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_ide/test_data/highlight_unsafe.html') diff --git a/crates/ra_ide/test_data/highlight_unsafe.html b/crates/ra_ide/test_data/highlight_unsafe.html index 7c519ef5e..87d8c1556 100644 --- a/crates/ra_ide/test_data/highlight_unsafe.html +++ b/crates/ra_ide/test_data/highlight_unsafe.html @@ -47,7 +47,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd a: u8 } -static mut global_mut: TypeForStaticMut = TypeForStaticMut { a: 0 }; +static mut global_mut: TypeForStaticMut = TypeForStaticMut { a: 0 }; fn main() { let x = &5 as *const usize; @@ -56,6 +56,6 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd HasUnsafeFn.unsafe_method(); let y = *(x); let z = -x; - let a = global_mut.a; + let a = global_mut.a; } } \ No newline at end of file -- cgit v1.2.3 From a6532905a983c4a3f035fde95ec288dc751f833a Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Thu, 6 Aug 2020 21:15:31 -0400 Subject: Add test for unsafe union field access highlighting --- crates/ra_ide/test_data/highlight_unsafe.html | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'crates/ra_ide/test_data/highlight_unsafe.html') diff --git a/crates/ra_ide/test_data/highlight_unsafe.html b/crates/ra_ide/test_data/highlight_unsafe.html index b81b6f1c3..39582b5bb 100644 --- a/crates/ra_ide/test_data/highlight_unsafe.html +++ b/crates/ra_ide/test_data/highlight_unsafe.html @@ -37,6 +37,11 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
unsafe fn unsafe_fn() {}
 
+union Union {
+    a: u32,
+    b: f32,
+}
+
 struct HasUnsafeFn;
 
 impl HasUnsafeFn {
@@ -45,8 +50,14 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 
 fn main() {
     let x = &5 as *const usize;
+    let u = Union { b: 0 };
     unsafe {
         unsafe_fn();
+        let b = u.b;
+        match u {
+            Union { b: 0 } => (),
+            Union { a } => (),
+        }
         HasUnsafeFn.unsafe_method();
         let y = *(x);
         let z = -x;
-- 
cgit v1.2.3


From 3bf033e54814919f2214ca4e9b73cebc5ba7d86d Mon Sep 17 00:00:00 2001
From: Paul Daniel Faria 
Date: Fri, 7 Aug 2020 09:24:20 -0400
Subject: Add support for unions in inference and lowering

---
 crates/ra_ide/test_data/highlight_unsafe.html | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

(limited to 'crates/ra_ide/test_data/highlight_unsafe.html')

diff --git a/crates/ra_ide/test_data/highlight_unsafe.html b/crates/ra_ide/test_data/highlight_unsafe.html
index 39582b5bb..de70363da 100644
--- a/crates/ra_ide/test_data/highlight_unsafe.html
+++ b/crates/ra_ide/test_data/highlight_unsafe.html
@@ -50,13 +50,13 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 
 fn main() {
     let x = &5 as *const usize;
-    let u = Union { b: 0 };
+    let u = Union { b: 0 };
     unsafe {
         unsafe_fn();
-        let b = u.b;
+        let b = u.b;
         match u {
-            Union { b: 0 } => (),
-            Union { a } => (),
+            Union { b: 0 } => (),
+            Union { a } => (),
         }
         HasUnsafeFn.unsafe_method();
         let y = *(x);
-- 
cgit v1.2.3


From be935b2b56dcbda5a5918d8c600552b0adbb3a96 Mon Sep 17 00:00:00 2001
From: Paul Daniel Faria 
Date: Fri, 7 Aug 2020 09:33:40 -0400
Subject: Apply unsafe semantic highlighting to union field access

---
 crates/ra_ide/test_data/highlight_unsafe.html | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'crates/ra_ide/test_data/highlight_unsafe.html')

diff --git a/crates/ra_ide/test_data/highlight_unsafe.html b/crates/ra_ide/test_data/highlight_unsafe.html
index de70363da..cfc872832 100644
--- a/crates/ra_ide/test_data/highlight_unsafe.html
+++ b/crates/ra_ide/test_data/highlight_unsafe.html
@@ -53,10 +53,10 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
     let u = Union { b: 0 };
     unsafe {
         unsafe_fn();
-        let b = u.b;
+        let b = u.b;
         match u {
-            Union { b: 0 } => (),
-            Union { a } => (),
+            Union { b: 0 } => (),
+            Union { a } => (),
         }
         HasUnsafeFn.unsafe_method();
         let y = *(x);
-- 
cgit v1.2.3