Reputation: 457
I'm working on a Rust workspace which uses tokio 0.2.6 and futures 0.3.0 and I get the following error trying to compile this code:
#[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() {
| ^^
This error makes no sense to me, because it is just a plain-old unit test that doesn't do anything async. More over, the entire project this code is located in doesn't do async either. There are other projects in the workspace which are heavy on async code using both tokio and futures, but I'm not seeing how these affect each other.
Upvotes: 2
Views: 1462
Reputation: 1181
For me it was:
#[macro_use]
extern crate tokio;
It only worked after I removed it.
Upvotes: 2
Reputation: 457
As user mcarton noted, the problem occurred because I had use tokio::*;
in my project somewhere. Removing that import solved the problem.
Upvotes: 3