Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion crates/hir_def/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,6 @@ fn macro_call_as_call_id(
&|path: ast::Path| resolver(path::ModPath::from_src(db, path, &hygiene)?),
error_sink,
)
.map(MacroCallId::from)
} else {
Ok(def.as_lazy_macro(
db.upcast(),
Expand Down
13 changes: 9 additions & 4 deletions crates/hir_def/src/nameres/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1939,17 +1939,22 @@ impl ModCollector<'_, '_> {
self.macro_depth + 1,
);

if let Some(err) = error {
self.def_collector.def_map.diagnostics.push(DefDiagnostic::macro_error(
self.module_id,
MacroCallKind::FnLike { ast_id: ast_id.ast_id, expand_to: mac.expand_to },
err.to_string(),
));
}

return;
}
Ok(Err(_)) => {
// Built-in macro failed eager expansion.

// FIXME: don't parse the file here
let macro_call = ast_id.ast_id.to_node(self.def_collector.db.upcast());
let expand_to = hir_expand::ExpandTo::from_call_site(&macro_call);
self.def_collector.def_map.diagnostics.push(DefDiagnostic::macro_error(
self.module_id,
MacroCallKind::FnLike { ast_id: ast_id.ast_id, expand_to },
MacroCallKind::FnLike { ast_id: ast_id.ast_id, expand_to: mac.expand_to },
error.unwrap().to_string(),
));
return;
Expand Down
6 changes: 6 additions & 0 deletions crates/ide_diagnostics/src/handlers/macro_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@ mod tests {
#[rustc_builtin_macro]
macro_rules! include { () => {} }

#[rustc_builtin_macro]
macro_rules! compile_error { () => {} }

include!("doesntexist");
//^^^^^^^^^^^^^^^^^^^^^^^^ error: failed to load file `doesntexist`

compile_error!("compile_error macro works");
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: compile_error macro works
"#,
);
}
Expand Down