mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-28 05:53:45 +00:00
fix panic with reference in macro
This commit is contained in:
parent
ae6e737724
commit
bd26403130
1 changed files with 8 additions and 0 deletions
|
@ -412,6 +412,14 @@ fn reference_to_node(
|
||||||
) -> Option<(ast::PathSegment, SyntaxNode, hir::Module)> {
|
) -> Option<(ast::PathSegment, SyntaxNode, hir::Module)> {
|
||||||
let segment =
|
let segment =
|
||||||
reference.name.as_name_ref()?.syntax().parent().and_then(ast::PathSegment::cast)?;
|
reference.name.as_name_ref()?.syntax().parent().and_then(ast::PathSegment::cast)?;
|
||||||
|
|
||||||
|
// filter out the reference in marco
|
||||||
|
let s_range = segment.syntax().text_range();
|
||||||
|
let origin_range = sema.original_range(segment.syntax()).range;
|
||||||
|
if s_range != origin_range {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
let parent = segment.parent_path().syntax().parent()?;
|
let parent = segment.parent_path().syntax().parent()?;
|
||||||
let expr_or_pat = match_ast! {
|
let expr_or_pat = match_ast! {
|
||||||
match parent {
|
match parent {
|
||||||
|
|
Loading…
Reference in a new issue