Skip to content

json byte position doesn't start at top of file #35164

Closed
@sophiajt

Description

@sophiajt

From the IRC conversation:

1:17 AM jntrnr: re json compiler output, i totally forgot to ask about byte_{start,end}! it's either not mapping to the byte indices of the source file (is it maybe counting them after after macro expansion or something?) or i'm stupid ;) do you know what's up this that? it'd make rustfix (and editor plugin i imagine) a bit easier to implement if we could use byte indices
4:38 AM killercup: you have to look at how they're created
4:38 AM src/libsyntax/json.rs: byte_start: span.lo.0,
4:39 AM see, that's wrong
4:39 AM that's the byte start within the crate
4:39 AM without the CodeMap you can't know where the file starts
4:39 AM it should subtract the file start
4:40 AM assuming the start and end are in the same file

The fix should be to alter the json output so that lo/hi of the span's byte position start at the top of the file rather than at a codemap offset.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions