From 11fbade585049d2ff2f51f66a1eb6106deaec619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= Date: Fri, 30 Jun 2023 00:44:52 +0200 Subject: gccrs: refactor: make crate.items private MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce Crate::get_items () and fixup all callers. gcc/rust/ChangeLog: * hir/tree/rust-hir.h (struct Crate): Rename struct into ... (class Crate): ... class, and add get_items. * backend/rust-compile.cc (CompileCrate::go): Adapt to visibility change of items. * checks/errors/privacy/rust-privacy-check.cc (Resolver::resolve): Likewise. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::go): Likewise. * checks/errors/privacy/rust-pub-restricted-visitor.cc (PubRestrictedVisitor::go): Likewise. * checks/errors/privacy/rust-visibility-resolver.cc (VisibilityResolver::go): Likewise. * checks/errors/rust-const-checker.cc (ConstChecker::go): Likewise. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::go): Likewise. * checks/lints/rust-lint-marklive.cc (FindEntryPoint::find): Likewise. * checks/lints/rust-lint-scan-deadcode.h (ScanDeadCode::Scan): Likewise. * metadata/rust-export-metadata.cc (PublicInterface::gather_export_data): Likewise. * typecheck/rust-hir-type-check.cc (TypeResolution::Resolve): Likewise. * hir/rust-hir-dump.cc (CompileCrate::go): Likewise. Signed-off-by: Marc Poulhiès --- gcc/rust/hir/tree/rust-hir.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'gcc/rust/hir/tree') diff --git a/gcc/rust/hir/tree/rust-hir.h b/gcc/rust/hir/tree/rust-hir.h index 8b60d10..662cbc6 100644 --- a/gcc/rust/hir/tree/rust-hir.h +++ b/gcc/rust/hir/tree/rust-hir.h @@ -863,18 +863,18 @@ protected: }; // A crate HIR object - holds all the data for a single compilation unit -struct Crate : public WithInnerAttrs +class Crate : public WithInnerAttrs { // dodgy spacing required here /* TODO: is it better to have a vector of items here or a module (implicit * top-level one)? */ - std::vector > items; + std::vector> items; Analysis::NodeMapping mappings; public: // Constructor - Crate (std::vector > items, AST::AttrVec inner_attrs, + Crate (std::vector> items, AST::AttrVec inner_attrs, Analysis::NodeMapping mappings) : WithInnerAttrs (std::move (inner_attrs)), items (std::move (items)), mappings (mappings) @@ -912,6 +912,7 @@ public: std::string as_string () const; const Analysis::NodeMapping &get_mappings () const { return mappings; } + std::vector> &get_items () { return items; } }; // Base path expression HIR node - abstract -- cgit v1.1