diff --git a/gcc/rust/parse/rust-parse-impl-expr.hxx b/gcc/rust/parse/rust-parse-impl-expr.hxx index 4de5599d62e..2a2d844b7fa 100644 --- a/gcc/rust/parse/rust-parse-impl-expr.hxx +++ b/gcc/rust/parse/rust-parse-impl-expr.hxx @@ -1957,9 +1957,15 @@ Parser::null_denotation_path ( switch (t->get_id ()) { case EXCLAM: - // macro - return parse_macro_invocation_partial (std::move (path), - std::move (outer_attrs)); + { + // macro + auto macro = parse_macro_invocation_partial (std::move (path), + std::move (outer_attrs)); + if (macro == nullptr) + return tl::unexpected ( + Parse::Error::Expr::CHILD_ERROR); + return std::unique_ptr (std::move (macro)); + } case LEFT_CURLY: { bool not_a_block = lexer.peek_token (1)->get_id () == IDENTIFIER diff --git a/gcc/testsuite/rust/compile/issue-4412.rs b/gcc/testsuite/rust/compile/issue-4412.rs new file mode 100644 index 00000000000..6ed93d0d789 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-4412.rs @@ -0,0 +1,9 @@ +// { dg-options "-frust-incomplete-and-experimental-compiler-do-not-use" } +#![feature(no_core)] +#![no_core] +struct Bug([u8; panic!"\t"]); +// { dg-error "unexpected token" "" { target *-*-* } .-1 } +// { dg-error "failed to parse" "" { target *-*-* } .-2 } +// { dg-error "could not parse" "" { target *-*-* } .-3 } +// { dg-error "expecting" "" { target *-*-* } .-4 } +fn main() {} \ No newline at end of file