Path: blob/master/rust/proc-macro2/probe/proc_macro_span.rs
38316 views
// SPDX-License-Identifier: Apache-2.0 OR MIT12// This code exercises the surface area that we expect of Span's unstable API.3// If the current toolchain is able to compile it, then proc-macro2 is able to4// offer these APIs too.56#![cfg_attr(procmacro2_build_probe, feature(proc_macro_span))]78extern crate proc_macro;910use core::ops::{Range, RangeBounds};11use proc_macro::{Literal, Span};12use std::path::PathBuf;1314pub fn byte_range(this: &Span) -> Range<usize> {15this.byte_range()16}1718pub fn start(this: &Span) -> Span {19this.start()20}2122pub fn end(this: &Span) -> Span {23this.end()24}2526pub fn line(this: &Span) -> usize {27this.line()28}2930pub fn column(this: &Span) -> usize {31this.column()32}3334pub fn file(this: &Span) -> String {35this.file()36}3738pub fn local_file(this: &Span) -> Option<PathBuf> {39this.local_file()40}4142pub fn join(this: &Span, other: Span) -> Option<Span> {43this.join(other)44}4546pub fn subspan<R: RangeBounds<usize>>(this: &Literal, range: R) -> Option<Span> {47this.subspan(range)48}4950// Include in sccache cache key.51#[cfg(procmacro2_build_probe)]52const _: Option<&str> = option_env!("RUSTC_BOOTSTRAP");535455