summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/macro_rules/eval.cpp62
1 files changed, 46 insertions, 16 deletions
diff --git a/src/macro_rules/eval.cpp b/src/macro_rules/eval.cpp
index e7b9a203..3315b24c 100644
--- a/src/macro_rules/eval.cpp
+++ b/src/macro_rules/eval.cpp
@@ -1712,29 +1712,46 @@ namespace
return false;
return consume_tt(lex);
case TOK_IDENT:
- if( lex.next_tok().str() != "union" )
- return false;
- lex.consume();
- if( lex.next() == TOK_EXCLAM )
+ if( lex.next_tok().str() == "union" )
{
- bool need_semicolon = (lex.next() != TOK_BRACE_OPEN);
- consume_tt(lex);
- if( need_semicolon )
+ lex.consume();
+ if( lex.next() == TOK_EXCLAM )
+ {
+ bool need_semicolon = (lex.next() != TOK_BRACE_OPEN);
+ consume_tt(lex);
+ if( need_semicolon )
+ {
+ if( !lex.consume_if(TOK_SEMICOLON) )
+ return false;
+ }
+ return true;
+ }
+ else
{
- if( !lex.consume_if(TOK_SEMICOLON) )
+ if( !H::maybe_generics(lex) )
return false;
+ if( !H::maybe_where(lex) )
+ return false;
+ if( lex.next() != TOK_BRACE_OPEN )
+ return false;
+ return consume_tt(lex);
}
- return true;
}
- else
+ else if( lex.next_tok().str() == "auto" )
{
- if( !H::maybe_generics(lex) )
- return false;
- if( !H::maybe_where(lex) )
- return false;
- if( lex.next() != TOK_BRACE_OPEN )
+ lex.consume();
+ if( lex.consume_if(TOK_RWORD_TRAIT) )
+ {
+ goto trait;
+ }
+ else
+ {
return false;
- return consume_tt(lex);
+ }
+ }
+ else
+ {
+ return false;
}
break;
// const fn
@@ -1761,6 +1778,19 @@ namespace
return false;
}
break;
+ case TOK_RWORD_TRAIT:
+ lex.consume();
+ trait:
+ if( !lex.consume_if(TOK_IDENT) )
+ return false;
+
+ if( !H::maybe_generics(lex) )
+ return false;
+ if(lex.next() != TOK_BRACE_OPEN)
+ return false;
+ if( !consume_tt(lex) )
+ return false;
+ break;
case TOK_RWORD_EXTERN:
lex.consume();
if( lex.consume_if(TOK_RWORD_CRATE) )