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

Out of memory with tuple struct initialization, async fn and use #122057

Closed
sgdxbc opened this issue Mar 6, 2024 · 2 comments
Closed

Out of memory with tuple struct initialization, async fn and use #122057

sgdxbc opened this issue Mar 6, 2024 · 2 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@sgdxbc
Copy link

sgdxbc commented Mar 6, 2024

It's very hard to precisely summarize the keywords, feel sorry if I missed a duplicated case when checking previous issues.

Code

In lib.rs

pub struct Foo<F> {
    pub f: F,
}
// these also works: private `f` field, `pub Foo<F>(F);`

impl<F> Foo<F> {
    pub async fn foo() {}
}

In main.rs

use foo::Foo;  // package named `foo`

fn main() {
    Foo(());
}

Run cargo check or cargo build, it looks like compiler allocate memory in infinite loop/recursion and eventually get killed.

Either the following does not trigger...:

  • Replace use foo::Foo with mod foo { /* lib.rs content */ }
  • Replace Foo(()) with Foo { f: () } with a private f field
  • All other variants that passes compilation. (the two cases above reports correct error)

...and after do either of them once, revert the code, rerun

error[E0391]: cycle detected when getting the resolver for lowering
  |
  = note: ...which requires normalizing `foo::Foo<F>::foo::{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`.

cargo clean and rerun, the issue is back.

Meta

rustc --version --verbose:

rustc 1.76.0 (07dca489a 2024-02-04)
binary: rustc
commit-hash: 07dca489ac2d933c78d3c5158e3f43beefeb02ce
commit-date: 2024-02-04
host: x86_64-unknown-linux-gnu
release: 1.76.0
LLVM version: 17.0.6
@sgdxbc sgdxbc added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 6, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 6, 2024
@lqd
Copy link
Member

lqd commented Mar 6, 2024

This is a duplicate of #119625, which has already been fixed by #119638 on nightly and beta, so I'll close the issue as such. The fix should land on stable 1.77, in 2 weeks.

Thanks for opening an issue!

@lqd lqd closed this as not planned Won't fix, can't repro, duplicate, stale Mar 6, 2024
@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 6, 2024
@sgdxbc
Copy link
Author

sgdxbc commented Mar 7, 2024

Thanks!

I so love the language when every annoying thing of it has a deadline to disappear :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ 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

4 participants