From 4551182f94fe81c314f79ddf8916a5520cfd03b0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 17 Sep 2019 02:54:22 +0300 Subject: use usual token tree for macro expansion --- crates/ra_mbe/src/mbe_expander.rs | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to 'crates/ra_mbe/src/mbe_expander.rs') diff --git a/crates/ra_mbe/src/mbe_expander.rs b/crates/ra_mbe/src/mbe_expander.rs index 15d9d83e2..b455b7321 100644 --- a/crates/ra_mbe/src/mbe_expander.rs +++ b/crates/ra_mbe/src/mbe_expander.rs @@ -8,7 +8,6 @@ mod transcriber; use ra_syntax::SmolStr; use rustc_hash::FxHashMap; -use crate::tt_cursor::TtCursor; use crate::ExpandError; pub(crate) fn expand( @@ -19,12 +18,8 @@ pub(crate) fn expand( } fn expand_rule(rule: &crate::Rule, input: &tt::Subtree) -> Result { - let mut input = TtCursor::new(input); - let bindings = matcher::match_lhs(&rule.lhs, &mut input)?; - if !input.is_eof() { - return Err(ExpandError::UnexpectedToken); - } - let res = transcriber::transcribe(&bindings, &rule.rhs)?; + let bindings = matcher::match_(&rule.lhs, input)?; + let res = transcriber::transcribe(&rule.rhs, &bindings)?; Ok(res) } @@ -103,13 +98,6 @@ mod tests { #[test] fn test_expand_rule() { - // FIXME: The missing $var check should be in parsing phase - // assert_err( - // "($i:ident) => ($j)", - // "foo!{a}", - // ExpandError::BindingError(String::from("could not find binding `j`")), - // ); - assert_err( "($($i:ident);*) => ($i)", "foo!{a}", @@ -118,9 +106,6 @@ mod tests { )), ); - assert_err("($i) => ($i)", "foo!{a}", ExpandError::UnexpectedToken); - assert_err("($i:) => ($i)", "foo!{a}", ExpandError::UnexpectedToken); - // FIXME: // Add an err test case for ($($i:ident)) => ($()) } -- cgit v1.2.3