From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7905) id 0ACE03857C43; Tue, 16 Jan 2024 18:08:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0ACE03857C43 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705428502; bh=6fT8/8qLTWhqEamubD/d6/IXxVHaiHU51bNYE1AT3so=; h=From:To:Subject:Date:From; b=hfmJU4OcEg2bFuJOYTg86fqKP9gSqhtEX1jpjsqk4TqPaItrFhsLvbei09QPQLmJo oLMQsr9Jo8AX/P+Tzm5vJe3tFSXgfqLjmrQUXUqblFaLbxWkfCUT/Ncw5f+Sy+adyR bcOG3hI2XVmdBWOFpuPVrCj1sZBpYBIGBw5V0RSk= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Arthur Cohen To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-7931] gccrs: Non-allowed default type paramters X-Act-Checkin: gcc X-Git-Author: Muhammad Mahad X-Git-Refname: refs/heads/trunk X-Git-Oldrev: b763d736a10793420945882436d7490385c7dc2d X-Git-Newrev: dd343c42d25d2ab2cc1549c5cf608d7d6b3f0589 Message-Id: <20240116180822.0ACE03857C43@sourceware.org> Date: Tue, 16 Jan 2024 18:08:22 +0000 (GMT) List-Id: https://gcc.gnu.org/g:dd343c42d25d2ab2cc1549c5cf608d7d6b3f0589 commit r14-7931-gdd343c42d25d2ab2cc1549c5cf608d7d6b3f0589 Author: Muhammad Mahad Date: Mon Aug 14 17:09:25 2023 +0500 gccrs: Non-allowed default type paramters gcc/rust/ChangeLog: * hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): Added more helpful error message. gcc/testsuite/ChangeLog: * rust/compile/generics10.rs: for dejagnu. Signed-off-by: Muhammad Mahad Diff: --- gcc/rust/hir/rust-ast-lower-item.cc | 24 +++++++++++++++++------- gcc/testsuite/rust/compile/generics10.rs | 2 +- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/gcc/rust/hir/rust-ast-lower-item.cc b/gcc/rust/hir/rust-ast-lower-item.cc index 6eaf75ffd0b..6d91c23e8d2 100644 --- a/gcc/rust/hir/rust-ast-lower-item.cc +++ b/gcc/rust/hir/rust-ast-lower-item.cc @@ -499,10 +499,15 @@ ASTLoweringItem::visit (AST::InherentImpl &impl_block) if (t.has_type ()) { - // see https://github.com/rust-lang/rust/issues/36887 - rust_error_at ( + rich_location rich_locus (line_table, t.get_locus ()); + rich_locus.add_fixit_replace ( t.get_locus (), - "defaults for type parameters are not allowed here"); + "for more information, see issue #36887 " + ""); + rust_error_at (rich_locus, + "defaults for type parameters are only " + "allowed in %, %, %, " + "or % definitions"); } } break; @@ -645,10 +650,15 @@ ASTLoweringItem::visit (AST::TraitImpl &impl_block) if (t.has_type ()) { - // see https://github.com/rust-lang/rust/issues/36887 - rust_error_at ( - t.get_locus (), - "defaults for type parameters are not allowed here"); + rich_location rich_locus (line_table, t.get_locus ()); + rich_locus.add_fixit_replace ( + t.get_locus (), "for more information, see issue #36887 " + ""); + rust_error_at (rich_locus, + "defaults for type parameters are only " + "allowed in %, %, %, " + "or % definitions"); } } break; diff --git a/gcc/testsuite/rust/compile/generics10.rs b/gcc/testsuite/rust/compile/generics10.rs index a734fa8a197..c66a08f7e16 100644 --- a/gcc/testsuite/rust/compile/generics10.rs +++ b/gcc/testsuite/rust/compile/generics10.rs @@ -1,6 +1,6 @@ struct Foo(A, B); -impl Foo { // { dg-error "defaults for type parameters are not allowed here" } +impl Foo { // { dg-error "defaults for type parameters are only allowed in .struct., .enum., .type., or .trait. definitions" } fn new(a: X, b: f32) -> Self { Self(a, b) }