From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by sourceware.org (Postfix) with ESMTPS id DE3BF3857C56 for ; Tue, 30 Jan 2024 12:11:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DE3BF3857C56 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 DE3BF3857C56 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::22e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616724; cv=none; b=m6VWpD6Y/Ff5OA7CMpNVwZP8flsHt3BQg8RY9dMM4sswhnBDPZ3GjjmBC6KDXuoN7Dz4Uixz7Bj2mxAscDIT2fRgE9k0Y05oF6bOZERfkpqD/U22rU6DSt/0ixbeRo46/XCx+A7jrGADiCLLvTIDHrh65UINHOzm/vdso5O8IxA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616724; c=relaxed/simple; bh=8v13uMTZBQOezwuk9WKqu20abwbWli1uKfWQQWKsMOM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=rDEDAin6U7ZglY1t+RFVIq0VfS2OyfgMW63buztO+iBpgHFLTPNlE7WqWmYYUxqriux3DVGV3KG81jMorK9LfhASxUZWEy4+tQCoepw95rwjAmo3VpG4HtbEDvyxXCIQ8OEf7oTjRoZne4hKaf1npXTZU4t7emQloFU2AWl/BBw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2d0600551ebso2569331fa.2 for ; Tue, 30 Jan 2024 04:11:30 -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=Qwm2nik0LZ94f05SjtQL81t7ySEL0R5X/44skJHeJYOH9QOTGfAuq/1hDOiRrdKA2s DSOAL9jxCh0CRzXHnGtZHUJDUlb2ZYXdSHl+2DEqQ6AntAwLuET2O7aMTiY8Qdy1Ext1 LaVwHJDe+gUT7yBp24TQo6vwQTA5mre7Vxe26a2rUkFyrPedqurHFrxLjsyo3wI4LijL Umy8F+KeefjiE1B57ttOuhtuNUg7nRPxoEOSf81BoS8whjCGNFt/cxIN52vN9aaKnf85 daW0Q6EwNjoMbYVHgpDV0uugeEXNCuuZVJWX9YnTOfIQIA9idAIf5vS2Peel3P+IxVO+ H3QQ== X-Gm-Message-State: AOJu0Yw1FxWEjiZ9n53UCVwTBN8lz5xAyg7pbF7C4cDYJOs1rZ3Jfn6f MBIesfiIXQ7jAdfZZfFrc98GAgBewBSH9wr+UOHoGxvNvodcLhjN7KVk6KtrUK/kIblTZRWyfn8 9pA== X-Google-Smtp-Source: AGHT+IEf5pUA6DoPdvFfjpGHug6NvzY+0NSr/S8xnS0qDOCN18xhCp4r6T0R8Q4aCn6bCFTzeczK6A== 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> Reply-To: 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=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 ( -- 2.42.1