Skip to content

ICE: index out of bounds in compiler/rustc_borrowck/src/lib.rs #141952

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

Open
cushionbadak opened this issue Jun 3, 2025 · 1 comment
Open

ICE: index out of bounds in compiler/rustc_borrowck/src/lib.rs #141952

cushionbadak opened this issue Jun 3, 2025 · 1 comment
Labels
C-bug Category: This is a bug. F-ergonomic_clones `#![feature(ergonomic_clones)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@cushionbadak
Copy link

cushionbadak commented Jun 3, 2025

Code

#![allow(incomplete_features)]
#![feature(ergonomic_clones)]

use std::clone::UseCloned;

impl UseCloned for Option<(S, S, S)> {}

struct S;

fn main() {
    macro_rules! m {
        ($p:pat = $s:expr) => {
            match $s {
                Some($p) => {}
                _ => {}
            }
        };
    }
    let mut tup1: Option<(S, S, S)> = None;
    let mut _closure = use || {
        m!((_, _, ref mut _borrow) = tup1);
    };
}

A mutant of tests/ui/pattern/move-ref-patterns/move-ref-patterns-closure-captures-inside.rs

Meta

rustc --version --verbose:

rustc 1.89.0-nightly (5d707b07e 2025-06-02)
binary: rustc
commit-hash: 5d707b07e42766c080c5012869c9988a18dcbb83
commit-date: 2025-06-02
host: aarch64-apple-darwin
release: 1.89.0-nightly
LLVM version: 20.1.5

Error output

command: rustc

error[E0117]: only traits defined in the current crate can be implemented for types defined outside of the crate
 --> ec_1.rs:6:1
  |
6 | impl UseCloned for Option<(S, S, S)> {}
  | ^^^^^^^^^^^^^^^^^^^-----------------
  |                    |
  |                    `Option` is not defined in the current crate
  |
  = note: impl doesn't have any local type before any uncovered type parameters
  = note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
  = note: define and implement a trait or new type instead


thread 'rustc' panicked at compiler/rustc_borrowck/src/lib.rs:1619:51:
index out of bounds: the len is 9 but the index is 9
Backtrace


thread 'rustc' panicked at compiler/rustc_borrowck/src/lib.rs:1619:51:
index out of bounds: the len is 9 but the index is 9
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_bounds_check
   3: <rustc_borrowck::MirBorrowckCtxt as rustc_mir_dataflow::framework::visitor::ResultsVisitor<rustc_borrowck::dataflow::Borrowck>>::visit_after_early_statement_effect
   4: rustc_borrowck::do_mir_borrowck
   5: rustc_borrowck::mir_borrowck
      [... omitted 1 frame ...]
   6: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
   7: rustc_interface::passes::run_required_analyses
   8: rustc_interface::passes::analysis
      [... omitted 1 frame ...]
   9: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
  10: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: please attach the file at `/Users/jisukbyun/workspace/250203 scratch/rustc-ice-2025-06-03T08_38_21-83141.txt` to your bug report

query stack during panic:
#0 [mir_borrowck] borrow-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0117`.

Bisects to

searched nightlies: from nightly-2025-01-01 to nightly-2025-06-02
regressed nightly: nightly-2025-03-08
searched commit range: b74da96...f5a1ef7
regressed commit: f5a1ef7

bisected with cargo-bisect-rustc v0.6.9

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --end=2025-06-02 --regress ice --preserve --script rustc -- ec_1.rs
********************************************************************************
Regression in f5a1ef7121ad661b5a21a1d02941c8064d54ee0b
********************************************************************************

Attempting to search unrolled perf builds
Found commits ["5cf66023", "16414e51", "0b6c069b", "aa349152", "275aad33", "eaf94402"]
installing 5cf660233fcc08fce21f8845d36982b25cb0535c
testing...
RESULT: 5cf660233fcc08fce21f8845d36982b25cb0535c, ===> Script found ICE

Regression in https://github.com/rust-lang-ci/rust/commit/5cf660233fcc08fce21f8845d36982b25cb0535c
The PR introducing the regression in this rollup is #134797: Ergonomic ref counting

Notes

  • ICE location: compiler/rustc_borrowck/src/lib.rs Line-1619
    let body = self.body;
    let bbd = &body[loc.block];
    let stmt = &bbd.statements[loc.statement_index];
    debug!("temporary assigned in: stmt={:?}", stmt);

@rustbot label F-ergonomic_clones

@cushionbadak cushionbadak added 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. C-bug Category: This is a bug. labels Jun 3, 2025
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. F-ergonomic_clones `#![feature(ergonomic_clones)]` labels Jun 3, 2025
@cushionbadak
Copy link
Author

cushionbadak commented Jun 3, 2025

Another ICE code:

#![allow(incomplete_features)]
#![feature(ergonomic_clones)]

use std::clone::UseCloned;

impl UseCloned for Point {}

struct Point {
    x: i32,
    y: i32,
}

fn main() {
    let mut p = Point { x: 10, y: 20 };
    use || {
        p.x += 10;
    };
}

(A mutant of tests/ui/closures/2229_closure_analysis/diagnostics/simple-struct-min-capture.rs)

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. F-ergonomic_clones `#![feature(ergonomic_clones)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. 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

2 participants