mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Make fields of Span
public again
This helps to avoid landing changes to rustc and rustfmt in one step
This commit is contained in:
parent
71dfe6487d
commit
a0c32641fd
@ -25,6 +25,7 @@
|
|||||||
#![feature(optin_builtin_traits)]
|
#![feature(optin_builtin_traits)]
|
||||||
#![allow(unused_attributes)]
|
#![allow(unused_attributes)]
|
||||||
#![feature(specialization)]
|
#![feature(specialization)]
|
||||||
|
#![feature(staged_api)]
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
@ -60,13 +61,20 @@ pub type FileName = String;
|
|||||||
/// range between files.
|
/// range between files.
|
||||||
#[derive(Clone, Copy, Hash, PartialEq, Eq, Ord, PartialOrd)]
|
#[derive(Clone, Copy, Hash, PartialEq, Eq, Ord, PartialOrd)]
|
||||||
pub struct Span {
|
pub struct Span {
|
||||||
lo: BytePos,
|
#[unstable(feature = "rustc_private", issue = "27812")]
|
||||||
hi: BytePos,
|
#[rustc_deprecated(since = "1.21", reason = "use getters/setters instead")]
|
||||||
|
pub lo: BytePos,
|
||||||
|
#[unstable(feature = "rustc_private", issue = "27812")]
|
||||||
|
#[rustc_deprecated(since = "1.21", reason = "use getters/setters instead")]
|
||||||
|
pub hi: BytePos,
|
||||||
/// Information about where the macro came from, if this piece of
|
/// Information about where the macro came from, if this piece of
|
||||||
/// code was created by a macro expansion.
|
/// code was created by a macro expansion.
|
||||||
ctxt: SyntaxContext,
|
#[unstable(feature = "rustc_private", issue = "27812")]
|
||||||
|
#[rustc_deprecated(since = "1.21", reason = "use getters/setters instead")]
|
||||||
|
pub ctxt: SyntaxContext,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
pub const DUMMY_SP: Span = Span { lo: BytePos(0), hi: BytePos(0), ctxt: NO_EXPANSION };
|
pub const DUMMY_SP: Span = Span { lo: BytePos(0), hi: BytePos(0), ctxt: NO_EXPANSION };
|
||||||
|
|
||||||
/// A collection of spans. Spans have two orthogonal attributes:
|
/// A collection of spans. Spans have two orthogonal attributes:
|
||||||
@ -82,11 +90,13 @@ pub struct MultiSpan {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Span {
|
impl Span {
|
||||||
|
#[allow(deprecated)]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(lo: BytePos, hi: BytePos, ctxt: SyntaxContext) -> Self {
|
pub fn new(lo: BytePos, hi: BytePos, ctxt: SyntaxContext) -> Self {
|
||||||
if lo <= hi { Span { lo, hi, ctxt } } else { Span { lo: hi, hi: lo, ctxt } }
|
if lo <= hi { Span { lo, hi, ctxt } } else { Span { lo: hi, hi: lo, ctxt } }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn lo(self) -> BytePos {
|
pub fn lo(self) -> BytePos {
|
||||||
self.lo
|
self.lo
|
||||||
@ -95,6 +105,7 @@ impl Span {
|
|||||||
pub fn with_lo(self, lo: BytePos) -> Span {
|
pub fn with_lo(self, lo: BytePos) -> Span {
|
||||||
Span::new(lo, self.hi(), self.ctxt())
|
Span::new(lo, self.hi(), self.ctxt())
|
||||||
}
|
}
|
||||||
|
#[allow(deprecated)]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn hi(self) -> BytePos {
|
pub fn hi(self) -> BytePos {
|
||||||
self.hi
|
self.hi
|
||||||
@ -103,6 +114,7 @@ impl Span {
|
|||||||
pub fn with_hi(self, hi: BytePos) -> Span {
|
pub fn with_hi(self, hi: BytePos) -> Span {
|
||||||
Span::new(self.lo(), hi, self.ctxt())
|
Span::new(self.lo(), hi, self.ctxt())
|
||||||
}
|
}
|
||||||
|
#[allow(deprecated)]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ctxt(self) -> SyntaxContext {
|
pub fn ctxt(self) -> SyntaxContext {
|
||||||
self.ctxt
|
self.ctxt
|
||||||
|
Loading…
Reference in New Issue
Block a user