From patchwork Tue Jan 30 12:06:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 194086 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1183289dyb; Tue, 30 Jan 2024 04:29:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IHocVMwNnDidaMMlm4H4MAe4BxIwaUKaMWRfKoH4HzIGFuNTO8hfhBpUbye3IgRGeuSIBJd X-Received: by 2002:a67:fe90:0:b0:46b:16fe:8871 with SMTP id b16-20020a67fe90000000b0046b16fe8871mr4150917vsr.65.1706617740501; Tue, 30 Jan 2024 04:29:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706617740; cv=pass; d=google.com; s=arc-20160816; b=CE0Ni/9ZP0mLfoywSnG0gdKVAqK+3yHFiqO9ULf4Ncs+haoion1Uz+QoCl5t1XKMGb zaClxuyp9l0GuVTlTeWn6JvMS22jar648SlaOhocAsAFwn6gOqHz4ubBEwbN/lGwo1I3 0figpdmjOK1vXVMOfVb2s0Lt5kMArWHqTLD/sAX2j7s0Ya6/rKAjyBMTrT5DedZJGGCu pZbVSlZKTFyXRFEvvCH6HC6TIAj7THqipUUydpXHAOSnlxTQ4glg+ct0PkydWzqQNq13 zqsXKNhZsSlcKt6PR7aqDkBp8roiDFFzjUYdDxCBGnisBlfv6+WAZimINNYZJ6iJRoRy sDFw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=JlNvBoB9Z/n9/WwzWrOvY19COsZ5wSmxkFc1drcPtbI=; fh=s1GzlUPo1djGkCl3rkRJI30hDOSCVwGp0RAbVwQ8dxQ=; b=LIIUJbmLVTcWuFt3LRrGbBocPdXG035C1AqYEgPGeb+8zz0FJss5Od6bYz4EYIRDwb OSh9guUOe9r+BNepmIcu9dnngzlL9TrZdVolKYHQVr7plvexoFuXP1QZ1GN4MuqS2Sxe f6Z471ms5DT/KV0NyJvLshQvr+jxkR2Cn4WjhdbQGRGgsPZTd3YMDl7UzAQuv+8W8L/Y lMaw36sFNikcaRQ8wweUx3FlZqukG68roB8Fu2UN7yVD+QFXlsldpBuLAbaktmtndnod WgoqZqbzTtZJ9n41Mdraw/0FkWepY/00qY/sh89eeP6DH7q4VnX3kwAdz9wKPxDE6H1a 3VoQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=Qp4hDwi2; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id r8-20020a056214212800b0068c51beaeeasi3636026qvc.127.2024.01.30.04.29.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 04:29:00 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=Qp4hDwi2; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 75F7F38618AE for ; Tue, 30 Jan 2024 12:28:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by sourceware.org (Postfix) with ESMTPS id A454F385800C for ; Tue, 30 Jan 2024 12:11:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A454F385800C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A454F385800C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::434 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616672; cv=none; b=X7QgVlBAmkEuEAd1mH0ICeG5e6uktNv+Vh9VA32c+bZMun9/clmdEHoOaKQ7Ro8CaJxox6IuJZXfU7CzujQ2W819gPF+sEpAOiKi1/6ILvDDuvi0aGVxQlt93dgkF0MkZzL2woP6Ro7JCWNjZ3YDGL1Ug/2ML2N70QGXGsRZ464= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616672; c=relaxed/simple; bh=f/eweAY8QY1x3Z3GLRKbV18bHJaX+5nlabgR0C4BgMY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ivxZ+xiQcQScCSCNQIzgfzigPZ3fo5mmwARHoQdteDbQHJVaDBXOMrWZTezOAZnza00VP4WcLvYBVFJJJMODxSmhY05dHQqfBlL3wqn8gAAZJapBqRwDi5tq5cLQHqVYjkbf2tI3qiOQqoJtUupefTX++lSa2iBcVPRnSRXHFa4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-33af3c7ef60so1151870f8f.0 for ; Tue, 30 Jan 2024 04:11:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1706616662; x=1707221462; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=JlNvBoB9Z/n9/WwzWrOvY19COsZ5wSmxkFc1drcPtbI=; b=Qp4hDwi2+vMXlO3SoA1oe/Bg4kxczq27a/qkFOi3c8M+QaChfvyIN5TjRWM87uWRWj 18RYG8Rr91hkDLEOKMMs77r0LIq2QQHLFIj5hoxm/XI8Mi/EYSTLzzc0tk8IvHKhQfj8 yKg6JTT6pM890vaIzctLxquDVnZROmSlU+OM2j69oV+/1j0YAdnyWMvsWJRImCgYP9ZH q5yj6j/M2rmVySKh1gP0YevSI9PexTJRsWikWc9zxXxF4UIpY/obv1la75H7jOBvw8R4 r/BcQyXpgiA8mrvwazVviQrdGVe39S4nWrB5G+vUgzcz/1xzjxawHbSzyYqIm91vB+9Q n6lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706616662; x=1707221462; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=JlNvBoB9Z/n9/WwzWrOvY19COsZ5wSmxkFc1drcPtbI=; b=IE775Qu3Zmaei49DrpA7U1jeTT2bR/doZAXp3zFePi+BpWduWZJhQ5UKbtX1663rdi pQC78tEnBcZb+aGUyIOltyqDvEgOOPC1gAc1m+kJQefQ1rh/11JosPJxU7kI+seXSGQb rMOQil4bd3sKGSpVgzOkHeHtMxQiSXOldofxlUhKplJ5rAxAJfxMyP+OHtAF8L36AMTb 8P9XVk973uBF6HusEcbd/etzQ+rSh7Y5LgeEYwDmnZS3usxMYSMXLU/bQ9lMcYSjxcux spyV1I5hAckHYCsvgNg0fAlf9SCQn/R63/dZot7VLjN+nf0HaS0iVpP4MuPp1wTdJpTL 0QIg== X-Gm-Message-State: AOJu0YwnXoQfppxH0VNXFoeQw/pjqSdWKRTulvEvhlqlfYiXcZacZKTX VIik7r6K4rgqK51oisHB86OYlZBHi51nhl52tJcxkCfqnjpJCdXFjoMM3PPKlFKaZFNsO0m5aaz N7Q== X-Received: by 2002:a5d:51ca:0:b0:33a:ee39:5b4a with SMTP id n10-20020a5d51ca000000b0033aee395b4amr4103305wrv.36.1706616662181; Tue, 30 Jan 2024 04:11:02 -0800 (PST) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id f9-20020a056000036900b00339307d9d31sm10569894wrf.112.2024.01.30.04.11.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 04:11:01 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Pierre-Emmanuel Patry Subject: [COMMITTED 016/101] gccrs: Reject auto traits with generic parameters Date: Tue, 30 Jan 2024 13:06:32 +0100 Message-ID: <20240130121026.807464-19-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20240130121026.807464-2-arthur.cohen@embecosm.com> References: <20240130121026.807464-2-arthur.cohen@embecosm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: arthur.cohen@embecosm.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789518403755711664 X-GMAIL-MSGID: 1789518403755711664 From: Pierre-Emmanuel Patry Generic parameters are not allowed on auto traits, the compiler should emit an error. gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Add check for generics on auto traits. * checks/errors/rust-ast-validation.h: Add visit function prototype. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/checks/errors/rust-ast-validation.cc | 14 ++++++++++++++ gcc/rust/checks/errors/rust-ast-validation.h | 1 + 2 files changed, 15 insertions(+) diff --git a/gcc/rust/checks/errors/rust-ast-validation.cc b/gcc/rust/checks/errors/rust-ast-validation.cc index f6ce45eacca..37d3668a9e0 100644 --- a/gcc/rust/checks/errors/rust-ast-validation.cc +++ b/gcc/rust/checks/errors/rust-ast-validation.cc @@ -96,4 +96,18 @@ ASTValidation::visit (AST::Function &function) AST::ContextualASTVisitor::visit (function); } +void +ASTValidation::visit (AST::Trait &trait) +{ + if (trait.is_auto ()) + { + if (trait.has_generics ()) + rust_error_at (trait.get_generic_params ()[0]->get_locus (), + ErrorCode::E0567, + "auto traits cannot have generic parameters"); + } + + AST::ContextualASTVisitor::visit (trait); +} + } // namespace Rust diff --git a/gcc/rust/checks/errors/rust-ast-validation.h b/gcc/rust/checks/errors/rust-ast-validation.h index 44995eb1fbc..49133ee0c3d 100644 --- a/gcc/rust/checks/errors/rust-ast-validation.h +++ b/gcc/rust/checks/errors/rust-ast-validation.h @@ -38,6 +38,7 @@ public: virtual void visit (AST::LoopLabel &label); virtual void visit (AST::ExternalFunctionItem &item); virtual void visit (AST::Function &function); + virtual void visit (AST::Trait &trait); }; } // namespace Rust