This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Make Rust error message mention the field name


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4a3fe98f885a2d1db804584e7ea265ab3ccef4d7

commit 4a3fe98f885a2d1db804584e7ea265ab3ccef4d7
Author: Tom Tromey <tom@tromey.com>
Date:   Thu Sep 13 10:56:34 2018 -0600

    Make Rust error message mention the field name
    
    I noticed a spot in rust-lang.c where the placeholder "foo" was used
    instead of the actual field name.  This patch fixes the bug.
    
    gdb/ChangeLog
    2018-09-13  Tom Tromey  <tom@tromey.com>
    
    	PR rust/23650:
    	* rust-lang.c (rust_evaluate_subexp): Use field name, not "foo".
    
    gdb/testsuite/ChangeLog
    2018-09-13  Tom Tromey  <tom@tromey.com>
    
    	PR rust/23650:
    	* gdb.rust/simple.exp: Add test for enum field access error.

Diff:
---
 gdb/ChangeLog                     | 5 +++++
 gdb/rust-lang.c                   | 4 ++--
 gdb/testsuite/ChangeLog           | 5 +++++
 gdb/testsuite/gdb.rust/simple.exp | 2 ++
 4 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1613808..5783e7c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2018-09-13  Tom Tromey  <tom@tromey.com>
 
+	PR rust/23650:
+	* rust-lang.c (rust_evaluate_subexp): Use field name, not "foo".
+
+2018-09-13  Tom Tromey  <tom@tromey.com>
+
 	PR rust/23626:
 	* rust-lang.c (rust_enum_variant): Now static.
 	(rust_empty_enum_p): New function.
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index b777389..43db722 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -1726,9 +1726,9 @@ tuple structs, and tuple-like enum variants"));
 	    struct type *outer_type = type;
 	    type = value_type (lhs);
 	    if (rust_tuple_type_p (type) || rust_tuple_struct_type_p (type))
-		error (_("Attempting to access named field foo of tuple "
+		error (_("Attempting to access named field %s of tuple "
 			 "variant %s::%s, which has only anonymous fields"),
-		       TYPE_NAME (outer_type),
+		       field_name, TYPE_NAME (outer_type),
 		       rust_last_path_segment (TYPE_NAME (type)));
 
 	    TRY
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index c356d02..7d6a2ec 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,10 @@
 2018-09-13  Tom Tromey  <tom@tromey.com>
 
+	PR rust/23650:
+	* gdb.rust/simple.exp: Add test for enum field access error.
+
+2018-09-13  Tom Tromey  <tom@tromey.com>
+
 	PR rust/23626:
 	* gdb.rust/simple.rs (EmptyEnum): New type.
 	(main): Use it.
diff --git a/gdb/testsuite/gdb.rust/simple.exp b/gdb/testsuite/gdb.rust/simple.exp
index 07b2512..956a6ca 100644
--- a/gdb/testsuite/gdb.rust/simple.exp
+++ b/gdb/testsuite/gdb.rust/simple.exp
@@ -134,6 +134,8 @@ gdb_test "print univariant" " = simple::Univariant::Foo{a: 1}"
 gdb_test "print univariant.a" " = 1"
 gdb_test "print univariant_anon" " = simple::UnivariantAnon::Foo\\(1\\)"
 gdb_test "print univariant_anon.0" " = 1"
+gdb_test "print univariant_anon.sss" \
+    "Attempting to access named field sss of tuple variant simple::UnivariantAnon::Foo, which has only anonymous fields"
 
 gdb_test_sequence "ptype simple::Univariant" "" {
     "type = enum simple::Univariant \\{"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]