提交 fc67d8fa 编写于 作者: N Nick Cameron

Give each PathSegment a NodeId

上级 8ec22e7e
......@@ -129,6 +129,8 @@ pub struct PathSegment {
/// The identifier portion of this path segment.
pub ident: Ident,
pub id: NodeId,
/// Type/lifetime parameters attached to this path. They come in
/// two flavors: `Path<A,B,C>` and `Path(A,B) -> C`.
/// `None` means that no parameter list is supplied (`Path`),
......@@ -140,10 +142,14 @@ pub struct PathSegment {
impl PathSegment {
pub fn from_ident(ident: Ident) -> Self {
PathSegment { ident, args: None }
PathSegment { ident, id: DUMMY_NODE_ID, args: None }
}
pub fn crate_root(span: Span) -> Self {
PathSegment::from_ident(Ident::new(keywords::CrateRoot.name(), span))
PathSegment {
ident: Ident::new(keywords::CrateRoot.name(), span),
id: CRATE_NODE_ID,
args: None,
}
}
}
......
......@@ -329,7 +329,11 @@ fn path_all(&self,
} else {
None
};
segments.push(ast::PathSegment { ident: last_ident.with_span_pos(span), args });
segments.push(ast::PathSegment {
ident: last_ident.with_span_pos(span),
id: ast::DUMMY_NODE_ID,
args,
});
let mut path = ast::Path { span, segments };
if global {
if let Some(seg) = path.make_root() {
......@@ -366,7 +370,7 @@ fn qpath_all(&self,
} else {
None
};
path.segments.push(ast::PathSegment { ident, args });
path.segments.push(ast::PathSegment { ident, id: ast::DUMMY_NODE_ID, args });
(ast::QSelf {
ty: self_type,
......
......@@ -468,8 +468,9 @@ pub fn noop_fold_usize<T: Folder>(i: usize, _: &mut T) -> usize {
pub fn noop_fold_path<T: Folder>(Path { segments, span }: Path, fld: &mut T) -> Path {
Path {
segments: segments.move_map(|PathSegment { ident, args }| PathSegment {
segments: segments.move_map(|PathSegment { ident, id, args }| PathSegment {
ident: fld.fold_ident(ident),
id: fld.new_id(id),
args: args.map(|args| args.map(|args| fld.fold_generic_args(args))),
}),
span: fld.new_span(span)
......@@ -1234,6 +1235,7 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span, attrs}: Expr, folder: &mu
ExprKind::MethodCall(
PathSegment {
ident: folder.fold_ident(seg.ident),
id: folder.new_id(seg.id),
args: seg.args.map(|args| {
args.map(|args| folder.fold_generic_args(args))
}),
......
......@@ -2134,10 +2134,10 @@ fn parse_path_segment(&mut self, style: PathStyle, enable_warning: bool)
ParenthesisedArgs { inputs, output, span }.into()
};
PathSegment { ident, args }
PathSegment { ident, args, id: ast::DUMMY_NODE_ID }
} else {
// Generic arguments are not found.
PathSegment::from_ident(ident)
PathSegment::from_ident(ident,)
})
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册