Skip to content

Commit 112a274

Browse files
committed
Auto merge of rust-lang#150348 - GuillaumeGomez:update-askama, r=kobzol,jieyouxu
Update askama version to `0.15` New release comes with lots of improvements like improved compile-time. More information here: https://github.com/askama-rs/askama/releases/tag/v0.15.0 r? `@yotamofek`
2 parents 123588a + 4559268 commit 112a274

File tree

9 files changed

+111
-122
lines changed

9 files changed

+111
-122
lines changed

Cargo.lock

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,20 @@ version = "0.14.0"
188188
source = "registry+https://github.com/rust-lang/crates.io-index"
189189
checksum = "f75363874b771be265f4ffe307ca705ef6f3baa19011c149da8674a87f1b75c4"
190190
dependencies = [
191-
"askama_derive",
191+
"askama_derive 0.14.0",
192+
"itoa",
193+
"percent-encoding",
194+
"serde",
195+
"serde_json",
196+
]
197+
198+
[[package]]
199+
name = "askama"
200+
version = "0.15.1"
201+
source = "registry+https://github.com/rust-lang/crates.io-index"
202+
checksum = "bb7125972258312e79827b60c9eb93938334100245081cf701a2dee981b17427"
203+
dependencies = [
204+
"askama_macros",
192205
"itoa",
193206
"percent-encoding",
194207
"serde",
@@ -201,7 +214,24 @@ version = "0.14.0"
201214
source = "registry+https://github.com/rust-lang/crates.io-index"
202215
checksum = "129397200fe83088e8a68407a8e2b1f826cf0086b21ccdb866a722c8bcd3a94f"
203216
dependencies = [
204-
"askama_parser",
217+
"askama_parser 0.14.0",
218+
"basic-toml",
219+
"memchr",
220+
"proc-macro2",
221+
"quote",
222+
"rustc-hash 2.1.1",
223+
"serde",
224+
"serde_derive",
225+
"syn 2.0.110",
226+
]
227+
228+
[[package]]
229+
name = "askama_derive"
230+
version = "0.15.1"
231+
source = "registry+https://github.com/rust-lang/crates.io-index"
232+
checksum = "8ba5e7259a1580c61571e3116ebaaa01e3c001b2132b17c4cc5c70780ca3e994"
233+
dependencies = [
234+
"askama_parser 0.15.1",
205235
"basic-toml",
206236
"memchr",
207237
"proc-macro2",
@@ -212,6 +242,15 @@ dependencies = [
212242
"syn 2.0.110",
213243
]
214244

245+
[[package]]
246+
name = "askama_macros"
247+
version = "0.15.1"
248+
source = "registry+https://github.com/rust-lang/crates.io-index"
249+
checksum = "236ce20b77cb13506eaf5024899f4af6e12e8825f390bd943c4c37fd8f322e46"
250+
dependencies = [
251+
"askama_derive 0.15.1",
252+
]
253+
215254
[[package]]
216255
name = "askama_parser"
217256
version = "0.14.0"
@@ -224,6 +263,19 @@ dependencies = [
224263
"winnow 0.7.13",
225264
]
226265

266+
[[package]]
267+
name = "askama_parser"
268+
version = "0.15.1"
269+
source = "registry+https://github.com/rust-lang/crates.io-index"
270+
checksum = "f3c63392767bb2df6aa65a6e1e3b80fd89bb7af6d58359b924c0695620f1512e"
271+
dependencies = [
272+
"rustc-hash 2.1.1",
273+
"serde",
274+
"serde_derive",
275+
"unicode-ident",
276+
"winnow 0.7.13",
277+
]
278+
227279
[[package]]
228280
name = "assert_cmd"
229281
version = "2.1.1"
@@ -624,7 +676,7 @@ name = "clippy"
624676
version = "0.1.94"
625677
dependencies = [
626678
"anstream",
627-
"askama",
679+
"askama 0.14.0",
628680
"cargo_metadata 0.18.1",
629681
"clippy_config",
630682
"clippy_lints",
@@ -1515,7 +1567,7 @@ name = "generate-copyright"
15151567
version = "0.1.0"
15161568
dependencies = [
15171569
"anyhow",
1518-
"askama",
1570+
"askama 0.15.1",
15191571
"cargo_metadata 0.21.0",
15201572
"serde",
15211573
"serde_json",
@@ -4862,7 +4914,7 @@ name = "rustdoc"
48624914
version = "0.0.0"
48634915
dependencies = [
48644916
"arrayvec",
4865-
"askama",
4917+
"askama 0.15.1",
48664918
"base64",
48674919
"expect-test",
48684920
"indexmap",

src/bootstrap/src/utils/proc_macro_deps.rs

Lines changed: 1 addition & 0 deletions
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_derive",
89
"askama_parser",
910
"basic-toml",
1011
"block-buffer",

src/ci/citool/Cargo.lock

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
6666

6767
[[package]]
6868
name = "askama"
69-
version = "0.14.0"
69+
version = "0.15.1"
7070
source = "registry+https://github.com/rust-lang/crates.io-index"
71-
checksum = "f75363874b771be265f4ffe307ca705ef6f3baa19011c149da8674a87f1b75c4"
71+
checksum = "bb7125972258312e79827b60c9eb93938334100245081cf701a2dee981b17427"
7272
dependencies = [
73-
"askama_derive",
73+
"askama_macros",
7474
"itoa",
7575
"percent-encoding",
7676
"serde",
@@ -79,9 +79,9 @@ dependencies = [
7979

8080
[[package]]
8181
name = "askama_derive"
82-
version = "0.14.0"
82+
version = "0.15.1"
8383
source = "registry+https://github.com/rust-lang/crates.io-index"
84-
checksum = "129397200fe83088e8a68407a8e2b1f826cf0086b21ccdb866a722c8bcd3a94f"
84+
checksum = "8ba5e7259a1580c61571e3116ebaaa01e3c001b2132b17c4cc5c70780ca3e994"
8585
dependencies = [
8686
"askama_parser",
8787
"basic-toml",
@@ -94,15 +94,25 @@ dependencies = [
9494
"syn",
9595
]
9696

97+
[[package]]
98+
name = "askama_macros"
99+
version = "0.15.1"
100+
source = "registry+https://github.com/rust-lang/crates.io-index"
101+
checksum = "236ce20b77cb13506eaf5024899f4af6e12e8825f390bd943c4c37fd8f322e46"
102+
dependencies = [
103+
"askama_derive",
104+
]
105+
97106
[[package]]
98107
name = "askama_parser"
99-
version = "0.14.0"
108+
version = "0.15.1"
100109
source = "registry+https://github.com/rust-lang/crates.io-index"
101-
checksum = "d6ab5630b3d5eaf232620167977f95eb51f3432fc76852328774afbd242d4358"
110+
checksum = "f3c63392767bb2df6aa65a6e1e3b80fd89bb7af6d58359b924c0695620f1512e"
102111
dependencies = [
103-
"memchr",
112+
"rustc-hash",
104113
"serde",
105114
"serde_derive",
115+
"unicode-ident",
106116
"winnow",
107117
]
108118

src/ci/citool/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2024"
55

66
[dependencies]
77
anyhow = "1"
8-
askama = "0.14"
8+
askama = "0.15.1"
99
clap = { version = "4.5", features = ["derive"] }
1010
csv = "1"
1111
diff = "0.1"

src/ci/citool/templates/test_group.askama

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ passed: {{ r.passed.len() }}, ignored: {{ r.ignored.len() }}
2424
{% for (name, test) in root_tests %}
2525
<li>
2626
{% if let Some(result) = test.single_test() %}
27-
<b>{{ name }}</b> ({% call test_result(result) %})
27+
<b>{{ name }}</b> ({% call test_result(result) %}{% endcall %})
2828
{% else %}
2929
<b>{{ name }}</b> ({{ test.revisions.len() }} revision{{ test.revisions.len() | pluralize }})
3030
<ul>
3131
{% for (revision, result) in test.revisions %}
32-
<li>#<i>{{ revision }}</i> ({% call test_result(result) %})</li>
32+
<li>#<i>{{ revision }}</i> ({% call test_result(result) %}{% endcall %})</li>
3333
{% endfor %}
3434
</ul>
3535
{% endif %}

src/librustdoc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ path = "lib.rs"
1010
[dependencies]
1111
# tidy-alphabetical-start
1212
arrayvec = { version = "0.7", default-features = false }
13-
askama = { version = "0.14", default-features = false, features = ["alloc", "config", "derive"] }
13+
askama = { version = "0.15.1", default-features = false, features = ["alloc", "config", "derive"] }
1414
base64 = "0.21.7"
1515
indexmap = { version = "2", features = ["serde"] }
1616
itertools = "0.12"

src/librustdoc/html/render/print_item.rs

Lines changed: 24 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -40,90 +40,6 @@ use crate::html::render::sidebar::filters;
4040
use crate::html::render::{document_full, document_item_info};
4141
use crate::html::url_parts_builder::UrlPartsBuilder;
4242

43-
/// Generates an Askama template struct for rendering items with common methods.
44-
///
45-
/// Usage:
46-
/// ```ignore (illustrative)
47-
/// item_template!(
48-
/// #[template(path = "<template.html>", /* additional values */)]
49-
/// /* additional meta items */
50-
/// struct MyItem<'a, 'cx> {
51-
/// cx: RefCell<&'a mut Context<'cx>>,
52-
/// it: &'a clean::Item,
53-
/// /* additional fields */
54-
/// },
55-
/// methods = [ /* method names (comma separated; refer to macro definition of `item_template_methods!()`) */ ]
56-
/// )
57-
/// ```
58-
///
59-
/// NOTE: ensure that the generic lifetimes (`'a`, `'cx`) and
60-
/// required fields (`cx`, `it`) are identical (in terms of order and definition).
61-
macro_rules! item_template {
62-
(
63-
$(#[$meta:meta])*
64-
struct $name:ident<'a, 'cx> {
65-
cx: &'a Context<'cx>,
66-
it: &'a clean::Item,
67-
$($field_name:ident: $field_ty:ty),*,
68-
},
69-
methods = [$($methods:tt),* $(,)?]
70-
) => {
71-
#[derive(Template)]
72-
$(#[$meta])*
73-
struct $name<'a, 'cx> {
74-
cx: &'a Context<'cx>,
75-
it: &'a clean::Item,
76-
$($field_name: $field_ty),*
77-
}
78-
79-
impl<'a, 'cx: 'a> ItemTemplate<'a, 'cx> for $name<'a, 'cx> {
80-
fn item_and_cx(&self) -> (&'a clean::Item, &'a Context<'cx>) {
81-
(&self.it, &self.cx)
82-
}
83-
}
84-
85-
impl<'a, 'cx: 'a> $name<'a, 'cx> {
86-
item_template_methods!($($methods)*);
87-
}
88-
};
89-
}
90-
91-
/// Implement common methods for item template structs generated by `item_template!()`.
92-
///
93-
/// NOTE: this macro is intended to be used only by `item_template!()`.
94-
macro_rules! item_template_methods {
95-
() => {};
96-
(document $($rest:tt)*) => {
97-
fn document(&self) -> impl fmt::Display {
98-
let (item, cx) = self.item_and_cx();
99-
document(cx, item, None, HeadingOffset::H2)
100-
}
101-
item_template_methods!($($rest)*);
102-
};
103-
(document_type_layout $($rest:tt)*) => {
104-
fn document_type_layout(&self) -> impl fmt::Display {
105-
let (item, cx) = self.item_and_cx();
106-
let def_id = item.item_id.expect_def_id();
107-
document_type_layout(cx, def_id)
108-
}
109-
item_template_methods!($($rest)*);
110-
};
111-
(render_assoc_items $($rest:tt)*) => {
112-
fn render_assoc_items(&self) -> impl fmt::Display {
113-
let (item, cx) = self.item_and_cx();
114-
let def_id = item.item_id.expect_def_id();
115-
render_assoc_items(cx, item, def_id, AssocItemRender::All)
116-
}
117-
item_template_methods!($($rest)*);
118-
};
119-
($method:ident $($rest:tt)*) => {
120-
compile_error!(concat!("unknown method: ", stringify!($method)));
121-
};
122-
($token:tt $($rest:tt)*) => {
123-
compile_error!(concat!("unexpected token: ", stringify!($token)));
124-
};
125-
}
126-
12743
const ITEM_TABLE_OPEN: &str = "<dl class=\"item-table\">";
12844
const REEXPORTS_TABLE_OPEN: &str = "<dl class=\"item-table reexports\">";
12945
const ITEM_TABLE_CLOSE: &str = "</dl>";
@@ -300,10 +216,6 @@ fn toggle_close(mut w: impl fmt::Write) {
300216
w.write_str("</details>").unwrap();
301217
}
302218

303-
trait ItemTemplate<'a, 'cx: 'a>: askama::Template + Display {
304-
fn item_and_cx(&self) -> (&'a clean::Item, &'a Context<'cx>);
305-
}
306-
307219
fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> impl fmt::Display {
308220
fmt::from_fn(|w| {
309221
write!(w, "{}", document(cx, item, None, HeadingOffset::H2))?;
@@ -1482,20 +1394,32 @@ fn item_type_alias(cx: &Context<'_>, it: &clean::Item, t: &clean::TypeAlias) ->
14821394
})
14831395
}
14841396

1485-
item_template!(
1486-
#[template(path = "item_union.html")]
1487-
struct ItemUnion<'a, 'cx> {
1488-
cx: &'a Context<'cx>,
1489-
it: &'a clean::Item,
1490-
fields: &'a [clean::Item],
1491-
generics: &'a clean::Generics,
1492-
is_type_alias: bool,
1493-
def_id: DefId,
1494-
},
1495-
methods = [document, document_type_layout, render_assoc_items]
1496-
);
1397+
#[derive(Template)]
1398+
#[template(path = "item_union.html")]
1399+
struct ItemUnion<'a, 'cx> {
1400+
cx: &'a Context<'cx>,
1401+
it: &'a clean::Item,
1402+
fields: &'a [clean::Item],
1403+
generics: &'a clean::Generics,
1404+
is_type_alias: bool,
1405+
def_id: DefId,
1406+
}
14971407

14981408
impl<'a, 'cx: 'a> ItemUnion<'a, 'cx> {
1409+
fn document(&self) -> impl fmt::Display {
1410+
document(self.cx, self.it, None, HeadingOffset::H2)
1411+
}
1412+
1413+
fn document_type_layout(&self) -> impl fmt::Display {
1414+
let def_id = self.it.item_id.expect_def_id();
1415+
document_type_layout(self.cx, def_id)
1416+
}
1417+
1418+
fn render_assoc_items(&self) -> impl fmt::Display {
1419+
let def_id = self.it.item_id.expect_def_id();
1420+
render_assoc_items(self.cx, self.it, def_id, AssocItemRender::All)
1421+
}
1422+
14991423
fn render_union(&self) -> impl Display {
15001424
render_union(
15011425
self.it,

src/librustdoc/html/render/sidebar.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,12 @@ pub(crate) mod filters {
128128
use askama::filters::Safe;
129129

130130
use crate::html::escape::EscapeBodyTextWithWbr;
131-
pub(crate) fn wrapped<T, V: askama::Values>(v: T, _: V) -> askama::Result<Safe<impl Display>>
132-
where
133-
T: Display,
134-
{
131+
132+
#[askama::filter_fn]
133+
pub(crate) fn wrapped(
134+
v: impl Display,
135+
_: &dyn askama::Values,
136+
) -> askama::Result<Safe<impl Display>> {
135137
let string = v.to_string();
136138
Ok(Safe(fmt::from_fn(move |f| EscapeBodyTextWithWbr(&string).fmt(f))))
137139
}

src/tools/generate-copyright/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description = "Produces a manifest of all the copyrighted materials in the Rust
88

99
[dependencies]
1010
anyhow = "1.0.65"
11-
askama = "0.14.0"
11+
askama = "0.15.1"
1212
cargo_metadata = "0.21"
1313
serde = { version = "1.0.147", features = ["derive"] }
1414
serde_json = "1.0.85"

0 commit comments

Comments
 (0)