aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_def/src')
-rw-r--r--crates/hir_def/src/body.rs7
-rw-r--r--crates/hir_def/src/lib.rs22
2 files changed, 13 insertions, 16 deletions
diff --git a/crates/hir_def/src/body.rs b/crates/hir_def/src/body.rs
index d2dcd6727..1080d9c2c 100644
--- a/crates/hir_def/src/body.rs
+++ b/crates/hir_def/src/body.rs
@@ -121,11 +121,8 @@ impl Expander {
121 err.get_or_insert(e); 121 err.get_or_insert(e);
122 })?; 122 })?;
123 let call_id = match call_id { 123 let call_id = match call_id {
124 Some(it) => it, 124 Ok(it) => it,
125 None => { 125 Err(_) => {
126 if err.is_none() {
127 log::warn!("no error despite `as_call_id_with_errors` returning `None`");
128 }
129 return Ok(ExpandResult { value: None, err }); 126 return Ok(ExpandResult { value: None, err });
130 } 127 }
131 }; 128 };
diff --git a/crates/hir_def/src/lib.rs b/crates/hir_def/src/lib.rs
index 4b5cdd7a1..6758411a0 100644
--- a/crates/hir_def/src/lib.rs
+++ b/crates/hir_def/src/lib.rs
@@ -58,7 +58,7 @@ use std::{
58use base_db::{impl_intern_key, salsa, CrateId}; 58use base_db::{impl_intern_key, salsa, CrateId};
59use hir_expand::{ 59use hir_expand::{
60 ast_id_map::FileAstId, 60 ast_id_map::FileAstId,
61 eager::{expand_eager_macro, ErrorEmitted}, 61 eager::{expand_eager_macro, ErrorEmitted, ErrorSink},
62 hygiene::Hygiene, 62 hygiene::Hygiene,
63 AstId, HirFileId, InFile, MacroCallId, MacroCallKind, MacroDefId, MacroDefKind, 63 AstId, HirFileId, InFile, MacroCallId, MacroCallKind, MacroDefId, MacroDefKind,
64}; 64};
@@ -583,7 +583,7 @@ pub trait AsMacroCall {
583 krate: CrateId, 583 krate: CrateId,
584 resolver: impl Fn(path::ModPath) -> Option<MacroDefId>, 584 resolver: impl Fn(path::ModPath) -> Option<MacroDefId>,
585 ) -> Option<MacroCallId> { 585 ) -> Option<MacroCallId> {
586 self.as_call_id_with_errors(db, krate, resolver, &mut |_| ()).ok()? 586 self.as_call_id_with_errors(db, krate, resolver, &mut |_| ()).ok()?.ok()
587 } 587 }
588 588
589 fn as_call_id_with_errors( 589 fn as_call_id_with_errors(
@@ -592,7 +592,7 @@ pub trait AsMacroCall {
592 krate: CrateId, 592 krate: CrateId,
593 resolver: impl Fn(path::ModPath) -> Option<MacroDefId>, 593 resolver: impl Fn(path::ModPath) -> Option<MacroDefId>,
594 error_sink: &mut dyn FnMut(mbe::ExpandError), 594 error_sink: &mut dyn FnMut(mbe::ExpandError),
595 ) -> Result<Option<MacroCallId>, UnresolvedMacro>; 595 ) -> Result<Result<MacroCallId, ErrorEmitted>, UnresolvedMacro>;
596} 596}
597 597
598impl AsMacroCall for InFile<&ast::MacroCall> { 598impl AsMacroCall for InFile<&ast::MacroCall> {
@@ -601,18 +601,19 @@ impl AsMacroCall for InFile<&ast::MacroCall> {
601 db: &dyn db::DefDatabase, 601 db: &dyn db::DefDatabase,
602 krate: CrateId, 602 krate: CrateId,
603 resolver: impl Fn(path::ModPath) -> Option<MacroDefId>, 603 resolver: impl Fn(path::ModPath) -> Option<MacroDefId>,
604 error_sink: &mut dyn FnMut(mbe::ExpandError), 604 mut error_sink: &mut dyn FnMut(mbe::ExpandError),
605 ) -> Result<Option<MacroCallId>, UnresolvedMacro> { 605 ) -> Result<Result<MacroCallId, ErrorEmitted>, UnresolvedMacro> {
606 let ast_id = AstId::new(self.file_id, db.ast_id_map(self.file_id).ast_id(self.value)); 606 let ast_id = AstId::new(self.file_id, db.ast_id_map(self.file_id).ast_id(self.value));
607 let h = Hygiene::new(db.upcast(), self.file_id); 607 let h = Hygiene::new(db.upcast(), self.file_id);
608 let path = self.value.path().and_then(|path| path::ModPath::from_src(path, &h)); 608 let path = self.value.path().and_then(|path| path::ModPath::from_src(path, &h));
609 609
610 let path = match path { 610 let path = match error_sink
611 None => { 611 .option(path, || mbe::ExpandError::Other("malformed macro invocation".into()))
612 error_sink(mbe::ExpandError::Other("malformed macro invocation".into())); 612 {
613 return Ok(None); 613 Ok(path) => path,
614 Err(error) => {
615 return Ok(Err(error));
614 } 616 }
615 Some(path) => path,
616 }; 617 };
617 618
618 macro_call_as_call_id( 619 macro_call_as_call_id(
@@ -622,7 +623,6 @@ impl AsMacroCall for InFile<&ast::MacroCall> {
622 resolver, 623 resolver,
623 error_sink, 624 error_sink,
624 ) 625 )
625 .map(Result::ok)
626 } 626 }
627} 627}
628 628