rust-ipfs
rust-ipfs copied to clipboard
Reached type-length limit error when using axum with `cargo run`
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
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.