From patchwork Tue Jan 30 12:07:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 1892913 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=embecosm.com header.i=@embecosm.com header.a=rsa-sha256 header.s=google header.b=DjeABG0v; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TPQ325SHdz23gc for ; Tue, 30 Jan 2024 23:49:02 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 99D5D386483A for ; Tue, 30 Jan 2024 12:49:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id AFF493857712 for ; Tue, 30 Jan 2024 12:11:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AFF493857712 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 AFF493857712 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::329 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616755; cv=none; b=GIY9LkvCcN+dr01+nv/gPOwKPcqSUvVNfhcvVTZ9yftfHj24Vo46a8VxAytCK5fOPFY13CekW7a+Cb8iCqrYm5jbBqD3YUSsAY5TIQp24f3dmShEKIEd2NQQp22I2V4xHnq7FIMCY/UkEAoFSzkAq6S7uAP4uvASMV7ShjFBHTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616755; c=relaxed/simple; bh=JDGFYD/XD8zgA0vk8AQ9CI+ljipxYg5B1XmpqYksP2o=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=sCC1bOhaRwu/NQ+w4jz24/5rm4bHNUevbRd8HFWFxC5GbJuBo0YoSRca5F6VC1CjTd2iQbXrK+vdxNiz1x5Mf8JRDTfStooV/VKX8L9mNPbpK8+vPlzx+7wrUloneIF5is8sBI2/VrbcWTqzqEvH3PhM33IW10DQBHxJemJzeZQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-40e5afc18f5so41949755e9.3 for ; Tue, 30 Jan 2024 04:11:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1706616709; x=1707221509; 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=fTlsG0U+P+xPeCbxGECUsEuoD2TRCDBbPHKYwC7Rj0w=; b=DjeABG0vhDhBUQG8onCvzF6GkVFcN0fT5ShyRr43qZTWl3ZwTU4zoi96dfua8xBTbc JIV55BzJylmb9GQoCuNtpQw+v7yW2X/aMWS1f6BUiYi8ATveZ7IytSF+8eVamFxsGG8s SYJ4FR0qM/YjBl+yqETZls9PQrxD1x3ZH9DVsWLWBhJorq5HE3M9u7mC+dqvoacc861v yDIubRsJWy5iRdve9i7t/O1XZm5dnO72gtv4GyW3EhHQ2YgB2YYgkGelnQ8BuN3+3Lck 7t5sengCjPCTtADA+06yIJKNxB1kN3ji9EzARXeUtfOjyxR/Snv5BFa5tHqQeScrnL2o pnXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706616709; x=1707221509; 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=fTlsG0U+P+xPeCbxGECUsEuoD2TRCDBbPHKYwC7Rj0w=; b=JKy0Zi/7Yi8a/lQAiItoelJ7C6NMpf5K7F986ygZS/E8RXs7k3kWxBsDC2k61tPiVT CLCKS/NNGmHvLb2MFZZea8tgiip69g7TCo8XXdp3CKJb6hpu36P5I/fwMd0qS/Ua5A0t Dp5mDmdtnGySSQS76SvQOpACJopd+y/cwbX9BFEmxwkcb7TfgtlUWgvbtnMqvyV3yynj kDyHxtTHNElFUZSOB50aAqUma6OWLM/74W/CObaryC58moEUUoMrd4O2pzusILLFFVST quNgfWr3epE5ZEHArMJLqSvwVocrI6KUJh5yF6dQl0DuYWKVTmDlrZ2pdwMNZ/Y+I3Zv E8fw== X-Gm-Message-State: AOJu0YwVc5Y0vpjz+MD82br8d7oXVKTK3ApSrJJTlgDQBM/u/5e3Uvji ONlNzHbG31pfP87whjiSPCcY6dmA8GO7nVenqS69YC9I/OuK6ycelnPzQT50hRXmPemT17UfqA+ A0w== X-Google-Smtp-Source: AGHT+IHx8bsT752hNnhZr3v/jHRpydWw9MPY/X3lZad9CLWYzg4rAE0p7iOWMHY/XUQ4qxTibCSYcQ== X-Received: by 2002:adf:ea0b:0:b0:33a:e6dc:2e98 with SMTP id q11-20020adfea0b000000b0033ae6dc2e98mr5355938wrm.5.1706616709407; Tue, 30 Jan 2024 04:11:49 -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.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 04:11:48 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Kushal Pal Subject: [COMMITTED 081/101] gccrs: Generate error for `async` trait fucntions Date: Tue, 30 Jan 2024 13:07:37 +0100 Message-ID: <20240130121026.807464-84-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=unavailable 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+incoming=patchwork.ozlabs.org@gcc.gnu.org From: Kushal Pal Fixes #2767 gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Added check for `async` function inside trait. gcc/testsuite/ChangeLog: * rust/compile/issue-2767.rs: New test. Signed-off-by: Kushal Pal --- gcc/rust/checks/errors/rust-ast-validation.cc | 5 +++++ gcc/testsuite/rust/compile/issue-2767.rs | 13 +++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 gcc/testsuite/rust/compile/issue-2767.rs diff --git a/gcc/rust/checks/errors/rust-ast-validation.cc b/gcc/rust/checks/errors/rust-ast-validation.cc index cd197fc1ea7..b50e9cdf858 100644 --- a/gcc/rust/checks/errors/rust-ast-validation.cc +++ b/gcc/rust/checks/errors/rust-ast-validation.cc @@ -107,6 +107,11 @@ ASTValidation::visit (AST::Function &function) rust_error_at (function.get_locus (), ErrorCode::E0379, "functions in traits cannot be declared const"); + // may change soon + if (qualifiers.is_async () && context.back () == Context::TRAIT_IMPL) + rust_error_at (function.get_locus (), ErrorCode::E0706, + "functions in traits cannot be declared %"); + if (valid_context.find (context.back ()) == valid_context.end () && function.has_self_param ()) rust_error_at ( diff --git a/gcc/testsuite/rust/compile/issue-2767.rs b/gcc/testsuite/rust/compile/issue-2767.rs new file mode 100644 index 00000000000..9e7e0f983d2 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-2767.rs @@ -0,0 +1,13 @@ +// { dg-additional-options "-frust-edition=2018" } +trait Foo { + fn f() -> u32; +} + +impl Foo for u32 { + async fn f() -> u32 { + // { dg-error "functions in traits cannot be declared .async." "" { target *-*-* } .-1 } + 22 + } +} + +fn main() {}