diff options
author | Paul Daniel Faria <[email protected]> | 2020-06-27 19:42:42 +0100 |
---|---|---|
committer | Paul Daniel Faria <[email protected]> | 2020-08-10 13:44:54 +0100 |
commit | 38440d53d8329ac9f3f2013c6e32b3f69b069c72 (patch) | |
tree | 9f8bef46fc35c1ad4476e6c91e68c085c39da811 /crates/ra_ide | |
parent | c9e670b8754b8262b5071a96c32cbcd22ff968f4 (diff) |
Cleanup repr check, fix packed repr check and test
Diffstat (limited to 'crates/ra_ide')
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting/tests.rs | 14 |
2 files changed, 7 insertions, 11 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 9e8419c5f..a4a7aa228 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs | |||
@@ -565,7 +565,7 @@ fn highlight_element( | |||
565 | _ => h, | 565 | _ => h, |
566 | } | 566 | } |
567 | } | 567 | } |
568 | T![&] => { | 568 | REF_EXPR => { |
569 | let ref_expr = element.into_node().and_then(ast::RefExpr::cast)?; | 569 | let ref_expr = element.into_node().and_then(ast::RefExpr::cast)?; |
570 | let expr = ref_expr.expr()?; | 570 | let expr = ref_expr.expr()?; |
571 | let field_expr = match expr { | 571 | let field_expr = match expr { |
@@ -582,7 +582,7 @@ fn highlight_element( | |||
582 | // FIXME This needs layout computation to be correct. It will highlight | 582 | // FIXME This needs layout computation to be correct. It will highlight |
583 | // more than it should with the current implementation. | 583 | // more than it should with the current implementation. |
584 | 584 | ||
585 | Highlight::new(HighlightTag::Operator) | HighlightModifier::Unsafe | 585 | HighlightTag::Operator | HighlightModifier::Unsafe |
586 | } | 586 | } |
587 | p if p.is_punct() => match p { | 587 | p if p.is_punct() => match p { |
588 | T![::] | T![->] | T![=>] | T![&] | T![..] | T![=] | T![@] => { | 588 | T![::] | T![->] | T![=>] | T![&] | T![..] | T![=] | T![@] => { |
diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index c40805850..a7f5ad862 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs | |||
@@ -295,8 +295,6 @@ static mut global_mut: TypeForStaticMut = TypeForStaticMut { a: 0 }; | |||
295 | #[repr(packed)] | 295 | #[repr(packed)] |
296 | struct Packed { | 296 | struct Packed { |
297 | a: u16, | 297 | a: u16, |
298 | b: u8, | ||
299 | c: u32, | ||
300 | } | 298 | } |
301 | 299 | ||
302 | trait DoTheAutoref { | 300 | trait DoTheAutoref { |
@@ -313,11 +311,11 @@ struct HasAligned { | |||
313 | } | 311 | } |
314 | 312 | ||
315 | impl DoTheAutoref for NeedsAlign { | 313 | impl DoTheAutoref for NeedsAlign { |
316 | fn calls_autored(&self) {} | 314 | fn calls_autoref(&self) {} |
317 | } | 315 | } |
318 | 316 | ||
319 | fn main() { | 317 | fn main() { |
320 | let x = &5 as *const usize; | 318 | let x = &5 as *const _ as *const usize; |
321 | let u = Union { b: 0 }; | 319 | let u = Union { b: 0 }; |
322 | unsafe { | 320 | unsafe { |
323 | unsafe_fn(); | 321 | unsafe_fn(); |
@@ -327,13 +325,11 @@ fn main() { | |||
327 | Union { a } => (), | 325 | Union { a } => (), |
328 | } | 326 | } |
329 | HasUnsafeFn.unsafe_method(); | 327 | HasUnsafeFn.unsafe_method(); |
330 | let y = *(x); | 328 | let _y = *(x); |
331 | let z = -x; | 329 | let z = -x; |
332 | let a = global_mut.a; | 330 | let a = global_mut.a; |
333 | let packed = Packed { a: 0, b: 0, c: 0 }; | 331 | let packed = Packed { a: 0 }; |
334 | let a = &packed.a; | 332 | let _a = &packed.a; |
335 | let b = &packed.b; | ||
336 | let c = &packed.c; | ||
337 | let h = HasAligned{ a: NeedsAlign { a: 1 } }; | 333 | let h = HasAligned{ a: NeedsAlign { a: 1 } }; |
338 | h.a.calls_autoref(); | 334 | h.a.calls_autoref(); |
339 | } | 335 | } |