I was using actix-web
to make my project, but after importing the serde_json
crate my code refused to compile and gave this error:
error[E0432]: unresolved import `actix_web::HttpServer`
--> src/main.rs:1:41
|
1 | use actix_web::{web, App, HttpResponse, HttpServer};
| ^^^^^^^^^^ no `HttpServer` in the root
For more information about this error, try `rustc --explain E0432`.
which is weird, because before that it was working fine, so i decided to test it again on a different project using cargo new
, with the following code presented in actix-web's documentation as an example:
use actix_web::{web, App, HttpResponse, HttpServer};
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| App::new().route("/", web::get().to(HttpResponse::Ok)))
.bind(("127.0.0.1", 8080))?
.run()
.await
}
and it continued to give the same error.
I tried using cargo clean
to no avail, but when i degraded actix-web = "4"
to actix-web = "3"
, in my Cargo.toml
file it started working again. I'm guessing this is a more general Rust problem.
Cargo.toml
:
[package]
name = "project-name"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
actix-files = "0.6.2"
actix-web = "4"
serde_json = "1.0.94"
I'm running rustc/cargo 1.68.0 and Arch Linux-6.1.1 x86-64 if that has something to do with it.
I've asked other people to try and reproduce it but in their machine it worked.