All proc_macro_span APIs tracked at #54725 now

This commit is contained in:
Alex Crichton 2018-10-01 10:53:03 -07:00
parent 7662523492
commit 526ca7ce79

View File

@ -298,7 +298,7 @@ pub fn call_site() -> Span {
}
/// The original source file into which this span points.
#[unstable(feature = "proc_macro_span", issue = "38356")]
#[unstable(feature = "proc_macro_span", issue = "54725")]
pub fn source_file(&self) -> SourceFile {
SourceFile {
source_file: __internal::lookup_char_pos(self.0.lo()).file,
@ -307,7 +307,7 @@ pub fn source_file(&self) -> SourceFile {
/// The `Span` for the tokens in the previous macro expansion from which
/// `self` was generated from, if any.
#[unstable(feature = "proc_macro_span", issue = "38356")]
#[unstable(feature = "proc_macro_span", issue = "54725")]
pub fn parent(&self) -> Option<Span> {
self.0.parent().map(Span)
}
@ -315,13 +315,13 @@ pub fn parent(&self) -> Option<Span> {
/// The span for the origin source code that `self` was generated from. If
/// this `Span` wasn't generated from other macro expansions then the return
/// value is the same as `*self`.
#[unstable(feature = "proc_macro_span", issue = "38356")]
#[unstable(feature = "proc_macro_span", issue = "54725")]
pub fn source(&self) -> Span {
Span(self.0.source_callsite())
}
/// Get the starting line/column in the source file for this span.
#[unstable(feature = "proc_macro_span", issue = "38356")]
#[unstable(feature = "proc_macro_span", issue = "54725")]
pub fn start(&self) -> LineColumn {
let loc = __internal::lookup_char_pos(self.0.lo());
LineColumn {
@ -331,7 +331,7 @@ pub fn start(&self) -> LineColumn {
}
/// Get the ending line/column in the source file for this span.
#[unstable(feature = "proc_macro_span", issue = "38356")]
#[unstable(feature = "proc_macro_span", issue = "54725")]
pub fn end(&self) -> LineColumn {
let loc = __internal::lookup_char_pos(self.0.hi());
LineColumn {
@ -343,7 +343,7 @@ pub fn end(&self) -> LineColumn {
/// Create a new span encompassing `self` and `other`.
///
/// Returns `None` if `self` and `other` are from different files.
#[unstable(feature = "proc_macro_span", issue = "38356")]
#[unstable(feature = "proc_macro_span", issue = "54725")]
pub fn join(&self, other: Span) -> Option<Span> {
let self_loc = __internal::lookup_char_pos(self.0.lo());
let other_loc = __internal::lookup_char_pos(other.0.lo());
@ -355,20 +355,20 @@ pub fn join(&self, other: Span) -> Option<Span> {
/// 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_span", issue = "38356")]
#[unstable(feature = "proc_macro_span", issue = "54725")]
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_span", issue = "38356")]
#[unstable(feature = "proc_macro_span", issue = "54725")]
pub fn located_at(&self, other: Span) -> Span {
other.resolved_at(*self)
}
/// Compares to spans to see if they're equal.
#[unstable(feature = "proc_macro_span", issue = "38356")]
#[unstable(feature = "proc_macro_span", issue = "54725")]
pub fn eq(&self, other: &Span) -> bool {
self.0 == other.0
}
@ -391,33 +391,33 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
}
/// A line-column pair representing the start or end of a `Span`.
#[unstable(feature = "proc_macro_span", issue = "38356")]
#[unstable(feature = "proc_macro_span", issue = "54725")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct LineColumn {
/// The 1-indexed line in the source file on which the span starts or ends (inclusive).
#[unstable(feature = "proc_macro_span", issue = "38356")]
#[unstable(feature = "proc_macro_span", issue = "54725")]
pub line: usize,
/// The 0-indexed column (in UTF-8 characters) in the source file on which
/// the span starts or ends (inclusive).
#[unstable(feature = "proc_macro_span", issue = "38356")]
#[unstable(feature = "proc_macro_span", issue = "54725")]
pub column: usize
}
#[unstable(feature = "proc_macro_span", issue = "38356")]
#[unstable(feature = "proc_macro_span", issue = "54725")]
impl !Send for LineColumn {}
#[unstable(feature = "proc_macro_span", issue = "38356")]
#[unstable(feature = "proc_macro_span", issue = "54725")]
impl !Sync for LineColumn {}
/// The source file of a given `Span`.
#[unstable(feature = "proc_macro_span", issue = "38356")]
#[unstable(feature = "proc_macro_span", issue = "54725")]
#[derive(Clone)]
pub struct SourceFile {
source_file: Lrc<syntax_pos::SourceFile>,
}
#[unstable(feature = "proc_macro_span", issue = "38356")]
#[unstable(feature = "proc_macro_span", issue = "54725")]
impl !Send for SourceFile {}
#[unstable(feature = "proc_macro_span", issue = "38356")]
#[unstable(feature = "proc_macro_span", issue = "54725")]
impl !Sync for SourceFile {}
impl SourceFile {
@ -431,7 +431,7 @@ impl SourceFile {
/// the command line, the path as given may not actually be valid.
///
/// [`is_real`]: #method.is_real
#[unstable(feature = "proc_macro_span", issue = "38356")]
#[unstable(feature = "proc_macro_span", issue = "54725")]
pub fn path(&self) -> PathBuf {
match self.source_file.name {
FileName::Real(ref path) => path.clone(),
@ -441,7 +441,7 @@ pub fn path(&self) -> PathBuf {
/// Returns `true` if this source file is a real source file, and not generated by an external
/// macro's expansion.
#[unstable(feature = "proc_macro_span", issue = "38356")]
#[unstable(feature = "proc_macro_span", issue = "54725")]
pub fn is_real(&self) -> bool {
// This is a hack until intercrate spans are implemented and we can have real source files
// for spans generated in external macros.
@ -451,7 +451,7 @@ pub fn is_real(&self) -> bool {
}
#[unstable(feature = "proc_macro_span", issue = "38356")]
#[unstable(feature = "proc_macro_span", issue = "54725")]
impl fmt::Debug for SourceFile {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("SourceFile")
@ -461,14 +461,14 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
}
}
#[unstable(feature = "proc_macro_span", issue = "38356")]
#[unstable(feature = "proc_macro_span", issue = "54725")]
impl PartialEq for SourceFile {
fn eq(&self, other: &Self) -> bool {
Lrc::ptr_eq(&self.source_file, &other.source_file)
}
}
#[unstable(feature = "proc_macro_span", issue = "38356")]
#[unstable(feature = "proc_macro_span", issue = "54725")]
impl Eq for SourceFile {}
/// A single token or a delimited sequence of token trees (e.g. `[1, (), ..]`).
@ -679,7 +679,7 @@ pub fn span(&self) -> Span {
/// pub fn span_open(&self) -> Span {
/// ^
/// ```
#[unstable(feature = "proc_macro_span", issue = "38356")]
#[unstable(feature = "proc_macro_span", issue = "54725")]
pub fn span_open(&self) -> Span {
Span(self.span.open)
}
@ -690,7 +690,7 @@ pub fn span_open(&self) -> Span {
/// pub fn span_close(&self) -> Span {
/// ^
/// ```
#[unstable(feature = "proc_macro_span", issue = "38356")]
#[unstable(feature = "proc_macro_span", issue = "54725")]
pub fn span_close(&self) -> Span {
Span(self.span.close)
}