Message ID | 20240130121026.807464-92-arthur.cohen@embecosm.com |
---|---|
State | Unresolved |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1195131dyb; Tue, 30 Jan 2024 04:51:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IFVVezg1pqvntA2mC3NIrKW7AygcWuKZHt2k4iIsjAMpTtf8pRBgJikReatRo+MI1Y128M+ X-Received: by 2002:a05:622a:5c99:b0:42a:7122:61db with SMTP id ge25-20020a05622a5c9900b0042a712261dbmr12414041qtb.20.1706619064196; Tue, 30 Jan 2024 04:51:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706619064; cv=pass; d=google.com; s=arc-20160816; b=FqDXiP+BiZQyA++xwH5ggAOL9vjE+7Rum+7SVg48XAW7GrBNlmT2YsHhb2+BPsmxdS 1yqNU0XFFxQy7AHu+JVhiqWJKfgEQAv+hHTCrzbs/1A1g8g23tqVrymQwZ7iJHBAYXeT XEqLmllQCicrlSkqFtszqm8hdnwQUnzbefgrEPt7Or2tBfW6frclD77HkrCgn5dUxtcY T+EGJQInFbKL4oLJEoF+vyGpVQooiYMJhOL19bUG1iZicrfcG0AP4VyKbEE6XRBjyTmf Aw2GMKt68xHC7xnXewXp5WRsNIRB6zotTY8H6SoiORi1HSeiJoehY8KiGZC5k+ga4b3G SPQA== 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=UHRqBOxOtqWYWRSwQg/aqnHJ0bDUu14A9mOmF+1PYW8=; fh=l06p/z5UT27+088UaGrnZSJk+7w7syaJEbG8CLKfrIk=; b=G68eeA3sDQD++KB4otyV2e54veh+W5mEfGwPhEtFB450tJtXMrORbpFm5j37CYhRdb rIbtJtKIG8TmujnuALCVk7ckP2GaqvsJxBcws3ChfXNWbRyTbNCVaHzPKTgtpYPbUMMM GIQ63gp+VnI+3dt26lK94c++OI24ielTDbBkWQxTvLrylLM98dRfDHV5Td0hHJVTwmWW cVr5Lf0xjMexs+FQnyF2ie+iaUawjpf40tMqSdx9QLblur0E4NgnAgHjB4CfUtywRKEC +i3yjtbnGwVHdspmF+B88zDzwCtAJSbKTP21ggv88wxqDSJ2Za49ZLLfRSNAp+ZmjCLd 1HGA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=CP+THBjL; 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 t17-20020a05622a149100b0042ab54356e6si1563184qtx.193.2024.01.30.04.51.04 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 04:51:04 -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=CP+THBjL; 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 D9564385E446 for <ouuuleilei@gmail.com>; Tue, 30 Jan 2024 12:51:03 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 135333857715 for <gcc-patches@gcc.gnu.org>; Tue, 30 Jan 2024 12:11:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 135333857715 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 135333857715 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::330 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616766; cv=none; b=ivxbCVyKePDiqLJ3Mo4nFeW3qKtYn6RxQF+dx90KELi14YmD5DO5lTRgVtZIgX19QYMwhsz7peFdYaMrHFtRp4GbgL3mZu+7ONwWA8QQUxq1kPoncNWTiW9oVvzjGYh2nhohk5W9zIVsKfdJS+d08XG8fdDwP1QEb6tC/9WdCog= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616766; c=relaxed/simple; bh=WLmEbuZuCNSzxnWiTdJoX7lGY8hInPsouNyCN9PkNvY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hf1Rr9PzDbj+KktubztlUVVnV2B19aNhqjLmahc/EBzqB+CEm2F+DBhFhn3emD5JitVtGgUj+943F3dgSn/oW7WpNdfqK776HUyBDCSHBuZE6r7aCYhU18fx7HdOjyDvo8p9rePVJFSxB6Dh/klZNLfxyA9z9KvevLA5JJxxbmM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-40eebe7767cso31016615e9.1 for <gcc-patches@gcc.gnu.org>; Tue, 30 Jan 2024 04:11:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1706616714; x=1707221514; 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=UHRqBOxOtqWYWRSwQg/aqnHJ0bDUu14A9mOmF+1PYW8=; b=CP+THBjL/6Aq+Wp5G/YTAg0AaNgr9pQBNs6FV3BUX2yD5M2Cn0kw9kda7es/Y4XvYd EYcN2qibUM8h69AiZlQDIGWXku/jkQ6GgqzMsowJ+YEVhFgjBlbjcAawZ+r6BRZqJpmk 25h/IbnYW/DYuLVu4QTBjy7CEj7XfhtidrscDKIsl0k8D4uwQPSL54ERyL4pxCaM45yv QhauAWRCqO7h5mlWUDBER2MODx3hsChgPe6jgW1avbCunWHp1/1XtDeGGJgG6a0HtD9b QUu5aHgo7t9qDjhusQbZMl+UF066MrsC5Zwc6OwvVpOobu1ea6K0+SPbL5wziR2lHN+f yN1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706616714; x=1707221514; 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=UHRqBOxOtqWYWRSwQg/aqnHJ0bDUu14A9mOmF+1PYW8=; b=KlKr0BuAYt6ge8OUVKqn77eeKx8IWLtF1Og/lbvWRJTjM7Y4/Sw+fcicGTUrh0mZ2Y rz827y1Rg8RLYhYiFUq6nKvz0tp52f0+owm32bHLqsn7CmVPQkeRyrFEvvxdP5zdxofc CfuEHeHV1IS0m+jE9MxXlO5G/U9u3za21lNOGYIfb7YSvXfbSLY6CbCtufDJJzN7vA+N izzVIRcYo921oV6xmSV1Jtqvqt1o5ITmeeVZTkba27o15mpjNs/1XVxe8p33nQXwJinN kPNWMfxaZCoC5muiCggPD73m3XkCw3BnbKWx1Oljj4ch7AbX5W4fQxDTqm6iqXj1AVjK nynw== X-Gm-Message-State: AOJu0YyPIHOFGA2qfrFXOwD2pmaR+m6wRTb2Yism92suE3T8bqNZ13IS 8eYSL5P2poxVYaKnBKrae3V2YwYN5I91I2E7RzdnNWKOpAGIe6ibjRu8k3a4dnwTC42d9xhdL4t XSA== X-Received: by 2002:a5d:53c5:0:b0:339:39c3:d274 with SMTP id a5-20020a5d53c5000000b0033939c3d274mr6953363wrw.36.1706616714182; Tue, 30 Jan 2024 04:11:54 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 04:11:53 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Kushal Pal <kushalpal109@gmail.com> Subject: [COMMITTED 089/101] gccrs: Handle `async` functions in traits Date: Tue, 30 Jan 2024 13:07:45 +0100 Message-ID: <20240130121026.807464-92-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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.2 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=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: 1789519791477341119 X-GMAIL-MSGID: 1789519791477341119 |
Series |
[COMMITTED,001/101] gccrs: Add visibility to trait item
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | warning | Git am fail log |
Commit Message
Arthur Cohen
Jan. 30, 2024, 12:07 p.m. UTC
From: Kushal Pal <kushalpal109@gmail.com> Fixes #2785 gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Added check for `async` functions inside trait. * parse/rust-parse-impl.h (Parser::parse_trait_item): Added switch-case for ASYNC token. gcc/testsuite/ChangeLog: * rust/compile/issue-2785.rs: New test. Signed-off-by: Kushal Pal <kushalpal109@gmail.com> --- gcc/rust/checks/errors/rust-ast-validation.cc | 13 ++++++++++--- gcc/rust/parse/rust-parse-impl.h | 1 + gcc/testsuite/rust/compile/issue-2785.rs | 9 +++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/rust/compile/issue-2785.rs
diff --git a/gcc/rust/checks/errors/rust-ast-validation.cc b/gcc/rust/checks/errors/rust-ast-validation.cc index b50e9cdf858..0ed5d060894 100644 --- a/gcc/rust/checks/errors/rust-ast-validation.cc +++ b/gcc/rust/checks/errors/rust-ast-validation.cc @@ -141,9 +141,16 @@ ASTValidation::visit (AST::TraitFunctionDecl &decl) { const auto &qualifiers = decl.get_qualifiers (); - if (context.back () == Context::TRAIT && qualifiers.is_const ()) - rust_error_at (decl.get_identifier ().get_locus (), ErrorCode::E0379, - "functions in traits cannot be declared const"); + if (context.back () == Context::TRAIT) + { + // may change soon + if (qualifiers.is_async ()) + rust_error_at (decl.get_identifier ().get_locus (), ErrorCode::E0706, + "functions in traits cannot be declared %<async%>"); + if (qualifiers.is_const ()) + rust_error_at (decl.get_identifier ().get_locus (), ErrorCode::E0379, + "functions in traits cannot be declared const"); + } } void diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index dfa2762c5c3..3055a3959cf 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -5096,6 +5096,7 @@ Parser<ManagedTokenSource>::parse_trait_item () // else, fallthrough to function // TODO: find out how to disable gcc "implicit fallthrough" error gcc_fallthrough (); + case ASYNC: case UNSAFE: case EXTERN_KW: case FN_KW: { diff --git a/gcc/testsuite/rust/compile/issue-2785.rs b/gcc/testsuite/rust/compile/issue-2785.rs new file mode 100644 index 00000000000..08f6346f60b --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-2785.rs @@ -0,0 +1,9 @@ +// { dg-additional-options "-frust-edition=2018" } +trait Foo { + async fn foo(){} + // { dg-error "functions in traits cannot be declared .async." "" { target *-*-* } .-1 } + async fn bar(); + // { dg-error "functions in traits cannot be declared .async." "" { target *-*-* } .-1 } +} + +fn main() {}