diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-12-03 16:55:15 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-12-03 16:55:15 +0000 |
commit | d46fce88f5af1a97888edf91df2cb51ff5bfd61c (patch) | |
tree | 1f0351e895fa8b24ae4fa5a1854fb6c4285efcd2 /crates/hir_def/src/body.rs | |
parent | 74de29b223c2e6f01d1ed0912d72787c202bb225 (diff) | |
parent | bca1e5fcb825c6c4e09ec197513b5568fce3d985 (diff) |
Merge #6700
6700: More macro diagnostics improvements r=jonas-schievink a=jonas-schievink
This threads macro expansion errors through `eager.rs` and the `AsMacroCall` trait, improving macro diagnostics emitted during body lowering.
Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/hir_def/src/body.rs')
-rw-r--r-- | crates/hir_def/src/body.rs | 20 |
1 files changed, 13 insertions, 7 deletions
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 { | |||
120 | self.resolve_path_as_macro(db, &path) | 120 | self.resolve_path_as_macro(db, &path) |
121 | }; | 121 | }; |
122 | 122 | ||
123 | let call_id = match macro_call.as_call_id(db, self.crate_def_map.krate, resolver) { | 123 | let mut err = None; |
124 | let call_id = | ||
125 | macro_call.as_call_id_with_errors(db, self.crate_def_map.krate, resolver, &mut |e| { | ||
126 | err.get_or_insert(e); | ||
127 | }); | ||
128 | let call_id = match call_id { | ||
124 | Some(it) => it, | 129 | Some(it) => it, |
125 | None => { | 130 | None => { |
126 | // FIXME: this can mean other things too, but `as_call_id` doesn't provide enough | 131 | if err.is_none() { |
127 | // info. | 132 | eprintln!("no error despite `as_call_id_with_errors` returning `None`"); |
128 | return ExpandResult::only_err(mbe::ExpandError::Other( | 133 | } |
129 | "failed to parse or resolve macro invocation".into(), | 134 | return ExpandResult { value: None, err }; |
130 | )); | ||
131 | } | 135 | } |
132 | }; | 136 | }; |
133 | 137 | ||
134 | let err = db.macro_expand_error(call_id); | 138 | if err.is_none() { |
139 | err = db.macro_expand_error(call_id); | ||
140 | } | ||
135 | 141 | ||
136 | let file_id = call_id.as_file(); | 142 | let file_id = call_id.as_file(); |
137 | 143 | ||