You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment, I think Logos forbids having more than one lifetime parameter on a token type, and assumes that the lifetime, if present, is that of the input.
This isn't a fair assumption. I actually have things I want to arena-allocate inside the payload of my tokens, so I need to be able to use the lifetime of the arena.
The text was updated successfully, but these errors were encountered:
Hi @414owen, it's true that it is not a smart constraint.
A workaround might be to require the user to explicitly mention which lifetime refers to the source, if multiple lifetimes are passed.
What do you think?
E.g.,
// OK - defaults to 'source#[derive(Logos)]enum<'source> Token<'source>{}// OK - 'other lifetime has nothing to do with source#[derive(Logos)]#[logos(lifetime = None)]enum<'other> Token{}// OK - defaults to 'source#[derive(Logos)]enum<'source> Token<'source>{}// OK#[derive(Logos)]#[logos(lifetime = 'source)]enum<'source,'other> Token{}// NOT OK - emits an error saying the source lifetime must be explicitly specified#[derive(Logos)]enum<'source,'other> Token{}// NOT OK - emits an error saying the specified lifetime was not found#[derive(Logos)]#[logos(lifetime = 'source)]enum<'other_source,'other> Token{}// NOT OK - emits an error saying the specified lifetime was not found#[derive(Logos)]#[logos(lifetime = 'source)]enumToken{}
The second example is to provide backward compatibility with existing code.
At the moment, I think Logos forbids having more than one lifetime parameter on a token type, and assumes that the lifetime, if present, is that of the input.
This isn't a fair assumption. I actually have things I want to arena-allocate inside the payload of my tokens, so I need to be able to use the lifetime of the arena.
The text was updated successfully, but these errors were encountered: