From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by sourceware.org (Postfix) with ESMTPS id 10CEB3858015 for ; Wed, 7 Feb 2024 12:44:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 10CEB3858015 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 10CEB3858015 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707309866; cv=none; b=TWO09DLxrTxSIZ4IVgqidSRS0dNlXX3SmpoT0nl6qvgTyYKuZBvV51Ilf8aVLKIZ27KBjbBOgKjPi/yoJnaBzsuY/N0PMUbTsufuAt+XmCgAevWevqgoWrp7292V4j6W/cAtmFc4xp0dzAQ1VBXUburhGzBzOWQY8NeoykM+zh8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707309866; c=relaxed/simple; bh=HXLpM8UJd3Jh9gVekPDZ+dQCUhjWNL7ZXGboOyTy7is=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=GDJBGeptRBtKRp+kqp7+9O+AePJ8WgJccTvRKSQrJ6LuU6t12HYL17HZTDjtGTjQ48YqQbb/bwzxh/SFBUnh6E+5lQ9sj/wSmJCJZxk5jxXHZ81i9D6cG73aomdfihK8SRLuav9LttHZUlY5QiqxzJmQGfErq8ftG0eDWezNTfU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-5116588189aso982420e87.1 for ; Wed, 07 Feb 2024 04:44:17 -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=OMeeAawzxMCa//Q4EX/tVLJWRO/X30y7QGOxod68YbVNQ7o4gQOx34pst78V9rIP4V J99uJp9wpHJpZcuAZFAXaVPy2AMfdFuGaU9oGhgliDf3aYPwqkBoFGpusAYxkezudlSR 9IlZvADoEqjRg3QJ3cYS7EXbtm3TBlf6S2dP34xPJZ34D3Wd60wOD3uAJO3gobVhVMAZ bTznCKrXkklN9xR92MqaFhClpM28C4tua8aGscoiou0cm6hYQgDSHdTejPoGqX5+3hMa kjvaaAn84QbyhA9ZvBWEtqFldEH9X+KguKZBSvL9ksv6QGmCcd1XoseqRYNZeYXUTPTL DXsg== X-Gm-Message-State: AOJu0YwpEeLgO3Xf0zaVHaq/wZJ0V5S8sEPUejo4YwCXi0Sx3tZInK+3 BXTA0HCAJ3koXNYCaKoTX6lDBJtS9SI8T6F0iZaAOtgsXX9BzYPKTRQBgb9Ulg== X-Google-Smtp-Source: AGHT+IGZJ6lgLkofhb/y69OSm9Xw1W9kgE+H2AAlNZiI0YZLESHNTXNbzYU9Nb5Kaa9TBMyAcDOwGQ== 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> Reply-To: arthur.cohen@embecosm.com MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.4 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: 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 (); -- 2.42.1