Skip to content

Commit c3d47ac

Browse files
committed
Give each PathSegment a NodeId
1 parent f8d3459 commit c3d47ac

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

src/libsyntax/ast.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ pub struct PathSegment {
121121
/// The identifier portion of this path segment.
122122
pub ident: Ident,
123123

124+
pub id: NodeId,
125+
124126
/// Type/lifetime parameters attached to this path. They come in
125127
/// two flavors: `Path<A,B,C>` and `Path(A,B) -> C`.
126128
/// `None` means that no parameter list is supplied (`Path`),
@@ -132,10 +134,14 @@ pub struct PathSegment {
132134

133135
impl PathSegment {
134136
pub fn from_ident(ident: Ident) -> Self {
135-
PathSegment { ident, args: None }
137+
PathSegment { ident, id: DUMMY_NODE_ID, args: None }
136138
}
137139
pub fn crate_root(span: Span) -> Self {
138-
PathSegment::from_ident(Ident::new(keywords::CrateRoot.name(), span))
140+
PathSegment {
141+
ident: Ident::new(keywords::CrateRoot.name(), span),
142+
id: CRATE_NODE_ID,
143+
args: None,
144+
}
139145
}
140146
}
141147

src/libsyntax/ext/build.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,11 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
329329
} else {
330330
None
331331
};
332-
segments.push(ast::PathSegment { ident: last_ident.with_span_pos(span), args });
332+
segments.push(ast::PathSegment {
333+
ident: last_ident.with_span_pos(span),
334+
id: ast::DUMMY_NODE_ID,
335+
args,
336+
});
333337
let mut path = ast::Path { span, segments };
334338
if global {
335339
if let Some(seg) = path.make_root() {
@@ -366,7 +370,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
366370
} else {
367371
None
368372
};
369-
path.segments.push(ast::PathSegment { ident, args });
373+
path.segments.push(ast::PathSegment { ident, id: ast::DUMMY_NODE_ID, args });
370374

371375
(ast::QSelf {
372376
ty: self_type,

src/libsyntax/fold.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,9 @@ pub fn noop_fold_usize<T: Folder>(i: usize, _: &mut T) -> usize {
448448

449449
pub fn noop_fold_path<T: Folder>(Path { segments, span }: Path, fld: &mut T) -> Path {
450450
Path {
451-
segments: segments.move_map(|PathSegment { ident, args }| PathSegment {
451+
segments: segments.move_map(|PathSegment { ident, id, args }| PathSegment {
452452
ident: fld.fold_ident(ident),
453+
id: fld.new_id(id),
453454
args: args.map(|args| args.map(|args| fld.fold_generic_args(args))),
454455
}),
455456
span: fld.new_span(span)
@@ -1210,6 +1211,7 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span, attrs}: Expr, folder: &mu
12101211
ExprKind::MethodCall(
12111212
PathSegment {
12121213
ident: folder.fold_ident(seg.ident),
1214+
id: folder.new_id(seg.id),
12131215
args: seg.args.map(|args| {
12141216
args.map(|args| folder.fold_generic_args(args))
12151217
}),

src/libsyntax/parse/parser.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2082,10 +2082,10 @@ impl<'a> Parser<'a> {
20822082
ParenthesisedArgs { inputs, output, span }.into()
20832083
};
20842084

2085-
PathSegment { ident, args }
2085+
PathSegment { ident, args, id: ast::DUMMY_NODE_ID }
20862086
} else {
20872087
// Generic arguments are not found.
2088-
PathSegment::from_ident(ident)
2088+
PathSegment::from_ident(ident,)
20892089
})
20902090
}
20912091

0 commit comments

Comments
 (0)