From patchwork Thu Apr 12 17:07:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 26696 Received: (qmail 123032 invoked by alias); 12 Apr 2018 17:07:10 -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 123021 invoked by uid 89); 12 Apr 2018 17:07:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.2 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=tom@tromey.com, D*tromey.com, tomtromeycom, fedora X-HELO: gateway23.websitewelcome.com Received: from gateway23.websitewelcome.com (HELO gateway23.websitewelcome.com) (192.185.49.184) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 12 Apr 2018 17:07:08 +0000 Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway23.websitewelcome.com (Postfix) with ESMTP id 015DE12727 for ; Thu, 12 Apr 2018 12:07:07 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 6fggfkUHYh46F6fggfmeOI; Thu, 12 Apr 2018 12:07:06 -0500 Received: from 75-166-37-45.hlrn.qwest.net ([75.166.37.45]:54258 helo=pokyo.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1f6fgg-001HNB-ON; Thu, 12 Apr 2018 12:07:06 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [FYI] Remove old univariant code from rust-lang.c Date: Thu, 12 Apr 2018 11:07:03 -0600 Message-Id: <20180412170703.7595-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1f6fgg-001HNB-ON X-Source-Sender: 75-166-37-45.hlrn.qwest.net (pokyo.Home) [75.166.37.45]:54258 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes Since moving Rust enum handling into dwarf2read.c, some old code for handling univariant enums in rust-lang.c has been obsolete. This patch removes this code. Tested on x86-64 Fedora 26, using rustc 1.23 (1.24 emits incorrect DWARF for enums and so can't be used for this test). 2018-04-12 Tom Tromey * rust-lang.c (rust_print_struct_def): Remove univariant code. (rust_evaluate_subexp): Likewise. --- gdb/ChangeLog | 5 +++++ gdb/rust-lang.c | 25 ++----------------------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 66ca520aad..836ac9e100 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2018-04-12 Tom Tromey + + * rust-lang.c (rust_print_struct_def): Remove univariant code. + (rust_evaluate_subexp): Likewise. + 2018-04-12 Pedro Alves * procfs.c (procfs_detach): Make forward declaration's prototype diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 6e0537f358..cf8a15ee43 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -631,7 +631,6 @@ rust_print_struct_def (struct type *type, const char *varstring, bool is_tuple_struct = rust_tuple_struct_type_p (type); bool is_tuple = rust_tuple_type_p (type); bool is_enum = rust_enum_p (type); - bool is_univariant = false; int enum_discriminant_index = -1; @@ -653,12 +652,6 @@ rust_print_struct_def (struct type *type, const char *varstring, = (struct discriminant_info *) discriminant_prop->data.baton; enum_discriminant_index = info->discriminant_index; } - else if (TYPE_CODE (type) == TYPE_CODE_UNION && TYPE_NFIELDS (type) == 1) - { - /* Probably a univariant enum. */ - fputs_filtered ("enum ", stream); - is_univariant = true; - } else if (TYPE_CODE (type) == TYPE_CODE_STRUCT) fputs_filtered ("struct ", stream); else @@ -695,19 +688,12 @@ rust_print_struct_def (struct type *type, const char *varstring, continue; fputs_filtered (TYPE_FIELD_NAME (type, i), stream); } - else if (is_univariant) - { - const char *name - = rust_last_path_segment (TYPE_NAME (TYPE_FIELD_TYPE (type, i))); - fputs_filtered (name, stream); - } else if (!is_tuple_struct) fprintf_filtered (stream, "%s: ", TYPE_FIELD_NAME (type, i)); rust_internal_print_type (TYPE_FIELD_TYPE (type, i), NULL, - stream, - ((is_enum || is_univariant) ? show : show - 1), - level + 2, flags, is_enum || is_univariant); + stream, (is_enum ? show : show - 1), + level + 2, flags, is_enum); if (!for_rust_enum) fputs_filtered (",\n", stream); else if (i + 1 < TYPE_NFIELDS (type)) @@ -1592,13 +1578,6 @@ rust_evaluate_subexp (struct type *expect_type, struct expression *exp, type = value_type (lhs); - /* Treat a univariant union as if it were an enum. */ - if (TYPE_CODE (type) == TYPE_CODE_UNION && TYPE_NFIELDS (type) == 1) - { - lhs = value_primitive_field (lhs, 0, 0, type); - type = value_type (lhs); - } - if (TYPE_CODE (type) == TYPE_CODE_STRUCT) { struct type *outer_type = NULL;