From 12df5c002dcbfc5ac54983e1e7040a182f71a753 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 11 Jul 2016 15:02:10 -0600 Subject: Allow empty struct expressions in Rust I learned recently that empty struct expressions, like "X{}", have been promoted from experimental to stable in Rust. This patch changes the Rust expression parser to allow this case. New test case included. Built and regtested on x86-64 Fedora 23, using Rust 1.11 beta. 2016-07-21 Tom Tromey * rust-lang.c (rust_tuple_struct_type_p): Return false for empty structs. * rust-exp.y (struct_expr_list): Allow empty elements. 2016-07-21 Tom Tromey * gdb.rust/simple.rs (main): Use empty struct expression. * gdb.rust/simple.exp: Add tests for empty struct expression. --- gdb/rust-lang.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'gdb/rust-lang.c') diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 3deb525..481a4fc 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -294,7 +294,10 @@ rust_underscore_fields (struct type *type, int offset) int rust_tuple_struct_type_p (struct type *type) { - return rust_underscore_fields (type, 0); + /* This is just an approximation until DWARF can represent Rust more + precisely. We exclude zero-length structs because they may not + be tuple structs, and there's no way to tell. */ + return TYPE_NFIELDS (type) > 0 && rust_underscore_fields (type, 0); } /* Return true if a variant TYPE is a tuple variant, false otherwise. */ -- cgit v1.1