mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Infallibe ExpandDatabase::macro_def
This commit is contained in:
parent
4ff93398fd
commit
d5f64f875a
10 changed files with 215 additions and 164 deletions
|
@ -698,16 +698,18 @@ impl Module {
|
|||
|
||||
fn emit_macro_def_diagnostics(db: &dyn HirDatabase, acc: &mut Vec<AnyDiagnostic>, m: Macro) {
|
||||
let id = macro_id_to_def_id(db.upcast(), m.id);
|
||||
if let Err(e) = db.macro_def(id) {
|
||||
let Some(ast) = id.ast_id().left() else {
|
||||
never!("MacroDefError for proc-macro: {:?}", e);
|
||||
return;
|
||||
};
|
||||
emit_def_diagnostic_(
|
||||
db,
|
||||
acc,
|
||||
&DefDiagnosticKind::MacroDefError { ast, message: e.to_string() },
|
||||
);
|
||||
if let hir_expand::db::TokenExpander::DeclarativeMacro(expander) = db.macro_def(id) {
|
||||
if let Some(e) = expander.mac.err() {
|
||||
let Some(ast) = id.ast_id().left() else {
|
||||
never!("declarative expander for non decl-macro: {:?}", e);
|
||||
return;
|
||||
};
|
||||
emit_def_diagnostic_(
|
||||
db,
|
||||
acc,
|
||||
&DefDiagnosticKind::MacroDefError { ast, message: e.to_string() },
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue