public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] parse: Add correct location to all public visibilities
@ 2022-06-08 12:39 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:39 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:b4fa67403f3f5f5579e30e03102ca56c4ed6f049
commit b4fa67403f3f5f5579e30e03102ca56c4ed6f049
Author: Arthur Cohen <arthur.cohen@embecosm.com>
Date: Thu Apr 28 09:47:41 2022 +0200
parse: Add correct location to all public visibilities
Diff:
---
gcc/rust/ast/rust-item.h | 22 ++++++++++++----------
gcc/rust/hir/rust-ast-lower.cc | 6 ------
gcc/rust/parse/rust-parse-impl.h | 7 ++++---
3 files changed, 16 insertions(+), 19 deletions(-)
diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h
index 5907516472d..5d1e0d63565 100644
--- a/gcc/rust/ast/rust-item.h
+++ b/gcc/rust/ast/rust-item.h
@@ -666,23 +666,25 @@ public:
return Visibility (PUB, SimplePath::create_empty ());
}
- // Creates a public visibility with crate-relative paths or whatever.
- static Visibility create_crate ()
+ // Creates a public visibility with crate-relative paths
+ static Visibility create_crate (Location crate_tok_location)
{
- return Visibility (PUB_CRATE, SimplePath::create_empty ());
+ return Visibility (PUB_CRATE,
+ SimplePath::from_str ("crate", crate_tok_location));
}
- // Creates a public visibility with self-relative paths or whatever.
- static Visibility create_self ()
+ // Creates a public visibility with self-relative paths
+ static Visibility create_self (Location self_tok_location)
{
- return Visibility (PUB_SELF, SimplePath::create_empty ());
+ return Visibility (PUB_SELF,
+ SimplePath::from_str ("self", self_tok_location));
}
- // Creates a public visibility with parent module-relative paths or
- // whatever.
- static Visibility create_super ()
+ // Creates a public visibility with parent module-relative paths
+ static Visibility create_super (Location super_tok_location)
{
- return Visibility (PUB_SUPER, SimplePath::create_empty ());
+ return Visibility (PUB_SUPER,
+ SimplePath::from_str ("super", super_tok_location));
}
// Creates a private visibility
diff --git a/gcc/rust/hir/rust-ast-lower.cc b/gcc/rust/hir/rust-ast-lower.cc
index 630eded1291..bc613e12e49 100644
--- a/gcc/rust/hir/rust-ast-lower.cc
+++ b/gcc/rust/hir/rust-ast-lower.cc
@@ -43,14 +43,8 @@ translate_visibility (const AST::Visibility &vis)
case AST::Visibility::PRIV:
case AST::Visibility::PUB_SELF:
return Visibility (Visibility::VisType::PRIVATE);
- // Desugar pub(crate) into pub(in crate) and so on
- // FIXME: How do we get a location for the SimplePath here?
case AST::Visibility::PUB_CRATE:
- return Visibility (Visibility::PUBLIC,
- AST::SimplePath::from_str ("crate", Location ()));
case AST::Visibility::PUB_SUPER:
- return Visibility (Visibility::PUBLIC,
- AST::SimplePath::from_str ("super", Location ()));
case AST::Visibility::PUB_IN_PATH:
return Visibility (Visibility::VisType::PUBLIC, vis.get_path ());
break;
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index 6715a778233..23ab32c832e 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -2136,6 +2136,7 @@ Parser<ManagedTokenSource>::parse_visibility ()
lexer.skip_token ();
const_TokenPtr t = lexer.peek_token ();
+ auto path_loc = t->get_locus ();
switch (t->get_id ())
{
@@ -2144,19 +2145,19 @@ Parser<ManagedTokenSource>::parse_visibility ()
skip_token (RIGHT_PAREN);
- return AST::Visibility::create_crate ();
+ return AST::Visibility::create_crate (path_loc);
case SELF:
lexer.skip_token ();
skip_token (RIGHT_PAREN);
- return AST::Visibility::create_self ();
+ return AST::Visibility::create_self (path_loc);
case SUPER:
lexer.skip_token ();
skip_token (RIGHT_PAREN);
- return AST::Visibility::create_super ();
+ return AST::Visibility::create_super (path_loc);
case IN: {
lexer.skip_token ();
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-08 12:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 12:39 [gcc/devel/rust/master] parse: Add correct location to all public visibilities Thomas Schwinge
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).