2312 Commits

Author SHA1 Message Date
Guillaume Gomez
d475e7a4a1
Merge pull request #292 from Kijewski/pr-target-writer
derive: reserve variable prefix `__rinja` and free name `writer`
2024-12-21 22:58:22 +01:00
René Kijewski
0cc0189927 Add missing softlinks 2024-12-21 19:55:15 +01:00
René Kijewski
e800b7ca90 derive: reserve variable prefix __rinja and free name writer 2024-12-21 19:42:03 +01:00
René Kijewski
ea4b2b3e79
Merge pull request #286 from Kijewski/pr-no-std
Make rinja `#![no_std]` compatible
2024-12-21 19:23:47 +01:00
René Kijewski
e7540e17a1 Add no-std and alloc-only tests 2024-12-21 18:53:44 +01:00
René Kijewski
fe36573926 Let operator ? only wrap the error in Box if needed
This leads to fewer needless allocations, and makes the operator `?`
usable in an no-alloc context.
2024-12-21 18:53:44 +01:00
René Kijewski
bedc31797c Make #![no_std] compatible 2024-12-21 18:53:44 +01:00
René Kijewski
f00e5e2091 Duplicate filter impl builtin.rs into alloc.rs
To make the next change more readable / easy to follow.
2024-12-21 18:53:44 +01:00
Guillaume Gomez
8cd0675de1
Merge pull request #291 from epage/winnow-06
refactor(parser): Upgrade to Winnow 0.6
2024-12-20 19:04:31 +01:00
Ed Page
64b4893f93 refactor(parser): Upgrade to Winnow 0.6 2024-12-20 10:36:24 -06:00
Ed Page
47a7334321
Upgrade from Winnow 0.4 to 0.5 (#214)
* refactor(parser): Consistently use 'i' in skip_till

* refactor(parser): Clarify second input in skip_till

* refactor(parser): Consistently use 'i' in Comment::parse::content

* refactor(parser): Clarify second input in Comment::parse::content

* refactor(parser): Rename ParseResult to InputParseResult

This leaves room for a new `ParseResult` that doesn't have the input as
we transition to the Winnow 0.5 API.

* refactor(parser): Temporarily switch from parse_next to parse_peek

In 0.4, `parse_next` and `parse_peek` are the same.
In 0.5, `parse_next`s signature will change.
By switching to `parse_peek` now, we can make it so we gradually adopt
the new `parse_next` signature.

* refactor(parser): Temporarilly add unpeeks

In 0.4, `unpeek` is a no-op.
In 0.5, the `FnMut` signature impled for `Parser` changes and `unpeek`
will take the old signature and adapt it to work.
This allows us to more gradually migrate to the new `FnMut` signature.

Yes, the name `unpeek` isn't ideal but its only transitional.

* refactor(parser): Upgrade to Winnow 0.5

Note: `tests::fuzzed_target_recursion` fails on debug builds because of
the extra overhead from the deprecated APIs adapting to their
non-deprecated forms

* refactor(parser): Update signature for 'identifier'

* refactor(parser): Update signature for 'bool_lit'

* refactor(parser): Update signature for 'num_lit_suffix'

* refactor(parser): Update body for 'num_lit::int_with_base'

* refactor(parser): Update signature for 'num_lit::float'

* refactor(parser): Update signature for 'num_lit'

* refactor(parser): Update signature for 'str_lit_without_prefix'

* refactor(parser): Update signature for 'str_lit'

* refactor(parser): Update signature for 'char_lit'

* refactor(parser): Update signature for 'Char::parse'

* refactor(parser): Update signature for 'path_or_identifier'

* refactor(parser): Update signature for 'filter'

* refactor(parser): Update signature for 'State::tag_block_start'

* refactor(parser): Update signature for 'State::tag_block_end'

* refactor(parser): Update signature for 'State::tag_comment_start'

* refactor(parser): Update signature for 'State::tag_comment_end'

* refactor(parser): Update signature for 'State::tag_expr_start'

* refactor(parser): Update signature for 'State::tag_expr_end'

* refactor(parser): Update signature for 'State::nest'

* refactor(parser): Update signature for 'Level::nest'

I had considered making the input a `&mut &str` but didn't really see
the benefit, especially at this stage.
That can always be changed later.

* refactor(parser): Update signature for 'skip_ws0'

* refactor(parser): Update signature for 'skip_ws1'

* refactor(parser): Update signature for 'separated_digits' closure

* refactor(parser): Update signature for 'skip_till' closure

* refactor(parser): Update signature for 'Target::lit'

* refactor(parser): Update signature for 'Target::unnamed'

* refactor(parser): Update signature for 'Target::named'

* refactor(parser): Update signature for 'Target::rest'

* refactor(parser): Update signature for 'collect_targets'

* refactor(parser): Update signature for 'Target::parse'

* refactor(parser): Update signature for 'Target::parse_one'

* refactor(parser): Update signature for 'Suffix::try'

* refactor(parser): Update signature for 'Suffix::call'

* refactor(parser): Update signature for 'Suffix::index'

* refactor(parser): Update signature for 'Suffix::attr'

* refactor(parser): Update signature for 'Suffix::macro'

* refactor(parser): Update signature for 'token_bitand'

* refactor(parser): Update signature for 'token_xor'

* refactor(parser): Update signature for 'Expr::char'

* refactor(parser): Update signature for 'Expr::num'

* refactor(parser): Update signature for 'Expr::str'

* refactor(parser): Update signature for 'Expr::path_var_bool'

* refactor(parser): Update signature for 'Expr::array'

* refactor(parser): Update signature for 'Expr::group'

* refactor(parser): Update signature for 'Expr::single'

* refactor(parser): Update signature for 'Expr::prefix'

* refactor(parser): Update signature for 'Expr::filtered'

* refactor(parser): Update signature for 'Expr::is_as'

* refactor(parser): Update signature for 'Expr::concat'

* refactor(parser): Update signature for 'expr_prec_layer'

* refactor(parser): Update signature for 'Suffix::parse'

* refactor(parser): Update signature for 'Expr::parse'

* refactor(parser): Update signature for 'Expr::named_argument'

* refactor(parser): Update signature for 'Expr::arguments'

* refactor(parser): Update signature for 'Expr::arguments' closure

* refactor(parser): Update signature for 'Comment::parse::tag

* refactor(parser): Update signature for 'Comment::parse::content

* refactor(parser): Update signature for 'Comment::parse'

* refactor(parser): Update signature for 'Extends::parse'

* refactor(parser): Update signature for 'Include::parse'

* refactor(parser): Update signature for 'Import::parse'

* refactor(parser): Update signature for 'Whitespace::parse'

* refactor(parser): Update signature for 'Lit::parse'

* refactor(parser): Update signature for 'Node::expr'

* refactor(parser): Update signature for 'Node::many'

* refactor(parser): Update signature for 'Node::parse'

* refactor(parser): Update signature for 'Node::parse_template'

* refactor(parser): Update signature for 'cut_node' closure

* refactor(parser): Avoid 'parse_peek' in 'cut_node'

* refactor(parser): Update signature for 'unexpected_raw_tag'

* refactor(parser): Update signature for 'unexpected_tag'

* refactor(parser): Update signature for 'check_end_name'

* refactor(parser): Update signature for 'CondTest::parse_cond'

* refactor(parser): Update signature for 'check_block_start'

* refactor(parser): Update signature for 'Loop::parse::content'

* refactor(parser): Update signature for 'Macro::parse::parameters'

* refactor(parser): Update signature for 'Loop::parse::else_block'

* refactor(parser): Update signature for 'Loop::parse::body_and_end'

* refactor(parser): Reuse built-in empty parser

* refactor(parser): Update signature for remaining '*::parse'

* refactor(parser): Resolve remaining deprecations
2024-12-20 17:25:20 +01:00
René Kijewski
ecf473e809
Merge pull request #290 from Kijewski/pr-find_template
derive: use `file_info` in `find_template`
2024-12-16 19:46:59 +01:00
René Kijewski
78ea25d48f derive: use file_info in find_template 2024-12-16 19:27:48 +01:00
René Kijewski
1e662042ac
Merge pull request #289 from LukeMathWalker/includes
Canonicalize paths to ensure includes behave as expected when folders are involved
2024-12-16 12:00:58 +01:00
René Kijewski
74bf996ff3 derive: update expected output for newer trybuild versions 2024-12-16 11:46:16 +01:00
Luca Palmieri
2cf65d18cc Fix: canonicalize paths to ensure hashmap lookups behave as expected 2024-12-16 10:48:42 +01:00
Luca Palmieri
f0ac41df30 Reproduce bug with a test 2024-12-15 12:07:11 +01:00
Guillaume Gomez
f71ce236d6
Merge pull request #287 from Kijewski/pr-urlencode-uppercase
derive: fix typo that mixes up `uppercase` and `urlencode`
2024-12-14 01:21:13 +01:00
René Kijewski
a443415dd0 derive: fix typo that mixes up uppercase and urlencode 2024-12-13 23:18:34 +01:00
Guillaume Gomez
43a0efda7c
Merge pull request #276 from Kijewski/pr-one-CompileError
derive: less `format!()`, shorter context on error
2024-12-13 12:02:49 +01:00
Guillaume Gomez
63a96256d3
Merge pull request #285 from Kijewski/pr-tomlfmt
Use cargo reference manifest section order
2024-12-13 11:55:18 +01:00
René Kijewski
b49e42f0ea Use cargo reference manifest section order
In [#131] I added a check that ensures that the section in `Cargo.toml`
(and there values) are in a specific order. I invented the order quite
randomly, in the order which I thought might be useful.

This PR changes the order to be the same as in Cargo's reference about
[The Manifest Format]. Also some missing softlinks were added.

[#131]: <https://github.com/rinja-rs/rinja/pull/131>
[The Manifest Format]: <https://doc.rust-lang.org/cargo/reference/manifest.html>
2024-12-13 10:00:48 +01:00
René Kijewski
657b70d8bb Remove stray commas 2024-12-13 02:54:43 +01:00
René Kijewski
42b4a1c272 derive: fix typo to not print whole rem file on error 2024-12-13 02:54:43 +01:00
René Kijewski
1a8ac14e3b derive: do not format to String if we can help it 2024-12-13 02:54:41 +01:00
Guillaume Gomez
b16056534f
Merge pull request #284 from Kijewski/pr-rust-1.85.0-warnings
Fix clippy warnings in rust nightly 1.85
2024-12-11 22:40:06 +01:00
René Kijewski
430b99bdac Fix clippy warnings in rust nightly 1.85 2024-12-11 19:50:29 +01:00
René Kijewski
e08c28c126 Only run UI tests on stable rust 2024-12-11 19:50:29 +01:00
Guillaume Gomez
96e9815fd5
Merge pull request #278 from Kijewski/issue-272
Add failing test from issue 272
2024-11-26 13:46:21 +01:00
Guillaume Gomez
23f61306cc
Merge pull request #277 from Kijewski/pr-error
Make working with `Error`s a bit easier
2024-11-26 11:16:57 +01:00
René Kijewski
66dac1df06 Add failing test from issue 272
Reported by Ciprian Dorin Craciun ([@cipriancraciun]) in issue [#272].

[#272]: <https://github.com/rinja-rs/rinja/issues/272>
[@cipriancraciun]: <https://github.com/cipriancraciun>
2024-11-26 07:23:37 +01:00
René Kijewski
ed5f485642 Make working with Errors a bit easier 2024-11-26 05:57:09 +01:00
Ed Page
e31f4e210e
refactor(parser): Be explicit about input state (#275)
* refactor(parser): In 'filter', name a checkpoint

* refactor(parser): In 'Target::named', name a checkpoint

* refactor(parser): In 'Target::named', remove a checkpoint

* refactor(parser): In 'Target::rest', name a checkpoint

* refactor(parser): In 'Target::parse_one', name a checkpoint

* refactor(parser): In 'Target::parse', align the input

* refactor(parser): In 'Expr::is_as', name a checkpoint

* refactor(parser): In 'Expr::concat', name a checkpoint

* refactor(parser): In 'Suffix::parse', name a checkpoint

* refactor(parser): In 'Node::break', name a checkpoint

* refactor(parser): In 'Node::continue', name a checkpoint

* refactor(parser): In 'Macro::parse', name a checkpoint

* refactor(parser): In 'When::else', name a checkpoint
2024-11-25 23:56:11 +01:00
René Kijewski
c1e59c4296
Merge pull request #274 from Kijewski/pr-no-generics-cloning
derive: remove generics injection for `write_header()`
2024-11-25 22:10:41 +01:00
René Kijewski
45aac915b3 derive: remove generics injection for write_header()
With the integrations gone, this feature is not needed anymore.
2024-11-25 21:45:37 +01:00
Guillaume Gomez
8ec8f21e66
Merge pull request #271 from Kijewski/pr-no-integrations
Remove integrations and `MIME_TYPE` guessing
2024-11-25 15:08:11 +01:00
René Kijewski
20e9c2f000 Remove const Template::Template 2024-11-25 03:03:16 +01:00
René Kijewski
69ad5ea026 Remove integration crates 2024-11-25 03:03:15 +01:00
René Kijewski
87f611e871
Merge pull request #257 from Kijewski/pr-smaller-span
parser: shrink the size of `WithSpan` to one register
2024-11-24 22:47:10 +01:00
René Kijewski
611647a82b derive: replace generic &WithSpan<'_, T> with Span where possible 2024-11-24 22:31:52 +01:00
René Kijewski
47c3f6cc65 parser: shrink the size of WithSpan to one register 2024-11-24 22:30:47 +01:00
Guillaume Gomez
067fd379b8
Merge pull request #270 from Kijewski/pr-saturating
`std::num::Saturating` is stable since rust 1.74
2024-11-24 21:11:56 +01:00
René Kijewski
2688da0b2f std::num::Saturating is stable since rust 1.74 2024-11-24 20:50:31 +01:00
Guillaume Gomez
829ebb0ab3
Merge pull request #266 from Kijewski/pr-enum-optimizations
Second round of optimizations extracted from PR to implement `enum` variants
2024-11-24 20:45:09 +01:00
Guillaume Gomez
2aa3db966f
Merge pull request #268 from Kijewski/pr-no-proc-macro
derive standalone: opt out of native `proc-macro` support
2024-11-24 20:02:56 +01:00
Guillaume Gomez
8da1865912
Merge pull request #269 from Kijewski/pr-safer-match-on-unit-structs
derive: a safe-guard to disable bindings a unit struct was expected
2024-11-24 20:02:12 +01:00
René Kijewski
50f50e3931 derive: a safe-guard to disable bindings a unit struct was expected
This does not fix the error, as rinja is not able to tell was the
actually intended to do, but rust gives you a guide what the error is,
and the error is not silently ignored.
2024-11-24 19:06:47 +01:00
René Kijewski
78136c2351 derive standalone: opt out of native proc-macro support
We know that there is none, because `rinja_derive_standalone` is not run
inside of rust, but, as the name says, standalone. This makes the
playground WASM data a little smaller.
2024-11-24 18:57:53 +01:00
René Kijewski
87ee5fb948 Templates always implement FastWritable 2024-11-24 18:24:37 +01:00
René Kijewski
ebbd9ce4c8 derive: make PartialTemplateArgs::new() return None if there is no #[template] 2024-11-24 18:24:37 +01:00