Skip to content

Commit 68082ce

Browse files
Kijewskiseijikun
authored andcommitted
We need syn/full
1 parent c243ea2 commit 68082ce

File tree

8 files changed

+16
-53
lines changed

8 files changed

+16
-53
lines changed

askama/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,14 @@ maintenance = { status = "actively-developed" }
4545

4646
[features]
4747
default = ["config", "derive", "std", "urlencode"]
48-
full = ["default", "blocks", "code-in-doc", "serde_json"]
48+
full = ["default", "code-in-doc", "serde_json"]
4949

5050
alloc = [
5151
"askama_macros?/alloc",
5252
"serde?/alloc",
5353
"serde_json?/alloc",
5454
"percent-encoding?/alloc",
5555
]
56-
blocks = ["askama_macros?/blocks"]
5756
code-in-doc = ["askama_macros?/code-in-doc"]
5857
config = ["askama_macros?/config"]
5958
derive = ["dep:askama_macros", "dep:askama_macros"]

askama_derive/Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,18 @@ memchr = "2"
3030
proc-macro2 = { version = "1", default-features = false }
3131
quote = { version = "1", default-features = false }
3232
rustc-hash = "2.0.0"
33-
syn = { version = "2.0.3", default-features = false, features = ["clone-impls", "derive", "parsing", "printing"] }
33+
syn = { version = "2.0.3", default-features = false, features = ["clone-impls", "derive", "full", "parsing", "printing"] }
3434

3535
[dev-dependencies]
3636
console = "0.16.0"
3737
criterion = "0.7"
3838
prettyplease = "0.2.20"
3939
similar = "2.6.0"
40-
syn = { version = "2.0.3", features = ["full"] }
4140

4241
[features]
4342
# Use every feature to aid testing. `askama_macros` will opt-out of default features.
4443
default = [
4544
"alloc",
46-
"blocks",
4745
"code-in-doc",
4846
"config",
4947
"external-sources",
@@ -54,7 +52,6 @@ default = [
5452
]
5553

5654
alloc = []
57-
blocks = ["syn/full"]
5855
code-in-doc = ["dep:pulldown-cmark"]
5956
config = [
6057
"external-sources",

askama_derive/src/generator.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ pub(crate) enum TmplKind<'a> {
5959
/// [`askama::helpers::EnumVariantTemplate`]
6060
Variant,
6161
/// Used in `blocks` implementation
62-
#[allow(unused)]
6362
Block(&'a str),
6463
}
6564

@@ -254,15 +253,13 @@ impl<'a, 'h> Generator<'a, 'h> {
254253
#size_hint_s
255254
} });
256255

257-
#[cfg(feature = "blocks")]
258256
for block in self.input.blocks {
259257
self.impl_block(buf, block)?;
260258
}
261259

262260
Ok(size_hint)
263261
}
264262

265-
#[cfg(feature = "blocks")]
266263
fn impl_block(
267264
&self,
268265
buf: &mut Buffer,

askama_derive/src/input.rs

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ pub(crate) struct TemplateInput<'a> {
2424
pub(crate) source: &'a Source,
2525
pub(crate) source_span: SourceSpan,
2626
pub(crate) block: Option<(&'a str, Span)>,
27-
#[cfg(feature = "blocks")]
2827
pub(crate) blocks: &'a [Block],
2928
pub(crate) print: Print,
3029
pub(crate) escaper: &'a str,
@@ -46,7 +45,6 @@ impl TemplateInput<'_> {
4645
template_span,
4746
source: (source, source_span),
4847
block,
49-
#[cfg(feature = "blocks")]
5048
blocks,
5149
print,
5250
escaping,
@@ -142,7 +140,6 @@ impl TemplateInput<'_> {
142140
source,
143141
source_span: source_span.clone(),
144142
block: block.as_ref().map(|(block, span)| (block.as_str(), *span)),
145-
#[cfg(feature = "blocks")]
146143
blocks: blocks.as_slice(),
147144
print: *print,
148145
escaper,
@@ -411,7 +408,6 @@ impl AnyTemplateArgs {
411408
}
412409
}
413410

414-
#[cfg(feature = "blocks")]
415411
pub(crate) struct Block {
416412
pub(crate) name: String,
417413
pub(crate) span: Span,
@@ -421,7 +417,6 @@ pub(crate) struct TemplateArgs {
421417
template_span: Span,
422418
pub(crate) source: (Source, SourceSpan),
423419
block: Option<(String, Span)>,
424-
#[cfg(feature = "blocks")]
425420
blocks: Vec<Block>,
426421
print: Print,
427422
escaping: Option<String>,
@@ -476,7 +471,6 @@ impl TemplateArgs {
476471
}
477472
},
478473
block: args.block.map(|value| (value.value(), value.span())),
479-
#[cfg(feature = "blocks")]
480474
blocks: args
481475
.blocks
482476
.unwrap_or_default()
@@ -503,7 +497,6 @@ impl TemplateArgs {
503497
template_span: Span::call_site(),
504498
source: (Source::Source("".into()), SourceSpan::empty()),
505499
block: None,
506-
#[cfg(feature = "blocks")]
507500
blocks: vec![],
508501
print: Print::default(),
509502
escaping: None,
@@ -765,7 +758,6 @@ pub(crate) struct PartialTemplateArgs {
765758
pub(crate) config: Option<LitStr>,
766759
pub(crate) whitespace: Option<Whitespace>,
767760
pub(crate) crate_name: Option<ExprPath>,
768-
#[cfg(feature = "blocks")]
769761
pub(crate) blocks: Option<Vec<LitStr>>,
770762
}
771763

@@ -831,7 +823,6 @@ const _: () = {
831823
config: None,
832824
whitespace: None,
833825
crate_name: None,
834-
#[cfg(feature = "blocks")]
835826
blocks: None,
836827
};
837828
let mut has_data = false;
@@ -886,30 +877,22 @@ const _: () = {
886877
this.crate_name = Some(get_exprpath(ident, pair.value)?);
887878
continue;
888879
} else if ident == "blocks" {
889-
if !cfg!(feature = "blocks") {
890-
return Err(CompileError::no_file_info(
891-
"enable feature `blocks` to use `blocks` argument",
892-
Some(ident.span()),
893-
));
894-
} else if is_enum_variant {
880+
if is_enum_variant {
895881
return Err(CompileError::no_file_info(
896882
"template attribute `blocks` can only be used on the `enum`, \
897883
not its variants",
898884
Some(ident.span()),
899885
));
900886
}
901-
#[cfg(feature = "blocks")]
902-
{
903-
ensure_only_once(ident, &mut this.blocks)?;
904-
this.blocks = Some(
905-
get_exprarray(ident, pair.value)?
906-
.elems
907-
.into_iter()
908-
.map(|value| get_strlit(ident, get_lit(ident, value)?))
909-
.collect::<Result<_, _>>()?,
910-
);
911-
continue;
912-
}
887+
ensure_only_once(ident, &mut this.blocks)?;
888+
this.blocks = Some(
889+
get_exprarray(ident, pair.value)?
890+
.elems
891+
.into_iter()
892+
.map(|value| get_strlit(ident, get_lit(ident, value)?))
893+
.collect::<Result<_, _>>()?,
894+
);
895+
continue;
913896
}
914897

915898
let value = get_lit(ident, pair.value)?;
@@ -1081,7 +1064,6 @@ const _: () = {
10811064
}
10821065
}
10831066

1084-
#[cfg(feature = "blocks")]
10851067
fn get_exprarray(name: &Ident, mut expr: Expr) -> Result<syn::ExprArray, CompileError> {
10861068
loop {
10871069
match expr {

askama_macros/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ askama_derive = { package = "askama_derive", path = "../askama_derive", version
2222

2323
[features]
2424
default = ["config", "derive", "std", "urlencode"]
25-
full = ["default", "blocks", "code-in-doc", "serde_json"]
25+
full = ["default", "code-in-doc", "serde_json"]
2626

2727
alloc = ["askama_derive/alloc"]
28-
blocks = ["askama_derive/blocks"]
2928
code-in-doc = ["askama_derive/code-in-doc"]
3029
config = ["askama_derive/config"]
3130
nightly-spans = ["askama_derive/nightly-spans"]

book/src/features.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,12 @@ The most useful catch-all feature for a quick start might be `"full"`,
9292
which enables all implemented features, i.e.:
9393

9494
```toml
95-
full = ["default", "blocks", "code-in-doc", "serde_json"]
95+
full = ["default", "code-in-doc", "serde_json"]
9696
```
9797

9898
In production or once your project is “maturing” you might want to manually opt-in to any needed
9999
features with a finer granularity instead of depending on `"full"`.
100100

101-
### `"blocks"`
102-
103-
<blockquote class="right" style="padding:0.5ex 1ex; margin:0 0 1ex 1ex; font-size:80%">
104-
enabled by <code>"full"</code>
105-
</blockquote>
106-
107-
Enables using [the template attribute `blocks`](creating_templates.html#the-template-attribute).
108-
109101
### `"serde_json"`
110102

111103
<blockquote class="right" style="padding:0.5ex 1ex; margin:0 0 1ex 1ex; font-size:80%">

testing/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ serde_json = { version = "1.0", optional = true }
1919
core = { package = "intentionally-empty", version = "1.0.0" }
2020

2121
[dev-dependencies]
22-
askama = { path = "../askama", version = "0.14.0", features = ["blocks", "code-in-doc", "serde_json"] }
22+
askama = { path = "../askama", version = "0.14.0", features = ["code-in-doc", "serde_json"] }
2323
askama_parser = { path = "../askama_parser", version = "0.14.0" }
2424

2525
assert_matches = "1.5.0"
@@ -28,8 +28,7 @@ pulldown-cmark = "0.13"
2828
trybuild = "1.0.100"
2929

3030
[features]
31-
default = ["blocks", "code-in-doc", "serde_json"]
32-
blocks = ["askama/blocks"]
31+
default = ["code-in-doc", "serde_json"]
3332
code-in-doc = ["askama/code-in-doc"]
3433
nightly-spans = ["askama/nightly-spans"]
3534
serde_json = ["dep:serde_json", "askama/serde_json"]

testing/tests/blocks.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg(feature = "blocks")]
2-
31
use std::fmt::Display;
42

53
use askama::Template;

0 commit comments

Comments
 (0)