From patchwork Tue Jan 30 12:07:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 194084 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1183110dyb; Tue, 30 Jan 2024 04:28:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IEvb1v8ICrsa7CWdrhoDGVX+EOAvlRTTUv8yseTQVjNokUqdMtfPuslL2ILS1D7v7JGFcxn X-Received: by 2002:a05:620a:4042:b0:783:f8ea:17d2 with SMTP id i2-20020a05620a404200b00783f8ea17d2mr5681169qko.22.1706617718046; Tue, 30 Jan 2024 04:28:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706617718; cv=pass; d=google.com; s=arc-20160816; b=VZ4uQdyjZTqYVeUNs5gnGXhhge5h9udrQFlmQm0Dq0cH/1xk7ExzHARXah0rMXU85g nMxDU6On4uGd1StEvRJvaOcMV1ZAgWXzhDKIatwhzDZou9UwOSma53n0jYNlE3x0QReB OsJwbTz6JkjcHFaDx+3r67CY7UIymExtedBjlzLwOTZ44hU3WRq6kpSfa4pDGuAyalf0 dd5Y0jjnhn+T7poHnDzLVyn9dWeLBAHA+7gd4FpYB77Se54WJxAULSoaCprYcGOEO4A6 h2IxbTgDmAfKdu3mJuxFbkWaXpomz6hBtdo8MRebhnxlABVZG68/kjR6WA8bvWog0m3S 5/7A== 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=Q5KCibpANi3i0FkYg0XOm/2drj/+e8CsnR0CuD4DLh8=; fh=s1GzlUPo1djGkCl3rkRJI30hDOSCVwGp0RAbVwQ8dxQ=; b=OP5n+tLOTWy9g0Mv6+m4264RsWb/1llxPgSz15DYHWZidPsuTmxabCNiCcc8J5vPHV MxiSBjSyGCRHchK+qQVES7tN3tP9v5e0yD5eDP4r63S40uANbEM81wu1bLcDiaKuptby LNJ1YtaSBFqBh/1gYwxEv728hUX3Pd73t40updW4z9U8POXIwufMocB3kbZsnuqwepqU Z8H9uBVcTDAuqfpltGwWE8Xry9AH0Eri9COjeA68lc+XY5ipdzpq57PQGsPwTuUPXvqm A9drubbzx2tRCcpRD9K/qKyIAONQs4PXfmfodEcIIUjdlB0iXkSIipUHGLEpUwCV+7Jg 9jHg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=T7sCr2Vd; 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 bs37-20020a05620a472500b007840a35c995si1831218qkb.81.2024.01.30.04.28.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 04:28:38 -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=T7sCr2Vd; 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 5C71B3865C25 for ; Tue, 30 Jan 2024 12:28:30 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by sourceware.org (Postfix) with ESMTPS id 283D83857C77 for ; Tue, 30 Jan 2024 12:11:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 283D83857C77 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 283D83857C77 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::235 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616723; cv=none; b=RMKuo+d8Qab89jdh5oX4QuYIGBmfZ5bCHwhC5Hq7nAz8Y9ww6YzVed9wPySluKVtFjpz75j/7WNKezkamygzTmrzQBv5k4u5dDD6cil0S/phBTHVdGq/B3WHBdgFdLcHC3FqHTldF5dOd1iN138SeJXfalaAUt+MWrqaFPNsUhw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616723; c=relaxed/simple; bh=8v13uMTZBQOezwuk9WKqu20abwbWli1uKfWQQWKsMOM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=qM7hJ3jFeHtLETM1UyijiimVkVbYMakFXNu//S/V+B460QAwvjd7/kEhWjSR38PnUvtLhjYn5F7c1/0e5tTjBfZenCiwHZ1Ztd238rEgqVeRAZDm8Vi1/TakyvHdaepBRt8/bZiSRSFhwvMfKrNiKNX/ljmbTW6VdSDY7Zwb0Qo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2cf3a0b2355so46403941fa.0 for ; Tue, 30 Jan 2024 04:11:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1706616689; x=1707221489; 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=Q5KCibpANi3i0FkYg0XOm/2drj/+e8CsnR0CuD4DLh8=; b=T7sCr2Vdg64RPteP9ixA4SZP6AhZh3kogF663Hfi9AlMzSTcHPoqC9c0n5hqT1QLSe HvD5LpqfNPmYH0c2VLBY3Ry57lDbH8mSm+I0fI5XcIJPtV5YOyB0MAp4kbo3TUO2GwgZ ofKi0f+mUhBVHAaCbYtnl56jOZeuQ14JrMU1cKDReNr2k9pqz5Sn58VJn6KTPIEwOVu9 2NXRl22H68+3r+m/zo5NyLTUJlphHoL+0AZDGvKewpoiVZOSJwWo8XcaoqCUmEJP4I1H +Vv/+pZ2cZqLn1RM4dFZ1GvbKm+NrlsExeTmlUJpEvdAzcThAwocTT8fTZGtbCZ/YK6a tjhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706616689; x=1707221489; 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=Q5KCibpANi3i0FkYg0XOm/2drj/+e8CsnR0CuD4DLh8=; b=RaIzKlvkg1kwSexTyKFfdupDmR8k0fKF3yFM0heMI/Dt4KOjiuyyrgxkzjJthaTV4v FQfCU/bc6+kdPc2BDa1VTE64bxuaeN02hWqyh/2xMa/CVxqGEs0taKt85vWcsKF7Gt+H j1yKxdckMo85TkNyEZHNIOBtChdpzUnGW8YEYi+S+K+74m3G4xUTBpxpleinEA+/Sox7 XCu6a1DPMgDx+FGE8yPZ4QiZRZrJJMnHe5kTNJpRj0dOkHtp0fKm3LHiVDOGQ6ljEdCs 6tarv2qags604XLvC6I64J3Xj7COebAVcv2acp0PXsAoKibNgxwEffV4HMNXK8CJze1F ivVg== X-Gm-Message-State: AOJu0YxPPwAE9NWQ3rDzg09cv5bVNWxFL4n2cYc14L/3jwTFPiYJ8f9A tFBBYskE1SdhyBlZ6V5sYSr4/e7Sp2rbBioDlHWA/AMhsPaF82K3UYkJ9D2WApvtv8m/jcPgHzO 9UA== X-Received: by 2002:a05:651c:128d:b0:2cf:4e53:7c38 with SMTP id 13-20020a05651c128d00b002cf4e537c38mr5520259ljc.22.1706616689465; Tue, 30 Jan 2024 04:11:29 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 04:11:28 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Pierre-Emmanuel Patry Subject: [COMMITTED 053/101] gccrs: Add async const function ast validation pass Date: Tue, 30 Jan 2024 13:07:09 +0100 Message-ID: <20240130121026.807464-56-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: 1789518380551293084 X-GMAIL-MSGID: 1789518380551293084 From: Pierre-Emmanuel Patry Add a check during AST validation pass to ensure functions are either const or async but not both. gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Add async const check. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/checks/errors/rust-ast-validation.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gcc/rust/checks/errors/rust-ast-validation.cc b/gcc/rust/checks/errors/rust-ast-validation.cc index 4b209908f9e..54276e8fd59 100644 --- a/gcc/rust/checks/errors/rust-ast-validation.cc +++ b/gcc/rust/checks/errors/rust-ast-validation.cc @@ -98,6 +98,11 @@ ASTValidation::visit (AST::Function &function) std::set valid_context = {Context::INHERENT_IMPL, Context::TRAIT_IMPL}; + const auto &qualifiers = function.get_qualifiers (); + if (qualifiers.is_async () && qualifiers.is_const ()) + rust_error_at (function.get_locus (), + "functions cannot be both % and %"); + if (valid_context.find (context.back ()) == valid_context.end () && function.has_self_param ()) rust_error_at (