diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-09-30 09:46:08 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-09-30 09:46:08 +0100 |
commit | 733f1d8b709788225bd06f8c0aee1819db92620b (patch) | |
tree | d17395e4c3f7965c5cf9bdd50ef940e52eef1155 /crates/ra_hir/src | |
parent | c913b48928107710d6ec87a455b1ae6891297c2b (diff) | |
parent | f7e12559cb26b59a9a2ecee4deecaf6fe9100d16 (diff) |
Merge #1934
1934: Parse Path and AttrInput in Attr r=matklad a=uHOOCCOOHu
[Syntax reference](https://doc.rust-lang.org/reference/attributes.html#attributes)
Co-authored-by: uHOOCCOOHu <[email protected]>
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/lang_item.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/nameres/raw.rs | 5 |
2 files changed, 3 insertions, 4 deletions
diff --git a/crates/ra_hir/src/lang_item.rs b/crates/ra_hir/src/lang_item.rs index bcce314d8..dbba433fe 100644 --- a/crates/ra_hir/src/lang_item.rs +++ b/crates/ra_hir/src/lang_item.rs | |||
@@ -151,7 +151,7 @@ impl LangItems { | |||
151 | 151 | ||
152 | fn lang_item_name<T: AttrsOwner>(node: &T) -> Option<SmolStr> { | 152 | fn lang_item_name<T: AttrsOwner>(node: &T) -> Option<SmolStr> { |
153 | node.attrs() | 153 | node.attrs() |
154 | .filter_map(|a| a.as_key_value()) | 154 | .filter_map(|a| a.as_simple_key_value()) |
155 | .filter(|(key, _)| key == "lang") | 155 | .filter(|(key, _)| key == "lang") |
156 | .map(|(_, val)| val) | 156 | .map(|(_, val)| val) |
157 | .nth(0) | 157 | .nth(0) |
diff --git a/crates/ra_hir/src/nameres/raw.rs b/crates/ra_hir/src/nameres/raw.rs index c494b95b0..0e27dd2db 100644 --- a/crates/ra_hir/src/nameres/raw.rs +++ b/crates/ra_hir/src/nameres/raw.rs | |||
@@ -353,8 +353,7 @@ impl<DB: AstDatabase> RawItemsCollector<&DB> { | |||
353 | 353 | ||
354 | let name = m.name().map(|it| it.as_name()); | 354 | let name = m.name().map(|it| it.as_name()); |
355 | let ast_id = self.source_ast_id_map.ast_id(&m); | 355 | let ast_id = self.source_ast_id_map.ast_id(&m); |
356 | let export = m.has_atom_attr("macro_export") | 356 | let export = m.attrs().filter_map(|x| x.simple_name()).any(|name| name == "macro_export"); |
357 | || m.attrs().filter_map(|x| x.as_call()).any(|(name, _)| name == "macro_export"); | ||
358 | 357 | ||
359 | let m = self.raw_items.macros.alloc(MacroData { ast_id, path, name, export }); | 358 | let m = self.raw_items.macros.alloc(MacroData { ast_id, path, name, export }); |
360 | self.push_item(current_module, RawItem::Macro(m)); | 359 | self.push_item(current_module, RawItem::Macro(m)); |
@@ -385,7 +384,7 @@ impl<DB: AstDatabase> RawItemsCollector<&DB> { | |||
385 | 384 | ||
386 | fn extract_mod_path_attribute(module: &ast::Module) -> Option<SmolStr> { | 385 | fn extract_mod_path_attribute(module: &ast::Module) -> Option<SmolStr> { |
387 | module.attrs().into_iter().find_map(|attr| { | 386 | module.attrs().into_iter().find_map(|attr| { |
388 | attr.as_key_value().and_then(|(name, value)| { | 387 | attr.as_simple_key_value().and_then(|(name, value)| { |
389 | let is_path = name == "path"; | 388 | let is_path = name == "path"; |
390 | if is_path { | 389 | if is_path { |
391 | Some(value) | 390 | Some(value) |