aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def
diff options
context:
space:
mode:
authorPaul Daniel Faria <[email protected]>2020-06-27 19:42:42 +0100
committerPaul Daniel Faria <[email protected]>2020-08-10 13:44:54 +0100
commit38440d53d8329ac9f3f2013c6e32b3f69b069c72 (patch)
tree9f8bef46fc35c1ad4476e6c91e68c085c39da811 /crates/ra_hir_def
parentc9e670b8754b8262b5071a96c32cbcd22ff968f4 (diff)
Cleanup repr check, fix packed repr check and test
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r--crates/ra_hir_def/src/adt.rs11
1 files changed, 8 insertions, 3 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};
12use tt::{Delimiter, DelimiterKind, Leaf, Subtree, TokenTree}; 12use tt::{Delimiter, DelimiterKind, Leaf, Subtree, TokenTree};
13 13
14use crate::{ 14use 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
70fn repr_from_value(item_tree: &ItemTree, of: AttrOwner) -> Option<ReprKind> { 71fn 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