From patchwork Thu Aug 1 14:56:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 1967732 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=embecosm.com header.i=@embecosm.com header.a=rsa-sha256 header.s=google header.b=SHrEZlrz; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WZXPV0jxZz1ybX for ; Fri, 2 Aug 2024 01:07:10 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5CE66385EC59 for ; Thu, 1 Aug 2024 15:07:08 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id C4D86385E83D for ; Thu, 1 Aug 2024 14:58:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C4D86385E83D 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 C4D86385E83D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::62c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722524341; cv=none; b=QzyyBJSt86HTfOuGs39n5FRs3kd1LqkDkIByZeA8APyH7rIQRlljW/xXyoTKtvg1nXkD99QC6dZ+UbjKHXkeS3rwGC4DZXjWNPFDzyTPW2/A57dHi8IkQDfyfW53J1rXYODeWqSZ9E156zV9ZtqEfhaylmYTgdCKklNHEE2tRzo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722524341; c=relaxed/simple; bh=sdkJ/weydDbu4P5wMJhuFjFKZ8TedcT9yaDSxWtb7B8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Rvx+UphlED/jFMkokWERa+v2YiI5h7NN0y4dkjH3KK1LlYQWwlB2o5N2Vu6hx3gPQJzvD3Fzgw7tHQ+EyuqmNBqAFrdntkQ3g8pz7et/5EwVVNkTGG03BAPMTQ4YwMlDf+X6OT1mEZYKRBggH9mxO0okTsUICWT8SEqAMYll4zo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a728f74c23dso928387666b.1 for ; Thu, 01 Aug 2024 07:58:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1722524330; x=1723129130; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nVZzD9ylb7bu25QWK1chdVobC8JWf2ZHp5l/UQ4cD4c=; b=SHrEZlrz9ouNw4bJYwV39UAHPqH/e0sJ21Gsjgq0mxLbAgjFcTaAIIVmqzwVK78kub 9ICQ7N4FSmdBDIiTYvGUfqjrRRLnIhcqBt9ALgXUKH9jvpoEXEDFTO+uPfwvHpmlfdBt +NT/LbUjXFRQPMxEl8j7Ajff9jX/mz8cSmIw3zXOVUE2sNv1XGplDLqk6avD6HL5If1s 86ZelB2X7EK1/oiGIQX9ETVW1KO8OiaWr+3JSWOxByimPWMkZwCOitxPkDTXZcEDHR5Y RlM8sNCI783NlaH2+CU0VjiMgFOS6Mr4fBD8EmJoebajfbC0ONZReFpzsBZMZo16yj/p ayhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722524330; x=1723129130; h=content-transfer-encoding:mime-version: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=nVZzD9ylb7bu25QWK1chdVobC8JWf2ZHp5l/UQ4cD4c=; b=OLQgq0Uy3Vria3CgWRp2p4sSI2QA8i+ejNH443TRvqlj84G9+q84QHPkKkH0R73J67 IwGQUdi611RLQdiX5VV1tQXu7LM+bsO1bif2goLO7Ui0bVKfmAU7HZRNE8IEIHQq7CdS /npQV7MjFR49UA+cJ7/CmyqHfnWQ8bLWYb2QXsrzQvDE5+BdFSZwNDrckx1KpnXKbb+k zK9Ki5TBTm+JUM3wEl0d5xRYwzhByRqfaA5EnL/wlCVpUE0lvrT9vkXLDb0lWovL2nbu pxXrg/NxBrLeUH2OLY31ED6WApcO0857yTTswgPYj7z0HhEjRmijyO824GdmOlB7uwzc zwDA== X-Gm-Message-State: AOJu0Yy48tiY4jwVMTFGuVUu7r1tTix29ZJSHepHf1/NUUSePGuaD4od 6hdo3yq2tl7QjzFuq0gpOWkuWyxCaB8LlfLMX2JNlDGmef7ytPZFHIlzEI17iaiNH4/foh06vFI sHeMe X-Google-Smtp-Source: AGHT+IEKONg1ERtl1L/EsOW6aPUgGZvs5YvFx726naHdyNIcA5ton36k9jUR0NzGWjOowqG4Ac4hDg== X-Received: by 2002:a17:907:724b:b0:a7a:a46e:dc39 with SMTP id a640c23a62f3a-a7dc4abf26fmr45351666b.0.1722524329987; Thu, 01 Aug 2024 07:58:49 -0700 (PDT) Received: from platypus.lan ([2a04:cec2:9:dc84:3622:6733:ff49:ee91]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ac63590592sm10252456a12.25.2024.08.01.07.58.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 07:58:49 -0700 (PDT) From: Arthur Cohen To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Arthur Cohen Subject: [PATCH 024/125] gccrs: extern-types: Declare external types in name resolver. Date: Thu, 1 Aug 2024 16:56:20 +0200 Message-ID: <20240801145809.366388-26-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801145809.366388-2-arthur.cohen@embecosm.com> References: <20240801145809.366388-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 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: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org gcc/rust/ChangeLog: * resolve/rust-ast-resolve-implitem.h: Declare external types as new types. --- gcc/rust/resolve/rust-ast-resolve-implitem.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gcc/rust/resolve/rust-ast-resolve-implitem.h b/gcc/rust/resolve/rust-ast-resolve-implitem.h index fabc25817f5..4f4d2893f83 100644 --- a/gcc/rust/resolve/rust-ast-resolve-implitem.h +++ b/gcc/rust/resolve/rust-ast-resolve-implitem.h @@ -228,6 +228,25 @@ public: mappings->insert_module_child_item (current_module, decl); } + void visit (AST::ExternalTypeItem &type) override + { + auto decl = CanonicalPath::new_seg (type.get_node_id (), + type.get_identifier ().as_string ()); + auto path = prefix.append (decl); + + resolver->get_type_scope ().insert ( + path, type.get_node_id (), type.get_locus (), false, Rib::ItemType::Type, + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { + rich_location r (line_table, type.get_locus ()); + r.add_range (locus); + + rust_error_at (r, "redefined multiple times"); + }); + + NodeId current_module = resolver->peek_current_module_scope (); + mappings->insert_module_child_item (current_module, decl); + } + private: ResolveToplevelExternItem (const CanonicalPath &prefix) : ResolverBase (), prefix (prefix)