From patchwork Wed Feb 7 11:44:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 197917 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2204385dyb; Wed, 7 Feb 2024 04:54:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IGfxPp21JaVHkz+IPESgmRXLw6omkr/9okAdnLs/FtDQgppJSKFJb7ZmzpkDtfv73x3ZePf X-Received: by 2002:a05:622a:1453:b0:42c:b29:ad6a with SMTP id v19-20020a05622a145300b0042c0b29ad6amr12235530qtx.31.1707310473736; Wed, 07 Feb 2024 04:54:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707310473; cv=pass; d=google.com; s=arc-20160816; b=bbVwQZWW+qk307D54zuwYCcgqyEsv8Uz349P0mBbJ2FcqOKKffeeyMqbRAJiTkD4aH yHNIG26+wVoBP5lgMNI+G2GZjWQ+9Rh483QBjYzy4cYV137ZEeQi0iODzapDTLEMUekc K7XTBrs7JmusCcKp5s6psdF2YU/kkfcV/+9hCt1ycO9g0JwyjSdnCi/GlRbda4g6EXl+ sMIri6nsVv7y27wydCUS2sN68oezuMRE6l1/hsm1H3Ocf2IhVkHgU0wYWNqZB/pTZTBv oCnVr+bhNURVpMr0LWnGsBzVLsthoc/xyf49E4Av0N7B97LjiP9NlhP3ThPgWsVdOSw/ LOfQ== 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=35jofY51ecUsirhQmojVytRMLoCnU83j2hMm1aKGhmM=; fh=rHGhaTGp+T5IXBvEP9xgKFpb9+1SBhnUa5tcdmAwtos=; b=PkUkX9hx1vvvf6AyoJccqVc6Islqi6QotPsVUdJJjPMQlzYZIms9GPIaAgQdifyTQ8 R2iMyQjh6ZoYRjO+O91D/bMGrL/xb0gZtD24wKkGUPSDLSDcADGR5ijuazm5lc241eC3 cI8+qNSIa5DDcR+rbHaccpoNJ0k2U8dUHA8Zw75/88OLFmDwjiK/6Z/AqMKmsc/PjLIU TECUFqaWVMRd/pj7bVLCzZvZd+UIus5JNum3S1VAdvYN0gBng4ZjL6ovq4OGn+gZvAob 7rIv/9vQjIUD9sT/7XRGb5TCac0F0UN8KS36toUhGdD8i90JnzUNLl6DoZI61iqDxQAD 4vLQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b="U8BtX/Ch"; 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" X-Forwarded-Encrypted: i=2; AJvYcCWtBUiwWpNcdryfvqrPLmPth2mtHqZbxU1O5wnhut9n0gp5g4hAa6Kgt8zvGPMsb59rXL9u4S8M4MzpfE93kn9o6rHiXg== Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id t22-20020a05622a181600b0042aad1f71bdsi1022671qtc.618.2024.02.07.04.54.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 04:54:33 -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="U8BtX/Ch"; 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 649FF3857708 for ; Wed, 7 Feb 2024 12:54:33 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by sourceware.org (Postfix) with ESMTPS id 360F33857C48 for ; Wed, 7 Feb 2024 12:44:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 360F33857C48 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 360F33857C48 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707309867; cv=none; b=EMLp26jq+k/LD5eLxqaViDe9kxvtOJEYBHSvWda1JmONB9DDI9V3XvCjVRPH5d1RSiq1b0FmR07pFWMNlJxoaU53As5FeakWT/jygxQBrpKedwEyV/p7X5Pk+M+SK4PouFGkryA9UTNp/Vq/wYAxPocjZPquyU+gZDPuTlob21g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707309867; c=relaxed/simple; bh=HXLpM8UJd3Jh9gVekPDZ+dQCUhjWNL7ZXGboOyTy7is=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=EByHdKh+Yvr+0BGCECWrb6MqwNXxwpxxgm/91+V6eqm+ip+TDhTO7y7OSJHvWcE3J/4hYW1m9bDhmU6EELBRB2fbQqSAbRg9ld+wEG7ut4LjMO6TZyexMKkPEi9F8pPrLfcj4OKeyCZhXIU8akwphsxpc5ysKYN9dF22JS+F2GQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-51167496943so822818e87.2 for ; Wed, 07 Feb 2024 04:44:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1707309856; x=1707914656; 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=35jofY51ecUsirhQmojVytRMLoCnU83j2hMm1aKGhmM=; b=U8BtX/ChTjj5PDNFXe0qzD+hgMBnfCQY2/RqcBWTDt5pGziXAjjXN0Yo61NVQxnzxl KuVpWu/B5hJ8jbogDc6QGLoER0XYFnAOYWOrFH8vkM1On2fQMBiv1zVNvsmeuP3W6F5O XkBdvDk+ks6+vERiXdEuUW0UdiPA7Er7EWJe/A2mCOFv/Cpjl4DRSCP4D24AFfrriJ9S EG8Ix7WqxnTkvUEaZJlZ4NY2Ar8IdUS/NLXlqCxo/qmSt8VWYKTfxBO13FtOlU5fAWTj aSsCfMojXmH05jT1BxIWLapF9hrJIACbzDvbo5ILtStcCMCiGdE+Yf/AyNnPwFfH+SU+ Hc/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707309856; x=1707914656; 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=35jofY51ecUsirhQmojVytRMLoCnU83j2hMm1aKGhmM=; b=K1iS5SAN+DZaGYSbrY5t6P2+rzdhMQTlJeAnJgKEoLckU+wrvw+xYB2omH+wFyYMNK AX4xqQ36GtQUHZoQZ/UhAZcvrakC3jmoDMVBf8H1b0q6IZMsLsiCEx5R1CfIQ/clXZ7V tZ3vNnuAkW/WGMpvpyolESJvStOj5l/HJyvP4JWcKVaQQXHVEe1Dwh75euDj/topFIZ6 lnpgh4WE1jA2EqkFERkmUn/rbn+36pkI2IT/LIpjy7C4VIDKY4Kf2vt59CRQzZG372a9 lPLXSOw5SwvlDj+vFR3AKLjfKXI4OJXuo3+1qHkYRSbOHzsZwCwv7LUyqrHaf3LKs3mL jEoQ== X-Gm-Message-State: AOJu0Yzd4gf+5Mco1mkt4sbRUn3Uk1xNG4dDGoewD6G+9RX1VHST7r0/ Sl80LKi9mrwRWhWxQMHfmK4BJZU/vg6iYDFfij3gj8iPzoJRZblAkxNTZYrZOIzDVmC1qgs+Um2 ngg== X-Received: by 2002:a05:6512:470:b0:511:558f:f398 with SMTP id x16-20020a056512047000b00511558ff398mr4020897lfd.27.1707309856522; Wed, 07 Feb 2024 04:44:16 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWUfxRIv628Ft1s4vsqMetJ4D0KYc+bJcLlrXtDgADM8wt0fBL35X1KMIGKvTu88pvsth5LRpV/moOofz9IAHLIjMqSGoC4 Received: from platypus.sou.embecosm-corp.com ([212.69.42.53]) by smtp.gmail.com with ESMTPSA id x19-20020a05600c2a5300b0040fbdd6f69bsm5044188wme.33.2024.02.07.04.44.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 04:44:16 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Kushal Pal Subject: [COMMITTED 19/25] gccrs: Use AssociatedItem in place of TraitItem Date: Wed, 7 Feb 2024 12:44:05 +0100 Message-ID: <20240207114419.1100894-20-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20240207114419.1100894-2-arthur.cohen@embecosm.com> References: <20240207114419.1100894-2-arthur.cohen@embecosm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.9 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790244786774902651 X-GMAIL-MSGID: 1790244786774902651 From: Kushal Pal gcc/rust/ChangeLog: * ast/rust-ast.h: Replace TraitItem with AssociatedItem. * ast/rust-item.h (class Trait): Likewise. * expand/rust-expand-visitor.cc (ExpandVisitor::visit): Likewise. * parse/rust-parse-impl.h (Parser::parse_trait): Likewise. * parse/rust-parse.h: Likewise. Signed-off-by: Kushal Pal --- gcc/rust/ast/rust-ast.h | 6 +++--- gcc/rust/ast/rust-item.h | 16 ++++++++-------- gcc/rust/expand/rust-expand-visitor.cc | 3 ++- gcc/rust/parse/rust-parse-impl.h | 6 +++--- gcc/rust/parse/rust-parse.h | 2 +- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index e96ac349733..1422d77eade 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -1907,11 +1907,11 @@ public: return std::move (item); } - std::unique_ptr take_trait_item () + std::unique_ptr take_trait_item () { rust_assert (!is_error ()); - return std::unique_ptr ( - static_cast (assoc_item.release ())); + return std::unique_ptr ( + static_cast (assoc_item.release ())); } std::unique_ptr take_external_item () diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h index 1553f29ad2d..1defecc4452 100644 --- a/gcc/rust/ast/rust-item.h +++ b/gcc/rust/ast/rust-item.h @@ -3140,7 +3140,7 @@ class Trait : public VisItem std::vector> type_param_bounds; WhereClause where_clause; std::vector inner_attrs; - std::vector> trait_items; + std::vector> trait_items; location_t locus; public: @@ -3171,9 +3171,9 @@ public: std::vector> generic_params, std::vector> type_param_bounds, WhereClause where_clause, - std::vector> trait_items, Visibility vis, - std::vector outer_attrs, std::vector inner_attrs, - location_t locus) + std::vector> trait_items, + Visibility vis, std::vector outer_attrs, + std::vector inner_attrs, location_t locus) : VisItem (std::move (vis), std::move (outer_attrs)), has_unsafe (is_unsafe), has_auto (is_auto), name (std::move (name)), generic_params (std::move (generic_params)), @@ -3199,7 +3199,7 @@ public: trait_items.reserve (other.trait_items.size ()); for (const auto &e : other.trait_items) - trait_items.push_back (e->clone_trait_item ()); + trait_items.push_back (e->clone_associated_item ()); } // Overloaded assignment operator with vector clone @@ -3223,7 +3223,7 @@ public: trait_items.reserve (other.trait_items.size ()); for (const auto &e : other.trait_items) - trait_items.push_back (e->clone_trait_item ()); + trait_items.push_back (e->clone_associated_item ()); return *this; } @@ -3244,11 +3244,11 @@ public: const std::vector &get_inner_attrs () const { return inner_attrs; } std::vector &get_inner_attrs () { return inner_attrs; } - const std::vector> &get_trait_items () const + const std::vector> &get_trait_items () const { return trait_items; } - std::vector> &get_trait_items () + std::vector> &get_trait_items () { return trait_items; } diff --git a/gcc/rust/expand/rust-expand-visitor.cc b/gcc/rust/expand/rust-expand-visitor.cc index dad2417eac4..bc0149ca99d 100644 --- a/gcc/rust/expand/rust-expand-visitor.cc +++ b/gcc/rust/expand/rust-expand-visitor.cc @@ -903,7 +903,8 @@ ExpandVisitor::visit (AST::Trait &trait) expander.push_context (MacroExpander::ContextType::TRAIT); - std::function (AST::SingleASTNode)> extractor + std::function (AST::SingleASTNode)> + extractor = [] (AST::SingleASTNode node) { return node.take_trait_item (); }; expand_macro_children (MacroExpander::ContextType::TRAIT, diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 89e3731a898..a7de948006b 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -5045,12 +5045,12 @@ Parser::parse_trait (AST::Visibility vis, AST::AttrVec inner_attrs = parse_inner_attributes (); // parse trait items - std::vector> trait_items; + std::vector> trait_items; const_TokenPtr t = lexer.peek_token (); while (t->get_id () != RIGHT_CURLY) { - std::unique_ptr trait_item = parse_trait_item (); + std::unique_ptr trait_item = parse_trait_item (); if (trait_item == nullptr) { @@ -5082,7 +5082,7 @@ Parser::parse_trait (AST::Visibility vis, // Parses a trait item used inside traits (not trait, the Item). template -std::unique_ptr +std::unique_ptr Parser::parse_trait_item () { // parse outer attributes (if they exist) diff --git a/gcc/rust/parse/rust-parse.h b/gcc/rust/parse/rust-parse.h index 34397540321..1614d19e4a5 100644 --- a/gcc/rust/parse/rust-parse.h +++ b/gcc/rust/parse/rust-parse.h @@ -169,7 +169,7 @@ public: = ParseRestrictions ()); std::unique_ptr parse_type (bool save_errors = true); std::unique_ptr parse_external_item (); - std::unique_ptr parse_trait_item (); + std::unique_ptr parse_trait_item (); std::unique_ptr parse_inherent_impl_item (); std::unique_ptr parse_trait_impl_item (); AST::PathInExpression parse_path_in_expression ();