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.rs79
1 files changed, 26 insertions, 53 deletions
diff --git a/crates/hir-def/src/nameres/diagnostics.rs b/crates/hir-def/src/nameres/diagnostics.rs
index 4ab53d20b5..bc1617c55b 100644
--- a/crates/hir-def/src/nameres/diagnostics.rs
+++ b/crates/hir-def/src/nameres/diagnostics.rs
@@ -2,14 +2,13 @@
use std::ops::Not;
-use base_db::CrateId;
use cfg::{CfgExpr, CfgOptions};
-use hir_expand::{attrs::AttrId, ErasedAstId, MacroCallKind};
+use hir_expand::{attrs::AttrId, ExpandErrorKind, MacroCallKind};
use la_arena::Idx;
use syntax::ast;
use crate::{
- item_tree::{self, ItemTreeId},
+ item_tree::{self, AttrOwner, ItemTreeId, TreeId},
nameres::LocalModuleId,
path::ModPath,
AstId,
@@ -17,47 +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 {
- ast: ErasedAstId,
- 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)]
@@ -114,21 +82,26 @@ impl DefDiagnostic {
Self { in_module: container, kind: DefDiagnosticKind::UnresolvedImport { id, index } }
}
- pub fn unconfigured_code(
+ pub fn macro_error(
container: LocalModuleId,
- ast: ErasedAstId,
- cfg: CfgExpr,
- opts: CfgOptions,
+ ast: AstId<ast::Item>,
+ path: ModPath,
+ err: ExpandErrorKind,
) -> Self {
- Self { in_module: container, kind: DefDiagnosticKind::UnconfiguredCode { ast, cfg, opts } }
+ Self { in_module: container, kind: DefDiagnosticKind::MacroError { ast, path, err } }
}
- pub fn unresolved_proc_macro(
+ pub fn unconfigured_code(
container: LocalModuleId,
- ast: MacroCallKind,
- krate: CrateId,
+ tree: TreeId,
+ item: AttrOwner,
+ cfg: CfgExpr,
+ opts: CfgOptions,
) -> Self {
- Self { in_module: container, kind: DefDiagnosticKind::UnresolvedProcMacro { ast, krate } }
+ Self {
+ in_module: container,
+ kind: DefDiagnosticKind::UnconfiguredCode { tree, item, cfg, opts },
+ }
}
// FIXME: Whats the difference between this and unresolved_proc_macro