Skip to content

Commit dd682f7

Browse files
authored
Rollup merge of #139321 - GuillaumeGomez:update-rinja, r=notriddle,lolbinarycat,yotamofek
Update to new rinja version (askama) Askama maintenance was handed over to rinja maintainers so new `rinja` release is actually `askama`. More information [here](https://blog.guillaume-gomez.fr/articles/2025-03-19+Askama+and+Rinja+merge). r? ``@notriddle``
2 parents 5913c52 + d37bd4d commit dd682f7

File tree

14 files changed

+81
-30
lines changed

14 files changed

+81
-30
lines changed

Cargo.lock

+54-5
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,48 @@ version = "0.7.6"
186186
source = "registry+https://github.com/rust-lang/crates.io-index"
187187
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
188188

189+
[[package]]
190+
name = "askama"
191+
version = "0.13.0"
192+
source = "registry+https://github.com/rust-lang/crates.io-index"
193+
checksum = "9a4e46abb203e00ef226442d452769233142bbfdd79c3941e84c8e61c4112543"
194+
dependencies = [
195+
"askama_derive",
196+
"itoa",
197+
"percent-encoding",
198+
"serde",
199+
"serde_json",
200+
]
201+
202+
[[package]]
203+
name = "askama_derive"
204+
version = "0.13.0"
205+
source = "registry+https://github.com/rust-lang/crates.io-index"
206+
checksum = "54398906821fd32c728135f7b351f0c7494ab95ae421d41b6f5a020e158f28a6"
207+
dependencies = [
208+
"askama_parser",
209+
"basic-toml",
210+
"memchr",
211+
"proc-macro2",
212+
"quote",
213+
"rustc-hash 2.1.1",
214+
"serde",
215+
"serde_derive",
216+
"syn 2.0.100",
217+
]
218+
219+
[[package]]
220+
name = "askama_parser"
221+
version = "0.13.0"
222+
source = "registry+https://github.com/rust-lang/crates.io-index"
223+
checksum = "cf315ce6524c857bb129ff794935cf6d42c82a6cff60526fe2a63593de4d0d4f"
224+
dependencies = [
225+
"memchr",
226+
"serde",
227+
"serde_derive",
228+
"winnow 0.7.4",
229+
]
230+
189231
[[package]]
190232
name = "autocfg"
191233
version = "1.4.0"
@@ -1345,8 +1387,8 @@ name = "generate-copyright"
13451387
version = "0.1.0"
13461388
dependencies = [
13471389
"anyhow",
1390+
"askama",
13481391
"cargo_metadata 0.18.1",
1349-
"rinja",
13501392
"serde",
13511393
"serde_json",
13521394
"thiserror 1.0.69",
@@ -3069,9 +3111,7 @@ version = "0.3.5"
30693111
source = "registry+https://github.com/rust-lang/crates.io-index"
30703112
checksum = "3dc4940d00595430b3d7d5a01f6222b5e5b51395d1120bdb28d854bb8abb17a5"
30713113
dependencies = [
3072-
"humansize",
30733114
"itoa",
3074-
"percent-encoding",
30753115
"rinja_derive",
30763116
]
30773117

@@ -4628,6 +4668,7 @@ name = "rustdoc"
46284668
version = "0.0.0"
46294669
dependencies = [
46304670
"arrayvec",
4671+
"askama",
46314672
"base64",
46324673
"expect-test",
46334674
"indexmap",
@@ -4636,7 +4677,6 @@ dependencies = [
46364677
"pulldown-cmark 0.9.6",
46374678
"pulldown-cmark-escape",
46384679
"regex",
4639-
"rinja",
46404680
"rustdoc-json-types",
46414681
"serde",
46424682
"serde_json",
@@ -5426,7 +5466,7 @@ dependencies = [
54265466
"serde",
54275467
"serde_spanned",
54285468
"toml_datetime",
5429-
"winnow",
5469+
"winnow 0.5.40",
54305470
]
54315471

54325472
[[package]]
@@ -6437,6 +6477,15 @@ dependencies = [
64376477
"memchr",
64386478
]
64396479

6480+
[[package]]
6481+
name = "winnow"
6482+
version = "0.7.4"
6483+
source = "registry+https://github.com/rust-lang/crates.io-index"
6484+
checksum = "0e97b544156e9bebe1a0ffbc03484fc1ffe3100cbce3ffb17eac35f7cdd7ab36"
6485+
dependencies = [
6486+
"memchr",
6487+
]
6488+
64406489
[[package]]
64416490
name = "winsplit"
64426491
version = "0.1.0"

src/bootstrap/src/utils/proc_macro_deps.rs

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pub static CRATES: &[&str] = &[
55
// tidy-alphabetical-start
66
"annotate-snippets",
77
"anstyle",
8+
"askama_parser",
89
"basic-toml",
910
"block-buffer",
1011
"bumpalo",
@@ -64,6 +65,7 @@ pub static CRATES: &[&str] = &[
6465
"wasm-bindgen-backend",
6566
"wasm-bindgen-macro-support",
6667
"wasm-bindgen-shared",
68+
"winnow",
6769
"yoke",
6870
"zerofrom",
6971
"zerovec",

src/librustdoc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ path = "lib.rs"
99

1010
[dependencies]
1111
arrayvec = { version = "0.7", default-features = false }
12-
rinja = { version = "0.3", default-features = false, features = ["config"] }
12+
askama = { version = "0.13", default-features = false, features = ["alloc", "config", "derive"] }
1313
base64 = "0.21.7"
1414
itertools = "0.12"
1515
indexmap = "2"
File renamed without changes.

src/librustdoc/html/layout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::fmt::{self, Display};
22
use std::path::PathBuf;
33

4-
use rinja::Template;
4+
use askama::Template;
55
use rustc_data_structures::fx::FxIndexMap;
66

77
use super::static_files::{STATIC_FILES, StaticFiles};

src/librustdoc/html/render/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::io;
55
use std::path::{Path, PathBuf};
66
use std::sync::mpsc::{Receiver, channel};
77

8-
use rinja::Template;
8+
use askama::Template;
99
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet};
1010
use rustc_hir::def_id::{DefIdMap, LOCAL_CRATE};
1111
use rustc_middle::ty::TyCtxt;

src/librustdoc/html/render/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use std::iter::Peekable;
4343
use std::path::PathBuf;
4444
use std::{fs, str};
4545

46-
use rinja::Template;
46+
use askama::Template;
4747
use rustc_attr_parsing::{
4848
ConstStability, DeprecatedSince, Deprecation, RustcVersion, StabilityLevel, StableSince,
4949
};

src/librustdoc/html/render/print_item.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::cmp::Ordering;
22
use std::fmt::{self, Display, Write as _};
33
use std::iter;
44

5-
use rinja::Template;
5+
use askama::Template;
66
use rustc_abi::VariantIdx;
77
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
88
use rustc_hir as hir;
@@ -37,7 +37,7 @@ use crate::html::markdown::{HeadingOffset, MarkdownSummaryLine};
3737
use crate::html::render::{document_full, document_item_info};
3838
use crate::html::url_parts_builder::UrlPartsBuilder;
3939

40-
/// Generates a Rinja template struct for rendering items with common methods.
40+
/// Generates an Askama template struct for rendering items with common methods.
4141
///
4242
/// Usage:
4343
/// ```ignore (illustrative)
@@ -301,7 +301,7 @@ fn toggle_close(mut w: impl fmt::Write) {
301301
w.write_str("</details>").unwrap();
302302
}
303303

304-
trait ItemTemplate<'a, 'cx: 'a>: rinja::Template + Display {
304+
trait ItemTemplate<'a, 'cx: 'a>: askama::Template + Display {
305305
fn item_and_cx(&self) -> (&'a clean::Item, &'a Context<'cx>);
306306
}
307307

@@ -1867,7 +1867,7 @@ fn item_proc_macro(cx: &Context<'_>, it: &clean::Item, m: &clean::ProcMacro) ->
18671867
}
18681868
}
18691869
}
1870-
Ok(())
1870+
fmt::Result::Ok(())
18711871
})?;
18721872
write!(w, "{}", document(cx, it, None, HeadingOffset::H2))
18731873
})
@@ -1944,7 +1944,7 @@ fn item_constant(
19441944
}
19451945
}
19461946
}
1947-
Ok(())
1947+
Ok::<(), fmt::Error>(())
19481948
})?;
19491949

19501950
write!(w, "{}", document(cx, it, None, HeadingOffset::H2))

src/librustdoc/html/render/sidebar.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::borrow::Cow;
22
use std::cmp::Ordering;
33

4-
use rinja::Template;
4+
use askama::Template;
55
use rustc_data_structures::fx::FxHashSet;
66
use rustc_hir::def::CtorKind;
77
use rustc_hir::def_id::{DefIdMap, DefIdSet};
@@ -123,10 +123,10 @@ impl<'a> Link<'a> {
123123
pub(crate) mod filters {
124124
use std::fmt::{self, Display};
125125

126-
use rinja::filters::Safe;
126+
use askama::filters::Safe;
127127

128128
use crate::html::escape::EscapeBodyTextWithWbr;
129-
pub(crate) fn wrapped<T>(v: T) -> rinja::Result<Safe<impl Display>>
129+
pub(crate) fn wrapped<T>(v: T) -> askama::Result<Safe<impl Display>>
130130
where
131131
T: Display,
132132
{

src/librustdoc/html/render/type_layout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::fmt;
22

3-
use rinja::Template;
3+
use askama::Template;
44
use rustc_abi::{Primitive, TagEncoding, Variants};
55
use rustc_hir::def_id::DefId;
66
use rustc_middle::span_bug;

src/librustdoc/html/sources.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::ffi::OsStr;
33
use std::path::{Component, Path, PathBuf};
44
use std::{fmt, fs};
55

6-
use rinja::Template;
6+
use askama::Template;
77
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
88
use rustc_hir::def_id::LOCAL_CRATE;
99
use rustc_middle::ty::TyCtxt;
+8-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Style for Templates
22

3-
This directory has templates in the [Rinja templating language][rinjadoc], which is very
3+
This directory has templates in the [Askama templating language][askamadoc], which is very
44
similar to [Jinja2][jinjadoc].
55

66
[jinjadoc]: https://jinja.palletsprojects.com/en/3.1.x/templates/
7-
[rinjadoc]: https://docs.rs/rinja/latest/rinja/
7+
[askamadoc]: https://docs.rs/askama/latest/askama/
88

99
We want our rendered output to have as little unnecessary whitespace as
10-
possible, so that pages load quickly. To achieve that we use Rinja's
10+
possible, so that pages load quickly. To achieve that we use Askama's
1111
[whitespace control] features. By default, whitespace characters are removed
1212
around jinja tags (`{% %}` for example). At the end of most lines, we put an
1313
empty comment tag: `{# #}`. This causes all whitespace between the end of the
@@ -18,19 +18,19 @@ remove following whitespace but not preceding. We also use the whitespace
1818
control characters in most instances of tags with control flow, for example
1919
`{% if foo %}`.
2020

21-
[whitespace control]: https://rinja.readthedocs.io/en/stable/configuration.html#whitespace-control
21+
[whitespace control]: https://askama.readthedocs.io/en/stable/configuration.html#whitespace-control
2222

2323
We want our templates to be readable, so we use indentation and newlines
2424
liberally. We indent by four spaces after opening an HTML tag _or_ a Jinja
2525
tag. In most cases an HTML tag should be followed by a newline, but if the
2626
tag has simple contents and fits with its close tag on a single line, the
2727
contents don't necessarily need a new line.
2828

29-
Rinja templates support quite sophisticated control flow. To keep our templates
29+
Askama templates support quite sophisticated control flow. To keep our templates
3030
simple and understandable, we use only a subset: `if` and `for`. In particular
31-
we avoid [assignments in the template logic][assignments] and [Rinja
31+
we avoid [assignments in the template logic][assignments] and [Askama
3232
macros][macros]. This also may make things easier if we switch to a different
3333
Jinja-style template system in the future.
3434

35-
[assignments]: https://rinja.readthedocs.io/en/stable/template_syntax.html#assignments
36-
[macros]: https://rinja.readthedocs.io/en/stable/template_syntax.html#macros
35+
[assignments]: https://askama.readthedocs.io/en/stable/template_syntax.html#assignments
36+
[macros]: https://askama.readthedocs.io/en/stable/template_syntax.html#macros

src/tools/generate-copyright/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ description = "Produces a manifest of all the copyrighted materials in the Rust
88

99
[dependencies]
1010
anyhow = "1.0.65"
11+
askama = "0.13.0"
1112
cargo_metadata = "0.18.1"
12-
rinja = "0.3.0"
1313
serde = { version = "1.0.147", features = ["derive"] }
1414
serde_json = "1.0.85"
1515
thiserror = "1"

src/tools/generate-copyright/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::collections::BTreeMap;
22
use std::path::{Path, PathBuf};
33

44
use anyhow::Error;
5-
use rinja::Template;
5+
use askama::Template;
66

77
mod cargo_metadata;
88

@@ -117,7 +117,7 @@ struct Metadata {
117117
}
118118

119119
/// Describes one node in our metadata tree
120-
#[derive(serde::Deserialize, rinja::Template, Clone, Debug, PartialEq, Eq)]
120+
#[derive(serde::Deserialize, Template, Clone, Debug, PartialEq, Eq)]
121121
#[serde(rename_all = "kebab-case", tag = "type")]
122122
#[template(path = "Node.html")]
123123
pub(crate) enum Node {

0 commit comments

Comments
 (0)