stack overflow in `rustc_ty_utils::opaque_types::OpaqueTypeCollector as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty::{closure#0}`
Open
Nobody has claimed this yet.
A-impl-trait
C-bug
I-crash
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
struct Foo<F: FnOnce(T), F: FnOnce(T)> {
f: FooImpl,
}
type FooImpl = Foo<FooImpl, impl FnOnce(ImplT)>;
fn bar() -> FooImpl {}
does not seem to be fixed by the new solver
Meta
rustc --version --verbose:
rustc 1.80.0-nightly (faefc618c 2024-05-07)
binary: rustc
commit-hash: faefc618cf48bd794cbc808448df1bf3f59f36af
commit-date: 2024-05-07
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.4
Error output
<output>
Backtrace
error[E0403]: the name `F` is already used for a generic parameter in this item's generic parameters
--> ice.rs:1:26
|
1 | struct Foo<F: FnOnce(T), F: FnOnce(T)> {
| - ^ already used
| |
| first use of `F`
error[E0412]: cannot find type `T` in this scope
--> ice.rs:1:22
|
1 | struct Foo<F: FnOnce(T), F: FnOnce(T)> {
| ^ not found in this scope
error[E0412]: cannot find type `T` in this scope
--> ice.rs:1:36
|
1 | struct Foo<F: FnOnce(T), F: FnOnce(T)> {
| ^ not found in this scope
error[E0412]: cannot find type `ImplT` in this scope
--> ice.rs:5:41
|
5 | type FooImpl = Foo<FooImpl, impl FnOnce(ImplT)>;
| ^^^^^ not found in this scope
|
help: you might be missing a type parameter
|
5 | type FooImpl<ImplT> = Foo<FooImpl, impl FnOnce(ImplT)>;
| +++++++
error[E0658]: `impl Trait` in type aliases is unstable
--> ice.rs:5:29
|
5 | type FooImpl = Foo<FooImpl, impl FnOnce(ImplT)>;
| ^^^^^^^^^^^^^^^^^^
|
= note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
= note: this compiler was built on 2024-05-07; consider upgrading it if it is out of date
error[E0601]: `main` function not found in crate `ice`
--> ice.rs:7:23
|
7 | fn bar() -> FooImpl {}
| ^ consider adding a `main` function to `ice.rs`
error[E0275]: overflow normalizing the type alias `FooImpl`
--> ice.rs:2:8
|
2 | f: FooImpl,
| ^^^^^^^
|
= note: in case this is a recursive type alias, consider using a struct, enum, or union instead
error[E0275]: overflow normalizing the type alias `FooImpl`
--> ice.rs:5:16
|
5 | type FooImpl = Foo<FooImpl, impl FnOnce(ImplT)>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: in case this is a recursive type alias, consider using a struct, enum, or union instead
error: rustc interrupted by SIGSEGV, printing backtrace
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-baba34ae40c356f7.so(+0x30d8ca6)[0x7f697f2d8ca6]
/usr/lib/libc.so.6(+0x40770)[0x7f697c05a770]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-baba34ae40c356f7.so(+0x489a5bc)[0x7f6980a9a5bc]
### cycle encountered after 3 frames with period 4
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-baba34ae40c356f7.so(+0x489a60d)[0x7f6980a9a60d]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-baba34ae40c356f7.so(+0x489b76f)[0x7f6980a9b76f]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-baba34ae40c356f7.so(+0x489a60d)[0x7f6980a9a60d]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-baba34ae40c356f7.so(+0x489b76f)[0x7f6980a9b76f]
### recursed 63 times
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-baba34ae40c356f7.so(+0x489a60d)[0x7f6980a9a60d]
note: rustc unexpectedly overflowed its stack! this is a bug
note: maximum backtrace depth reached, frames may have been lost
note: we would appreciate a report at https://github.com/rust-lang/rust
help: you can increase rustc's stack size by setting RUST_MIN_STACK=16777216
[1] 135140 segmentation fault rustc ice.rs
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the crash with the provided ice.rs example on the reported nightly toolchain. Trace the rustc_ty_utils::opaque_types::OpaqueTypeCollector visitor named in the title and compare behavior with the new solver. Done means the example no longer overflows rustc's stack or segfaults, with a regression test covering the failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100