More precise spans for HIR paths

This commit is contained in:
Vadim Petrochenkov 2021-03-13 19:14:18 +03:00
parent 2ccf06302c
commit 7e66e9d6b0
22 changed files with 60 additions and 30 deletions

View file

@ -149,9 +149,17 @@ impl PathSegment {
pub fn from_ident(ident: Ident) -> Self {
PathSegment { ident, id: DUMMY_NODE_ID, args: None }
}
pub fn path_root(span: Span) -> Self {
PathSegment::from_ident(Ident::new(kw::PathRoot, span))
}
pub fn span(&self) -> Span {
match &self.args {
Some(args) => self.ident.span.to(args.span()),
None => self.ident.span,
}
}
}
/// The arguments of a path segment.