Skip to content

Invalid Program with tokio::fs::File creates Type Dependency Cycle (E0391) #125867

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

Closed
bengsparks opened this issue Jun 1, 2024 · 1 comment
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@bengsparks
Copy link
Contributor

I tried this code:

#[tokio::main]
async fn main() {
    let file = tokio::fs::File("commands.pixelflut").await;
    //                      ^^^^ missing File::open
}

with

[package]
name = "tokio-file-bug"
version = "0.1.0"
edition = "2021"

[dependencies]
tokio = { version = "1.38.0", features = ["fs", "macros", "rt-multi-thread"] }

I expected to see this happen:

error[E0423]: expected function, tuple struct or tuple variant, found struct `tokio::fs::File`.

Instead, this happened:

$ cargo r 
   Compiling tokio-file-bug v0.1.0 (/Users/ben/coding/mre/tokio-file-bug)
error[E0391]: cycle detected when getting the resolver for lowering
  |
  = note: ...which requires normalizing `tokio::fs::file::File::open::{opaque#0}`...
  = note: ...which requires looking up limits...
  = note: ...which requires getting the crate HIR...
  = note: ...which again requires getting the resolver for lowering, completing the cycle
  = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

For more information about this error, try `rustc --explain E0391`.
error: could not compile `tokio-file-bug` (bin "tokio-file-bug") due to 1 previous error

The process also commonly hangs until it is killed.

Meta

rustc --version --verbose:

rustc 1.76.0 (07dca489a 2024-02-04)
binary: rustc
commit-hash: 07dca489ac2d933c78d3c5158e3f43beefeb02ce
commit-date: 2024-02-04
host: aarch64-apple-darwin
release: 1.76.0
LLVM version: 17.0.6
Backtrace (is identical, but included for completion's sake)

$ RUST_BACKTRACE=1 cargo build
   Compiling tokio-file-bug v0.1.0 (/Users/ben/coding/mre/tokio-file-bug)
error[E0391]: cycle detected when getting the resolver for lowering
  |
  = note: ...which requires normalizing `tokio::fs::file::File::open::{opaque#0}`...
  = note: ...which requires looking up limits...
  = note: ...which requires getting the crate HIR...
  = note: ...which again requires getting the resolver for lowering, completing the cycle
  = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
  
For more information about this error, try `rustc --explain E0391`.
error: could not compile `tokio-file-bug` (bin "tokio-file-bug") due to 1 previous error

@bengsparks bengsparks added the C-bug Category: This is a bug. label Jun 1, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 1, 2024
@saethlin saethlin added T-types Relevant to the types team, which will review and decide on the PR/issue. 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. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jun 3, 2024
@bengsparks
Copy link
Contributor Author

Compiles on Rust 1.77 and 1.85, so presumably this has been rectified.

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 C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants