mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
internal: reduce coupling
tt is a data structure, data structures cant' go wrong, they shouldn't have the knowledge that the world outside of them has all kinds of errors.
This commit is contained in:
parent
d8a3d6f378
commit
81602f8a5d
6 changed files with 25 additions and 32 deletions
|
@ -1,7 +1,7 @@
|
|||
//! Proc Macro Expander stub
|
||||
|
||||
use crate::db::AstDatabase;
|
||||
use base_db::{CrateId, ProcMacroId};
|
||||
use base_db::{CrateId, ProcMacroExpansionError, ProcMacroId};
|
||||
use mbe::ExpandResult;
|
||||
|
||||
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
|
||||
|
@ -42,7 +42,14 @@ impl ProcMacroExpander {
|
|||
// Proc macros have access to the environment variables of the invoking crate.
|
||||
let env = &krate_graph[calling_crate].env;
|
||||
|
||||
proc_macro.expander.expand(tt, attr_arg, env).map_err(mbe::ExpandError::from).into()
|
||||
proc_macro
|
||||
.expander
|
||||
.expand(tt, attr_arg, env)
|
||||
.map_err(|err| match err {
|
||||
ProcMacroExpansionError::Panic(text) => mbe::ExpandError::Other(text),
|
||||
ProcMacroExpansionError::System(text) => mbe::ExpandError::Other(text),
|
||||
})
|
||||
.into()
|
||||
}
|
||||
None => ExpandResult::only_err(mbe::ExpandError::UnresolvedProcMacro),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue