Ability to map subspans of a `LitStr` into subspans of the backing `Literal`
- Dominant language
- Rust
- Stars
- 3.4k
- Forks
- 374
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 2
Description
In order to create accurate subspans into a `LitStr` there needs to be some way to map offsets from the string value into offsets of the `Literal`. As an example for the literal `r#"\x7Ba}"` the string value is `{a}`, the `a` character has the range `1..2` which has to be mapped to `7..8`, or the `{` character has the range `0..1` which has to be mapped to `3..7`.
#621 is tangentially related, but that only applies if the literal is parsed through `syn::Parse`. If instead the string value is being parsed via another parser that is able to give back subranges those need to be manually mapped somehow.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading the LitStr and backing Literal APIs, then trace how literal offsets are represented and how escaped values such as r#"\x7Ba}" are handled. Define the mapping behavior for both escaped and unescaped ranges, including the examples in the issue, and verify that callers can obtain accurate subspans.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100