Generate a TokenStream rather than a String#558
Conversation
| DisplayWrap::Unwrapped | ||
| } | ||
|
|
||
| // FIXME: This function should have a `Span`, but `cond.target` isn't `WithSpan`. |
Check notice
Code scanning / devskim
A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note
| match self { | ||
| Self::Literal(lit) => lit.span(), | ||
| Self::Literal(lit) => Some(lit.span()), | ||
| // FIXME: How do we get the span of the included file? |
Check notice
Code scanning / devskim
A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note
81eddaf to
ef79d66
Compare
|
PR is now ready for review! Took me way too long to finally finish it and rebase was a nightmare. ^^' |
| } | ||
| } else if pos != 0 { | ||
| buf.write("} else {"); | ||
| // FIXME: Should have a span. |
Check notice
Code scanning / devskim
A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note
| } | ||
| if has_cond { | ||
| let block_buf = block_buf.into_token_stream(); | ||
| // FIXME Should have a span. |
Check notice
Code scanning / devskim
A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note
|
I removed |
* No need to manually escape raw identifiers * Allow a few warnings
|
Yep, it was quite the nightmare. ^^' |
* prefix temporaries in `{{ expr }}` with `__askama`
* replace custom `spanned!(..)` with `quote_spanned!(..)`
* replace `buf.write_tokens(quote_spanned!(..))` with `quote_into!(..)`
The invocation is not only bad for performance, but also not necessarily correct: * The output of `TokenStream::to_string()` is free to add spaces between `self` and `.`, or before `self`. * The `.` might belong to `..` or `..=`.
| } | ||
| buf.write('>'); | ||
| let tmp = tmp.into_token_stream(); | ||
| // FIXME: use a better span |
Check notice
Code scanning / devskim
A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note
|
Sorry, my commits are terribly unorganized. :-/ I only found a possible bug with |
Kijewski
left a comment
There was a problem hiding this comment.
Thank you! Could you please review my commits?
|
I can't approve because it's my PR, github doesn't allow it. But changes look good to me, thanks! |
|
Thank you for your work, this change is great! Hopefully someday soon |
Part of #420.
This PR allows to greatly improve compile-time errors by using
Span. Even better: even a compiler error occurs, it shows which part of the jinja code generated it.BIG limitations with this PR:
path, onlysrc.includesorextends).As a first step though, I think it's good enough.