shssoichiro / sqlformat-rs

SQL Formatter written in Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fails to build versus nom 6.0.0

kworr opened this issue · comments

commented
error: reached the type-length limit while instantiating `nom::branch::alt::<&str, &str, n...nd_of_word}])])])])])])])])])])>`
  --> /home/arcade/.cargo/registry/src/github.com-1ecc6299db9ec823/nom-6.0.0/src/branch/mod.rs:47:1
   |
47 | / pub fn alt<I: Clone, O, E: ParseError<I>, List: Alt<I, O, E>>(
48 | |   mut l: List,
49 | | ) -> impl FnMut(I) -> IResult<I, O, E> {
50 | |   move |i: I| l.choice(i)
51 | | }
   | |_^
   |
   = note: consider adding a `#![type_length_limit="1363374"]` attribute to your crate

error: aborting due to previous error

error: could not compile `sqlformat`.

rust: 1.46.0

commented

I also got the same error, I tried clone this project and adding #![type_length_limit="42037006"] on lib.rs it seems to fix it.

I'm new at Rust so i don't know if this is good fix or not. I also found nested function call on fn get_plain_reserved_token in tokenizer.rs probably that's the cause of it. CMIIW.

We are also running into this issue when trying to build sqlx. A simple fix for those running into it right now is to force version 0.1.1 within the [dependencies] section of your project's Cargo.toml file:

sqlformat = "=0.1.1"

This way, sqlx will also fall back to version 0.1.1 and things should work again until the 0.1.2 release is fixed.

Interesting that I didn't run into this when testing or bumping my projects that depend on it. But I see no reason not to merge and publish the workaround.

Published 0.1.3 with this fix

Getting this even with v0.1.3

   Compiling sqlformat v0.1.3
error: reached the type-length limit while instantiating `nom::branch::alt::<&str, &str, n...])])])])])])])])>::{{closure}}#0`
  --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/nom-6.0.0/src/branch/mod.rs:50:3
   |
50 |   move |i: I| l.choice(i)
   |   ^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: consider adding a `#![type_length_limit="43675237"]` attribute to your crate

error: aborting due to previous error

error: could not compile `sqlformat`.

I bumped this number to one arbitrarily large that should cover this once and for all, and published 0.1.4 for it.