54 Commits

Author SHA1 Message Date
René Kijewski
6fe504e133 Bump version numbers to v0.3.0 2024-08-01 15:41:37 +02:00
Guillaume Gomez
4de78ad9be Improve compilation error message for invalid usage of rest pattern 2024-07-31 19:28:50 +02:00
Guillaume Gomez
2771533594 Add rest pattern support 2024-07-30 22:31:42 +02:00
René Kijewski
380ecc1d8e derive: properly display error locations 2024-07-29 05:05:00 +02:00
Guillaume Gomez
e74f0d20ba Change the error message to make it start at the as keyword 2024-07-28 21:37:22 +02:00
René Kijewski
7b99783f00 parser: use memchr to speed-up skip_till()
`skip_till()` is used in the parser to find the next block `{%`,
comment `{#` or expression `{{`. At every character position, it is
tested if one of these three substrings follows. Using [`memchr3()`],
we could at least skip to the next candidate, a `{`. The syntax for
blocks, comments and expressions can be modified by the user, but that
does not matter much; we can simply supply `memchr3()` with the first
byte in each of these strings.

[`memchr3()`]: <https://docs.rs/memchr/2.7.4/memchr/fn.memrchr3.html>

```text
librustdoc/all          time:   [366.54 µs 366.78 µs 367.02 µs]
                        thrpt:  [38.475 MiB/s 38.500 MiB/s 38.525 MiB/s]
                 change:
                        time:   [-17.358% -17.065% -16.820%] (p = 0.00 < 0.05)
                        thrpt:  [+20.221% +20.576% +21.004%]
                        Performance has improved.

librustdoc/item_info    time:   [6.3315 µs 6.3400 µs 6.3495 µs]
                        thrpt:  [24.783 MiB/s 24.820 MiB/s 24.853 MiB/s]
                 change:
                        time:   [-6.5547% -6.4090% -6.2633%] (p = 0.00 < 0.05)
                        thrpt:  [+6.6818% +6.8479% +7.0144%]
                        Performance has improved.

librustdoc/item_union   time:   [39.377 µs 39.551 µs 39.720 µs]
                        thrpt:  [24.850 MiB/s 24.957 MiB/s 25.067 MiB/s]
                 change:
                        time:   [-6.9834% -6.2455% -5.5849%] (p = 0.00 < 0.05)
                        thrpt:  [+5.9153% +6.6616% +7.5077%]
                        Performance has improved.

librustdoc/page         time:   [170.83 µs 170.99 µs 171.23 µs]
                        thrpt:  [36.164 MiB/s 36.213 MiB/s 36.248 MiB/s]
                 change:
                        time:   [-12.413% -12.183% -11.968%] (p = 0.00 < 0.05)
                        thrpt:  [+13.595% +13.873% +14.173%]
                        Performance has improved.

librustdoc/print_item   time:   [21.163 µs 21.234 µs 21.322 µs]
                        thrpt:  [44.280 MiB/s 44.463 MiB/s 44.612 MiB/s]
                 change:
                        time:   [-19.848% -18.613% -17.491%] (p = 0.00 < 0.05)
                        thrpt:  [+21.198% +22.870% +24.763%]
                        Performance has improved.

librustdoc/short_item_info
                        time:   [19.781 µs 19.813 µs 19.846 µs]
                        thrpt:  [45.652 MiB/s 45.727 MiB/s 45.801 MiB/s]
                 change:
                        time:   [-18.027% -17.806% -17.574%] (p = 0.00 < 0.05)
                        thrpt:  [+21.321% +21.663% +21.991%]
                        Performance has improved.

librustdoc/sidebar      time:   [40.694 µs 40.806 µs 40.957 µs]
                        thrpt:  [30.131 MiB/s 30.242 MiB/s 30.325 MiB/s]
                 change:
                        time:   [-14.698% -14.069% -13.456%] (p = 0.00 < 0.05)
                        thrpt:  [+15.548% +16.372% +17.231%]
                        Performance has improved.

librustdoc/source       time:   [15.249 µs 15.264 µs 15.278 µs]
                        thrpt:  [48.251 MiB/s 48.295 MiB/s 48.343 MiB/s]
                 change:
                        time:   [-25.832% -25.678% -25.532%] (p = 0.00 < 0.05)
                        thrpt:  [+34.285% +34.550% +34.829%]
                        Performance has improved.

librustdoc/type_layout_size
                        time:   [9.0168 µs 9.0446 µs 9.0789 µs]
                        thrpt:  [29.832 MiB/s 29.945 MiB/s 30.038 MiB/s]
                 change:
                        time:   [-11.100% -10.437% -9.4426%] (p = 0.00 < 0.05)
                        thrpt:  [+10.427% +11.653% +12.486%]
                        Performance has improved.

librustdoc/type_layout  time:   [34.088 µs 34.114 µs 34.139 µs]
                        thrpt:  [78.860 MiB/s 78.919 MiB/s 78.979 MiB/s]
                 change:
                        time:   [-37.865% -37.723% -37.585%] (p = 0.00 < 0.05)
                        thrpt:  [+60.217% +60.573% +60.941%]
                        Performance has improved.
```
2024-07-28 18:14:57 +02:00
René Kijewski
d413474217 parser: store list of primitive types at one place 2024-07-28 18:02:52 +02:00
René Kijewski
a6a474514e Implement operator as in template language
Because it is not always super obvious if an identifier refers to `T` or
`&T`, any references are automatically followed.
2024-07-28 18:02:14 +02:00
Guillaume Gomez
eb4ceae2a3 Store bool for BoolLit instead of str 2024-07-26 22:12:55 +02:00
Guillaume Gomez
5c5d9a2fc3 Remove level nesting in is_defined parsing 2024-07-24 13:14:51 +02:00
Guillaume Gomez
0372dac003 Implement is (not) defined 2024-07-24 10:27:35 +02:00
René Kijewski
b593f1ffa7 parser: better error msg for unkn. number suffices 2024-07-20 12:15:13 +02:00
Guillaume Gomez
f45aff074a Add newly added f16 and f128 types in parsing 2024-07-19 15:05:59 +02:00
René Kijewski
10e67fa312 Reimplement {% filter %} block
This PR reimplements the code generation for `{% filter %}` blocks, so
that the data is written directly into its destination writer, without
using a buffer. This way it behaves like a specialized
`{{ expr|filter1|filter2 }}` would, if the `expr` was a `Template` that
contained the body of the filter block.
2024-07-13 11:11:04 +02:00
René Kijewski
34073642b1 Run typos to fix typos 2024-07-12 07:07:00 +02:00
René Kijewski
b295ff62ef derive: Replace Rcs with Arcs 2024-07-11 03:40:33 +02:00
René Kijewski
85330b353a Raise the MSRV to 1.71 2024-07-10 21:38:43 +02:00
Guillaume Gomez
69671826cc Remove links to discord server 2024-07-09 13:46:58 +02:00
René Kijewski
277cff4ebf Reset all version numbers to 0.2.0 2024-07-09 12:48:41 +02:00
René Kijewski
9987770dda Store template source in Rc<str> 2024-07-06 00:40:34 +02:00
René Kijewski
aa93b2a986 Implement Hash + PartialEq for more parser + derive types 2024-07-05 03:31:17 +02:00
René Kijewski
ee3a9e675a Add .rustfmt.toml configuration
This PR configures the formatting with a few defaults that aid
readability, in my opinion. One drawback of adding this file is that
rustfmt uses unstable features, now, and you have to use nightly to run
it:

```sh
cargo +nightly fmt --all
```
2024-07-04 07:05:57 +02:00
Guillaume Gomez
37c300d483
Merge pull request #42 from GuillaumeGomez/top-level-nodes-errors
Generate better errors for top level nodes
2024-07-03 10:39:33 +02:00
René Kijewski
20dc1a0139 Fix lifetime of WithSpan::span() 2024-07-03 00:48:09 +02:00
Sheldon Young
9e1e20cdb4 strip_common test was failing 2024-07-02 13:39:49 -07:00
René Kijewski
79e747a28a
Merge pull request #39 from GuillaumeGomez/ref-deref-ops
Allow to use `*` and `&` in expressions
2024-07-02 02:03:25 +02:00
Guillaume Gomez
e9fc4a6db3 Allow to use * and & in expressions 2024-07-01 20:54:13 +02:00
René Kijewski
f4ccdb6585 Better information that .. must come last in a named struct 2024-06-28 23:32:13 +02:00
René Kijewski
e84e1a6af2 Move Target into its own file 2024-06-28 22:56:34 +02:00
René Kijewski
6b8b97672a Better error message on missing comma 2024-06-28 22:48:45 +02:00
René Kijewski
e94525f483 Add support for .. in let pattern matching for structs 2024-06-28 05:25:21 +02:00
René Kijewski
78878f08b6
Merge pull request #31 from GuillaumeGomez/improve-level-api
Improve Level API a bit
2024-06-25 00:05:42 +02:00
Guillaume Gomez
fd1108c4bc
Merge pull request #18 from Kijewski/pr-iso646
Use ISO 646 alternative operators for bit ops + proper error messages for spaces around the `|filter` operator
2024-06-24 14:04:53 +02:00
Guillaume Gomez
4b847a27b2 Improve Level API a bit 2024-06-24 11:07:54 +02:00
Guillaume Gomez
ae1e188118 Improve error message in case too much nesting 2024-06-23 20:55:23 +02:00
René Kijewski
50ac555684 Remove helper functions 2024-06-23 20:55:00 +02:00
René Kijewski
fb4d8a6073 Better error message for space + filter 2024-06-23 20:54:28 +02:00
René Kijewski
879d889bb2 Use ISO 646 alternative operators for bit ops
This change allows simplifying the use of filter expressions, because
you won't have to care about spaces around the `|` pipe operator.
2024-06-23 20:47:27 +02:00
Guillaume Gomez
d4e36fa59e Remove duplicated code to detect Rust keywords/identifiers 2024-06-20 23:16:52 +02:00
René Kijewski
bdc3c79e95 Test UTF-8-ness only in #[test]s 2024-06-20 22:02:39 +02:00
René Kijewski
5da686643d Deny all rust keywords as macro names 2024-06-20 21:46:20 +02:00
Guillaume Gomez
fc1d52d604 Add more tests for recursion errors 2024-06-20 18:53:14 +02:00
Guillaume Gomez
847d0bc2b9 Fix invalid "start" given to errors 2024-06-20 18:53:14 +02:00
Guillaume Gomez
20c26dbf0f Limit nested filters to avoid stack overflow 2024-06-20 18:53:14 +02:00
Guillaume Gomez
e7a8acf42e Fix formatting 2024-06-17 17:25:11 +02:00
Guillaume Gomez
9699f636a7 Migrate config errors to new more complete CompileError version 2024-06-17 17:18:55 +02:00
Guillaume Gomez
21a9a160e6 Add askama_derive::FileInfo type 2024-06-17 17:18:55 +02:00
Guillaume Gomez
6f8a09b8c9 Update askama_parser AST tests 2024-06-17 17:18:55 +02:00
Guillaume Gomez
5e91d33d77 Add Node::span method 2024-06-17 17:18:55 +02:00
Guillaume Gomez
369562bbdd Update Node variants to use WithSpan 2024-06-17 17:18:55 +02:00