Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

rustc: Compiler index error, out of bound #108664

Closed
alimkoca opened this issue Mar 2, 2023 · 3 comments · Fixed by #108667
Closed

rustc: Compiler index error, out of bound #108664

alimkoca opened this issue Mar 2, 2023 · 3 comments · Fixed by #108667
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-beta Performance or correctness regression from stable to beta. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Milestone

Comments

@alimkoca
Copy link

alimkoca commented Mar 2, 2023

Code

fn prime_elem(n: u64) -> u64 {
    let mut primes = Vec::new();
    let mut j = 0;

    for i in 2..n+1 {
        if primes.contains(i) {
            j = i*i;
            while j < n+1 {
                primes.push(j);
                j += i;
            }
        }
    }

    primes[n]
}

fn main() {
    let _prime = prime_elem(10001);
    println!("{_prime}");
}

Meta

rustc --version --verbose:

rustc 1.69.0-nightly (7281249a1 2023-02-27)
binary: rustc
commit-hash: 7281249a19a9755e9d889ee251ec323629caadab
commit-date: 2023-02-27
host: x86_64-unknown-linux-gnu
release: 1.69.0-nightly
LLVM version: 15.0.7

Error output

thread 'rustc' panicked at 'index out of bounds: the len is 33 but the index is 34', /cargo/registry/src/index.crates.io-6f17d22bba15001f/ena-0.14.1/src/snapshot_vec.rs:199:10
stack backtrace:
   0:     0x7f8538f66baa - std::backtrace_rs::backtrace::libunwind::trace::hed88b98b82d4f2e9
                               at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f8538f66baa - std::backtrace_rs::backtrace::trace_unsynchronized::ha265951554c18f80
                               at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f8538f66baa - std::sys_common::backtrace::_print_fmt::h905c58b80bf24d6a
                               at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f8538f66baa - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h42fd3bc77561f5c7
                               at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f8538fca2fe - core::fmt::write::hb1a89058387c66a8
                               at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/core/src/fmt/mod.rs:1232:17
   5:     0x7f8538f59c15 - std::io::Write::write_fmt::h807c51614e4697cf
                               at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/std/src/io/mod.rs:1684:15
   6:     0x7f8538f66975 - std::sys_common::backtrace::_print::h94c45e542d878e8b
                               at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f8538f66975 - std::sys_common::backtrace::print::hf09a0b93d8d5d616
                               at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f8538f696ef - std::panicking::default_hook::{{closure}}::h854554d33df993ef
                               at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/std/src/panicking.rs:271:22
   9:     0x7f8538f6942b - std::panicking::default_hook::h47e0374d899bdb79
                               at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/std/src/panicking.rs:290:9
  10:     0x7f853c1d22f5 - rustc_driver_impl[1328d09be3dc1a8e]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f8538f69f2d - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hd6f08b1b7897cbbd
                               at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/alloc/src/boxed.rs:2002:9
  12:     0x7f8538f69f2d - std::panicking::rust_panic_with_hook::h73cfebaefb6d5c31
                               at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/std/src/panicking.rs:696:13
  13:     0x7f8538f69ca9 - std::panicking::begin_panic_handler::{{closure}}::h2e79312bef9db676
                               at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/std/src/panicking.rs:583:13
  14:     0x7f8538f67016 - std::sys_common::backtrace::__rust_end_short_backtrace::h7972a918610407b0
                               at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/std/src/sys_common/backtrace.rs:137:18
  15:     0x7f8538f699b2 - rust_begin_unwind
                               at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/std/src/panicking.rs:579:5
  16:     0x7f8538fc6663 - core::panicking::panic_fmt::h28cbdee921d72b75
                               at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/core/src/panicking.rs:64:14
  17:     0x7f8538fc6852 - core::panicking::panic_bounds_check::he3128e0a6749543f
                               at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/core/src/panicking.rs:159:5
  18:     0x7f853a26458e - <ena[62b90b3c74b9b623]::unify::UnificationTable<ena[62b90b3c74b9b623]::unify::backing_vec::InPlace<rustc_infer[8a4c236fb3c80402]::infer::type_variable::TyVidEqKey, &mut alloc[24dd174104beeac0]::vec::Vec<ena[62b90b3c74b9b623]::unify::VarValue<rustc_infer[8a4c236fb3c80402]::infer::type_variable::TyVidEqKey>>, &mut rustc_infer[8a4c236fb3c80402]::infer::undo_log::InferCtxtUndoLogs>>>::uninlined_get_root_key
  19:     0x7f853a3175cb - <rustc_infer[8a4c236fb3c80402]::infer::combine::Generalizer as rustc_middle[1bc382fc214918e1]::ty::relate::TypeRelation>::tys
  20:     0x7f853a30fc52 - rustc_middle[1bc382fc214918e1]::ty::relate::super_relate_tys::<rustc_infer[8a4c236fb3c80402]::infer::combine::Generalizer>
  21:     0x7f853a31740d - <rustc_infer[8a4c236fb3c80402]::infer::combine::Generalizer as rustc_middle[1bc382fc214918e1]::ty::relate::TypeRelation>::tys
  22:     0x7f853a286dde - <rustc_infer[8a4c236fb3c80402]::infer::equate::Equate as rustc_middle[1bc382fc214918e1]::ty::relate::TypeRelation>::tys
  23:     0x7f853b12e944 - <rustc_infer[8a4c236fb3c80402]::infer::at::At>::eq::<rustc_middle[1bc382fc214918e1]::ty::Ty>
  24:     0x7f853c3eaadc - <rustc_infer[8a4c236fb3c80402]::infer::InferCtxt>::can_eq::<rustc_middle[1bc382fc214918e1]::ty::Ty>
  25:     0x7f853c387499 - <rustc_hir_typeck[af19b78cf5e4e420]::fn_ctxt::FnCtxt>::point_at_expr_source_of_inferred_type
  26:     0x7f853c39a09d - <rustc_hir_typeck[af19b78cf5e4e420]::fn_ctxt::FnCtxt>::report_arg_errors
  27:     0x7f853a815bc7 - <rustc_hir_typeck[af19b78cf5e4e420]::fn_ctxt::FnCtxt>::check_argument_types
  28:     0x7f853a547ff8 - <rustc_hir_typeck[af19b78cf5e4e420]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  29:     0x7f853a5487d1 - <rustc_hir_typeck[af19b78cf5e4e420]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  30:     0x7f853a548432 - <rustc_hir_typeck[af19b78cf5e4e420]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  31:     0x7f853a575a79 - <rustc_hir_typeck[af19b78cf5e4e420]::fn_ctxt::FnCtxt>::check_block_with_expected
  32:     0x7f853a5467ca - <rustc_hir_typeck[af19b78cf5e4e420]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  33:     0x7f853a5a4a15 - <rustc_hir_typeck[af19b78cf5e4e420]::fn_ctxt::FnCtxt>::check_match::{closure#0}
  34:     0x7f853a5482a4 - <rustc_hir_typeck[af19b78cf5e4e420]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  35:     0x7f853a57597e - <rustc_hir_typeck[af19b78cf5e4e420]::fn_ctxt::FnCtxt>::check_block_with_expected
  36:     0x7f853a54a60c - <rustc_hir_typeck[af19b78cf5e4e420]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  37:     0x7f853a5a4a15 - <rustc_hir_typeck[af19b78cf5e4e420]::fn_ctxt::FnCtxt>::check_match::{closure#0}
  38:     0x7f853a5482a4 - <rustc_hir_typeck[af19b78cf5e4e420]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  39:     0x7f853a5487d1 - <rustc_hir_typeck[af19b78cf5e4e420]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  40:     0x7f853a57597e - <rustc_hir_typeck[af19b78cf5e4e420]::fn_ctxt::FnCtxt>::check_block_with_expected
  41:     0x7f853a5467ca - <rustc_hir_typeck[af19b78cf5e4e420]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  42:     0x7f853b128484 - <rustc_hir_typeck[af19b78cf5e4e420]::fn_ctxt::FnCtxt>::check_return_expr
  43:     0x7f853b120877 - rustc_hir_typeck[af19b78cf5e4e420]::check::check_fn
  44:     0x7f853b10a907 - rustc_hir_typeck[af19b78cf5e4e420]::typeck
  45:     0x7f853a3fb7b9 - rustc_query_system[90808657c38d1bea]::query::plumbing::try_execute_query::<rustc_query_impl[b7eb43ed52c37c26]::queries::typeck, rustc_query_impl[b7eb43ed52c37c26]::plumbing::QueryCtxt>
  46:     0x7f853b9a34ff - rustc_data_structures[177608677af0df82]::sync::par_for_each_in::<&[rustc_span[ca1c0a0508e86155]::def_id::LocalDefId], <rustc_middle[1bc382fc214918e1]::hir::map::Map>::par_body_owners<rustc_hir_typeck[af19b78cf5e4e420]::typeck_item_bodies::{closure#0}>::{closure#0}>
  47:     0x7f853b9a32bf - rustc_hir_typeck[af19b78cf5e4e420]::typeck_item_bodies
  48:     0x7f853b81f0cd - rustc_query_system[90808657c38d1bea]::query::plumbing::try_execute_query::<rustc_query_impl[b7eb43ed52c37c26]::queries::typeck_item_bodies, rustc_query_impl[b7eb43ed52c37c26]::plumbing::QueryCtxt>
  49:     0x7f853b81edbb - <rustc_query_impl[b7eb43ed52c37c26]::Queries as rustc_middle[1bc382fc214918e1]::ty::query::QueryEngine>::typeck_item_bodies
  50:     0x7f853a62b673 - <rustc_session[b38dad6cf268045a]::session::Session>::time::<(), rustc_hir_analysis[58bd12f7f7a259]::check_crate::{closure#7}>
  51:     0x7f853a6285b8 - rustc_hir_analysis[58bd12f7f7a259]::check_crate
  52:     0x7f853a61e472 - rustc_interface[e667fd6539aa89ef]::passes::analysis
  53:     0x7f853ba28f6d - rustc_query_system[90808657c38d1bea]::query::plumbing::try_execute_query::<rustc_query_impl[b7eb43ed52c37c26]::queries::analysis, rustc_query_impl[b7eb43ed52c37c26]::plumbing::QueryCtxt>
  54:     0x7f853ba28c6f - <rustc_query_impl[b7eb43ed52c37c26]::Queries as rustc_middle[1bc382fc214918e1]::ty::query::QueryEngine>::analysis
  55:     0x7f853b84ef06 - <rustc_middle[1bc382fc214918e1]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[1328d09be3dc1a8e]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[dfaf1ef37f016df7]::result::Result<(), rustc_span[ca1c0a0508e86155]::ErrorGuaranteed>>
  56:     0x7f853b4308d8 - rustc_span[ca1c0a0508e86155]::with_source_map::<core[dfaf1ef37f016df7]::result::Result<(), rustc_span[ca1c0a0508e86155]::ErrorGuaranteed>, rustc_interface[e667fd6539aa89ef]::interface::run_compiler<core[dfaf1ef37f016df7]::result::Result<(), rustc_span[ca1c0a0508e86155]::ErrorGuaranteed>, rustc_driver_impl[1328d09be3dc1a8e]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  57:     0x7f853b427fbc - std[d01210ab3b315fe2]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[e667fd6539aa89ef]::util::run_in_thread_pool_with_globals<rustc_interface[e667fd6539aa89ef]::interface::run_compiler<core[dfaf1ef37f016df7]::result::Result<(), rustc_span[ca1c0a0508e86155]::ErrorGuaranteed>, rustc_driver_impl[1328d09be3dc1a8e]::run_compiler::{closure#1}>::{closure#0}, core[dfaf1ef37f016df7]::result::Result<(), rustc_span[ca1c0a0508e86155]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dfaf1ef37f016df7]::result::Result<(), rustc_span[ca1c0a0508e86155]::ErrorGuaranteed>>
  58:     0x7f853b4279ea - <<std[d01210ab3b315fe2]::thread::Builder>::spawn_unchecked_<rustc_interface[e667fd6539aa89ef]::util::run_in_thread_pool_with_globals<rustc_interface[e667fd6539aa89ef]::interface::run_compiler<core[dfaf1ef37f016df7]::result::Result<(), rustc_span[ca1c0a0508e86155]::ErrorGuaranteed>, rustc_driver_impl[1328d09be3dc1a8e]::run_compiler::{closure#1}>::{closure#0}, core[dfaf1ef37f016df7]::result::Result<(), rustc_span[ca1c0a0508e86155]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dfaf1ef37f016df7]::result::Result<(), rustc_span[ca1c0a0508e86155]::ErrorGuaranteed>>::{closure#1} as core[dfaf1ef37f016df7]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  59:     0x7f8538f73d63 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h23732028e1dd2dcf
                               at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/alloc/src/boxed.rs:1988:9
  60:     0x7f8538f73d63 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h10e7b0e430440157
                               at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/alloc/src/boxed.rs:1988:9
  61:     0x7f8538f73d63 - std::sys::unix::thread::Thread::new::thread_start::hf1c234831da9bd27
                               at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/std/src/sys/unix/thread.rs:108:17
  62:     0x7f8538c8cdcd - start_thread
                               at /usr/src/debug/glibc-2.35-22.fc36.x86_64/nptl/pthread_create.c:442:8
  63:     0x7f8538d12630 - clone3
                               at /usr/src/debug/glibc-2.35-22.fc36.x86_64/misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
  64:                0x0 - <unknown>

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: rustc 1.69.0-nightly (7281249a1 2023-02-27) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `prime_elem`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: no errors reported for args
 --> 10001st-prime.rs:6:19
  |
6 |         if primes.contains(i) {
  |                   ^^^^^^^^
  |
  = note: delayed at    0: <rustc_errors::HandlerInner>::emit_diagnostic
             1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, &str>
             2: <rustc_hir_typeck::fn_ctxt::FnCtxt>::report_arg_errors
             3: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_argument_types
             4: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
             5: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
             6: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
             7: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_block_with_expected
             8: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
             9: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_match::{closure#0}
            10: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
            11: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_block_with_expected
            12: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
            13: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_match::{closure#0}
            14: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
            15: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
            16: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_block_with_expected
            17: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
            18: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_return_expr
            19: rustc_hir_typeck::check::check_fn
            20: rustc_hir_typeck::typeck
            21: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::typeck, rustc_query_impl::plumbing::QueryCtxt>
            22: rustc_data_structures::sync::par_for_each_in::<&[rustc_span::def_id::LocalDefId], <rustc_middle::hir::map::Map>::par_body_owners<rustc_hir_typeck::typeck_item_bodies::{closure#0}>::{closure#0}>
            23: rustc_hir_typeck::typeck_item_bodies
            24: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::typeck_item_bodies, rustc_query_impl::plumbing::QueryCtxt>
            25: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck_item_bodies
            26: <rustc_session::session::Session>::time::<(), rustc_hir_analysis::check_crate::{closure#7}>
            27: rustc_hir_analysis::check_crate
            28: rustc_interface::passes::analysis
            29: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
            30: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
            31: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            32: rustc_span::with_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
            33: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            34: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
            35: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/alloc/src/boxed.rs:1988:9
            36: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/alloc/src/boxed.rs:1988:9
            37: std::sys::unix::thread::Thread::new::thread_start
                       at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/std/src/sys/unix/thread.rs:108:17
            38: start_thread
                       at /usr/src/debug/glibc-2.35-22.fc36.x86_64/nptl/pthread_create.c:442:8
            39: clone3
                       at /usr/src/debug/glibc-2.35-22.fc36.x86_64/misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
          

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: rustc 1.69.0-nightly (7281249a1 2023-02-27) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
thread panicked while panicking. aborting.
Aborted (core dumped)
Backtrace

stack backtrace:
   0: rust_begin_unwind
             at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/std/src/panicking.rs:579:5
   1: core::panicking::panic_fmt
             at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/core/src/panicking.rs:64:14
   2: core::panicking::panic_bounds_check
             at /rustc/7281249a19a9755e9d889ee251ec323629caadab/library/core/src/panicking.rs:159:5
   3: <ena::unify::UnificationTable<ena::unify::backing_vec::InPlace<rustc_infer::infer::type_variable::TyVidEqKey, &mut alloc::vec::Vec<ena::unify::VarValue<rustc_infer::infer::type_variable::TyVidEqKey>>, &mut rustc_infer::infer::undo_log::InferCtxtUndoLogs>>>::uninlined_get_root_key
   4: <rustc_infer::infer::combine::Generalizer as rustc_middle::ty::relate::TypeRelation>::tys
   5: rustc_middle::ty::relate::super_relate_tys::<rustc_infer::infer::combine::Generalizer>
   6: <rustc_infer::infer::combine::Generalizer as rustc_middle::ty::relate::TypeRelation>::tys
   7: <rustc_infer::infer::equate::Equate as rustc_middle::ty::relate::TypeRelation>::tys
   8: <rustc_infer::infer::at::At>::eq::<rustc_middle::ty::Ty>
   9: <rustc_infer::infer::InferCtxt>::can_eq::<rustc_middle::ty::Ty>
  10: <rustc_hir_typeck::fn_ctxt::FnCtxt>::point_at_expr_source_of_inferred_type
  11: <rustc_hir_typeck::fn_ctxt::FnCtxt>::report_arg_errors
  12: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_argument_types
  13: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  14: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  15: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  16: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_block_with_expected
  17: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  18: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_match::{closure#0}
  19: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  20: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_block_with_expected
  21: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  22: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_match::{closure#0}
  23: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  24: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  25: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_block_with_expected
  26: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  27: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_return_expr
  28: rustc_hir_typeck::check::check_fn
  29: rustc_hir_typeck::typeck
  30: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::typeck, rustc_query_impl::plumbing::QueryCtxt>
  31: rustc_data_structures::sync::par_for_each_in::<&[rustc_span::def_id::LocalDefId], <rustc_middle::hir::map::Map>::par_body_owners<rustc_hir_typeck::typeck_item_bodies::{closure#0}>::{closure#0}>
  32: rustc_hir_typeck::typeck_item_bodies
  33: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::typeck_item_bodies, rustc_query_impl::plumbing::QueryCtxt>
  34: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck_item_bodies
  35: <rustc_session::session::Session>::time::<(), rustc_hir_analysis::check_crate::{closure#7}>
  36: rustc_hir_analysis::check_crate
  37: rustc_interface::passes::analysis
  38: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
  39: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  40: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
  41: rustc_span::with_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@alimkoca alimkoca 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 2, 2023
@matthiaskrgr matthiaskrgr added S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue regression-from-stable-to-beta Performance or correctness regression from stable to beta. labels Mar 2, 2023
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Mar 2, 2023
@matthiaskrgr
Copy link
Member

mcve

fn main() {
    let primes = Vec::new();
    primes.contains(3);
}

Crashes on nightly and rustc 1.68.0-beta.6, stable 167:

error[E0308]: mismatched types
    --> prim.rs:3:21
     |
3    |     primes.contains(3);
     |            -------- ^
     |            |        |
     |            |        expected reference, found integer
     |            |        help: consider borrowing here: `&3`
     |            arguments to this function are incorrect
     |
     = note: expected reference `&_`
                     found type `{integer}`
note: associated function defined here
    --> /home/matthias/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs:2195:12
     |
2195 |     pub fn contains(&self, x: &T) -> bool
     |            ^^^^^^^^

@compiler-errors
Copy link
Member

@rustbot claim

@Noratrieb
Copy link
Member

searched nightlies: from nightly-2023-01-01 to nightly-2023-03-02
regressed nightly: nightly-2023-01-07
searched commit range: 388538f...0fb8b72
regressed commit: 1146560

bisected with cargo-bisect-rustc v0.6.4

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

cargo bisect-rustc --access github --timeout 30 --start 2023-01-01 --end 2023-03-02 --regress ice 

#106400 cc @estebank

@Mark-Simulacrum Mark-Simulacrum added this to the 1.68.0 milestone Mar 3, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 3, 2023
…tebank

Fix another ICE in `point_at_expr_source_of_inferred_type`

Types coming from method probes must only be investigated *structurally*, since they often contain escaping infer variables from generalization and autoderef. We already have a hack in this PR that erases variables from types, so just use that.

Fixes rust-lang#108664

The note attached to this error is pretty bad:

```
here the type of `primes` is inferred to be `[_]`
```

But that's unrelated to the PR.

---

Side-note: This is a pretty easy to trigger beta regression, so I've nominated it. Alternatively, I'm slightly inclined to remove this code altogether until it can be reformulated to be more accurate and less ICEy.
@bors bors closed this as completed in db4b3dd Mar 3, 2023
@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Apr 27, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-beta Performance or correctness regression from stable to beta. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants