diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-02-20 16:22:20 +0100 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2024-02-29 15:53:03 +0000 |
commit | 9ee5b51f57b358531ad0aeb84e4ef307e59e195c (patch) | |
tree | 69873381237878b177627ff8abe3726afc401742 /gcc/rust | |
parent | 8e3c34aa04229b0364d9834fc682ca1707ed9a01 (diff) | |
download | gcc-9ee5b51f57b358531ad0aeb84e4ef307e59e195c.zip gcc-9ee5b51f57b358531ad0aeb84e4ef307e59e195c.tar.gz gcc-9ee5b51f57b358531ad0aeb84e4ef307e59e195c.tar.bz2 |
extern-types: Lower to HIR::ExternalTypeItem properly
gcc/rust/ChangeLog:
* hir/rust-ast-lower-extern.h: Lower to HIR::ExternalTypeItem nodes.
* hir/tree/rust-hir-item.h (class ExternalTypeItem): Create private
visibility by default as extern types have no visibility - add a comment
about the correctness of this.
Diffstat (limited to 'gcc/rust')
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-extern.h | 9 | ||||
-rw-r--r-- | gcc/rust/hir/tree/rust-hir-item.h | 10 |
2 files changed, 16 insertions, 3 deletions
diff --git a/gcc/rust/hir/rust-ast-lower-extern.h b/gcc/rust/hir/rust-ast-lower-extern.h index e495b16..f9e067c 100644 --- a/gcc/rust/hir/rust-ast-lower-extern.h +++ b/gcc/rust/hir/rust-ast-lower-extern.h @@ -22,6 +22,7 @@ #include "rust-ast-lower-base.h" #include "rust-ast-lower-type.h" #include "rust-ast-lower.h" +#include "rust-hir-full-decls.h" namespace Rust { namespace HIR { @@ -116,7 +117,13 @@ public: void visit (AST::ExternalTypeItem &type) override { - rust_sorry_at (type.get_locus (), "extern types are not implemented yet"); + auto crate_num = mappings->get_current_crate (); + Analysis::NodeMapping mapping (crate_num, type.get_node_id (), + mappings->get_next_hir_id (crate_num), + mappings->get_next_localdef_id (crate_num)); + + translated = new HIR::ExternalTypeItem (mapping, type.get_identifier (), + type.get_locus ()); } private: diff --git a/gcc/rust/hir/tree/rust-hir-item.h b/gcc/rust/hir/tree/rust-hir-item.h index 40093a2..3bd0102 100644 --- a/gcc/rust/hir/tree/rust-hir-item.h +++ b/gcc/rust/hir/tree/rust-hir-item.h @@ -3152,16 +3152,20 @@ protected: class ExternalTypeItem : public ExternalItem { +public: ExternalTypeItem (Analysis::NodeMapping mappings, Identifier item_name, - Visibility vis, AST::AttrVec outer_attrs, location_t locus) + location_t locus) : ExternalItem (std::move (mappings), std::move (item_name), - std::move (vis), std::move (outer_attrs), locus) + Visibility (Visibility::PRIVATE), + /* FIXME: Is that correct? */ + {}, locus) {} ExternalTypeItem (ExternalTypeItem const &other) : ExternalItem (other) {} ExternalTypeItem (ExternalTypeItem &&other) = default; ExternalTypeItem &operator= (ExternalTypeItem &&other) = default; + ExternalTypeItem &operator= (ExternalTypeItem const &other) = default; std::string as_string () const override; @@ -3171,6 +3175,8 @@ class ExternalTypeItem : public ExternalItem ExternKind get_extern_kind () override { return ExternKind::Type; } protected: + /* Use covariance to implement clone function as returning this object + * rather than base */ ExternalTypeItem *clone_external_item_impl () const override { return new ExternalTypeItem (*this); |