diff options
-rw-r--r-- | Cargo.lock | 13 | ||||
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 12 | ||||
-rw-r--r-- | crates/ra_hir_def/src/path.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_db/src/symbol_index.rs | 7 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/extensions.rs | 13 |
5 files changed, 25 insertions, 22 deletions
diff --git a/Cargo.lock b/Cargo.lock index 3f4d9204c..f8d26192d 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -845,14 +845,9 @@ checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" | |||
845 | 845 | ||
846 | [[package]] | 846 | [[package]] |
847 | name = "proc-macro-hack" | 847 | name = "proc-macro-hack" |
848 | version = "0.5.12" | 848 | version = "0.5.14" |
849 | source = "registry+https://github.com/rust-lang/crates.io-index" | 849 | source = "registry+https://github.com/rust-lang/crates.io-index" |
850 | checksum = "f918f2b601f93baa836c1c2945faef682ba5b6d4828ecb45eeb7cc3c71b811b4" | 850 | checksum = "fcfdefadc3d57ca21cf17990a28ef4c0f7c61383a28cb7604cf4a18e6ede1420" |
851 | dependencies = [ | ||
852 | "proc-macro2", | ||
853 | "quote", | ||
854 | "syn", | ||
855 | ] | ||
856 | 851 | ||
857 | [[package]] | 852 | [[package]] |
858 | name = "proc-macro2" | 853 | name = "proc-macro2" |
@@ -1480,9 +1475,9 @@ checksum = "ab16ced94dbd8a46c82fd81e3ed9a8727dac2977ea869d217bcc4ea1f122e81f" | |||
1480 | 1475 | ||
1481 | [[package]] | 1476 | [[package]] |
1482 | name = "syn" | 1477 | name = "syn" |
1483 | version = "1.0.16" | 1478 | version = "1.0.17" |
1484 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1479 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1485 | checksum = "123bd9499cfb380418d509322d7a6d52e5315f064fe4b3ad18a53d6b92c07859" | 1480 | checksum = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03" |
1486 | dependencies = [ | 1481 | dependencies = [ |
1487 | "proc-macro2", | 1482 | "proc-macro2", |
1488 | "quote", | 1483 | "quote", |
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index e8c58ed32..3cf0c66ea 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -453,7 +453,7 @@ impl ExprCollector<'_> { | |||
453 | } | 453 | } |
454 | } | 454 | } |
455 | ast::Expr::MacroCall(e) => { | 455 | ast::Expr::MacroCall(e) => { |
456 | if let Some(name) = is_macro_rules(&e) { | 456 | if let Some(name) = e.is_macro_rules().map(|it| it.as_name()) { |
457 | let mac = MacroDefId { | 457 | let mac = MacroDefId { |
458 | krate: Some(self.expander.module.krate), | 458 | krate: Some(self.expander.module.krate), |
459 | ast_id: Some(self.expander.ast_id(&e)), | 459 | ast_id: Some(self.expander.ast_id(&e)), |
@@ -697,16 +697,6 @@ impl ExprCollector<'_> { | |||
697 | } | 697 | } |
698 | } | 698 | } |
699 | 699 | ||
700 | fn is_macro_rules(m: &ast::MacroCall) -> Option<Name> { | ||
701 | let name = m.path()?.segment()?.name_ref()?.as_name(); | ||
702 | |||
703 | if name == name![macro_rules] { | ||
704 | Some(m.name()?.as_name()) | ||
705 | } else { | ||
706 | None | ||
707 | } | ||
708 | } | ||
709 | |||
710 | impl From<ast::BinOp> for BinaryOp { | 700 | impl From<ast::BinOp> for BinaryOp { |
711 | fn from(ast_op: ast::BinOp) -> Self { | 701 | fn from(ast_op: ast::BinOp) -> Self { |
712 | match ast_op { | 702 | match ast_op { |
diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs index 246032c13..904080341 100644 --- a/crates/ra_hir_def/src/path.rs +++ b/crates/ra_hir_def/src/path.rs | |||
@@ -95,7 +95,7 @@ pub struct Path { | |||
95 | /// Note that paths like `<Type as Trait>::foo` are desugard to `Trait::<Self=Type>::foo`. | 95 | /// Note that paths like `<Type as Trait>::foo` are desugard to `Trait::<Self=Type>::foo`. |
96 | type_anchor: Option<Box<TypeRef>>, | 96 | type_anchor: Option<Box<TypeRef>>, |
97 | mod_path: ModPath, | 97 | mod_path: ModPath, |
98 | /// Invariant: the same len as self.path.segments | 98 | /// Invariant: the same len as `self.mod_path.segments` |
99 | generic_args: Vec<Option<Arc<GenericArgs>>>, | 99 | generic_args: Vec<Option<Arc<GenericArgs>>>, |
100 | } | 100 | } |
101 | 101 | ||
diff --git a/crates/ra_ide_db/src/symbol_index.rs b/crates/ra_ide_db/src/symbol_index.rs index 884359ee3..0f46f93c1 100644 --- a/crates/ra_ide_db/src/symbol_index.rs +++ b/crates/ra_ide_db/src/symbol_index.rs | |||
@@ -362,6 +362,13 @@ fn to_symbol(node: &SyntaxNode) -> Option<(SmolStr, SyntaxNodePtr, TextRange)> { | |||
362 | ast::TypeAliasDef(it) => { decl(it) }, | 362 | ast::TypeAliasDef(it) => { decl(it) }, |
363 | ast::ConstDef(it) => { decl(it) }, | 363 | ast::ConstDef(it) => { decl(it) }, |
364 | ast::StaticDef(it) => { decl(it) }, | 364 | ast::StaticDef(it) => { decl(it) }, |
365 | ast::MacroCall(it) => { | ||
366 | if it.is_macro_rules().is_some() { | ||
367 | decl(it) | ||
368 | } else { | ||
369 | None | ||
370 | } | ||
371 | }, | ||
365 | _ => None, | 372 | _ => None, |
366 | } | 373 | } |
367 | } | 374 | } |
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs index c3ae8f90e..392731dac 100644 --- a/crates/ra_syntax/src/ast/extensions.rs +++ b/crates/ra_syntax/src/ast/extensions.rs | |||
@@ -4,7 +4,7 @@ | |||
4 | use itertools::Itertools; | 4 | use itertools::Itertools; |
5 | 5 | ||
6 | use crate::{ | 6 | use crate::{ |
7 | ast::{self, child_opt, children, AstNode, AttrInput, SyntaxNode}, | 7 | ast::{self, child_opt, children, AstNode, AttrInput, NameOwner, SyntaxNode}, |
8 | SmolStr, SyntaxElement, | 8 | SmolStr, SyntaxElement, |
9 | SyntaxKind::*, | 9 | SyntaxKind::*, |
10 | SyntaxToken, T, | 10 | SyntaxToken, T, |
@@ -514,3 +514,14 @@ impl ast::Visibility { | |||
514 | self.syntax().children_with_tokens().any(|it| it.kind() == T![super]) | 514 | self.syntax().children_with_tokens().any(|it| it.kind() == T![super]) |
515 | } | 515 | } |
516 | } | 516 | } |
517 | |||
518 | impl ast::MacroCall { | ||
519 | pub fn is_macro_rules(&self) -> Option<ast::Name> { | ||
520 | let name_ref = self.path()?.segment()?.name_ref()?; | ||
521 | if name_ref.text() == "macro_rules" { | ||
522 | self.name() | ||
523 | } else { | ||
524 | None | ||
525 | } | ||
526 | } | ||
527 | } | ||