diff options
author | Aleksey Kladov <[email protected]> | 2021-06-13 16:41:04 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-06-13 16:41:04 +0100 |
commit | 00303284b5cc3a82e32dc3ecbbcfeb2f99de6818 (patch) | |
tree | 685e3f21289eaeb25df597413528f25c6239813f /crates/hir/src/lib.rs | |
parent | 1e4aaee7bbc1d56698e70158aa35f578422623d9 (diff) |
internal: refactor macro error
Diffstat (limited to 'crates/hir/src/lib.rs')
-rw-r--r-- | crates/hir/src/lib.rs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 87a3db946..d891d0ec1 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs | |||
@@ -587,19 +587,19 @@ impl Module { | |||
587 | } | 587 | } |
588 | 588 | ||
589 | DefDiagnosticKind::MacroError { ast, message } => { | 589 | DefDiagnosticKind::MacroError { ast, message } => { |
590 | let (file, ast) = match ast { | 590 | let node = match ast { |
591 | MacroCallKind::FnLike { ast_id, .. } => { | 591 | MacroCallKind::FnLike { ast_id, .. } => { |
592 | let node = ast_id.to_node(db.upcast()); | 592 | let node = ast_id.to_node(db.upcast()); |
593 | (ast_id.file_id, SyntaxNodePtr::from(AstPtr::new(&node))) | 593 | ast_id.with_value(SyntaxNodePtr::from(AstPtr::new(&node))) |
594 | } | 594 | } |
595 | MacroCallKind::Derive { ast_id, .. } | 595 | MacroCallKind::Derive { ast_id, .. } |
596 | | MacroCallKind::Attr { ast_id, .. } => { | 596 | | MacroCallKind::Attr { ast_id, .. } => { |
597 | // FIXME: point to the attribute instead, this creates very large diagnostics | 597 | // FIXME: point to the attribute instead, this creates very large diagnostics |
598 | let node = ast_id.to_node(db.upcast()); | 598 | let node = ast_id.to_node(db.upcast()); |
599 | (ast_id.file_id, SyntaxNodePtr::from(AstPtr::new(&node))) | 599 | ast_id.with_value(SyntaxNodePtr::from(AstPtr::new(&node))) |
600 | } | 600 | } |
601 | }; | 601 | }; |
602 | sink.push(MacroError { file, node: ast, message: message.clone() }); | 602 | acc.push(MacroError { node, message: message.clone() }.into()); |
603 | } | 603 | } |
604 | 604 | ||
605 | DefDiagnosticKind::UnimplementedBuiltinMacro { ast } => { | 605 | DefDiagnosticKind::UnimplementedBuiltinMacro { ast } => { |
@@ -1046,11 +1046,13 @@ impl Function { | |||
1046 | InactiveCode { node: node.clone(), cfg: cfg.clone(), opts: opts.clone() } | 1046 | InactiveCode { node: node.clone(), cfg: cfg.clone(), opts: opts.clone() } |
1047 | .into(), | 1047 | .into(), |
1048 | ), | 1048 | ), |
1049 | BodyDiagnostic::MacroError { node, message } => sink.push(MacroError { | 1049 | BodyDiagnostic::MacroError { node, message } => acc.push( |
1050 | file: node.file_id, | 1050 | MacroError { |
1051 | node: node.value.clone().into(), | 1051 | node: node.clone().map(|it| it.into()), |
1052 | message: message.to_string(), | 1052 | message: message.to_string(), |
1053 | }), | 1053 | } |
1054 | .into(), | ||
1055 | ), | ||
1054 | BodyDiagnostic::UnresolvedProcMacro { node } => acc.push( | 1056 | BodyDiagnostic::UnresolvedProcMacro { node } => acc.push( |
1055 | UnresolvedProcMacro { | 1057 | UnresolvedProcMacro { |
1056 | node: node.clone().map(|it| it.into()), | 1058 | node: node.clone().map(|it| it.into()), |