Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect imports suggestion for code inside tokio::main #86241

Closed
Cerber-Ursi opened this issue Jun 12, 2021 · 4 comments
Closed

Incorrect imports suggestion for code inside tokio::main #86241

Cerber-Ursi opened this issue Jun 12, 2021 · 4 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Cerber-Ursi
Copy link
Contributor

Given the following code:

#[tokio::main]
async fn main() {
    let _ = Duration::from_millis(97);
}

The current output is:

error[E0433]: failed to resolve: use of undeclared type `Duration`
 --> src/main.rs:3:13
  |
3 |     let _ = Duration::from_millis(97);
  |             ^^^^^^^^ not found in this scope
  |
help: consider importing one of these items
  |
2 | async use chrono::Duration;
  |       ^^^^^^^^^^^^^^^^^^^^^
2 | async use core::time::Duration;
  |       ^^^^^^^^^^^^^^^^^^^^^^^^^
2 | async use humantime::Duration;
  |       ^^^^^^^^^^^^^^^^^^^^^^^^
2 | async use instant::Duration;
  |       ^^^^^^^^^^^^^^^^^^^^^^
    and 5 other candidates

Note the async use bit, which is, obviously, invalid syntax.

@Cerber-Ursi Cerber-Ursi added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 12, 2021
@ehuss
Copy link
Contributor

ehuss commented Jun 12, 2021

Thanks for the report!

Even fixing the async part won't be sufficient because the #[tokio::main] attribute is in the way, too. There is more discussion at #85312 (comment) and #85427 as to why that doesn't work.

@pnkfelix
Copy link
Member

pnkfelix commented Nov 16, 2021

(This is probably fixed by proposed PR #90941.)

@Cerber-Ursi
Copy link
Contributor Author

Just checked in playground - seems to be fixed for now, probably should be closed?

@ehuss
Copy link
Contributor

ehuss commented Jun 5, 2022

Yea, I'm going to close as resolved by #94584.

@ehuss ehuss closed this as completed Jun 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants