Skip to content

proc_macro: Add API for loading external files into the SourceMap #92565

Closed as not planned

Description

Summary

With this feature, proc macros (like askama::Template) could parse external files and then emit diagnostics with appropriate spans.

Proposed API

Other APIs are possible, but I was thinking of something like this:

impl SourceFile {
    pub fn span(&self) -> Span { ... }
    pub fn contents(&self) -> &str { ... }
    pub fn load(path: &Path) -> Self { ... }
}

I'm not super familiar with the proc_macro API, so feel free to suggest better API designs.

See also

See this discussion on Zulip and this discussion on GitHub for why I think this feature would be useful.

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

Metadata

Assignees

No one assigned

    Labels

    A-proc-macrosArea: Procedural macrosC-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.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

    Issue actions