Skip to content

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

@m-ou-se

Description

@m-ou-se
Member

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.

Activity

added
C-discussionCategory: Discussion or questions that doesn't represent real issues.
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.
on Apr 16, 2025
self-assigned this
on Apr 16, 2025
added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Apr 16, 2025
m-ou-se

m-ou-se commented on Apr 16, 2025

@m-ou-se
MemberAuthor

FWIW, rustc internally uses "LocalPath" for this:

local_path: Option<PathBuf>,

removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Apr 16, 2025
m-ou-se

m-ou-se commented on Apr 16, 2025

@m-ou-se
MemberAuthor

I personally think local_file is good enough.

m-ou-se

m-ou-se commented on Apr 17, 2025

@m-ou-se
MemberAuthor

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

BurntSushi

BurntSushi commented on Apr 17, 2025

@BurntSushi
Member

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

m-ou-se

m-ou-se commented on Apr 30, 2025

@m-ou-se
MemberAuthor

We discussed this last week in the libs-api meeting. We didn't have any better ideas than local_file.

I'll make a PR to stabilize it under that name and propose an FCP.

11 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-proc-macrosArea: Procedural macrosC-discussionCategory: Discussion or questions that doesn't represent real issues.I-libs-api-nominatedNominated for discussion during a libs-api team meeting.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @BurntSushi@m-ou-se@rustbot

      Issue actions

        Naming of proc_macro::Span::local_file() · Issue #139903 · rust-lang/rust