proc_macro2/probe/
proc_macro_span.rs

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