Skip to content

Commit fc67d8f

Browse files
committed
Give each PathSegment a NodeId
1 parent 8ec22e7 commit fc67d8f

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

src/libsyntax/ast.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ pub struct PathSegment {
129129
/// The identifier portion of this path segment.
130130
pub ident: Ident,
131131

132+
pub id: NodeId,
133+
132134
/// Type/lifetime parameters attached to this path. They come in
133135
/// two flavors: `Path<A,B,C>` and `Path(A,B) -> C`.
134136
/// `None` means that no parameter list is supplied (`Path`),
@@ -140,10 +142,14 @@ pub struct PathSegment {
140142

141143
impl PathSegment {
142144
pub fn from_ident(ident: Ident) -> Self {
143-
PathSegment { ident, args: None }
145+
PathSegment { ident, id: DUMMY_NODE_ID, args: None }
144146
}
145147
pub fn crate_root(span: Span) -> Self {
146-
PathSegment::from_ident(Ident::new(keywords::CrateRoot.name(), span))
148+
PathSegment {
149+
ident: Ident::new(keywords::CrateRoot.name(), span),
150+
id: CRATE_NODE_ID,
151+
args: None,
152+
}
147153
}
148154
}
149155

src/libsyntax/ext/build.rs

Lines changed: 6 additions & 2 deletions
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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,9 @@ pub fn noop_fold_usize<T: Folder>(i: usize, _: &mut T) -> usize {
468468

469469
pub fn noop_fold_path<T: Folder>(Path { segments, span }: Path, fld: &mut T) -> Path {
470470
Path {
471-
segments: segments.move_map(|PathSegment { ident, args }| PathSegment {
471+
segments: segments.move_map(|PathSegment { ident, id, args }| PathSegment {
472472
ident: fld.fold_ident(ident),
473+
id: fld.new_id(id),
473474
args: args.map(|args| args.map(|args| fld.fold_generic_args(args))),
474475
}),
475476
span: fld.new_span(span)
@@ -1234,6 +1235,7 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span, attrs}: Expr, folder: &mu
12341235
ExprKind::MethodCall(
12351236
PathSegment {
12361237
ident: folder.fold_ident(seg.ident),
1238+
id: folder.new_id(seg.id),
12371239
args: seg.args.map(|args| {
12381240
args.map(|args| folder.fold_generic_args(args))
12391241
}),

src/libsyntax/parse/parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,10 +2134,10 @@ impl<'a> Parser<'a> {
21342134
ParenthesisedArgs { inputs, output, span }.into()
21352135
};
21362136

2137-
PathSegment { ident, args }
2137+
PathSegment { ident, args, id: ast::DUMMY_NODE_ID }
21382138
} else {
21392139
// Generic arguments are not found.
2140-
PathSegment::from_ident(ident)
2140+
PathSegment::from_ident(ident,)
21412141
})
21422142
}
21432143

0 commit comments

Comments
 (0)