1 // SPDX-License-Identifier: Apache-2.0 OR MIT 2 3 // This code exercises the surface area that we expect of Span's unstable API. 4 // If the current toolchain is able to compile it, then proc-macro2 is able to 5 // offer these APIs too. 6 7 #![cfg_attr(procmacro2_build_probe, feature(proc_macro_span))] 8 9 extern crate proc_macro; 10 11 use core::ops::{Range, RangeBounds}; 12 use proc_macro::{Literal, Span}; 13 use std::path::PathBuf; 14 byte_range(this: &Span) -> Range<usize>15pub fn byte_range(this: &Span) -> Range<usize> { 16 this.byte_range() 17 } 18 start(this: &Span) -> Span19pub fn start(this: &Span) -> Span { 20 this.start() 21 } 22 end(this: &Span) -> Span23pub fn end(this: &Span) -> Span { 24 this.end() 25 } 26 line(this: &Span) -> usize27pub fn line(this: &Span) -> usize { 28 this.line() 29 } 30 column(this: &Span) -> usize31pub fn column(this: &Span) -> usize { 32 this.column() 33 } 34 file(this: &Span) -> String35pub fn file(this: &Span) -> String { 36 this.file() 37 } 38 local_file(this: &Span) -> Option<PathBuf>39pub fn local_file(this: &Span) -> Option<PathBuf> { 40 this.local_file() 41 } 42 join(this: &Span, other: Span) -> Option<Span>43pub fn join(this: &Span, other: Span) -> Option<Span> { 44 this.join(other) 45 } 46 subspan<R: RangeBounds<usize>>(this: &Literal, range: R) -> Option<Span>47pub fn subspan<R: RangeBounds<usize>>(this: &Literal, range: R) -> Option<Span> { 48 this.subspan(range) 49 } 50 51 // Include in sccache cache key. 52 #[cfg(procmacro2_build_probe)] 53 const _: Option<&str> = option_env!("RUSTC_BOOTSTRAP"); 54