diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-10-10 16:05:42 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-10-10 16:05:42 +0100 |
commit | ceb6cddb8b63dc283ef7a5fd2abf9bf7662c68fb (patch) | |
tree | de420fe8d180aaaa6fe0dac39d4ffdd848a1bb93 /crates/ra_hir/src/attr.rs | |
parent | 19cc85bf0af04167cd75dcb5fdc40bcdfe51f3e0 (diff) | |
parent | 29e83988be5be6d2bc4d869f00f4bf931b1500fa (diff) |
Merge #1986
1986: don't special case module attrs r=matklad a=matklad
bors r+
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/attr.rs')
-rw-r--r-- | crates/ra_hir/src/attr.rs | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/crates/ra_hir/src/attr.rs b/crates/ra_hir/src/attr.rs index f67e80bfd..bd159a566 100644 --- a/crates/ra_hir/src/attr.rs +++ b/crates/ra_hir/src/attr.rs | |||
@@ -63,14 +63,24 @@ impl Attr { | |||
63 | self.path.as_ident().map_or(false, |s| s.to_string() == name) | 63 | self.path.as_ident().map_or(false, |s| s.to_string() == name) |
64 | } | 64 | } |
65 | 65 | ||
66 | // FIXME: handle cfg_attr :-) | ||
66 | pub(crate) fn as_cfg(&self) -> Option<&Subtree> { | 67 | pub(crate) fn as_cfg(&self) -> Option<&Subtree> { |
67 | if self.is_simple_atom("cfg") { | 68 | if !self.is_simple_atom("cfg") { |
68 | match &self.input { | 69 | return None; |
69 | Some(AttrInput::TokenTree(subtree)) => Some(subtree), | 70 | } |
70 | _ => None, | 71 | match &self.input { |
71 | } | 72 | Some(AttrInput::TokenTree(subtree)) => Some(subtree), |
72 | } else { | 73 | _ => None, |
73 | None | 74 | } |
75 | } | ||
76 | |||
77 | pub(crate) fn as_path(&self) -> Option<&SmolStr> { | ||
78 | if !self.is_simple_atom("path") { | ||
79 | return None; | ||
80 | } | ||
81 | match &self.input { | ||
82 | Some(AttrInput::Literal(it)) => Some(it), | ||
83 | _ => None, | ||
74 | } | 84 | } |
75 | } | 85 | } |
76 | 86 | ||