Skip to content

ICE: stack overflow with -Ztyping-mode-borrowck in inference #139446

Open
@matthiaskrgr

Description

@matthiaskrgr

code:

//@compile-flags: -Ztyping-mode-borrowck

trait T {}

fn wrap(x: impl T) -> impl T {
    //~^ WARN function cannot return without recursing
    wrap(wrap(x))
}

fn main() {}

Version information

rustc 1.88.0-nightly (1de931283 2025-04-06)
binary: rustc
commit-hash: 1de931283df18f3af4922fe9a96adcc8936ac42e
commit-date: 2025-04-06
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Ztyping-mode-borrowck

Program output

warning: function cannot return without recursing
 --> a.rs:5:1
  |
5 | fn wrap(x: impl T) -> impl T {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
6 |     //~^ WARN function cannot return without recursing
7 |     wrap(wrap(x))
  |          ------- recursive call site
  |
  = help: a `loop` may express intention better if this is on purpose
  = note: `#[warn(unconditional_recursion)]` on by default

error: rustc interrupted by SIGSEGV, printing backtrace

/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(+0x391999f) [0x7e969231999f]
/usr/lib/libc.so.6(+0x3dcd0) [0x7e968e84bcd0]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(+0x57e0005) [0x7e96941e0005]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(+0x57e00de) [0x7e96941e00de]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(+0x57e00de) [0x7e96941e00de]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(_RNvMs_NtNtCs9vGWXuItzyG_11rustc_infer5infer12opaque_typesNtB6_9InferCtxt18insert_hidden_type+0x34d) [0x7e9694994b9f]

### cycle encountered after 6 frames with period 12
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(+0x5f95d4a) [0x7e9694995d4a]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(+0x5f95c42) [0x7e9694995c42]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(_RNvMNtNtCs9vGWXuItzyG_11rustc_infer5infer12opaque_typesNtB4_9InferCtxt18handle_opaque_type+0x87) [0x7e9694995a87]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(_RNvXs_NtNtNtCs9vGWXuItzyG_11rustc_infer5infer6relate13type_relatingNtB4_12TypeRelatingINtNtCskmNsZO2KjvA_13rustc_type_ir6relate12TypeRelationNtNtNtCsjT0uPda8Ytm_12rustc_middle2ty7context6TyCtxtE3tys+0x179a) [0x7e9693b51432]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(+0x5c4dba9) [0x7e969464dba9]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(_RNvMs_NtNtCs9vGWXuItzyG_11rustc_infer5infer12opaque_typesNtB6_9InferCtxt18insert_hidden_type+0x21d) [0x7e9694994a6f]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(+0x5f95d4a) [0x7e9694995d4a]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(+0x5f95c42) [0x7e9694995c42]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(_RNvMNtNtCs9vGWXuItzyG_11rustc_infer5infer12opaque_typesNtB4_9InferCtxt18handle_opaque_type+0x87) [0x7e9694995a87]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(_RNvXs_NtNtNtCs9vGWXuItzyG_11rustc_infer5infer6relate13type_relatingNtB4_12TypeRelatingINtNtCskmNsZO2KjvA_13rustc_type_ir6relate12TypeRelationNtNtNtCsjT0uPda8Ytm_12rustc_middle2ty7context6TyCtxtE3tys+0x179a) [0x7e9693b51432]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(+0x5c4dba9) [0x7e969464dba9]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(_RNvMs_NtNtCs9vGWXuItzyG_11rustc_infer5infer12opaque_typesNtB6_9InferCtxt18insert_hidden_type+0x21d) [0x7e9694994a6f]
### recursed 20 times

/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(+0x5f95d4a) [0x7e9694995d4a]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(+0x5f95c42) [0x7e9694995c42]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(_RNvMNtNtCs9vGWXuItzyG_11rustc_infer5infer12opaque_typesNtB4_9InferCtxt18handle_opaque_type+0x87) [0x7e9694995a87]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(_RNvXs_NtNtNtCs9vGWXuItzyG_11rustc_infer5infer6relate13type_relatingNtB4_12TypeRelatingINtNtCskmNsZO2KjvA_13rustc_type_ir6relate12TypeRelationNtNtNtCsjT0uPda8Ytm_12rustc_middle2ty7context6TyCtxtE3tys+0x179a) [0x7e9693b51432]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(+0x5c4dba9) [0x7e969464dba9]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(_RNvMs_NtNtCs9vGWXuItzyG_11rustc_infer5infer12opaque_typesNtB6_9InferCtxt18insert_hidden_type+0x21d) [0x7e9694994a6f]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(+0x5f95d4a) [0x7e9694995d4a]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(+0x5f95c42) [0x7e9694995c42]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(_RNvMNtNtCs9vGWXuItzyG_11rustc_infer5infer12opaque_typesNtB4_9InferCtxt18handle_opaque_type+0x87) [0x7e9694995a87]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-cf045bbab0bf32f8.so(_RNvXs_NtNtNtCs9vGWXuItzyG_11rustc_infer5infer6relate13type_relatingNtB4_12TypeRelatingINtNtCskmNsZO2KjvA_13rustc_type_ir6relate12TypeRelationNtNtNtCsjT0uPda8Ytm_12rustc_middle2ty7context6TyCtxtE3tys+0x179a) [0x7e9693b51432]

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
note: backtrace dumped due to SIGSEGV! resuming signal
[1]    2747756 segmentation fault  rustc a.rs -Ztyping-mode-borrowck

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.A-inferenceArea: Type inferenceC-bugCategory: This is a bug.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions