1172: Temporarily disable tt matcher r=edwin0cheng a=edwin0cheng

Temporarily fix for #1170 by disable the `tt` matcher. The reason for that is normally a `$($tt:tt))* wildcard matcher will be added for recurisve macro. If we have any bugs in macro expansion, the macro will infinite expanding recursively. 

Let me add a fused system and add more test in later PR and then re-enable this one

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
This commit is contained in:
bors[bot] 2019-04-19 18:41:55 +00:00
commit 0d39b1c3fa
2 changed files with 30 additions and 26 deletions

View file

@ -763,29 +763,29 @@ MACRO_ITEMS@[0; 40)
); );
} }
#[test] // #[test]
fn test_tt_block() { // fn test_tt_block() {
let rules = create_rules( // let rules = create_rules(
r#" // r#"
macro_rules! foo { // macro_rules! foo {
($ i:tt) => { fn foo() $ i } // ($ i:tt) => { fn foo() $ i }
} // }
"#, // "#,
); // );
assert_expansion(&rules, r#"foo! { { 1; } }"#, r#"fn foo () {1 ;}"#); // assert_expansion(&rules, r#"foo! { { 1; } }"#, r#"fn foo () {1 ;}"#);
} // }
#[test] // #[test]
fn test_tt_group() { // fn test_tt_group() {
let rules = create_rules( // let rules = create_rules(
r#" // r#"
macro_rules! foo { // macro_rules! foo {
($($ i:tt)*) => { $($ i)* } // ($($ i:tt)*) => { $($ i)* }
} // }
"#, // "#,
); // );
assert_expansion(&rules, r#"foo! { fn foo() {} }"#, r#"fn foo () {}"#); // assert_expansion(&rules, r#"foo! { fn foo() {} }"#, r#"fn foo () {}"#);
} // }
#[test] #[test]
fn test_lifetime() { fn test_lifetime() {

View file

@ -171,10 +171,14 @@ fn match_lhs(pattern: &crate::Subtree, input: &mut TtCursor) -> Result<Bindings,
input.eat_meta().ok_or(ExpandError::UnexpectedToken)?.clone(); input.eat_meta().ok_or(ExpandError::UnexpectedToken)?.clone();
res.inner.insert(text.clone(), Binding::Simple(meta.into())); res.inner.insert(text.clone(), Binding::Simple(meta.into()));
} }
"tt" => { // FIXME:
let token = input.eat().ok_or(ExpandError::UnexpectedToken)?.clone(); // Enable followiing code when everything is fixed
res.inner.insert(text.clone(), Binding::Simple(token.into())); // At least we can dogfood itself to not stackoverflow
} //
// "tt" => {
// let token = input.eat().ok_or(ExpandError::UnexpectedToken)?.clone();
// res.inner.insert(text.clone(), Binding::Simple(token.into()));
// }
"item" => { "item" => {
let item = let item =
input.eat_item().ok_or(ExpandError::UnexpectedToken)?.clone(); input.eat_item().ok_or(ExpandError::UnexpectedToken)?.clone();