Skip to content

Commit b6bbf1f

Browse files
committed
macro_transcriber: Add TYPE context and associated transcriber
1 parent 229512d commit b6bbf1f

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

gcc/rust/expand/rust-macro-expand.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,19 @@ transcribe_expression (Parser<MacroInvocLexer> &parser)
909909
return {AST::SingleASTNode (std::move (expr))};
910910
}
911911

912+
/**
913+
* Transcribe one type from a macro invocation
914+
*
915+
* @param parser Parser to extract statements from
916+
*/
917+
static std::vector<AST::SingleASTNode>
918+
transcribe_type (Parser<MacroInvocLexer> &parser)
919+
{
920+
auto expr = parser.parse_type ();
921+
922+
return {AST::SingleASTNode (std::move (expr))};
923+
}
924+
912925
static std::vector<AST::SingleASTNode>
913926
transcribe_on_delimiter (Parser<MacroInvocLexer> &parser, bool semicolon,
914927
AST::DelimType delimiter, TokenId last_token_id)
@@ -957,6 +970,9 @@ transcribe_context (MacroExpander::ContextType ctx,
957970
case MacroExpander::ContextType::EXTERN:
958971
return transcribe_many_ext (parser, last_token_id);
959972
break;
973+
case MacroExpander::ContextType::TYPE:
974+
return transcribe_type (parser);
975+
break;
960976
default:
961977
return transcribe_on_delimiter (parser, semicolon, delimiter,
962978
last_token_id);

gcc/rust/expand/rust-macro-expand.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ struct MacroExpander
188188
ITEM,
189189
BLOCK,
190190
EXTERN,
191+
TYPE,
191192
TRAIT,
192193
IMPL,
193194
TRAIT_IMPL,

0 commit comments

Comments
 (0)