mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Auto merge of #14583 - Veykril:macro-def-err, r=Veykril
internal: Report macro definition errors on the definition We still report them on the call site as well for the time being, and the diagnostic doesn't know where the error in the definition comes from, but that can be done later on
This commit is contained in:
commit
f0a40c3a0e
10 changed files with 115 additions and 14 deletions
|
@ -190,8 +190,9 @@ impl Expander {
|
|||
|
||||
let file_id = call_id.as_file();
|
||||
|
||||
let raw_node = match db.parse_or_expand(file_id) {
|
||||
Some(it) => it,
|
||||
let raw_node = match db.parse_or_expand_with_err(file_id) {
|
||||
// FIXME: report parse errors
|
||||
Some(it) => it.syntax_node(),
|
||||
None => {
|
||||
// Only `None` if the macro expansion produced no usable AST.
|
||||
if err.is_none() {
|
||||
|
|
|
@ -641,7 +641,12 @@ impl<'a> AssocItemCollector<'a> {
|
|||
self.items.push((item.name.clone(), def.into()));
|
||||
}
|
||||
AssocItem::MacroCall(call) => {
|
||||
if let Some(root) = self.db.parse_or_expand(self.expander.current_file_id()) {
|
||||
if let Some(root) =
|
||||
self.db.parse_or_expand_with_err(self.expander.current_file_id())
|
||||
{
|
||||
// FIXME: report parse errors
|
||||
let root = root.syntax_node();
|
||||
|
||||
let call = &item_tree[call];
|
||||
|
||||
let ast_id_map = self.db.ast_id_map(self.expander.current_file_id());
|
||||
|
|
|
@ -1374,6 +1374,8 @@ impl DefCollector<'_> {
|
|||
|
||||
// Then, fetch and process the item tree. This will reuse the expansion result from above.
|
||||
let item_tree = self.db.file_item_tree(file_id);
|
||||
// FIXME: report parse errors for the macro expansion here
|
||||
|
||||
let mod_dir = self.mod_dirs[&module_id].clone();
|
||||
ModCollector {
|
||||
def_collector: &mut *self,
|
||||
|
|
|
@ -34,6 +34,8 @@ pub enum DefDiagnosticKind {
|
|||
InvalidDeriveTarget { ast: AstId<ast::Item>, id: usize },
|
||||
|
||||
MalformedDerive { ast: AstId<ast::Adt>, id: usize },
|
||||
|
||||
MacroDefError { ast: AstId<ast::Macro>, message: String },
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue