use std::sync::Arc;
use base_db::CrateId;
-use mbe::ExpandResult;
use syntax::{ted, SyntaxNode};
use crate::{
db::AstDatabase,
hygiene::Hygiene,
mod_path::ModPath,
- EagerCallInfo, ExpandTo, InFile, MacroCallId, MacroCallKind, MacroCallLoc, MacroDefId,
- MacroDefKind, UnresolvedMacro,
+ EagerCallInfo, ExpandError, ExpandResult, ExpandTo, InFile, MacroCallId, MacroCallKind,
+ MacroCallLoc, MacroDefId, MacroDefKind, UnresolvedMacro,
};
#[derive(Debug)]
}
pub trait ErrorSink {
- fn emit(&mut self, err: mbe::ExpandError);
+ fn emit(&mut self, err: ExpandError);
fn option<T>(
&mut self,
opt: Option<T>,
- error: impl FnOnce() -> mbe::ExpandError,
+ error: impl FnOnce() -> ExpandError,
) -> Result<T, ErrorEmitted> {
match opt {
Some(it) => Ok(it),
fn option_with<T>(
&mut self,
opt: impl FnOnce() -> Option<T>,
- error: impl FnOnce() -> mbe::ExpandError,
+ error: impl FnOnce() -> ExpandError,
) -> Result<T, ErrorEmitted> {
self.option(opt(), error)
}
- fn result<T>(&mut self, res: Result<T, mbe::ExpandError>) -> Result<T, ErrorEmitted> {
+ fn result<T>(&mut self, res: Result<T, ExpandError>) -> Result<T, ErrorEmitted> {
match res {
Ok(it) => Ok(it),
Err(e) => {
}
}
-impl ErrorSink for &'_ mut dyn FnMut(mbe::ExpandError) {
- fn emit(&mut self, err: mbe::ExpandError) {
+impl ErrorSink for &'_ mut dyn FnMut(ExpandError) {
+ fn emit(&mut self, err: ExpandError) {
self(err);
}
}
macro_call: InFile<ast::MacroCall>,
def: MacroDefId,
resolver: &dyn Fn(ModPath) -> Option<MacroDefId>,
- diagnostic_sink: &mut dyn FnMut(mbe::ExpandError),
+ diagnostic_sink: &mut dyn FnMut(ExpandError),
) -> Result<Result<MacroCallId, ErrorEmitted>, UnresolvedMacro> {
let hygiene = Hygiene::new(db, macro_call.file_id);
let parsed_args = macro_call
if let MacroDefKind::BuiltInEager(eager, _) = def.kind {
let res = eager.expand(db, arg_id, &subtree);
if let Some(err) = res.err {
- diagnostic_sink(err);
+ diagnostic_sink(err.into());
}
let loc = MacroCallLoc {
curr: InFile<SyntaxNode>,
krate: CrateId,
macro_resolver: &dyn Fn(ModPath) -> Option<MacroDefId>,
- mut diagnostic_sink: &mut dyn FnMut(mbe::ExpandError),
+ mut diagnostic_sink: &mut dyn FnMut(ExpandError),
) -> Result<Result<SyntaxNode, ErrorEmitted>, UnresolvedMacro> {
let original = curr.value.clone_for_update();
let def = match child.path().and_then(|path| ModPath::from_src(db, path, &hygiene)) {
Some(path) => macro_resolver(path.clone()).ok_or_else(|| UnresolvedMacro { path })?,
None => {
- diagnostic_sink(mbe::ExpandError::Other("malformed macro invocation".into()));
+ diagnostic_sink(ExpandError::Other("malformed macro invocation".into()));
continue;
}
};