Skip to content

[proc-macro] Add possibility to generate a Span from a path representation #140943

Open
@GuillaumeGomez

Description

@GuillaumeGomez

Currently, we cannot handle Span when using the proc-macro crate, which is problematic in many cases, like askama when the generated code triggers an error and we can't show the users where in their templates the error originates from.

So an idea I had was to provide a method looking like this:

struct FileLocation {
    line: u32,
    column: u32,
}

fn span_from_representation(file: &Path, beginning: FileLocation, end: Option<FileLocation>) -> Option<Span>;

It would allow to get the span we need without having to manipulate the Span content (which is not possible outside of the compiler anyway).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-proc-macrosArea: Procedural macrosC-feature-requestCategory: A feature request, i.e: not implemented / a PR.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