From b3b91046dd62fee7a0975f2962732e71027f1c6c Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Sun, 14 Mar 2021 11:22:10 +0800 Subject: Make sure ill-form macro handle propely --- crates/mbe/src/expander/transcriber.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'crates/mbe/src/expander') diff --git a/crates/mbe/src/expander/transcriber.rs b/crates/mbe/src/expander/transcriber.rs index c679e5e5d..dd7fa97d7 100644 --- a/crates/mbe/src/expander/transcriber.rs +++ b/crates/mbe/src/expander/transcriber.rs @@ -2,7 +2,7 @@ //! `$ident => foo`, interpolates variables in the template, to get `fn foo() {}` use syntax::SmolStr; -use tt::Delimiter; +use tt::{Delimiter, Subtree}; use super::ExpandResult; use crate::{ @@ -175,7 +175,10 @@ fn expand_repeat( counter += 1; if counter == limit { log::warn!("expand_tt in repeat pattern exceed limit => {:#?}\n{:#?}", template, ctx); - break; + return ExpandResult { + value: Fragment::Tokens(Subtree::default().into()), + err: Some(ExpandError::Other("Expand exceed limit".to_string())), + }; } if e.is_some() { -- cgit v1.2.3