diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index 41ccd88b4a887..f2936f2bca83d 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -254,6 +254,20 @@ impl Span { Some(Span(self.0.to(other.0))) } + /// Creates a new span with the same line/column information as `self` but + /// that resolves symbols as though it were at `other`. + #[unstable(feature = "proc_macro", issue = "38356")] + pub fn resolved_at(&self, other: Span) -> Span { + Span(self.0.with_ctxt(other.0.ctxt())) + } + + /// Creates a new span with the same name resolution behavior as `self` but + /// with the line/column information of `other`. + #[unstable(feature = "proc_macro", issue = "38356")] + pub fn located_at(&self, other: Span) -> Span { + other.resolved_at(*self) + } + diagnostic_method!(error, Level::Error); diagnostic_method!(warning, Level::Warning); diagnostic_method!(note, Level::Note);