Guillaume Gomez
034f1676b5
Fix invalid "duplicated block call" warning
2025-09-02 15:08:59 +02:00
René Kijewski
52c4dfd8c3
parser: reject extends
below top-level, too
2025-08-25 01:24:25 +02:00
Guillaume Gomez
b744cab2be
Emit an error if an extends block doesn't come first in a template
2025-08-24 22:26:17 +02:00
René Kijewski
cfa21a6513
parser: reject unclosed prefixed string
...
In macro invocations, the input `i"` was interpreted as the identifier
`i`, and the `"` was consumed without being interpreted. This change
makes the code not ignore the quotation mark.
Resolves <https://issues.oss-fuzz.com/issues/440177293 >.
2025-08-21 22:38:56 +02:00
René Kijewski
8d5f3a5290
parser: r#_
is not a valid identifier
...
Resolves <https://issues.oss-fuzz.com/issues/439492383 >.
2025-08-19 22:23:11 +02:00
René Kijewski
81252cd0a2
parser: make State
part of InputStream
2025-08-19 17:41:20 +02:00
René Kijewski
e5189b933d
Use Parser::[with_]span()
to generate proc_macro::Span
2025-08-19 17:41:20 +02:00
René Kijewski
27e7ff4fd5
parser(non-working commit!): remove lifetimes from [With]Span
2025-08-19 17:41:20 +02:00
Guillaume Gomez
1f31021632
Fix wrong macro argument parsing
2025-08-17 16:28:45 +02:00
René Kijewski
016fe82199
readme: fix a link, include readmes in lib.rs
2025-08-15 13:06:10 +02:00
René Kijewski
98ad5d5b3f
parser: better messages for (group)
2025-08-07 20:48:15 +02:00
René Kijewski
c0d6f0f0fc
parser: a little better spans
2025-08-07 20:39:38 +02:00
René Kijewski
329771152d
parser: use LocatingSlice<&str>
instead of &str
...
This will enable better span getting in subsequent PRs.
2025-08-07 18:41:51 +02:00
René Kijewski
267a115672
parser/derive: use only one hasher throughout the proc_macro
2025-08-06 20:41:20 +02:00
René Kijewski
693f86d1c4
derive: don't use format_args!
for code formatting
...
* No need to manually escape raw identifiers
* Allow a few warnings
2025-08-06 19:11:26 +02:00
Guillaume Gomez
89024013dd
Put Raw::lit
field into a span
2025-08-06 19:11:26 +02:00
René Kijewski
1f3c926c58
parser: r#self
is not a valid raw identifier in macro calls
...
It's not a valid raw identifier anywhere, actually, but the other cases
(in a path, as a field name, as a macro name) were already handled.
Resolves <https://issues.oss-fuzz.com/issues/435218013 >.
2025-07-31 18:46:35 +02:00
René Kijewski
d670d9b91c
parser: fail on unterminated byte literal
...
Resolves <https://issues.oss-fuzz.com/issues/433650278 >.
Also, I noticed that an Unicode escape in a byte literal, e.g.
`b'\u{42}'`, was accepted when it should not have been.
2025-07-28 21:56:40 +02:00
René Kijewski
6d849880d9
parser: remove one indirection in punction()
finding
2025-07-26 00:51:39 +02:00
René Kijewski
b8e11e86b6
parser/derive: replaces usages of Expr
/Node
with Box<Expr>
/Box<Node>
...
This means that there is much less copying of data done at runtime.
Two new `unsafe` transmutations had to be added, both in the same
function, because even though `&T` and `Box<T>` have the same layout,
rust currently rejects any `Box`es in a `const` value. Miri is happy
with `askama_derive`'s tests.
<details>
<summary>askama_derive benchmark</summary>
```text
synthetic/hello_world time: [35.108 µs 35.271 µs 35.412 µs]
thrpt: [1.3735 MiB/s 1.3790 MiB/s 1.3854 MiB/s]
change:
time: [−6.2826% −5.1769% −4.1151%] (p = 0.00 < 0.05)
thrpt: [+4.2917% +5.4595% +6.7038%]
Performance has improved.
librustdoc/item_info.html
time: [39.687 µs 39.957 µs 40.186 µs]
thrpt: [3.9157 MiB/s 3.9381 MiB/s 3.9649 MiB/s]
change:
time: [−3.5603% −2.5102% −1.3793%] (p = 0.00 < 0.05)
thrpt: [+1.3986% +2.5749% +3.6917%]
Performance has improved.
librustdoc/item_union.html
time: [101.64 µs 101.95 µs 102.27 µs]
thrpt: [9.6516 MiB/s 9.6818 MiB/s 9.7111 MiB/s]
change:
time: [−4.0638% −3.5966% −3.1652%] (p = 0.00 < 0.05)
thrpt: [+3.2686% +3.7307% +4.2359%]
Performance has improved.
librustdoc/page.html time: [379.80 µs 381.74 µs 383.65 µs]
thrpt: [16.140 MiB/s 16.221 MiB/s 16.304 MiB/s]
change:
time: [−6.6429% −5.2611% −4.3384%] (p = 0.00 < 0.05)
thrpt: [+4.5351% +5.5533% +7.1156%]
Performance has improved.
librustdoc/print_item.html
time: [88.483 µs 88.849 µs 89.313 µs]
thrpt: [10.571 MiB/s 10.626 MiB/s 10.670 MiB/s]
change:
time: [−2.5658% −2.0639% −1.5517%] (p = 0.00 < 0.05)
thrpt: [+1.5761% +2.1074% +2.6333%]
Performance has improved.
librustdoc/short_item_info.html
time: [90.028 µs 90.157 µs 90.281 µs]
thrpt: [10.035 MiB/s 10.049 MiB/s 10.063 MiB/s]
change:
time: [−2.4814% −1.9435% −1.3640%] (p = 0.00 < 0.05)
thrpt: [+1.3829% +1.9821% +2.5445%]
Performance has improved.
librustdoc/sidebar.html time: [106.91 µs 108.17 µs 109.57 µs]
thrpt: [11.263 MiB/s 11.408 MiB/s 11.543 MiB/s]
change:
time: [−4.2433% −3.3985% −2.6066%] (p = 0.00 < 0.05)
thrpt: [+2.6763% +3.5181% +4.4314%]
Performance has improved.
librustdoc/source.html time: [71.149 µs 71.416 µs 71.652 µs]
thrpt: [10.289 MiB/s 10.322 MiB/s 10.361 MiB/s]
change:
time: [−2.7381% −2.1144% −1.5588%] (p = 0.00 < 0.05)
thrpt: [+1.5835% +2.1601% +2.8152%]
Performance has improved.
librustdoc/type_layout.html
time: [88.405 µs 88.920 µs 89.595 µs]
thrpt: [30.049 MiB/s 30.277 MiB/s 30.453 MiB/s]
change:
time: [+0.6665% +1.8855% +3.0267%] (p = 0.00 < 0.05)
thrpt: [−2.9378% −1.8506% −0.6621%]
Change within noise threshold.
librustdoc/type_layout_size.html
time: [44.048 µs 44.246 µs 44.398 µs]
thrpt: [6.1004 MiB/s 6.1213 MiB/s 6.1488 MiB/s]
change:
time: [−5.8376% −4.9477% −4.0335%] (p = 0.00 < 0.05)
thrpt: [+4.2030% +5.2052% +6.1996%]
Performance has improved.
```
</details>
2025-07-25 23:44:34 +02:00
dependabot[bot]
f0a1fa467d
build(deps): update criterion requirement from 0.6 to 0.7
...
Updates the requirements on [criterion](https://github.com/bheisler/criterion.rs ) to permit the latest version.
- [Changelog](https://github.com/bheisler/criterion.rs/blob/master/CHANGELOG.md )
- [Commits](https://github.com/bheisler/criterion.rs/compare/0.6.0...0.7.0 )
---
updated-dependencies:
- dependency-name: criterion
dependency-version: 0.7.0
dependency-type: direct:production
...
Signed-off-by: dependabot[bot] <support@github.com>
2025-07-25 23:36:35 +02:00
René Kijewski
22092ecb15
parser: un-inline more error messages
...
Tiny follow up to [#501 ].
[#501 ]: <https://redirect.github.com/askama-rs/askama/pull/501 >
2025-07-23 18:23:59 +02:00
Markus Ebner
48d5dba024
Fix #531 : Allow named arguments in expr macro calls
2025-07-22 12:33:26 +02:00
René Kijewski
a37d9f5a90
derive: more if-let
2025-07-21 20:43:46 +02:00
Guillaume Gomez
0d256b011d
Support generics in more locations
2025-07-21 00:38:55 +02:00
Guillaume Gomez
6de8ff8042
Forbid string literal suffix
2025-07-21 00:35:48 +02:00
Guillaume Gomez
9e32a28d11
Improve Span
information
2025-07-20 16:27:23 +02:00
Guillaume Gomez
6f4a799e77
Merge pull request #527 from Kijewski/pr-if-let-chain
...
Use if-let-chains
2025-07-14 12:34:48 +02:00
René Kijewski
f201285ede
Use if-let-chains
...
I ran `cargo +nightly clippy --all-targets --fix -- -D warnings` and
made only tiny manual improvements.
2025-07-13 23:16:26 +02:00
René Kijewski
1836ffde5a
parser: reject bare CR in doc comments
...
Resolves <https://issues.oss-fuzz.com/issues/431448399 >.
2025-07-13 21:39:46 +02:00
Guillaume Gomez
79d8f8886b
Update to rust edition 2024 and to MSRV 1.88
2025-07-07 22:23:29 +02:00
René Kijewski
e8a3dba413
parser: reject isolated CR in macro inputs, too
...
Resolves <https://issues.oss-fuzz.com/issues/429645376 >.
2025-07-07 19:11:04 +02:00
René Kijewski
d47b791957
parser: fix check_expr()
recursion
...
`check_expr()` did not recurse for all recursive `Expr`s. This PR fixes
the problem.
Resolves <https://issues.oss-fuzz.com/issues/429130577 >.
2025-07-05 21:08:44 +02:00
René Kijewski
c71aead21b
parser: understand nested block comments in macro calls
...
Fixes <https://issues.oss-fuzz.com/issues/427825995 >.
2025-06-29 11:21:33 +02:00
René Kijewski
83e0f9c9c4
Fix clippy warnings for rust 1.90
2025-06-29 08:52:44 +02:00
René Kijewski
6c32499533
parser: un-inline error message generation
...
This change cuts 40 to 150 instructions per parsing function that
generates a `ErrorContext`, and reduces the stack usage per function 500
or more bytes.
Also, it's less code you have to read and type per error message.
<details>
<summary>Benchmark results (benches/from_str.rs)</summary>
```text
librustdoc/all time: [177.24 µs 177.92 µs 178.56 µs]
thrpt: [79.081 MiB/s 79.369 MiB/s 79.674 MiB/s]
change:
time: [−2.3057% −2.0764% −1.8236%] (p = 0.00 < 0.05)
thrpt: [+1.8575% +2.1204% +2.3601%]
Performance has improved.
librustdoc/item_info time: [3.1792 µs 3.1890 µs 3.1973 µs]
thrpt: [49.216 MiB/s 49.344 MiB/s 49.495 MiB/s]
change:
time: [−4.3188% −3.9734% −3.6065%] (p = 0.00 < 0.05)
thrpt: [+3.7414% +4.1378% +4.5137%]
Performance has improved.
librustdoc/item_union time: [18.237 µs 18.297 µs 18.369 µs]
thrpt: [53.734 MiB/s 53.945 MiB/s 54.123 MiB/s]
change:
time: [−3.6142% −3.2857% −2.9748%] (p = 0.00 < 0.05)
thrpt: [+3.0660% +3.3974% +3.7497%]
Performance has improved.
librustdoc/page time: [83.761 µs 84.102 µs 84.414 µs]
thrpt: [73.355 MiB/s 73.627 MiB/s 73.927 MiB/s]
change:
time: [−2.4929% −2.2196% −1.9439%] (p = 0.00 < 0.05)
thrpt: [+1.9825% +2.2700% +2.5566%]
Performance has improved.
librustdoc/print_item time: [9.5466 µs 9.5528 µs 9.5603 µs]
thrpt: [98.756 MiB/s 98.834 MiB/s 98.898 MiB/s]
change:
time: [−1.4294% −1.2085% −0.9713%] (p = 0.00 < 0.05)
thrpt: [+0.9808% +1.2233% +1.4501%]
Change within noise threshold.
librustdoc/short_item_info
time: [8.8031 µs 8.8127 µs 8.8204 µs]
thrpt: [102.72 MiB/s 102.80 MiB/s 102.92 MiB/s]
change:
time: [−4.3207% −3.9712% −3.6035%] (p = 0.00 < 0.05)
thrpt: [+3.7382% +4.1355% +4.5158%]
Performance has improved.
librustdoc/sidebar time: [20.181 µs 20.218 µs 20.253 µs]
thrpt: [60.933 MiB/s 61.036 MiB/s 61.150 MiB/s]
change:
time: [−2.5827% −2.3381% −2.0839%] (p = 0.00 < 0.05)
thrpt: [+2.1283% +2.3940% +2.6512%]
Performance has improved.
librustdoc/source time: [7.2338 µs 7.2377 µs 7.2423 µs]
thrpt: [101.79 MiB/s 101.85 MiB/s 101.91 MiB/s]
change:
time: [−3.1453% −2.8930% −2.6317%] (p = 0.00 < 0.05)
thrpt: [+2.7028% +2.9792% +3.2475%]
Performance has improved.
librustdoc/type_layout_size
time: [4.3755 µs 4.3774 µs 4.3792 µs]
thrpt: [61.847 MiB/s 61.874 MiB/s 61.900 MiB/s]
change:
time: [−6.6822% −6.5162% −6.3593%] (p = 0.00 < 0.05)
thrpt: [+6.7912% +6.9704% +7.1607%]
Performance has improved.
librustdoc/type_layout time: [14.297 µs 14.316 µs 14.331 µs]
thrpt: [187.86 MiB/s 188.06 MiB/s 188.30 MiB/s]
change:
time: [−3.2479% −2.8916% −2.6244%] (p = 0.00 < 0.05)
thrpt: [+2.6952% +2.9777% +3.3569%]
Performance has improved.
```
</details>
2025-06-24 19:34:23 +02:00
René Kijewski
758a75bc54
parser: import winnow::error::ErrMode
2025-06-24 17:37:22 +02:00
René Kijewski
4f5272406f
parser: replace manual i_before
with .with_taken()
2025-06-24 15:02:41 +02:00
René Kijewski
1a1b507722
parser: refactor |filter
and {% filter %}
parsing
...
Deduplicated and easier to read code.
2025-06-24 15:02:41 +02:00
Guillaume Gomez
ca6573bf56
Rename Expr::Attr
into Expr::AssociatedItem
2025-06-24 14:09:34 +02:00
René Kijewski
338369a424
parser: box Expr::Filter
to reduce Expr
's size
2025-06-24 12:21:41 +02:00
René Kijewski
2086d4f898
parser: introduce askama_parser::expr::Call
2025-06-24 12:21:41 +02:00
René Kijewski
49d4397f51
parser: introduce askama_parser::expr::Range
2025-06-24 12:21:41 +02:00
René Kijewski
9f882e2ca7
parser: introduce askama_parser::expr::BinOp
2025-06-24 12:21:41 +02:00
René Kijewski
edfa31f9cf
parser: ensure valid paths in generics
2025-06-23 18:31:16 +02:00
René Kijewski
749d4edd89
Import ErrMode
2025-06-23 18:31:16 +02:00
René Kijewski
3f380721a2
parser: reject illegal raw identifiers in attribute access
2025-06-23 18:31:16 +02:00
René Kijewski
76b26cd5fa
parser: str lit must not be followed by suffix#
...
Resolves <https://issues.oss-fuzz.com/issues/426509683 >.
2025-06-21 19:43:28 +02:00
René Kijewski
5ec46333de
parser: fix {% raw %}
for delimiters starting with -
...
Looking at the code once more I came up with an odd edge case. This PR
fixes it.
2025-06-17 15:29:54 +02:00
René Kijewski
53f4eb0b81
Add missing #[inline]
for <_ as Deref>::deref()
2025-06-17 05:25:40 +02:00