public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] add Location to AST::Visibility Date: Fri, 18 Nov 2022 23:33:08 +0000 (GMT) [thread overview] Message-ID: <20221118233308.D43773854178@sourceware.org> (raw) https://gcc.gnu.org/g:1531256aa661c8007c9bc6a496f5224bed55fe3a commit 1531256aa661c8007c9bc6a496f5224bed55fe3a Author: Dave <dme2223@gmail.com> Date: Wed Nov 9 23:17:50 2022 -0600 add Location to AST::Visibility Diff: --- gcc/rust/ast/rust-item.h | 28 ++++++++++++++++------------ gcc/rust/hir/rust-ast-lower.cc | 5 +++-- gcc/rust/hir/tree/rust-hir-item.h | 9 +++++---- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h index 20f1b93d948..e9826bd0e15 100644 --- a/gcc/rust/ast/rust-item.h +++ b/gcc/rust/ast/rust-item.h @@ -625,14 +625,14 @@ private: VisType vis_type; // Only assigned if vis_type is IN_PATH SimplePath in_path; + Location locus; // should this store location info? public: // Creates a Visibility - TODO make constructor protected or private? - Visibility (VisType vis_type, SimplePath in_path) - : vis_type (vis_type), in_path (std::move (in_path)) - {} + Visibility(VisType vis_type, SimplePath in_path, Location locus = Location()) + : vis_type(vis_type), in_path(std::move(in_path)), locus(locus) {} VisType get_vis_type () const { return vis_type; } @@ -648,6 +648,8 @@ public: // Returns whether visibility is public or not. bool is_public () const { return vis_type != PRIV && !is_error (); } + Location get_locus() const { return locus; } + // Creates an error visibility. static Visibility create_error () { @@ -671,22 +673,24 @@ public: // Creates a public visibility with crate-relative paths static Visibility create_crate (Location crate_tok_location) { - return Visibility (PUB_CRATE, - SimplePath::from_str ("crate", crate_tok_location)); + return Visibility(PUB_CRATE, + SimplePath::from_str("crate", crate_tok_location), + crate_tok_location); } // Creates a public visibility with self-relative paths static Visibility create_self (Location self_tok_location) { - return Visibility (PUB_SELF, - SimplePath::from_str ("self", self_tok_location)); + return Visibility(PUB_SELF, SimplePath::from_str("self", self_tok_location), + self_tok_location); } // Creates a public visibility with parent module-relative paths static Visibility create_super (Location super_tok_location) { - return Visibility (PUB_SUPER, - SimplePath::from_str ("super", super_tok_location)); + return Visibility(PUB_SUPER, + SimplePath::from_str("super", super_tok_location), + super_tok_location); } // Creates a private visibility @@ -698,7 +702,7 @@ public: // Creates a public visibility with a given path or whatever. static Visibility create_in_path (SimplePath in_path) { - return Visibility (PUB_IN_PATH, std::move (in_path)); + return Visibility(PUB_IN_PATH, std::move(in_path), in_path.get_locus()); } std::string as_string () const; @@ -3836,8 +3840,8 @@ class ExternalItem public: virtual ~ExternalItem () {} - /* TODO: spec syntax rules state that "MacroInvocationSemi" can be used as - * ExternalItem, but text body isn't so clear. Adding MacroInvocationSemi + /* TODO: spec syntax rules state that "MacroInvocationSemi" can be used as + * ExternalItem, but text body isn't so clear. Adding MacroInvocationSemi * support would require a lot of refactoring. */ // Returns whether item has outer attributes. diff --git a/gcc/rust/hir/rust-ast-lower.cc b/gcc/rust/hir/rust-ast-lower.cc index 52b7003a04a..9ac3674faa7 100644 --- a/gcc/rust/hir/rust-ast-lower.cc +++ b/gcc/rust/hir/rust-ast-lower.cc @@ -49,8 +49,9 @@ translate_visibility (const AST::Visibility &vis) case AST::Visibility::PUB_CRATE: case AST::Visibility::PUB_SUPER: case AST::Visibility::PUB_IN_PATH: - return Visibility (Visibility::VisType::RESTRICTED, - ASTLoweringSimplePath::translate (vis.get_path ())); + return Visibility(Visibility::VisType::RESTRICTED, + ASTLoweringSimplePath::translate(vis.get_path()), + vis.get_locus()); break; } diff --git a/gcc/rust/hir/tree/rust-hir-item.h b/gcc/rust/hir/tree/rust-hir-item.h index d84e41e81ee..0a8e688d391 100644 --- a/gcc/rust/hir/tree/rust-hir-item.h +++ b/gcc/rust/hir/tree/rust-hir-item.h @@ -571,14 +571,15 @@ public: private: VisType vis_type; HIR::SimplePath path; + Location locus; // should this store location info? public: - Visibility (VisType vis_type, - HIR::SimplePath path = HIR::SimplePath::create_empty ()) - : vis_type (vis_type), path (std::move (path)) - {} + Visibility(VisType vis_type, + HIR::SimplePath path = HIR::SimplePath::create_empty(), + Location locus = Location()) + : vis_type(vis_type), path(std::move(path)), locus(locus) {} // Returns whether visibility is in an error state. bool is_error () const { return vis_type == ERROR; }
reply other threads:[~2022-11-18 23:33 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20221118233308.D43773854178@sourceware.org \ --to=tschwinge@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).