@@ -33,13 +33,12 @@ namespace AST {
33
33
class PathIdentSegment
34
34
{
35
35
std::string segment_name;
36
-
37
- // TODO: should this have location info stored?
36
+ Location locus;
38
37
39
38
// only allow identifiers, "super", "self", "Self", "crate", or "$crate"
40
39
public:
41
- PathIdentSegment (std::string segment_name)
42
- : segment_name (std::move (segment_name))
40
+ PathIdentSegment (std::string segment_name, Location locus )
41
+ : segment_name (std::move (segment_name)), locus (locus)
43
42
{}
44
43
45
44
/* TODO: insert check in constructor for this? Or is this a semantic error
@@ -49,7 +48,10 @@ class PathIdentSegment
49
48
* not entirely sure */
50
49
51
50
// Creates an error PathIdentSegment.
52
- static PathIdentSegment create_error () { return PathIdentSegment (" " ); }
51
+ static PathIdentSegment create_error ()
52
+ {
53
+ return PathIdentSegment (" " , Location ());
54
+ }
53
55
54
56
// Returns whether PathIdentSegment is in an error state.
55
57
bool is_error () const { return segment_name.empty (); }
@@ -221,7 +223,7 @@ class PathExprSegment
221
223
bool has_generic_args () const { return generic_args.has_generic_args (); }
222
224
223
225
// Constructor for segment (from IdentSegment and GenericArgs)
224
- PathExprSegment (PathIdentSegment segment_name, Location locus = Location () ,
226
+ PathExprSegment (PathIdentSegment segment_name, Location locus,
225
227
GenericArgs generic_args = GenericArgs::create_empty ())
226
228
: segment_name (std::move (segment_name)),
227
229
generic_args (std::move (generic_args)), locus (locus),
@@ -237,7 +239,7 @@ class PathExprSegment
237
239
= std::vector<std::unique_ptr<Type> > (),
238
240
std::vector<GenericArgsBinding> binding_args
239
241
= std::vector<GenericArgsBinding> ())
240
- : segment_name (PathIdentSegment (std::move (segment_name))),
242
+ : segment_name (PathIdentSegment (std::move (segment_name), locus )),
241
243
generic_args (GenericArgs (std::move (lifetime_args),
242
244
std::move (type_args),
243
245
std::move (binding_args))),
@@ -250,7 +252,7 @@ class PathExprSegment
250
252
// Creates an error-state path expression segment.
251
253
static PathExprSegment create_error ()
252
254
{
253
- return PathExprSegment (PathIdentSegment::create_error ());
255
+ return PathExprSegment (PathIdentSegment::create_error (), Location () );
254
256
}
255
257
256
258
std::string as_string () const ;
@@ -440,7 +442,7 @@ class TypePathSegment
440
442
441
443
TypePathSegment (std::string segment_name,
442
444
bool has_separating_scope_resolution, Location locus)
443
- : ident_segment (PathIdentSegment (std::move (segment_name))),
445
+ : ident_segment (PathIdentSegment (std::move (segment_name), locus )),
444
446
locus (locus),
445
447
has_separating_scope_resolution (has_separating_scope_resolution),
446
448
node_id (Analysis::Mappings::get ()->get_next_node_id ())
0 commit comments