From a6342436343e01b32d4482a48994b8c22bcbe659 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 2 Dec 2020 16:52:14 +0100 Subject: Propagate eager expansion errors --- crates/hir_def/src/body.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'crates/hir_def/src/body.rs') diff --git a/crates/hir_def/src/body.rs b/crates/hir_def/src/body.rs index 33eb5e78c..92bcc1705 100644 --- a/crates/hir_def/src/body.rs +++ b/crates/hir_def/src/body.rs @@ -120,18 +120,24 @@ impl Expander { self.resolve_path_as_macro(db, &path) }; - let call_id = match macro_call.as_call_id(db, self.crate_def_map.krate, resolver) { + let mut err = None; + let call_id = + macro_call.as_call_id_with_errors(db, self.crate_def_map.krate, resolver, &mut |e| { + err.get_or_insert(e); + }); + let call_id = match call_id { Some(it) => it, None => { - // FIXME: this can mean other things too, but `as_call_id` doesn't provide enough - // info. - return ExpandResult::only_err(mbe::ExpandError::Other( - "failed to parse or resolve macro invocation".into(), - )); + if err.is_none() { + eprintln!("no error despite `as_call_id_with_errors` returning `None`"); + } + return ExpandResult { value: None, err }; } }; - let err = db.macro_expand_error(call_id); + if err.is_none() { + err = db.macro_expand_error(call_id); + } let file_id = call_id.as_file(); -- cgit v1.2.3