aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/syntax_highlighting
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-08-08 17:45:37 +0100
committerGitHub <[email protected]>2020-08-08 17:45:37 +0100
commit8a57afe5a4bfab40072a83f7dc4ca560bf860919 (patch)
tree167d3717945c94c7523bbda5018239ed3a1c5fca /crates/ra_ide/src/syntax_highlighting
parenteed05a95b47c00bf6ce06e156716cd0648a88fb2 (diff)
parentbe935b2b56dcbda5a5918d8c600552b0adbb3a96 (diff)
Merge #5684
5684: Semantic highlighting for unsafe union field access r=jonas-schievink a=Nashenas88 This change adds support for unions in inference and lowering, then extends on that to add the unsafe semantic modifier on field access only. The `is_possibly_unsafe` function in `syntax_highlighting.rs` could be extended to support fns and static muts so that their definitions are not highlighted as unsafe, but only their usage. Also, each commit of this PR updates the tests. By reviewing the files by commit, it's easy to see how the changes in the code affected the tests. Co-authored-by: Paul Daniel Faria <[email protected]>
Diffstat (limited to 'crates/ra_ide/src/syntax_highlighting')
-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 b9b358022..730efff0d 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#"
276unsafe fn unsafe_fn() {} 276unsafe fn unsafe_fn() {}
277 277
278union Union {
279 a: u32,
280 b: f32,
281}
282
278struct HasUnsafeFn; 283struct HasUnsafeFn;
279 284
280impl HasUnsafeFn { 285impl HasUnsafeFn {
@@ -289,8 +294,14 @@ static mut global_mut: TypeForStaticMut = TypeForStaticMut { a: 0 };
289 294
290fn main() { 295fn main() {
291 let x = &5 as *const usize; 296 let x = &5 as *const usize;
297 let u = Union { b: 0 };
292 unsafe { 298 unsafe {
293 unsafe_fn(); 299 unsafe_fn();
300 let b = u.b;
301 match u {
302 Union { b: 0 } => (),
303 Union { a } => (),
304 }
294 HasUnsafeFn.unsafe_method(); 305 HasUnsafeFn.unsafe_method();
295 let y = *(x); 306 let y = *(x);
296 let z = -x; 307 let z = -x;