mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Replace option with result in mbe
This commit is contained in:
parent
592b906604
commit
d3a252b559
4 changed files with 93 additions and 74 deletions
|
@ -24,6 +24,15 @@ use ra_syntax::SmolStr;
|
|||
|
||||
pub use tt::{Delimiter, Punct};
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum MacroRulesError {
|
||||
NoMatchingRule,
|
||||
UnexpectedToken,
|
||||
BindingError(String),
|
||||
ParseError,
|
||||
}
|
||||
|
||||
pub type Result<T> = ::std::result::Result<T, MacroRulesError>;
|
||||
pub use crate::syntax_bridge::{ast_to_token_tree, token_tree_to_ast_item_list};
|
||||
|
||||
/// This struct contains AST for a single `macro_rules` definition. What might
|
||||
|
@ -36,11 +45,11 @@ pub struct MacroRules {
|
|||
}
|
||||
|
||||
impl MacroRules {
|
||||
pub fn parse(tt: &tt::Subtree) -> Option<MacroRules> {
|
||||
pub fn parse(tt: &tt::Subtree) -> Result<MacroRules> {
|
||||
mbe_parser::parse(tt)
|
||||
}
|
||||
pub fn expand(&self, tt: &tt::Subtree) -> Option<tt::Subtree> {
|
||||
mbe_expander::exapnd(self, tt)
|
||||
pub fn expand(&self, tt: &tt::Subtree) -> Result<tt::Subtree> {
|
||||
mbe_expander::expand(self, tt)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue