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 14 pub fn byte_range(this: &Span) -> Range<usize> { 15 this.byte_range() 16 } 17 18 pub fn start(this: &Span) -> Span { 19 this.start() 20 } 21 22 pub fn end(this: &Span) -> Span { 23 this.end() 24 } 25 26 pub fn line(this: &Span) -> usize { 27 this.line() 28 } 29 30 pub fn column(this: &Span) -> usize { 31 this.column() 32 } 33 34 pub fn join(this: &Span, other: Span) -> Option<Span> { 35 this.join(other) 36 } 37 38 pub fn subspan<R: RangeBounds<usize>>(this: &Literal, range: R) -> Option<Span> { 39 this.subspan(range) 40 } 41 42 // Include in sccache cache key. 43 #[cfg(procmacro2_build_probe)] 44 const _: Option<&str> = option_env!("RUSTC_BOOTSTRAP"); 45