Repository: djc/askama (rust)

Issue:
Build error thanks to bitvec vs funty
I have a project using `askama@0.10.5` and `mysql@21.0.0` which leaves me with the following 

```
├── askama v0.10.5
│   ├── askama_derive v0.10.5 (proc-macro)
│   │   ├── askama_shared v0.11.1
│   │   │   ├── askama_escape v0.10.1
│   │   │   ├── humansize v1.1.1
│   │   │   ├── nom v6.1.1
│   │   │   │   ├── bitvec v0.19.4
│   │   │   │   │   ├── funty v1.2.0
│   │   │   │   │   ├── radium v0.5.3
│   │   │   │   │   ├── tap v1.0.1
│   │   │   │   │   └── wyz v0.2.0
│   │   │   │   ├── lexical-core v0.7.5
│   │   │   │   │   ├── arrayvec v0.5.2
│   │   │   │   │   ├── bitflags v1.2.1
│   │   │   │   │   ├── cfg-if v1.0.0
│   │   │   │   │   ├── ryu v1.0.5
│   │   │   │   │   └── static_assertions v1.1.0
│   │   │   │   └── memchr v2.3.4
│   │   │   │   [build-dependencies]
│   │   │   │   └── version_check v0.9.2
│   │   │   ├── num-traits v0.2.14
│   │   │   │   [build-dependencies]
│   │   │   │   └── autocfg v1.0.1
│   │   │   ├── percent-encoding v2.1.0
│   │   │   ├── proc-macro2 v1.0.24 (*)
│   │   │   ├── quote v1.0.9 (*)
│   │   │   ├── serde v1.0.124 (*)
│   │   │   ├── syn v1.0.61 (*)
│   │   │   └── toml v0.5.8
│   │   │       └── serde v1.0.124 (*)
│   │   ├── proc-macro2 v1.0.24 (*)
│   │   └── syn v1.0.61 (*)
│   ├── askama_escape v0.10.1
│   └── askama_shared v0.11.1 (*)
├── askama_derive v0.10.5 (proc-macro) (*)
├── askama_shared v0.11.1 (*)
```

The key thing (if I understood this) is that here we have `bitvec@0.19.4`.

Elsewhere in my dependency tree I have:

```
│   ├── mysql_common v0.27.4
│   │   ├── base64 v0.13.0
│   │   ├── bigdecimal v0.2.0
│   │   │   ├── num-bigint v0.3.2
│   │   │   │   ├── num-integer v0.1.44 (*)
│   │   │   │   └── num-traits v0.2.14 (*)
│   │   │   │   [build-dependencies]
│   │   │   │   └── autocfg v1.0.1
│   │   │   ├── num-integer v0.1.44 (*)
│   │   │   ├── num-traits v0.2.14 (*)
│   │   │   └── serde v1.0.124 (*)
│   │   ├── bitflags v1.2.1
│   │   ├── bitvec v0.22.3
│   │   │   ├── funty v1.2.0
│   │   │   ├── radium v0.6.2
│   │   │   ├── tap v1.0.1
│   │   │   └── wyz v0.4.0
│   │   │       └── tap v1.0.1
│   │   ├── byteorder v1.4.2
│   │   ├── bytes v1.0.1
│   │   ├── chrono v0.4.19 (*)
```

`bitvec@0.22.3` and `funty@1.2.0` work well enough together as evidenced by a min project I put together with just the two of them, but the build specifically mentions `0.19.4`:

```
error[E0034]: multiple applicable items in scope
   --> /home/leeh/.asdf/installs/rust/1.53.0/registry/src/github.com-1ecc6299db9ec823/bitvec-0.19.4/src/order.rs:315:15
    |
315 |         if ct == R::BITS {
    |                     ^^^^ multiple `BITS` found
    |
note: candidate #1 is defined in the trait `BitMemory`
   --> /home/leeh/.asdf/installs/rust/1.53.0/registry/src/github.com-1ecc6299db9ec823/bitvec-0.19.4/src/mem.rs:29:2
    |
29  |     const BITS: u8 = mem::size_of::<Self>() as u8 * 8;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: candidate #2 is defined in the trait `IsNumber`
   --> /home/leeh/.asdf/installs/rust/1.53.0/registry/src/github.com-1ecc6299db9ec823/funty-1.2.0/src/lib.rs:144:2
    |
144 |     const BITS: u32;
    |     ^^^^^^^^^^^^^^^^
help: disambiguate the associated constant for candidate #1
    |
315 |         if ct == BitMemory::BITS {
    |                  ^^^^^^^^^^^^^^^
help: disambiguate the associated constant for candidate #2
    |
315 |         if ct == IsNumber::BITS {
    |                  ^^^^^^^^^^^^^^

error: aborting due to 43 previous errors

Some errors have detailed explanations: E0034, E0308.
For more information about an error, try `rustc --explain E0034`.
error: could not compile `bitvec`
```

I reported it here because we have here in `askama` as `nom@6.1.1` as a dependency is inherited here. 

`nom@6.2.1` has a fix, apparently which allows newer versions of `bitvec` https://github.com/Geal/nom/issues/1311#issuecomment-880902973

I tried in a small patch, something like:

``` diff
diff --git a/askama_shared/Cargo.toml b/askama_shared/Cargo.toml
index e341b2e..95775e4 100644
--- a/askama_shared/Cargo.toml
+++ b/askama_shared/Cargo.toml
@@ -19,8 +19,8 @@ yaml = ["serde", "serde_yaml"]
 [dependencies]
 askama_escape = { version = "0.10", path = "../askama_escape" }
 humansize = { version = "1.1.0", optional = true }
-funty = "=1.1.0" # Temporary fix for bitvec, remove once fixed. (https://github.com/bitvecto-rs/bitvec/issues/105)
-nom = { version = "6", features = ["std"], default-features = false }
+funty = "=1.1.0"
+nom = { version = "6.2.1", features = ["std"], default-features = false }
 num-traits = { version = "0.2.6", optional = true }
 proc-macro2 = "1"
 quote = "1"
```

This seems to work locally, and `cargo clean && cargo test` seems to be :heavy_check_mark: - I'd be happy to send a PR for that, and bumping version numbers and the release notes/etc. Please just let me know. I'm switching my project to my own git fork of `askama` and check if it's working.

Pull request:
Upgrade to nom 7
Fixes #522.

Patch:
diff --git a/askama/Cargo.toml b/askama/Cargo.toml
index 85e1213..4df0021 100644
--- a/askama/Cargo.toml
+++ b/askama/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "askama"
-version = "0.10.6"
+version = "0.11.0-beta.1"
 authors = ["Dirkjan Ochtman <dirkjan@ochtman.nl>"]
 description = "Type-safe, compiled Jinja-like templates for Rust"
 documentation = "https://docs.rs/askama"
@@ -33,9 +33,9 @@ with-tide = ["askama_derive/tide"]
 with-warp = ["askama_derive/warp"]
 
 [dependencies]
-askama_derive = { version = "0.10.5", path = "../askama_derive" }
+askama_derive = { version = "0.11.0-beta.1", path = "../askama_derive" }
 askama_escape = { version = "0.10", path = "../askama_escape" }
-askama_shared = { version = "0.11.2", path = "../askama_shared", default-features = false }
+askama_shared = { version = "0.12.0-beta.1", path = "../askama_shared", default-features = false }
 mime = { version = "0.3", optional = true }
 mime_guess = { version = "2", optional = true }
 
diff --git a/askama_actix/Cargo.toml b/askama_actix/Cargo.toml
index a518ca2..253fbd0 100644
--- a/askama_actix/Cargo.toml
+++ b/askama_actix/Cargo.toml
@@ -15,7 +15,7 @@ edition = "2018"
 
 [dependencies]
 actix-web = { version = "3", default-features = false }
-askama = { version = "0.10.6", path = "../askama", default-features = false, features = ["with-actix-web", "mime", "mime_guess"] }
+askama = { version = "0.11.0-beta.1", path = "../askama", default-features = false, features = ["with-actix-web", "mime", "mime_guess"] }
 bytes = { version = "0.5" }
 futures-util = { version = "0.3" }
 
diff --git a/askama_derive/Cargo.toml b/askama_derive/Cargo.toml
index 258ad9e..92c05f3 100644
--- a/askama_derive/Cargo.toml
+++ b/askama_derive/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "askama_derive"
-version = "0.10.5"
+version = "0.11.0-beta.1"
 authors = ["Dirkjan Ochtman <dirkjan@ochtman.nl>"]
 description = "Procedural macro package for Askama"
 homepage = "https://github.com/djc/askama"
@@ -25,6 +25,6 @@ tide = []
 warp = []
 
 [dependencies]
-askama_shared = { version = "0.11", path = "../askama_shared", default-features = false }
+askama_shared = { version = "0.12.0-beta.1", path = "../askama_shared", default-features = false }
 proc-macro2 = "1"
 syn = "1"
diff --git a/askama_escape/Cargo.toml b/askama_escape/Cargo.toml
index 1c054f7..d815f75 100644
--- a/askama_escape/Cargo.toml
+++ b/askama_escape/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "askama_escape"
-version = "0.10.1"
+version = "0.10.2"
 authors = ["Dirkjan Ochtman <dirkjan@ochtman.nl>"]
 description = "Optimized HTML escaping code, extracted from Askama"
 documentation = "https://docs.rs/askama_escape"
diff --git a/askama_gotham/Cargo.toml b/askama_gotham/Cargo.toml
index 85da812..3fbca45 100644
--- a/askama_gotham/Cargo.toml
+++ b/askama_gotham/Cargo.toml
@@ -14,7 +14,7 @@ readme = "README.md"
 edition = "2018"
 
 [dependencies]
-askama = { version = "0.10", path = "../askama", default-features = false, features = ["with-gotham", "mime", "mime_guess"] }
+askama = { version = "0.11.0-beta.1", path = "../askama", default-features = false, features = ["with-gotham", "mime", "mime_guess"] }
 gotham = { version = "0.6", default-features = false }
 hyper = "0.14.4"
 
diff --git a/askama_rocket/Cargo.toml b/askama_rocket/Cargo.toml
index 4c87ba0..373ca4e 100644
--- a/askama_rocket/Cargo.toml
+++ b/askama_rocket/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "askama_rocket"
-version = "0.11.0-rc.1"
+version = "0.11.0-rc.2"
 authors = ["Dirkjan Ochtman <dirkjan@ochtman.nl>"]
 description = "Rocket integration for Askama templates"
 documentation = "https://docs.rs/askama"
@@ -14,5 +14,5 @@ readme = "README.md"
 edition = "2018"
 
 [dependencies]
-askama = { version = "0.10", path = "../askama", default-features = false, features = ["with-rocket", "mime", "mime_guess"] }
+askama = { version = "0.11.0-beta.1", path = "../askama", default-features = false, features = ["with-rocket", "mime", "mime_guess"] }
 rocket = { version = "0.5.0-rc.1", default-features = false }
diff --git a/askama_shared/Cargo.toml b/askama_shared/Cargo.toml
index 1ffbf1c..9fb6674 100644
--- a/askama_shared/Cargo.toml
+++ b/askama_shared/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "askama_shared"
-version = "0.11.2"
+version = "0.12.0-beta.1"
 authors = ["Dirkjan Ochtman <dirkjan@ochtman.nl>"]
 description = "Shared code for Askama"
 homepage = "https://github.com/djc/askama"
@@ -19,7 +19,7 @@ yaml = ["serde", "serde_yaml"]
 [dependencies]
 askama_escape = { version = "0.10", path = "../askama_escape" }
 humansize = { version = "1.1.0", optional = true }
-nom = { version = "6.2.1", features = ["std"], default-features = false } # Gets us a newer version of bitvec https://github.com/Geal/nom/issues/1311#issuecomment-880902973
+nom = "7"
 num-traits = { version = "0.2.6", optional = true }
 proc-macro2 = "1"
 quote = "1"
diff --git a/askama_shared/src/parser.rs b/askama_shared/src/parser.rs
index 957c778..22f9a1e 100644
--- a/askama_shared/src/parser.rs
+++ b/askama_shared/src/parser.rs
@@ -5,7 +5,7 @@ use nom::combinator::{complete, cut, map, opt, recognize, value};
 use nom::error::{Error, ParseError};
 use nom::multi::{fold_many0, many0, many1, separated_list0, separated_list1};
 use nom::sequence::{delimited, pair, preceded, terminated, tuple};
-use nom::{self, error_position, Compare, IResult, InputTake};
+use nom::{self, error_position, Compare, IResult, InputLength, InputTake};
 use std::str;
 
 use crate::{CompileError, Syntax};
@@ -126,7 +126,7 @@ pub struct CondTest<'a> {
 fn ws<F, I, O, E>(mut inner: F) -> impl FnMut(I) -> IResult<I, O, E>
 where
     F: FnMut(I) -> IResult<I, O, E>,
-    I: InputTake + Clone + PartialEq + for<'a> Compare<&'a [u8; 1]>,
+    I: InputLength + InputTake + Clone + PartialEq + for<'a> Compare<&'a [u8; 1]>,
     E: ParseError<I>,
 {
     move |i: I| {
@@ -388,9 +388,13 @@ fn target(i: &[u8]) -> IResult<&[u8], Target<'_>> {
 
         let mut targets = vec![first_target];
         let (i, _) = cut(tuple((
-            fold_many0(preceded(ws(tag(",")), target), (), |_, target| {
-                targets.push(target);
-            }),
+            fold_many0(
+                preceded(ws(tag(",")), target),
+                || (),
+                |_, target| {
+                    targets.push(target);
+                },
+            ),
             opt(ws(tag(","))),
             ws(cut(tag(")"))),
         )))(i)?;
diff --git a/askama_tide/Cargo.toml b/askama_tide/Cargo.toml
index efc773a..2e7e4e2 100644
--- a/askama_tide/Cargo.toml
+++ b/askama_tide/Cargo.toml
@@ -13,7 +13,7 @@ workspace = ".."
 readme = "README.md"
 
 [dependencies]
-askama = { version = "0.10.2", path = "../askama", default-features = false, features = ["with-tide"] }
+askama = { version = "0.11.0-beta.1", path = "../askama", default-features = false, features = ["with-tide"] }
 tide = { version = "0.16", default-features = false }
 
 [dev-dependencies]
diff --git a/askama_warp/Cargo.toml b/askama_warp/Cargo.toml
index 8cd26b4..3c820b2 100644
--- a/askama_warp/Cargo.toml
+++ b/askama_warp/Cargo.toml
@@ -14,7 +14,7 @@ readme = "README.md"
 edition = "2018"
 
 [dependencies]
-askama = { version = "0.10", path = "../askama", default-features = false, features = ["with-warp", "mime", "mime_guess"] }
+askama = { version = "0.11.0-beta.1", path = "../askama", default-features = false, features = ["with-warp", "mime", "mime_guess"] }
 warp = { version = "0.3", default-features = false }
 
 [dev-dependencies]


Test patch:
diff --git a/testing/Cargo.toml b/testing/Cargo.toml
index d676bef..daa2d68 100644
--- a/testing/Cargo.toml
+++ b/testing/Cargo.toml
@@ -10,7 +10,7 @@ publish = false
 default = ["serde_json", "askama/serde-json"]
 
 [dependencies]
-askama = { path = "../askama", version = "*" }
+askama = { path = "../askama", version = "0.11.0-beta.1" }
 serde_json = { version = "1.0", optional = true }
 
 [dev-dependencies]