Skip to content

Naming of proc_macro::Span::local_file() #139903

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

Open
m-ou-se opened this issue Apr 16, 2025 · 4 comments
Open

Naming of proc_macro::Span::local_file() #139903

m-ou-se opened this issue Apr 16, 2025 · 4 comments
Assignees
Labels
A-proc-macros Area: Procedural macros C-discussion Category: Discussion or questions that doesn't represent real issues. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@m-ou-se
Copy link
Member

m-ou-se commented Apr 16, 2025

This is about #54725's open question on the name of local_file:

The unstable API is now:

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 (e.g. `/src/lib.rs`) , or might be an artificial path (e.g. `"<command line>"`).
    pub fn file(&self) -> String;

    /// The path to the source file in which this span occurs on the local file system.
    ///
    /// This is unaffected by path remapping.
    ///
    /// This path should not be embedded in the output of the macro; prefer `file()` instead.
    pub fn local_file(&self) -> Option<PathBuf>;
}

The question is: What should we name local_file?

Keeping it as local_file is an option, but maybe we can think of something better.

@m-ou-se m-ou-se added A-proc-macros Area: Procedural macros C-discussion Category: Discussion or questions that doesn't represent real issues. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Apr 16, 2025
@m-ou-se m-ou-se self-assigned this Apr 16, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 16, 2025
@m-ou-se
Copy link
Member Author

m-ou-se commented Apr 16, 2025

FWIW, rustc internally uses "LocalPath" for this:

local_path: Option<PathBuf>,

@m-ou-se m-ou-se removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 16, 2025
@m-ou-se
Copy link
Member Author

m-ou-se commented Apr 16, 2025

I personally think local_file is good enough.

@m-ou-se
Copy link
Member Author

m-ou-se commented Apr 17, 2025

@rust-lang/libs-api If you have an opinion/ideas, please speak up!

@BurntSushi
Copy link
Member

I weakly prefer path/local_path, but I don't feel strongly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-proc-macros Area: Procedural macros C-discussion Category: Discussion or questions that doesn't represent real issues. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants