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
@ -270,7 +270,7 @@ impl Span {
|
||||
/// `self` was generated from, if any.
|
||||
#[unstable(feature = "proc_macro", issue = "38356")]
|
||||
pub fn parent(&self) -> Option<Span> {
|
||||
self.0.ctxt().outer().expn_info().map(|i| Span(i.call_site))
|
||||
self.0.parent().map(|x| { Span(x) })
|
||||
}
|
||||
|
||||
/// The span for the origin source code that `self` was generated from. If
|
||||
|
@ -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…
x
Reference in New Issue
Block a user