rust 如何修复“类型参数必须是一个tuple”的错误?

67up9zun  于 2023-01-13  发布在  其他
关注(0)|答案(2)|浏览(120)

当编译一个项目时,它会从toutour-rs crate中抛出错误:

Compiling detour v0.8.0 (https://github.com/darfink/detour-rs?rev=3b6f17a#3b6f17a8)
error[E0059]: type parameter to bare `Fn` trait must be a tuple
   --> C:\Users\Станислав\.cargo\git\checkouts\detour-rs-497fa4e2739f3073\3b6f17a\src\detours\statik.rs:106:8
    |
106 |     D: Fn<T::Arguments, Output = T::Output> + Send + 'static,
    |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Tuple` is not implemented for `<T as Function>::Arguments`
    |
note: required by a bound in `Fn`
help: consider further restricting the associated type
    |
106 |     D: Fn<T::Arguments, Output = T::Output> + Send + 'static, <T as Function>::Arguments: Tuple
    |                                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0059]: type parameter to bare `Fn` trait must be a tuple
   --> C:\Users\Станислав\.cargo\git\checkouts\detour-rs-497fa4e2739f3073\3b6f17a\src\detours\statik.rs:157:8
    |
157 |     C: Fn<T::Arguments, Output = T::Output> + Send + 'static,
    |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Tuple` is not implemented for `<T as Function>::Arguments`
    |
note: required by a bound in `Fn`
help: consider further restricting the associated type
    |
157 |     C: Fn<T::Arguments, Output = T::Output> + Send + 'static, <T as Function>::Arguments: Tuple
    |                                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

For more information about this error, try `rustc --explain E0059`.
error: could not compile `detour` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...

我试着改变绕道的版本,但是没有用。怎么解决?

5uzkadbs

5uzkadbs1#

detour依赖于使用夜间Rust特性来实现static_detour!宏。
夜间特性是不稳定的,可能会在没有警告的情况下发生更改-在本例中,it looks like that is what's happened
您的选项包括:

  • 如果您没有使用static_detour!,请禁用crate的默认特性标记,以避免在构建中包含此标记。
  • detour = { version = "0.8", default-features = false }
  • 等待crate更新以支持最新的nightly(但请注意detour自2021年以来就没有提交过)。
  • 或者,叉板条箱和做更新自己。
  • 降级到更早的夜间版本的 rust 。
xcitsw88

xcitsw882#

命令降级 rust 工具链,帮助我解决这个问题

rustup toolchain install nightly-2022-10-29-x86_64-pc-windows-msvc
rustup default nightly-2022-10-29-x86_64-pc-windows-msvc

相关问题