diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir_def/src/adt.rs | 11 | ||||
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting/tests.rs | 14 |
3 files changed, 15 insertions, 14 deletions
diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index 6d59c8642..4ba694480 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs | |||
@@ -12,10 +12,11 @@ use ra_syntax::ast::{self, NameOwner, VisibilityOwner}; | |||
12 | use tt::{Delimiter, DelimiterKind, Leaf, Subtree, TokenTree}; | 12 | use tt::{Delimiter, DelimiterKind, Leaf, Subtree, TokenTree}; |
13 | 13 | ||
14 | use crate::{ | 14 | use crate::{ |
15 | attr::AttrInput, | 15 | attr::{Attr, AttrInput}, |
16 | body::{CfgExpander, LowerCtx}, | 16 | body::{CfgExpander, LowerCtx}, |
17 | db::DefDatabase, | 17 | db::DefDatabase, |
18 | item_tree::{AttrOwner, Field, Fields, ItemTree, ModItem}, | 18 | item_tree::{AttrOwner, Field, Fields, ItemTree, ModItem}, |
19 | path::{ModPath, PathKind}, | ||
19 | src::HasChildSource, | 20 | src::HasChildSource, |
20 | src::HasSource, | 21 | src::HasSource, |
21 | trace::Trace, | 22 | trace::Trace, |
@@ -69,8 +70,12 @@ pub enum ReprKind { | |||
69 | 70 | ||
70 | fn repr_from_value(item_tree: &ItemTree, of: AttrOwner) -> Option<ReprKind> { | 71 | fn repr_from_value(item_tree: &ItemTree, of: AttrOwner) -> Option<ReprKind> { |
71 | item_tree.attrs(of).iter().find_map(|a| { | 72 | item_tree.attrs(of).iter().find_map(|a| { |
72 | if a.path.segments[0].to_string() == "repr" { | 73 | if let Attr { |
73 | if let Some(AttrInput::TokenTree(subtree)) = &a.input { | 74 | path: ModPath { kind: PathKind::Plain, segments }, |
75 | input: Some(AttrInput::TokenTree(subtree)), | ||
76 | } = a | ||
77 | { | ||
78 | if segments.len() == 1 && segments[0].to_string() == "repr" { | ||
74 | parse_repr_tt(subtree) | 79 | parse_repr_tt(subtree) |
75 | } else { | 80 | } else { |
76 | None | 81 | None |
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 | } |