Skip to content

Stabilize proc_macro::Span::{file, local_file}. #140514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions library/proc_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,18 +543,18 @@ impl Span {
/// The path to the source file in which this span occurs, for display purposes.
///
/// This might not correspond to a valid file system path.
/// It might be remapped, or might be an artificial path such as `"<macro expansion>"`.
#[unstable(feature = "proc_macro_span", issue = "54725")]
/// It might be remapped (e.g. `"/src/lib.rs"`) or an artificial path (e.g. `"<command line>"`).
#[stable(feature = "proc_macro_span_file", since = "CURRENT_RUSTC_VERSION")]
pub fn file(&self) -> String {
self.0.file()
}

/// The path to the source file in which this span occurs on disk.
/// The path to the source file in which this span occurs on the local file system.
///
/// This is the actual path on disk. It is unaffected by path remapping.
///
/// This path should not be embedded in the output of the macro; prefer `file()` instead.
#[unstable(feature = "proc_macro_span", issue = "54725")]
#[stable(feature = "proc_macro_span_file", since = "CURRENT_RUSTC_VERSION")]
pub fn local_file(&self) -> Option<PathBuf> {
self.0.local_file().map(|s| PathBuf::from(s))
}
Expand Down
Loading