Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/nameres/diagnostics.rs')
-rw-r--r--crates/hir-def/src/nameres/diagnostics.rs72
1 files changed, 20 insertions, 52 deletions
diff --git a/crates/hir-def/src/nameres/diagnostics.rs b/crates/hir-def/src/nameres/diagnostics.rs
index e1bd6966f3..bc1617c55b 100644
--- a/crates/hir-def/src/nameres/diagnostics.rs
+++ b/crates/hir-def/src/nameres/diagnostics.rs
@@ -2,9 +2,8 @@
use std::ops::Not;
-use base_db::CrateId;
use cfg::{CfgExpr, CfgOptions};
-use hir_expand::{attrs::AttrId, MacroCallKind};
+use hir_expand::{attrs::AttrId, ExpandErrorKind, MacroCallKind};
use la_arena::Idx;
use syntax::ast;
@@ -17,48 +16,16 @@ use crate::{
#[derive(Debug, PartialEq, Eq)]
pub enum DefDiagnosticKind {
- UnresolvedModule {
- ast: AstId<ast::Module>,
- candidates: Box<[String]>,
- },
- UnresolvedExternCrate {
- ast: AstId<ast::ExternCrate>,
- },
- UnresolvedImport {
- id: ItemTreeId<item_tree::Use>,
- index: Idx<ast::UseTree>,
- },
- UnconfiguredCode {
- tree: TreeId,
- item: AttrOwner,
- cfg: CfgExpr,
- opts: CfgOptions,
- },
- /// A proc-macro that is lacking an expander, this might be due to build scripts not yet having
- /// run or proc-macro expansion being disabled.
- UnresolvedProcMacro {
- ast: MacroCallKind,
- krate: CrateId,
- },
- UnresolvedMacroCall {
- ast: MacroCallKind,
- path: ModPath,
- },
- UnimplementedBuiltinMacro {
- ast: AstId<ast::Macro>,
- },
- InvalidDeriveTarget {
- ast: AstId<ast::Item>,
- id: usize,
- },
- MalformedDerive {
- ast: AstId<ast::Adt>,
- id: usize,
- },
- MacroDefError {
- ast: AstId<ast::Macro>,
- message: String,
- },
+ UnresolvedModule { ast: AstId<ast::Module>, candidates: Box<[String]> },
+ UnresolvedExternCrate { ast: AstId<ast::ExternCrate> },
+ UnresolvedImport { id: ItemTreeId<item_tree::Use>, index: Idx<ast::UseTree> },
+ UnconfiguredCode { tree: TreeId, item: AttrOwner, cfg: CfgExpr, opts: CfgOptions },
+ UnresolvedMacroCall { ast: MacroCallKind, path: ModPath },
+ UnimplementedBuiltinMacro { ast: AstId<ast::Macro> },
+ InvalidDeriveTarget { ast: AstId<ast::Item>, id: usize },
+ MalformedDerive { ast: AstId<ast::Adt>, id: usize },
+ MacroDefError { ast: AstId<ast::Macro>, message: String },
+ MacroError { ast: AstId<ast::Item>, path: ModPath, err: ExpandErrorKind },
}
#[derive(Clone, Debug, PartialEq, Eq)]
@@ -115,6 +82,15 @@ impl DefDiagnostic {
Self { in_module: container, kind: DefDiagnosticKind::UnresolvedImport { id, index } }
}
+ pub fn macro_error(
+ container: LocalModuleId,
+ ast: AstId<ast::Item>,
+ path: ModPath,
+ err: ExpandErrorKind,
+ ) -> Self {
+ Self { in_module: container, kind: DefDiagnosticKind::MacroError { ast, path, err } }
+ }
+
pub fn unconfigured_code(
container: LocalModuleId,
tree: TreeId,
@@ -128,14 +104,6 @@ impl DefDiagnostic {
}
}
- pub fn unresolved_proc_macro(
- container: LocalModuleId,
- ast: MacroCallKind,
- krate: CrateId,
- ) -> Self {
- Self { in_module: container, kind: DefDiagnosticKind::UnresolvedProcMacro { ast, krate } }
- }
-
// FIXME: Whats the difference between this and unresolved_proc_macro
pub(crate) fn unresolved_macro_call(
container: LocalModuleId,