@@ -195,7 +195,7 @@ MacroExpander::expand_invoc (AST::MacroInvocation &invoc)
195
195
bool ok = mappings->lookup_macro_def (resolved_node, &rules_def);
196
196
rust_assert (ok);
197
197
198
- auto fragment = AST::ASTFragment::create_empty ();
198
+ auto fragment = AST::ASTFragment::create_error ();
199
199
200
200
if (rules_def->is_builtin ())
201
201
fragment
@@ -236,7 +236,7 @@ MacroExpander::expand_invoc_semi (AST::MacroInvocation &invoc)
236
236
bool ok = mappings->lookup_macro_def (resolved_node, &rules_def);
237
237
rust_assert (ok);
238
238
239
- auto fragment = AST::ASTFragment::create_empty ();
239
+ auto fragment = AST::ASTFragment::create_error ();
240
240
241
241
if (rules_def->is_builtin ())
242
242
fragment
@@ -781,7 +781,7 @@ MacroExpander::match_repetition (Parser<MacroInvocLexer> &parser,
781
781
/* *
782
782
* Helper function to refactor calling a parsing function 0 or more times
783
783
*/
784
- static std::vector< AST::SingleASTNode>
784
+ static AST::ASTFragment
785
785
parse_many (Parser<MacroInvocLexer> &parser, TokenId &delimiter,
786
786
std::function<AST::SingleASTNode ()> parse_fn)
787
787
{
@@ -795,7 +795,7 @@ parse_many (Parser<MacroInvocLexer> &parser, TokenId &delimiter,
795
795
nodes.emplace_back (std::move (node));
796
796
}
797
797
798
- return nodes;
798
+ return AST::ASTFragment ( std::move ( nodes)) ;
799
799
}
800
800
801
801
/* *
@@ -804,7 +804,7 @@ parse_many (Parser<MacroInvocLexer> &parser, TokenId &delimiter,
804
804
* @param parser Parser to extract items from
805
805
* @param delimiter Id of the token on which parsing should stop
806
806
*/
807
- static std::vector< AST::SingleASTNode>
807
+ static AST::ASTFragment
808
808
transcribe_many_items (Parser<MacroInvocLexer> &parser, TokenId &delimiter)
809
809
{
810
810
return parse_many (parser, delimiter, [&parser] () {
@@ -819,7 +819,7 @@ transcribe_many_items (Parser<MacroInvocLexer> &parser, TokenId &delimiter)
819
819
* @param parser Parser to extract items from
820
820
* @param delimiter Id of the token on which parsing should stop
821
821
*/
822
- static std::vector< AST::SingleASTNode>
822
+ static AST::ASTFragment
823
823
transcribe_many_ext (Parser<MacroInvocLexer> &parser, TokenId &delimiter)
824
824
{
825
825
return parse_many (parser, delimiter, [&parser] () {
@@ -834,7 +834,7 @@ transcribe_many_ext (Parser<MacroInvocLexer> &parser, TokenId &delimiter)
834
834
* @param parser Parser to extract items from
835
835
* @param delimiter Id of the token on which parsing should stop
836
836
*/
837
- static std::vector< AST::SingleASTNode>
837
+ static AST::ASTFragment
838
838
transcribe_many_trait_items (Parser<MacroInvocLexer> &parser,
839
839
TokenId &delimiter)
840
840
{
@@ -850,7 +850,7 @@ transcribe_many_trait_items (Parser<MacroInvocLexer> &parser,
850
850
* @param parser Parser to extract items from
851
851
* @param delimiter Id of the token on which parsing should stop
852
852
*/
853
- static std::vector< AST::SingleASTNode>
853
+ static AST::ASTFragment
854
854
transcribe_many_impl_items (Parser<MacroInvocLexer> &parser, TokenId &delimiter)
855
855
{
856
856
return parse_many (parser, delimiter, [&parser] () {
@@ -865,7 +865,7 @@ transcribe_many_impl_items (Parser<MacroInvocLexer> &parser, TokenId &delimiter)
865
865
* @param parser Parser to extract items from
866
866
* @param delimiter Id of the token on which parsing should stop
867
867
*/
868
- static std::vector< AST::SingleASTNode>
868
+ static AST::ASTFragment
869
869
transcribe_many_trait_impl_items (Parser<MacroInvocLexer> &parser,
870
870
TokenId &delimiter)
871
871
{
@@ -881,7 +881,7 @@ transcribe_many_trait_impl_items (Parser<MacroInvocLexer> &parser,
881
881
* @param parser Parser to extract statements from
882
882
* @param delimiter Id of the token on which parsing should stop
883
883
*/
884
- static std::vector< AST::SingleASTNode>
884
+ static AST::ASTFragment
885
885
transcribe_many_stmts (Parser<MacroInvocLexer> &parser, TokenId &delimiter)
886
886
{
887
887
auto restrictions = ParseRestrictions ();
@@ -901,28 +901,28 @@ transcribe_many_stmts (Parser<MacroInvocLexer> &parser, TokenId &delimiter)
901
901
*
902
902
* @param parser Parser to extract statements from
903
903
*/
904
- static std::vector< AST::SingleASTNode>
904
+ static AST::ASTFragment
905
905
transcribe_expression (Parser<MacroInvocLexer> &parser)
906
906
{
907
907
auto expr = parser.parse_expr ();
908
908
909
- return { AST::SingleASTNode ( std::move (expr))} ;
909
+ return AST::ASTFragment ({ std::move (expr)}) ;
910
910
}
911
911
912
912
/* *
913
913
* Transcribe one type from a macro invocation
914
914
*
915
915
* @param parser Parser to extract statements from
916
916
*/
917
- static std::vector< AST::SingleASTNode>
917
+ static AST::ASTFragment
918
918
transcribe_type (Parser<MacroInvocLexer> &parser)
919
919
{
920
- auto expr = parser.parse_type ();
920
+ auto type = parser.parse_type ();
921
921
922
- return { AST::SingleASTNode ( std::move (expr))} ;
922
+ return AST::ASTFragment ({ std::move (type)}) ;
923
923
}
924
924
925
- static std::vector< AST::SingleASTNode>
925
+ static AST::ASTFragment
926
926
transcribe_on_delimiter (Parser<MacroInvocLexer> &parser, bool semicolon,
927
927
AST::DelimType delimiter, TokenId last_token_id)
928
928
{
@@ -932,7 +932,7 @@ transcribe_on_delimiter (Parser<MacroInvocLexer> &parser, bool semicolon,
932
932
return transcribe_expression (parser);
933
933
} // namespace Rust
934
934
935
- static std::vector< AST::SingleASTNode>
935
+ static AST::ASTFragment
936
936
transcribe_context (MacroExpander::ContextType ctx,
937
937
Parser<MacroInvocLexer> &parser, bool semicolon,
938
938
AST::DelimType delimiter, TokenId last_token_id)
@@ -1049,7 +1049,7 @@ MacroExpander::transcribe_rule (
1049
1049
// as a statement (either via ExpressionStatement or
1050
1050
// MacroInvocationWithSemi)
1051
1051
1052
- auto nodes
1052
+ auto fragment
1053
1053
= transcribe_context (ctx, parser, semicolon,
1054
1054
invoc_token_tree.get_delim_type (), last_token_id);
1055
1055
@@ -1072,6 +1072,6 @@ MacroExpander::transcribe_rule (
1072
1072
" tokens here and after are unparsed" );
1073
1073
}
1074
1074
1075
- return AST::ASTFragment ( std::move (nodes)) ;
1075
+ return fragment ;
1076
1076
}
1077
1077
} // namespace Rust
0 commit comments