[英]the `async` keyword is missing from the function declaration when compile rust project
[英]Error in Rust unit test: "The async keyword is missing from the function declaration"
我正在使用 tokio 0.2.6 和 futures 0.3.0 的 Rust 工作区工作,尝试编译此代码时出现以下错误:
#[cfg(test)]
mod tests {
#[test]
fn test() {
assert_eq!(true, true)
}
}
error: the async keyword is missing from the function declaration
--> api/src/order.rs:299:5
|
299 | fn test() {
| ^^
这个错误对我来说毫无意义,因为它只是一个不做任何异步操作的普通单元测试。 此外,此代码所在的整个项目也不执行异步操作。 工作区中还有其他项目使用 tokio 和 futures 都在使用异步代码,但我没有看到它们是如何相互影响的。
正如用户 mcarton 所指出的,出现问题是因为我use tokio::*;
在我的项目中的某个地方。 删除该导入解决了问题。
对我来说是:
#[macro_use]
extern crate tokio;
它只有在我删除它后才起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.