Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reached type-length limit error when using axum with cargo run #261

Closed
rieval opened this issue Jul 15, 2024 · 4 comments
Closed

Reached type-length limit error when using axum with cargo run #261

rieval opened this issue Jul 15, 2024 · 4 comments
Labels
bug Something isn't working p:low Low Priority question Further information is requested

Comments

@rieval
Copy link

rieval commented Jul 15, 2024

Hello, I encountered a type-length limit error when using axum in my project. The error occurs when I execute cargo run. Here are the details of my setup and the error message:

snipped log:

   Compiling rcgen v0.13.1
   Compiling libp2p v0.53.2
   Compiling libp2p-relay-manager v0.2.5 (https://github.com/dariusc93/rust-ipfs.git#e23881d5)
   Compiling rust-ipns v0.6.0 (https://github.com/dariusc93/rust-ipfs.git#e23881d5)
   Compiling rust-ipfs v0.11.20 (https://github.com/dariusc93/rust-ipfs.git#e23881d5)
   Compiling rust-demo v0.1.0 (C:\Users\admin\Desktop\rust-demo)
error: reached the type-length limit while instantiating `<std::iter::Chain<std::iter::Map<std::iter::Chain<std::iter::Map<std::iter::Chain<..., ...>, ...>, ...>, ...>, ...> as Iterator>::fold::<..., ...>`
   --> C:\Users\admin\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\iter\adapters\map.rs:129:9
    |
129 |         self.iter.fold(init, map_fold(self.f, g))
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: consider adding a `#![type_length_limit="23949260"]` attribute to your crate
    = note: the full type name has been written to 'C:\Users\admin\Desktop\rust-demo\target\debug\deps\rust_demo.long-type.txt'       

error: could not compile `rust-demo` (bin "rust-demo") due to 1 previous error

rust_demo.long-type.txt

main.rs:

use axum::{http::StatusCode, response::IntoResponse, routing::get, Router};
use rust_ipfs::UninitializedIpfsNoop;
use tokio::net::TcpListener;

#[tokio::main]
async fn main() {
    axum::serve(
        TcpListener::bind("0.0.0.0:3090").await.unwrap(),
        Router::new().route("/", get(handler)).into_make_service(),
    )
    .await
    .ok();
}

async fn handler() -> impl IntoResponse {
    let ipfs = UninitializedIpfsNoop::new()
        .with_default()
        .listen_as_external_addr()
        .start()
        .await
        .unwrap();
    ipfs.default_bootstrap().await.ok();
    ipfs.bootstrap().await.ok();
    (StatusCode::OK, "hello world!")
}

Cargo.toml:

[package]
name = "rust-demo"
version = "0.1.0"
edition = "2021"

[dependencies]
axum = { git = "https://github.com/tokio-rs/axum.git" }
rust-ipfs = { git = "https://github.com/dariusc93/rust-ipfs.git" }
tokio = { version = "1.38", features = ["net", "rt", "rt-multi-thread"] }

toolchain:
nightly-x86_64-pc-windows-msvc (default)
rustc 1.81.0-nightly (5315cbe15 2024-07-11)

It is confusing because the GitHub workflow of my project showed that the build passed on June 28th, so I'm not sure if it's caused by the nightly version of the compiler.

@rieval rieval added the bug Something isn't working label Jul 15, 2024
@rieval
Copy link
Author

rieval commented Jul 15, 2024

Okay...it seems to be caused by the compiler
rust-lang/rust#125507

@dariusc93
Copy link
Owner

Thank you for the report. It looks like it been disabled by default now but that is something i will keep my eyes on

@rieval
Copy link
Author

rieval commented Jul 16, 2024

Thank you! The issue has been resolved for me. I will keep this issue open, feel free to close it if you think it is no longer necessary.

@dariusc93 dariusc93 added question Further information is requested p:low Low Priority labels Jul 16, 2024
@dariusc93
Copy link
Owner

Closing since this is looks resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p:low Low Priority question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants