From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 90001 invoked by alias); 27 Jun 2016 16:15:40 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 89987 invoked by uid 89); 27 Jun 2016 16:15:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=HTo:U*manish, TYPE_LENGTH, type_length X-HELO: gproxy5-pub.mail.unifiedlayer.com Received: from gproxy5-pub.mail.unifiedlayer.com (HELO gproxy5-pub.mail.unifiedlayer.com) (67.222.38.55) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Mon, 27 Jun 2016 16:15:29 +0000 Received: (qmail 8839 invoked by uid 0); 27 Jun 2016 16:15:27 -0000 Received: from unknown (HELO cmgw4) (10.0.90.85) by gproxy5.mail.unifiedlayer.com with SMTP; 27 Jun 2016 16:15:27 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw4 with id BsFN1t00s2f2jeq01sFRSB; Mon, 27 Jun 2016 10:15:27 -0600 X-Authority-Analysis: v=2.1 cv=ecGuId0H c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=PnD2wP_eR3oA:10 a=7XZj0uCbPdcA:10 a=pD_ry4oyNxEA:10 a=BzObnAOqAAAA:8 a=tKEbIys39E10XXt8m8gA:9 a=PuSIgb6VMkSJ0_1bSHE4:22 Received: from [75.171.172.174] (port=41748 helo=pokyo) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2) (envelope-from ) id 1bHZBy-0004f6-Dd; Mon, 27 Jun 2016 10:15:22 -0600 From: Tom Tromey To: Manish Goregaokar Cc: gdb-patches@sourceware.org, Tom Tromey Subject: Re: [PATCH] Print void types correctly in Rust References: Date: Mon, 27 Jun 2016 16:15:00 -0000 In-Reply-To: (Manish Goregaokar's message of "Mon, 27 Jun 2016 21:22:33 +0530") Message-ID: <8760suk3qg.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.95 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Identified-User: {36111:box522.bluehost.com:elynrobi:tromey.com} {sentby:smtp auth 75.171.172.174 authed with tom+tromey.com} X-Exim-ID: 1bHZBy-0004f6-Dd X-Source-Sender: (pokyo) [75.171.172.174]:41748 X-Source-Auth: tom+tromey.com X-Email-Count: 0 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-SW-Source: 2016-06/txt/msg00448.txt.bz2 >>>>> "Manish" == Manish Goregaokar writes: Manish> Rust prefers to not specify the return type of a function when it is unit Manish> (`()`). The type is also referred to as "void" in debuginfo but not in actual Manish> usage, so we should never be printing "void" when the language is Rust. Thanks for finding and fixing this. The patch looks good overall but I have a few questions and some nits. Manish> * rust-lang.c: Print unit types as "()" Manish> * rust-lang.c: Omit return type for functions returning unit A ChangeLog entry is supposed to refer to function and variable names, so more like: * rust-lang.c (rust_decorations): Spell "void" as "()". (rust_print_type): Likewise. ... Manish> + /* Rust calls the unit type "void" in its debuginfo, Manish> + but we don't want to print it as that. */ Manish> + if (TYPE_CODE (type) == TYPE_CODE_VOID) Manish> + fputs_filtered ("()", stream); Manish> + else Manish> + fputs_filtered (TYPE_NAME (type), stream); This is fine but there is another case in rust_val_print: case TYPE_CODE_INT: /* Recognize the unit type. */ if (TYPE_UNSIGNED (type) && TYPE_LENGTH (type) == 0 && TYPE_NAME (type) != NULL && strcmp (TYPE_NAME (type), "()") == 0) { fputs_filtered ("()", stream); break; } goto generic_print; ... I wonder if that is something that changed after 1.8, or if it's the case that the unit type can be represented in multiple ways. (Or maybe this only handles the unit type constructed by rust_language_arch_info?) Anyway I wonder if a case like this is needed in rust_print_type, or if the one in rust_val_print can be removed or changed. Manish> + if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID) Manish> + { Manish> + fputs_filtered (" -> ", stream); Manish> + rust_print_type (TYPE_TARGET_TYPE (type), "", stream, -1, 0, flags); This should be formatted like: + if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID) + { + fputs_filtered (" -> ", stream); + rust_print_type (TYPE_TARGET_TYPE (type), "", stream, -1, 0, flags); Manish> +// Empty function, should not have "void" Manish> +// or "()" in its return type Manish> +fn empty() { I'm curious what happens if it does say "-> ()"? Tom