Skip to content

Commit c7b7e29

Browse files
powerboat9CohenArthur
authored andcommitted
Parse AttrInputMacro
gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_attr_input): Parse AttrInputMacro. gcc/testsuite/ChangeLog: * rust/compile/doc_macro.rs: New test. Signed-off-by: Owen Avery <[email protected]>
1 parent 4ddb7d1 commit c7b7e29

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

gcc/rust/parse/rust-parse-impl.h

+15
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,21 @@ Parser<ManagedTokenSource>::parse_attr_input ()
793793

794794
t = lexer.peek_token ();
795795

796+
// attempt to parse macro
797+
// TODO: macros may/may not be allowed in attributes
798+
// this is needed for "#[doc = include_str!(...)]"
799+
if (is_simple_path_segment (t->get_id ()))
800+
{
801+
std::unique_ptr<AST::MacroInvocation> invoke
802+
= parse_macro_invocation ({});
803+
804+
if (!invoke)
805+
return nullptr;
806+
807+
return std::unique_ptr<AST::AttrInput> (
808+
new AST::AttrInputMacro (std::move (invoke)));
809+
}
810+
796811
/* Ensure token is a "literal expression" (literally only a literal
797812
* token of any type) */
798813
if (!t->is_literal ())
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#![doc = concat!("AB")]

0 commit comments

Comments
 (0)