From patchwork Thu Sep 13 17:01:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 29366 Received: (qmail 116144 invoked by alias); 13 Sep 2018 17:01:55 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 116128 invoked by uid 89); 13 Sep 2018 17:01:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: gateway33.websitewelcome.com Received: from gateway33.websitewelcome.com (HELO gateway33.websitewelcome.com) (192.185.146.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Sep 2018 17:01:54 +0000 Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway33.websitewelcome.com (Postfix) with ESMTP id D0785A6654A for ; Thu, 13 Sep 2018 12:01:51 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 0UzQgLxy1bXuJ0UzjgenV0; Thu, 13 Sep 2018 12:01:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=7m1QmuQzV1J5ZYTzwKsrsbloYnzWZikqRquOoqVMauk=; b=GHzc8mXYZtjfetAtc52G+7wEt8 h/imfQL+hD8CjlS2crf3WEo+KSd0r34V1TwJoJPlbB9ep63ZY7yylzf1/NXah3gXN11032o1ClEsu zIJyH9tZ+8Xe+gZBTnR6F4X9H; Received: from 97-122-189-157.hlrn.qwest.net ([97.122.189.157]:39342 helo=pokyo.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1g0UzP-002XV4-VG; Thu, 13 Sep 2018 12:01:12 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [FYI v2 2/2] Make Rust error message mention the field name Date: Thu, 13 Sep 2018 11:01:09 -0600 Message-Id: <20180913170109.30237-3-tom@tromey.com> In-Reply-To: <20180913170109.30237-1-tom@tromey.com> References: <20180913170109.30237-1-tom@tromey.com> 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 PR rust/23650: * rust-lang.c (rust_evaluate_subexp): Use field name, not "foo". gdb/testsuite/ChangeLog 2018-09-13 Tom Tromey PR rust/23650: * gdb.rust/simple.exp: Add test for enum field access error. --- 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 1613808a6c..5783e7cb0a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2018-09-13 Tom Tromey + + PR rust/23650: + * rust-lang.c (rust_evaluate_subexp): Use field name, not "foo". + 2018-09-13 Tom Tromey PR rust/23626: diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index b77738979f..43db722142 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 c356d0287a..7d6a2ecbf0 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-09-13 Tom Tromey + + PR rust/23650: + * gdb.rust/simple.exp: Add test for enum field access error. + 2018-09-13 Tom Tromey PR rust/23626: diff --git a/gdb/testsuite/gdb.rust/simple.exp b/gdb/testsuite/gdb.rust/simple.exp index 07b2512220..956a6ca6fe 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 \\{"