2524 Commits

Author SHA1 Message Date
Markus Ebner
1b1d604dbc Add unit-tests for #517 2025-07-21 16:55:31 +02:00
Markus Ebner
fcf793c35a generator: Move macro invocation code generation to helper module
Introduced a new helpers module where code generation can be placed.
For this, some generator methods had to become pub(crate) instead of private.
2025-07-21 16:55:31 +02:00
Guillaume Gomez
cf558be7e6 Add regression test for generics support in macro default value and call 2025-07-21 00:38:55 +02:00
Guillaume Gomez
fc2b0349ac Add ui test for generics on loop.cycle 2025-07-21 00:38:55 +02:00
Guillaume Gomez
0d256b011d Support generics in more locations 2025-07-21 00:38:55 +02:00
Guillaume Gomez
da0bdcc34b Add new fuzzing test case 2025-07-21 00:35:48 +02:00
Guillaume Gomez
6de8ff8042 Forbid string literal suffix 2025-07-21 00:35:48 +02:00
Guillaume Gomez
d8bf38978c Add fuzzing test 2025-07-20 16:27:23 +02:00
Guillaume Gomez
57554f3d42 Update tests 2025-07-20 16:27:23 +02:00
Guillaume Gomez
9e32a28d11 Improve Span information 2025-07-20 16:27:23 +02:00
Guillaume Gomez
f7e88e021a Replace ANSI escape characters in generated code output 2025-07-19 13:24:38 +02:00
Guillaume Gomez
c1e4d4cd59 Improve askama_derive error output 2025-07-19 13:24:38 +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
Guillaume Gomez
e876730191
Merge pull request #528 from Kijewski/pr-no-nightly-rtd
book: fix rust-docs on readthedocs
2025-07-14 12:33:49 +02:00
Guillaume Gomez
97366c741b
Merge pull request #526 from Kijewski/6236623325167616
parser: reject bare CR in doc comments
2025-07-14 12:32:12 +02:00
René Kijewski
f691e72429 book: fix rust-docs on readthedocs
We want to use the nightly features `doc_cfg` and `doc_auto_cfg` when we
build our documentation. Still, we want to use a stable compiler, e.g.
to have stable links in our docs, so we opt in to the use of unstable
features with the use of `RUSTC_BOOTSTRAP=1`.

The problem is that `proc-macro2` only checks whether it can use any
unstable features, not which unstable features, and it always assumes
that you run the newest nightly rust version if the use of unstable
features is possible.

This PR disables the detection if unstable features are available to
`proc-macro2` by pretending that we are in an early stage of a
bootstrapped rustc build.
2025-07-14 01:49:11 +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
Guillaume Gomez
b16b47b4a9
Merge pull request #524 from Kijewski/5387873899839488
parser: reject isolated CR in macro inputs, too
2025-07-07 19:43:31 +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
Guillaume Gomez
37d2bad936
Merge pull request #521 from Kijewski/pr-rtd-1.88
book: update to rust 1.88
2025-07-06 12:47:19 +02:00
René Kijewski
a757469a2b book: update to rust 1.88 2025-07-06 02:32:59 +02:00
Guillaume Gomez
bbcb70e3f5
Merge pull request #510 from seijikun/mr-storable-caller
Treat caller() as variable with support for aliasing
2025-07-05 23:21:39 +02:00
Guillaume Gomez
6b936f4c1b
Merge pull request #519 from Kijewski/4793932351602688
parser: fix `check_expr()` recursion
2025-07-05 22:48:00 +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
Markus Ebner
d50cb4fcb7
Fix #505 and 507 - Treat caller() as local variable with aliasing 2025-07-05 03:21:34 +02:00
Markus Ebner
fca6e6f78b
Switch Rust edition of askama_derive to 2024 2025-07-05 03:21:34 +02:00
Markus Ebner
2bd436417a
Add unit-tests for #505 2025-07-05 03:21:34 +02:00
Markus Ebner
19c685b51a
Add unit-test for #507 2025-07-05 03:21:33 +02:00
Markus Ebner
89c4488b66
Prepare local chainmap for caller aliasing 2025-07-05 03:20:10 +02:00
Markus Ebner
dc2d9f5955 Fix #508: Context for includes in call-blocks not prepared 2025-07-05 01:45:18 +02:00
Markus Ebner
7a379df480 Add unit-tests for #508 2025-07-05 01:45:18 +02:00
Guillaume Gomez
a3f913af70
Merge pull request #504 from Kijewski/6503980895371264
parser: understand nested block comments in macro calls
2025-07-01 18:59:59 +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
Guillaume Gomez
7610b374db
Merge pull request #503 from Kijewski/pr-clippy
Fix clippy warnings for rust 1.90
2025-06-29 11:13:35 +02:00
René Kijewski
83e0f9c9c4 Fix clippy warnings for rust 1.90 2025-06-29 08:52:44 +02:00
dependabot[bot]
d858227e57 build(deps): update console requirement from 0.15.8 to 0.16.0
Updates the requirements on [console](https://github.com/console-rs/console) to permit the latest version.
- [Release notes](https://github.com/console-rs/console/releases)
- [Changelog](https://github.com/console-rs/console/blob/main/CHANGELOG.md)
- [Commits](https://github.com/console-rs/console/compare/0.15.8...0.16.0)

---
updated-dependencies:
- dependency-name: console
  dependency-version: 0.16.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-29 08:50:56 +02:00
Guillaume Gomez
73bbfa9200
Merge pull request #501 from Kijewski/pr-context_error
parser: un-inline error message generation
2025-06-24 23:20:33 +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