diff options
| author | bobtwinkles <srkoser+GitHub@gmail.com> | 2018-04-21 18:15:54 -0400 |
|---|---|---|
| committer | bobtwinkles <srkoser+GitHub@gmail.com> | 2018-04-23 23:59:58 -0400 |
| commit | 263b36b071ba8b52cd4f79ca36494b05d4762430 (patch) | |
| tree | 8b3471fd52750a0ae4c0fea9138d9fc081f60199 /src/libsyntax_pos | |
| parent | d2dc21df02a6f24b0c5629d3c3ebc7c9b85d20da (diff) | |
| download | rust-263b36b071ba8b52cd4f79ca36494b05d4762430.tar.gz rust-263b36b071ba8b52cd4f79ca36494b05d4762430.zip | |
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
Diffstat (limited to 'src/libsyntax_pos')
| -rw-r--r-- | src/libsyntax_pos/lib.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 9a7d1fd8ee6..19f52d83a01 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -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, |
