Skip to content

Provide a way to 'anonymize' line numbers when building a Snippet #2

Closed
@phansch

Description

@phansch

In the rust test suite there's the option to replace line numbers in the diagnostics output with letters, so that changes in the output produce less noisy diffs.

With that flag enabled, the following

error: cannot concatenate a byte string literal
  --> $DIR/concat.rs:2:13
   |
 2 |     concat!(b'f');
   |             ^^^^

is turned into

error: cannot concatenate a byte string literal
  --> $DIR/concat.rs:2:13
   |
LL |     concat!(b'f');
   |             ^^^^

Any line number is replaced by LL, no matter the digits of that number.

AFAICT, rustc would currently have to implement its own Snippet -> DisplayList conversion, which would duplicate a lot of the conversion code just to anonymize the line numbers.

I think this would be nice to have inside annotate-snippets too, maybe as an option when constructing a Snippet? I believe other users of this library could also benefit from this option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-help-wantedCall for participation: Help is requested to fix this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions