Skip to content

Fix impl ToTokens for SpannedValue#22

Open
H2CO3 wants to merge 1 commit into
jf2048:mainfrom
H2CO3:patch-1
Open

Fix impl ToTokens for SpannedValue#22
H2CO3 wants to merge 1 commit into
jf2048:mainfrom
H2CO3:patch-1

Conversation

@H2CO3
Copy link
Copy Markdown

@H2CO3 H2CO3 commented Jun 12, 2024

The ToTokens impl was previously abused as a proxy for Spanned::span() (through the blanket impl). This meant that whether or not the inner value was ToTokens, this wrapper always produced an empty group, just for the sake of returning something that had the span.

Since SpannedValue is supposed to be a transparent wrapper, we hereby fix this bug/surprising behavior. We furthermore implement an additional span() inherent method, that serves as a universal getter even when the inner type (and therefore SpannedValue<T> itself) does not implement ToTokens.

This fixes #21.

The `ToTokens` impl was previously abused as a proxy for `Spanned::span()` (through the blanket impl). This meant that whether or not the inner value was `ToTokens`, this wrapper always produced an empty group, just for the sake of returning _something_ that had the span.

Since `SpannedValue` is supposed to be a transparent wrapper, we hereby fix this bug/surprising behavior. We furthermore implement an additional `span()` inherent method, that serves as a universal getter even when the inner type (and therefore `SpannedValue<T>` itself) does not implement `ToTokens`.
@H2CO3
Copy link
Copy Markdown
Author

H2CO3 commented Jun 24, 2024

ping @jf2048

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.

impl ToTokens for SpannedValue is bogus

1 participant