parse_macro_expansion_error almost never contains values so Option it

This commit is contained in:
Lukas Wirth 2024-05-13 17:02:08 +02:00
parent 56552f4839
commit caddcccea5
3 changed files with 14 additions and 8 deletions

View file

@ -831,13 +831,15 @@ fn macro_call_diagnostics(
macro_call_id: MacroCallId,
acc: &mut Vec<AnyDiagnostic>,
) {
let ValueResult { value: parse_errors, err } = db.parse_macro_expansion_error(macro_call_id);
let Some(e) = db.parse_macro_expansion_error(macro_call_id) else {
return;
};
let ValueResult { value: parse_errors, err } = &*e;
if let Some(err) = err {
let loc = db.lookup_intern_macro_call(macro_call_id);
let (node, precise_location, macro_name, kind) = precise_macro_call_location(&loc.kind, db);
let diag = match err {
hir_expand::ExpandError::UnresolvedProcMacro(krate) => {
&hir_expand::ExpandError::UnresolvedProcMacro(krate) => {
UnresolvedProcMacro { node, precise_location, macro_name, kind, krate }.into()
}
err => MacroError { node, precise_location, message: err.to_string() }.into(),