From ab1e012116b2863ab51c296c60f628c3fbce603a Mon Sep 17 00:00:00 2001 From: Liam Naddell Date: Fri, 19 Jul 2024 20:49:24 -0400 Subject: [PATCH] #1806 I wrote up a better version, but eagar expansion doesn't work --- gcc/rust/expand/rust-macro-builtins-utility.cc | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/gcc/rust/expand/rust-macro-builtins-utility.cc b/gcc/rust/expand/rust-macro-builtins-utility.cc index 2e399438011..5b43ae3fe1b 100644 --- a/gcc/rust/expand/rust-macro-builtins-utility.cc +++ b/gcc/rust/expand/rust-macro-builtins-utility.cc @@ -237,7 +237,6 @@ tl::optional MacroBuiltin::option_env_handler (location_t invoc_locus, AST::MacroInvocData &invoc, AST::InvocKind semicolon) { - //TODO: Use ast/rust-ast-builder.h instead. auto invoc_token_tree = invoc.get_delim_tok_tree (); MacroInvocLexer lex (invoc_token_tree.to_token_stream ()); Parser parser (lex); @@ -268,19 +267,13 @@ MacroBuiltin::option_env_handler (location_t invoc_locus, AST::MacroInvocData &i return AST::Fragment::create_error (); } - //TODO: Fix {} if (expanded_expr.size () > 0) - { if (!(lit_expr = try_extract_string_literal_from_fragment (invoc_locus, expanded_expr[0]))) - { return AST::Fragment::create_error (); - } - } //TODO: Comments - //TODO: Pass tokens through parser.skip_token (last_token_id); auto env_value = getenv (lit_expr->as_string ().c_str ()); @@ -289,8 +282,6 @@ MacroBuiltin::option_env_handler (location_t invoc_locus, AST::MacroInvocData &i if (env_value == nullptr) { - //TODO: Fix token - auto tok = make_token (Token::make_string (invoc_locus, std::move ("DELETE ME"))); std::string none = "None"; std::unique_ptr none_expr = std::unique_ptr(new AST::PathInExpression(b.path_in_expression(std::vector({option,none})))); @@ -299,7 +290,7 @@ MacroBuiltin::option_env_handler (location_t invoc_locus, AST::MacroInvocData &i std::vector nodes; nodes.push_back(node); - return AST::Fragment (nodes, std::move (tok)); + return AST::Fragment (nodes, std::vector> ()); } std::string some = "Some"; //TODO: Vector constructors @@ -310,13 +301,11 @@ MacroBuiltin::option_env_handler (location_t invoc_locus, AST::MacroInvocData &i auto node = AST::SingleASTNode (std::move(some_expr)); - //TODO: Fix - auto tok = make_token (Token::make_string (invoc_locus, std::move (env_value))); std::vector nodes; nodes.push_back(node); - return AST::Fragment (nodes, std::move (tok)); + return AST::Fragment (nodes, std::vector> ()); } tl::optional