gcc/rust/ChangeLog:
* parse/rust-parse-impl.h
(Parser::null_denotation): Allow struct expression referencing.
gcc/testsuite/ChangeLog:
* rust/compile/struct-expr-parse.rs: New test.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
std::unique_ptr<AST::Expr> expr = nullptr;
bool is_mut_borrow = false;
- /* HACK: as struct expressions should always be value expressions,
- * cannot be referenced */
ParseRestrictions entered_from_unary;
entered_from_unary.entered_from_unary = true;
- entered_from_unary.can_be_struct_expr = false;
+ if (!restrictions.can_be_struct_expr)
+ entered_from_unary.can_be_struct_expr = false;
if (lexer.peek_token ()->get_id () == MUT)
{
--- /dev/null
+struct A { // { dg-warning "struct is never constructed" }
+ a: u32
+}
+
+pub fn foo(a: u32) {
+ (&A { a }.a, 1);
+}