Implement parent() on syntax_pos::Span
... and reimplement proc_macro::Span::parent using it. This function turns out to be useful in the compiler as well
This commit is contained in:
parent
d2dc21df02
commit
263b36b071
2 changed files with 7 additions and 1 deletions
|
@ -291,6 +291,12 @@ impl Span {
|
|||
self.ctxt().outer().expn_info().map(|info| info.call_site.source_callsite()).unwrap_or(self)
|
||||
}
|
||||
|
||||
/// The `Span for the tokens in the previous macro expansion from which `self` was generated,
|
||||
/// if any
|
||||
pub fn parent(self) -> Option<Span> {
|
||||
self.ctxt().outer().expn_info().map(|i| i.call_site)
|
||||
}
|
||||
|
||||
/// Return the source callee.
|
||||
///
|
||||
/// Returns None if the supplied span has no expansion trace,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue