diff options
author | Aleksey Kladov <[email protected]> | 2021-06-13 15:51:44 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-06-13 15:51:44 +0100 |
commit | 1e4aaee7bbc1d56698e70158aa35f578422623d9 (patch) | |
tree | 0d7a63a204895fb6c9f3425bb6fce9d6a46b1de5 /crates/hir/src/lib.rs | |
parent | f85e383b94376d55bb5ee6be375ef3dc0006590f (diff) |
internal: refactor unresolved proc macro diagnostic
Diffstat (limited to 'crates/hir/src/lib.rs')
-rw-r--r-- | crates/hir/src/lib.rs | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index d59b52b25..87a3db946 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs | |||
@@ -518,10 +518,10 @@ impl Module { | |||
518 | 518 | ||
519 | DefDiagnosticKind::UnresolvedProcMacro { ast } => { | 519 | DefDiagnosticKind::UnresolvedProcMacro { ast } => { |
520 | let mut precise_location = None; | 520 | let mut precise_location = None; |
521 | let (file, ast, name) = match ast { | 521 | let (node, name) = match ast { |
522 | MacroCallKind::FnLike { ast_id, .. } => { | 522 | MacroCallKind::FnLike { ast_id, .. } => { |
523 | let node = ast_id.to_node(db.upcast()); | 523 | let node = ast_id.to_node(db.upcast()); |
524 | (ast_id.file_id, SyntaxNodePtr::from(AstPtr::new(&node)), None) | 524 | (ast_id.with_value(SyntaxNodePtr::from(AstPtr::new(&node))), None) |
525 | } | 525 | } |
526 | MacroCallKind::Derive { ast_id, derive_name, .. } => { | 526 | MacroCallKind::Derive { ast_id, derive_name, .. } => { |
527 | let node = ast_id.to_node(db.upcast()); | 527 | let node = ast_id.to_node(db.upcast()); |
@@ -554,8 +554,7 @@ impl Module { | |||
554 | } | 554 | } |
555 | 555 | ||
556 | ( | 556 | ( |
557 | ast_id.file_id, | 557 | ast_id.with_value(SyntaxNodePtr::from(AstPtr::new(&node))), |
558 | SyntaxNodePtr::from(AstPtr::new(&node)), | ||
559 | Some(derive_name.clone()), | 558 | Some(derive_name.clone()), |
560 | ) | 559 | ) |
561 | } | 560 | } |
@@ -566,18 +565,14 @@ impl Module { | |||
566 | || panic!("cannot find attribute #{}", invoc_attr_index), | 565 | || panic!("cannot find attribute #{}", invoc_attr_index), |
567 | ); | 566 | ); |
568 | ( | 567 | ( |
569 | ast_id.file_id, | 568 | ast_id.with_value(SyntaxNodePtr::from(AstPtr::new(&attr))), |
570 | SyntaxNodePtr::from(AstPtr::new(&attr)), | ||
571 | Some(attr_name.clone()), | 569 | Some(attr_name.clone()), |
572 | ) | 570 | ) |
573 | } | 571 | } |
574 | }; | 572 | }; |
575 | sink.push(UnresolvedProcMacro { | 573 | acc.push( |
576 | file, | 574 | UnresolvedProcMacro { node, precise_location, macro_name: name }.into(), |
577 | node: ast, | 575 | ); |
578 | precise_location, | ||
579 | macro_name: name, | ||
580 | }); | ||
581 | } | 576 | } |
582 | 577 | ||
583 | DefDiagnosticKind::UnresolvedMacroCall { ast, path } => { | 578 | DefDiagnosticKind::UnresolvedMacroCall { ast, path } => { |
@@ -1056,12 +1051,14 @@ impl Function { | |||
1056 | node: node.value.clone().into(), | 1051 | node: node.value.clone().into(), |
1057 | message: message.to_string(), | 1052 | message: message.to_string(), |
1058 | }), | 1053 | }), |
1059 | BodyDiagnostic::UnresolvedProcMacro { node } => sink.push(UnresolvedProcMacro { | 1054 | BodyDiagnostic::UnresolvedProcMacro { node } => acc.push( |
1060 | file: node.file_id, | 1055 | UnresolvedProcMacro { |
1061 | node: node.value.clone().into(), | 1056 | node: node.clone().map(|it| it.into()), |
1062 | precise_location: None, | 1057 | precise_location: None, |
1063 | macro_name: None, | 1058 | macro_name: None, |
1064 | }), | 1059 | } |
1060 | .into(), | ||
1061 | ), | ||
1065 | BodyDiagnostic::UnresolvedMacroCall { node, path } => acc.push( | 1062 | BodyDiagnostic::UnresolvedMacroCall { node, path } => acc.push( |
1066 | UnresolvedMacroCall { macro_call: node.clone(), path: path.clone() }.into(), | 1063 | UnresolvedMacroCall { macro_call: node.clone(), path: path.clone() }.into(), |
1067 | ), | 1064 | ), |