Skip to content

Source annotate ranges should use bytes not chars #77

@Muscraft

Description

@Muscraft
Member

Currently, SourceAnnotation's range field is based on chars, not bytes. This can be a little confusing for users and can cause issues when dealing with spans from things like toml errors. It would make more sense to have users give us bytes, and we calculate the char spans internally. This would make the API easier to use as most people can handle going to bytes, but going from bytes -> chars can be very hard.

Activity

epage

epage commented on Jan 10, 2024

@epage
Contributor

For me, there are two aspects to this

  • annotate-snippets is responsible for rendering so it shouldn't accept a rendering-focused unit but handle that behind the scenes
  • Turning bytes into column counts is complicated and we likely don't want everyone re-implementing it incorrectly, in different ways
added
M-breaking-changeMeta: Implementing or merging this will introduce a breaking change
on Mar 4, 2024
added this to the Cargo Adoption milestone on Mar 4, 2024
epage

epage commented on Mar 12, 2024

@epage
Contributor

Closed via #90

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    M-breaking-changeMeta: Implementing or merging this will introduce a breaking change

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @epage@Muscraft

        Issue actions

          Source annotate ranges should use bytes not chars · Issue #77 · rust-lang/annotate-snippets-rs