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

Give each PathSegment a NodeId

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