< 返回版块

game4dream 发表于 2021-10-07 00:27

Tags:tokio, axum, http

空项目 Cargo.toml配置依赖如下:

[dependencies]
axum = { version = "0.2.6" }
tokio = {version = "1.11.0", features = ["full"] }

main.rs

fn main() {}

build报错如下

   Compiling axum v0.2.6
error[E0658]: const generics are unstable
  --> C:\Users\admin\.cargo\registry\src\mirrors.sjtug.sjtu.edu.cn-7a04d2510079875b\axum-0.2.6\src\extract\content_length_limit.rs:30:40
   |
30 | pub struct ContentLengthLimit<T, const N: u64>(pub T);
   |                                        ^
   |
   = note: see issue #74878 <https://github.com/rust-lang/rust/issues/74878> for more information

error[E0658]: const generics are unstable
  --> C:\Users\admin\.cargo\registry\src\mirrors.sjtug.sjtu.edu.cn-7a04d2510079875b\axum-0.2.6\src\extract\content_length_limit.rs:33:18
   |
33 | impl<T, B, const N: u64> FromRequest<B> for ContentLengthLimit<T, N>
   |                  ^
   |
   = note: see issue #74878 <https://github.com/rust-lang/rust/issues/74878> for more information

error[E0658]: const generics are unstable
  --> C:\Users\admin\.cargo\registry\src\mirrors.sjtug.sjtu.edu.cn-7a04d2510079875b\axum-0.2.6\src\extract\content_length_limit.rs:70:15
   |
70 | impl<T, const N: u64> Deref for ContentLengthLimit<T, N> {
   |               ^
   |
   = note: see issue #74878 <https://github.com/rust-lang/rust/issues/74878> for more information

error[E0276]: impl has stricter requirements than trait
   --> C:\Users\admin\.cargo\registry\src\mirrors.sjtug.sjtu.edu.cn-7a04d2510079875b\axum-0.2.6\src\extract\mod.rs:479:5
    |
270 |     async fn from_request(req: &mut RequestParts<B>) -> Result<Self, Self::Rejection>;
    |     ---------------------------------------------------------------------------------- definition of `from_request` from trait
...
479 |     async fn from_request(req: &mut RequestParts<B>) -> Result<Self, Self::Rejection> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `<T as FromRequest<B>>::Rejection: 'async_trait`

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0276, E0658.
For more information about an error, try `rustc --explain E0276`.
error: could not compile `axum`

这个错误是什么情况,从axum的github上down下来的例子跑起来也是类似的编译错误=。=

求大佬指点迷津

评论区

写评论
scrope 2021-10-09 09:02

感谢感谢!

--
👇
johnmave126: axum的msrv(最低要求rust版本号)是1.51,你是不是版本太低

johnmave126 2021-10-08 00:40

axum的msrv(最低要求rust版本号)是1.51,你是不是版本太低

E834159672 2021-10-07 00:44

是不是你的rust编译器 版本低啊,如果不是最新版升级到最新版试试

1 共 3 条评论, 1 页