Skip to content

Conversation

@dtolnay
Copy link
Owner

@dtolnay dtolnay commented Mar 5, 2021

This matches the span and set_span accessors we provide on all the various Lit variant types.

Lifetimes are ordinarily treated as a single token. Only the proc macro API splits them into ' punctuation and ident. Consequently the span of those two things is normally identical, except in pathological case when manually constructed from within a proc macro with differing spans. Thus, requiring macros to decide whether to write lifetime.apostrophe.span or lifetime.ident.span() for that span makes the code misleading. The new accessors reflect the fact that really there is only one span involved.

For example rustc parsers 'a as the following TokenStream, in which byte range 95..97 covers both characters of the entire 'a token.

TokenStream [
    Punct {
        ch: '\'',
        spacing: Joint,
        span: #0 bytes(95..97),
    },
    Ident {
        ident: "asdf",
        span: #0 bytes(95..97),
    },
]

@dtolnay dtolnay merged commit de1a51d into master Mar 5, 2021
@dtolnay dtolnay deleted the lifetime-span branch March 5, 2021 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants