public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] ast: SimplePath: Remove default location parameter
@ 2022-06-08 12:38 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:38 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:b3d85dc842f16513a807f404f061dbe8edb9465c
commit b3d85dc842f16513a807f404f061dbe8edb9465c
Author: Arthur Cohen <arthur.cohen@embecosm.com>
Date: Tue Apr 26 13:41:55 2022 +0200
ast: SimplePath: Remove default location parameter
Diff:
---
gcc/rust/ast/rust-ast-full-test.cc | 14 ++++++++++----
gcc/rust/ast/rust-ast.h | 8 ++++----
gcc/rust/hir/rust-ast-lower.cc | 5 +++--
gcc/rust/rust-session-manager.cc | 11 +++++++----
4 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/gcc/rust/ast/rust-ast-full-test.cc b/gcc/rust/ast/rust-ast-full-test.cc
index 5c6a7545d76..71cbb372d92 100644
--- a/gcc/rust/ast/rust-ast-full-test.cc
+++ b/gcc/rust/ast/rust-ast-full-test.cc
@@ -4695,7 +4695,10 @@ MetaNameValueStr::to_attribute () const
{
LiteralExpr lit_expr (str, Literal::LitType::STRING,
PrimitiveCoreType::CORETYPE_UNKNOWN, {}, Location ());
- return Attribute (SimplePath::from_str (ident),
+ // FIXME: What location do we put here? Is the literal above supposed to have
+ // an empty location as well?
+ // Should MetaNameValueStr keep a location?
+ return Attribute (SimplePath::from_str (ident, Location ()),
std::unique_ptr<AttrInputLiteral> (
new AttrInputLiteral (std::move (lit_expr))));
}
@@ -4722,7 +4725,8 @@ MetaItemSeq::to_attribute () const
Attribute
MetaWord::to_attribute () const
{
- return Attribute (SimplePath::from_str (ident), nullptr);
+ // FIXME: How do we get a location here?
+ return Attribute (SimplePath::from_str (ident, Location ()), nullptr);
}
Attribute
@@ -4740,7 +4744,8 @@ MetaListPaths::to_attribute () const
std::unique_ptr<AttrInputMetaItemContainer> new_seq_container (
new AttrInputMetaItemContainer (std::move (new_seq)));
- return Attribute (SimplePath::from_str (ident),
+ // FIXME: How do we get a location here?
+ return Attribute (SimplePath::from_str (ident, Location ()),
std::move (new_seq_container));
}
@@ -4755,7 +4760,8 @@ MetaListNameValueStr::to_attribute () const
std::unique_ptr<AttrInputMetaItemContainer> new_seq_container (
new AttrInputMetaItemContainer (std::move (new_seq)));
- return Attribute (SimplePath::from_str (ident),
+ // FIXME: How do we get a location here?
+ return Attribute (SimplePath::from_str (ident, Location ()),
std::move (new_seq_container));
}
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h
index fa261754bcb..f2b14ab337f 100644
--- a/gcc/rust/ast/rust-ast.h
+++ b/gcc/rust/ast/rust-ast.h
@@ -330,7 +330,7 @@ class SimplePathSegment : public PathSegment
// only allow identifiers, "super", "self", "crate", or "$crate"
public:
// TODO: put checks in constructor to enforce this rule?
- SimplePathSegment (std::string segment_name, Location locus = Location ())
+ SimplePathSegment (std::string segment_name, Location locus)
: segment_name (std::move (segment_name)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
{}
@@ -342,7 +342,7 @@ public:
// Creates an error SimplePathSegment
static SimplePathSegment create_error ()
{
- return SimplePathSegment (std::string (""));
+ return SimplePathSegment (std::string (""), Location ());
}
std::string as_string () const override;
@@ -398,10 +398,10 @@ public:
* ensure that this is a valid identifier in path, so be careful. Also, this
* will have no location data.
* TODO have checks? */
- static SimplePath from_str (std::string str)
+ static SimplePath from_str (std::string str, Location locus)
{
std::vector<AST::SimplePathSegment> single_segments
- = {AST::SimplePathSegment (std::move (str))};
+ = {AST::SimplePathSegment (std::move (str), locus)};
return SimplePath (std::move (single_segments));
}
};
diff --git a/gcc/rust/hir/rust-ast-lower.cc b/gcc/rust/hir/rust-ast-lower.cc
index b572716d33f..630eded1291 100644
--- a/gcc/rust/hir/rust-ast-lower.cc
+++ b/gcc/rust/hir/rust-ast-lower.cc
@@ -44,12 +44,13 @@ translate_visibility (const AST::Visibility &vis)
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"));
+ AST::SimplePath::from_str ("crate", Location ()));
case AST::Visibility::PUB_SUPER:
return Visibility (Visibility::PUBLIC,
- AST::SimplePath::from_str ("super"));
+ 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/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc
index bdab0d89feb..887645954de 100644
--- a/gcc/rust/rust-session-manager.cc
+++ b/gcc/rust/rust-session-manager.cc
@@ -870,7 +870,8 @@ Session::injection (AST::Crate &crate)
{
// create "macro use" attribute for use on extern crate item to enable
// loading macros from it
- AST::Attribute attr (AST::SimplePath::from_str ("macro_use"), nullptr);
+ AST::Attribute attr (AST::SimplePath::from_str ("macro_use", Location ()),
+ nullptr);
// create "extern crate" item with the name
std::unique_ptr<AST::ExternCrate> extern_crate (
@@ -885,13 +886,15 @@ Session::injection (AST::Crate &crate)
// create use tree path
// prelude is injected_crate_name
std::vector<AST::SimplePathSegment> segments
- = {AST::SimplePathSegment (injected_crate_name),
- AST::SimplePathSegment ("prelude"), AST::SimplePathSegment ("v1")};
+ = {AST::SimplePathSegment (injected_crate_name, Location ()),
+ AST::SimplePathSegment ("prelude", Location ()),
+ AST::SimplePathSegment ("v1", Location ())};
// create use tree and decl
std::unique_ptr<AST::UseTreeGlob> use_tree (
new AST::UseTreeGlob (AST::UseTreeGlob::PATH_PREFIXED,
AST::SimplePath (std::move (segments)), Location ()));
- AST::Attribute prelude_attr (AST::SimplePath::from_str ("prelude_import"),
+ AST::Attribute prelude_attr (AST::SimplePath::from_str ("prelude_import",
+ Location ()),
nullptr);
std::unique_ptr<AST::UseDeclaration> use_decl (
new AST::UseDeclaration (std::move (use_tree),
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-08 12:38 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:38 [gcc/devel/rust/master] ast: SimplePath: Remove default location parameter 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).