Skip to content

Commit

Permalink
All proc_macro_span APIs tracked at rust-lang#54725 now
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Oct 1, 2018
1 parent 7662523 commit 526ca7c
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions src/libproc_macro/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ impl 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,
Expand All @@ -307,21 +307,21 @@ impl Span {

/// 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)
}

/// 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 {
Expand All @@ -331,7 +331,7 @@ impl Span {
}

/// 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 {
Expand All @@ -343,7 +343,7 @@ impl Span {
/// 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());
Expand All @@ -355,20 +355,20 @@ impl 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
}
Expand All @@ -391,33 +391,33 @@ impl fmt::Debug for Span {
}

/// 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 {
Expand All @@ -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(),
Expand All @@ -441,7 +441,7 @@ impl SourceFile {

/// 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.
Expand All @@ -451,7 +451,7 @@ impl SourceFile {
}


#[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")
Expand All @@ -461,14 +461,14 @@ impl fmt::Debug for SourceFile {
}
}

#[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, (), ..]`).
Expand Down Expand Up @@ -679,7 +679,7 @@ impl Group {
/// 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)
}
Expand All @@ -690,7 +690,7 @@ impl Group {
/// 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)
}
Expand Down

0 comments on commit 526ca7c

Please sign in to comment.