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

[ICE]: index out of bounds: the len is 27 but the index is 28 snapshot_vec.rs #107158

Closed
justinpombrio opened this issue Jan 21, 2023 · 5 comments · Fixed by #107175
Closed

[ICE]: index out of bounds: the len is 27 but the index is 28 snapshot_vec.rs #107158

justinpombrio opened this issue Jan 21, 2023 · 5 comments · Fixed by #107175
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@justinpombrio
Copy link

I tried this code on nightly:

fn main() {
    let mut result = vec![1];       
    let mut vector = Vec::new();
    vector.sort();
    result.push(vector);
}

I expected to see this happen: compiler does not panic.

Instead, this happened: compiler panics and suggests I open a bug report.

I initially posted to #107087, but @compiler-errors says this is a different issue, despite panicking on the same line in snapshot_vec.rs. (Though I'm realizing now that might be the proximal cause but not very related to the root cause.)

Meta

rustc --version --verbose:

rustc 1.68.0-nightly (4c83bd03a 2023-01-19)
binary: rustc
commit-hash: 4c83bd03a9d94af35c97a6b8b595d40e291af84a
commit-date: 2023-01-19
host: x86_64-unknown-linux-gnu
release: 1.68.0-nightly
LLVM version: 15.0.6
Panic message

    Checking bug v0.1.0 (/home/justin/tmp/bug)
thread 'rustc' panicked at 'index out of bounds: the len is 27 but the index is 28', /cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/ena-0.14.0/src/snapshot_vec.rs:199:10
stack backtrace:
   0:     0x7f4ccc4243ca - std::backtrace_rs::backtrace::libunwind::trace::h240142d7476be758
                               at /rustc/4c83bd03a9d94af35c97a6b8b595d40e291af84a/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f4ccc4243ca - std::backtrace_rs::backtrace::trace_unsynchronized::h5e356256b4987c19
                               at /rustc/4c83bd03a9d94af35c97a6b8b595d40e291af84a/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f4ccc4243ca - std::sys_common::backtrace::_print_fmt::ha2c0b9ff14028819
                               at /rustc/4c83bd03a9d94af35c97a6b8b595d40e291af84a/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f4ccc4243ca - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h202f667f13be0d32
                               at /rustc/4c83bd03a9d94af35c97a6b8b595d40e291af84a/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f4ccc48767e - core::fmt::write::hca6198797d826fb5
                               at /rustc/4c83bd03a9d94af35c97a6b8b595d40e291af84a/library/core/src/fmt/mod.rs:1213:17
   5:     0x7f4ccc414b15 - std::io::Write::write_fmt::h9127c5ca6131839e
                               at /rustc/4c83bd03a9d94af35c97a6b8b595d40e291af84a/library/std/src/io/mod.rs:1682:15
   6:     0x7f4ccc424195 - std::sys_common::backtrace::_print::h2df011719ccaa054
                               at /rustc/4c83bd03a9d94af35c97a6b8b595d40e291af84a/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f4ccc424195 - std::sys_common::backtrace::print::h594ed649c1c172ec
                               at /rustc/4c83bd03a9d94af35c97a6b8b595d40e291af84a/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f4ccc426f5f - std::panicking::default_hook::{{closure}}::h84aa3e23eadf5096
                               at /rustc/4c83bd03a9d94af35c97a6b8b595d40e291af84a/library/std/src/panicking.rs:267:22
   9:     0x7f4ccc426c9b - std::panicking::default_hook::hdd8861adcd6741f0
                               at /rustc/4c83bd03a9d94af35c97a6b8b595d40e291af84a/library/std/src/panicking.rs:286:9
  10:     0x7f4ccb194424 - <rustc_driver[82fc56ae0c97c151]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[90be0cd059b0ba41]::ops::function::FnOnce<(&core[90be0cd059b0ba41]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f4ccc42779a - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h512020bcd5d92782
                               at /rustc/4c83bd03a9d94af35c97a6b8b595d40e291af84a/library/alloc/src/boxed.rs:2002:9
  12:     0x7f4ccc42779a - std::panicking::rust_panic_with_hook::h2a3da871355c45e5
                               at /rustc/4c83bd03a9d94af35c97a6b8b595d40e291af84a/library/std/src/panicking.rs:692:13
  13:     0x7f4ccc427519 - std::panicking::begin_panic_handler::{{closure}}::h35c7ba0797c3260c
                               at /rustc/4c83bd03a9d94af35c97a6b8b595d40e291af84a/library/std/src/panicking.rs:579:13
  14:     0x7f4ccc42487c - std::sys_common::backtrace::__rust_end_short_backtrace::hcacfc4b36485c220
                               at /rustc/4c83bd03a9d94af35c97a6b8b595d40e291af84a/library/std/src/sys_common/backtrace.rs:137:18
  15:     0x7f4ccc427222 - rust_begin_unwind
                               at /rustc/4c83bd03a9d94af35c97a6b8b595d40e291af84a/library/std/src/panicking.rs:575:5
  16:     0x7f4ccc484023 - core::panicking::panic_fmt::h1b211a78e89d52ab
                               at /rustc/4c83bd03a9d94af35c97a6b8b595d40e291af84a/library/core/src/panicking.rs:64:14
  17:     0x7f4ccc484212 - core::panicking::panic_bounds_check::hb023c560538cc7c8
                               at /rustc/4c83bd03a9d94af35c97a6b8b595d40e291af84a/library/core/src/panicking.rs:159:5
  18:     0x7f4cc91532fe - <ena[14e3c45f7ace6a7e]::unify::UnificationTable<ena[14e3c45f7ace6a7e]::unify::backing_vec::InPlace<rustc_infer[97fe693e526540ea]::infer::type_variable::TyVidEqKey, &mut alloc[40bef2c5ac843958]::vec::Vec<ena[14e3c45f7ace6a7e]::unify::VarValue<rustc_infer[97fe693e526540ea]::infer::type_variable::TyVidEqKey>>, &mut rustc_infer[97fe693e526540ea]::infer::undo_log::InferCtxtUndoLogs>>>::uninlined_get_root_key
  19:     0x7f4cc9878f43 - <rustc_infer[97fe693e526540ea]::infer::InferCtxt>::root_var
  20:     0x7f4ccb415545 - <rustc_middle[7c7e45da0fed0bf4]::ty::fold::BottomUpFolder<<rustc_hir_typeck[3db7b1b72557ee6d]::fn_ctxt::FnCtxt>::point_at_expr_source_of_inferred_type::{closure#2}, <rustc_hir_typeck[3db7b1b72557ee6d]::fn_ctxt::FnCtxt>::point_at_expr_source_of_inferred_type::{closure#0}, <rustc_hir_typeck[3db7b1b72557ee6d]::fn_ctxt::FnCtxt>::point_at_expr_source_of_inferred_type::{closure#1}> as rustc_middle[7c7e45da0fed0bf4]::ty::fold::TypeFolder>::fold_ty
  21:     0x7f4ccb3e62e4 - <rustc_middle[7c7e45da0fed0bf4]::ty::Ty as rustc_middle[7c7e45da0fed0bf4]::ty::fold::TypeSuperFoldable>::super_fold_with::<rustc_middle[7c7e45da0fed0bf4]::ty::fold::BottomUpFolder<<rustc_hir_typeck[3db7b1b72557ee6d]::fn_ctxt::FnCtxt>::point_at_expr_source_of_inferred_type::{closure#2}, <rustc_hir_typeck[3db7b1b72557ee6d]::fn_ctxt::FnCtxt>::point_at_expr_source_of_inferred_type::{closure#0}, <rustc_hir_typeck[3db7b1b72557ee6d]::fn_ctxt::FnCtxt>::point_at_expr_source_of_inferred_type::{closure#1}>>
  22:     0x7f4ccb415503 - <rustc_middle[7c7e45da0fed0bf4]::ty::fold::BottomUpFolder<<rustc_hir_typeck[3db7b1b72557ee6d]::fn_ctxt::FnCtxt>::point_at_expr_source_of_inferred_type::{closure#2}, <rustc_hir_typeck[3db7b1b72557ee6d]::fn_ctxt::FnCtxt>::point_at_expr_source_of_inferred_type::{closure#0}, <rustc_hir_typeck[3db7b1b72557ee6d]::fn_ctxt::FnCtxt>::point_at_expr_source_of_inferred_type::{closure#1}> as rustc_middle[7c7e45da0fed0bf4]::ty::fold::TypeFolder>::fold_ty
  23:     0x7f4ccb34694d - <rustc_hir_typeck[3db7b1b72557ee6d]::fn_ctxt::FnCtxt>::point_at_expr_source_of_inferred_type
  24:     0x7f4ccb3438a1 - <rustc_hir_typeck[3db7b1b72557ee6d]::fn_ctxt::FnCtxt>::emit_type_mismatch_suggestions
  25:     0x7f4ccb343f61 - <rustc_hir_typeck[3db7b1b72557ee6d]::fn_ctxt::FnCtxt>::emit_coerce_suggestions
  26:     0x7f4ccb357c44 - <rustc_hir_typeck[3db7b1b72557ee6d]::fn_ctxt::FnCtxt>::report_arg_errors
  27:     0x7f4cc93e978c - <rustc_hir_typeck[3db7b1b72557ee6d]::fn_ctxt::FnCtxt>::check_argument_types
  28:     0x7f4cc94d6326 - <rustc_hir_typeck[3db7b1b72557ee6d]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  29:     0x7f4cc95112a3 - <rustc_hir_typeck[3db7b1b72557ee6d]::fn_ctxt::FnCtxt>::check_block_with_expected
  30:     0x7f4cc94d4603 - <rustc_hir_typeck[3db7b1b72557ee6d]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  31:     0x7f4cc985c171 - <rustc_hir_typeck[3db7b1b72557ee6d]::fn_ctxt::FnCtxt>::check_return_expr
  32:     0x7f4cc9852e4b - rustc_hir_typeck[3db7b1b72557ee6d]::check::check_fn
  33:     0x7f4cc983ecd1 - <rustc_hir_typeck[3db7b1b72557ee6d]::inherited::InheritedBuilder>::enter::<rustc_hir_typeck[3db7b1b72557ee6d]::typeck_with_fallback<rustc_hir_typeck[3db7b1b72557ee6d]::typeck::{closure#0}>::{closure#0}::{closure#1}, &rustc_middle[7c7e45da0fed0bf4]::ty::typeck_results::TypeckResults>
  34:     0x7f4cc98375bb - rustc_hir_typeck[3db7b1b72557ee6d]::typeck
  35:     0x7f4cc983b877 - <rustc_query_system[fadc47c25162020e]::dep_graph::graph::DepGraph<rustc_middle[7c7e45da0fed0bf4]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[7c7e45da0fed0bf4]::ty::context::TyCtxt, rustc_span[2207f72a79e3e416]::def_id::LocalDefId, &rustc_middle[7c7e45da0fed0bf4]::ty::typeck_results::TypeckResults>
  36:     0x7f4cc982ff5b - rustc_query_system[fadc47c25162020e]::query::plumbing::try_execute_query::<rustc_query_impl[64d55931afd15afd]::queries::typeck, rustc_query_impl[64d55931afd15afd]::plumbing::QueryCtxt>
  37:     0x7f4cca92531d - rustc_data_structures[ac989c4732f77e61]::sync::par_for_each_in::<&[rustc_span[2207f72a79e3e416]::def_id::LocalDefId], <rustc_middle[7c7e45da0fed0bf4]::hir::map::Map>::par_body_owners<rustc_hir_typeck[3db7b1b72557ee6d]::typeck_item_bodies::{closure#0}>::{closure#0}>
  38:     0x7f4cca9250b3 - rustc_hir_typeck[3db7b1b72557ee6d]::typeck_item_bodies
  39:     0x7f4cca93eb27 - <rustc_query_system[fadc47c25162020e]::dep_graph::graph::DepGraph<rustc_middle[7c7e45da0fed0bf4]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[7c7e45da0fed0bf4]::ty::context::TyCtxt, (), ()>
  40:     0x7f4cca756be6 - rustc_query_system[fadc47c25162020e]::query::plumbing::try_execute_query::<rustc_query_impl[64d55931afd15afd]::queries::typeck_item_bodies, rustc_query_impl[64d55931afd15afd]::plumbing::QueryCtxt>
  41:     0x7f4ccab84d8b - <rustc_query_impl[64d55931afd15afd]::Queries as rustc_middle[7c7e45da0fed0bf4]::ty::query::QueryEngine>::typeck_item_bodies
  42:     0x7f4cc96ddf72 - <rustc_session[936e6eae97bea9e0]::session::Session>::time::<(), rustc_hir_analysis[b10c5039352f00c6]::check_crate::{closure#7}>
  43:     0x7f4cc96dd3f2 - rustc_hir_analysis[b10c5039352f00c6]::check_crate
  44:     0x7f4cc96dd04b - rustc_interface[36159b7d810b5b55]::passes::analysis
  45:     0x7f4cca8f8436 - <rustc_query_system[fadc47c25162020e]::dep_graph::graph::DepGraph<rustc_middle[7c7e45da0fed0bf4]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[7c7e45da0fed0bf4]::ty::context::TyCtxt, (), core[90be0cd059b0ba41]::result::Result<(), rustc_errors[5823355ac9be31e5]::ErrorGuaranteed>>
  46:     0x7f4cca8f75f1 - rustc_query_system[fadc47c25162020e]::query::plumbing::try_execute_query::<rustc_query_impl[64d55931afd15afd]::queries::analysis, rustc_query_impl[64d55931afd15afd]::plumbing::QueryCtxt>
  47:     0x7f4ccab8163a - <rustc_query_impl[64d55931afd15afd]::Queries as rustc_middle[7c7e45da0fed0bf4]::ty::query::QueryEngine>::analysis
  48:     0x7f4cca41bec0 - <rustc_interface[36159b7d810b5b55]::passes::QueryContext>::enter::<rustc_driver[82fc56ae0c97c151]::run_compiler::{closure#1}::{closure#2}::{closure#2}, core[90be0cd059b0ba41]::result::Result<(), rustc_errors[5823355ac9be31e5]::ErrorGuaranteed>>
  49:     0x7f4cca41acc1 - <rustc_interface[36159b7d810b5b55]::interface::Compiler>::enter::<rustc_driver[82fc56ae0c97c151]::run_compiler::{closure#1}::{closure#2}, core[90be0cd059b0ba41]::result::Result<core[90be0cd059b0ba41]::option::Option<rustc_interface[36159b7d810b5b55]::queries::Linker>, rustc_errors[5823355ac9be31e5]::ErrorGuaranteed>>
  50:     0x7f4cca418d94 - rustc_span[2207f72a79e3e416]::with_source_map::<core[90be0cd059b0ba41]::result::Result<(), rustc_errors[5823355ac9be31e5]::ErrorGuaranteed>, rustc_interface[36159b7d810b5b55]::interface::run_compiler<core[90be0cd059b0ba41]::result::Result<(), rustc_errors[5823355ac9be31e5]::ErrorGuaranteed>, rustc_driver[82fc56ae0c97c151]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  51:     0x7f4cca4188a4 - <scoped_tls[90ae59e5c43b8233]::ScopedKey<rustc_span[2207f72a79e3e416]::SessionGlobals>>::set::<rustc_interface[36159b7d810b5b55]::interface::run_compiler<core[90be0cd059b0ba41]::result::Result<(), rustc_errors[5823355ac9be31e5]::ErrorGuaranteed>, rustc_driver[82fc56ae0c97c151]::run_compiler::{closure#1}>::{closure#0}, core[90be0cd059b0ba41]::result::Result<(), rustc_errors[5823355ac9be31e5]::ErrorGuaranteed>>
  52:     0x7f4cca417fa2 - std[4c81cade61ecd3c1]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[36159b7d810b5b55]::util::run_in_thread_pool_with_globals<rustc_interface[36159b7d810b5b55]::interface::run_compiler<core[90be0cd059b0ba41]::result::Result<(), rustc_errors[5823355ac9be31e5]::ErrorGuaranteed>, rustc_driver[82fc56ae0c97c151]::run_compiler::{closure#1}>::{closure#0}, core[90be0cd059b0ba41]::result::Result<(), rustc_errors[5823355ac9be31e5]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[90be0cd059b0ba41]::result::Result<(), rustc_errors[5823355ac9be31e5]::ErrorGuaranteed>>
  53:     0x7f4cca417d4a - <<std[4c81cade61ecd3c1]::thread::Builder>::spawn_unchecked_<rustc_interface[36159b7d810b5b55]::util::run_in_thread_pool_with_globals<rustc_interface[36159b7d810b5b55]::interface::run_compiler<core[90be0cd059b0ba41]::result::Result<(), rustc_errors[5823355ac9be31e5]::ErrorGuaranteed>, rustc_driver[82fc56ae0c97c151]::run_compiler::{closure#1}>::{closure#0}, core[90be0cd059b0ba41]::result::Result<(), rustc_errors[5823355ac9be31e5]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[90be0cd059b0ba41]::result::Result<(), rustc_errors[5823355ac9be31e5]::ErrorGuaranteed>>::{closure#1} as core[90be0cd059b0ba41]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  54:     0x7f4ccc431bd3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4e5910f04ceb1361
                               at /rustc/4c83bd03a9d94af35c97a6b8b595d40e291af84a/library/alloc/src/boxed.rs:1988:9
  55:     0x7f4ccc431bd3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he68553db813d76f7
                               at /rustc/4c83bd03a9d94af35c97a6b8b595d40e291af84a/library/alloc/src/boxed.rs:1988:9
  56:     0x7f4ccc431bd3 - std::sys::unix::thread::Thread::new::thread_start::hf58a7b00111c6b83
                               at /rustc/4c83bd03a9d94af35c97a6b8b595d40e291af84a/library/std/src/sys/unix/thread.rs:108:17
  57:     0x7f4cc790d184 - start_thread
                               at /build/eglibc-xkFqqE/eglibc-2.19/nptl/pthread_create.c:312
  58:     0x7f4cc763a03d - __clone
                               at /build/eglibc-xkFqqE/eglibc-2.19/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:111
  59:                0x0 - <unknown>

error: internal compiler error: unexpected panic

note: 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.68.0-nightly (4c83bd03a 2023-01-19) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [typeck] type-checking `main`
#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
 --> src/main.rs:5:12
  |
5 |     result.push(vector);
  |            ^^^^
  |
  = 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_block_with_expected
             6: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
             7: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_return_expr
             8: rustc_hir_typeck::check::check_fn
             9: <rustc_hir_typeck::inherited::InheritedBuilder>::enter::<rustc_hir_typeck::typeck_with_fallback<rustc_hir_typeck::typeck::{closure#0}>::{closure#0}::{closure#1}, &rustc_middle::ty::typeck_results::TypeckResults>
            10: rustc_hir_typeck::typeck
            11: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId, &rustc_middle::ty::typeck_results::TypeckResults>
            12: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::typeck, rustc_query_impl::plumbing::QueryCtxt>
            13: 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}>
            14: rustc_hir_typeck::typeck_item_bodies
            15: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), ()>
            16: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::typeck_item_bodies, rustc_query_impl::plumbing::QueryCtxt>
            17: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck_item_bodies
            18: <rustc_session::session::Session>::time::<(), rustc_hir_analysis::check_crate::{closure#7}>
            19: rustc_hir_analysis::check_crate
            20: rustc_interface::passes::analysis
            21: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorGuaranteed>>
            22: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
            23: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
            24: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#2}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
            25: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorGuaranteed>>
            26: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
            27: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
            28: 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_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
            29: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
            30: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/4c83bd03a9d94af35c97a6b8b595d40e291af84a/library/alloc/src/boxed.rs:1988:9
            31: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/4c83bd03a9d94af35c97a6b8b595d40e291af84a/library/alloc/src/boxed.rs:1988:9
            32: std::sys::unix::thread::Thread::new::thread_start
                       at /rustc/4c83bd03a9d94af35c97a6b8b595d40e291af84a/library/std/src/sys/unix/thread.rs:108:17
            33: start_thread
                       at /build/eglibc-xkFqqE/eglibc-2.19/nptl/pthread_create.c:312
            34: __clone
                       at /build/eglibc-xkFqqE/eglibc-2.19/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:111
          

note: 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.68.0-nightly (4c83bd03a 2023-01-19) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
thread panicked while panicking. aborting.
error: could not compile `bug`

Caused by:
  process didn't exit successfully: `rustc --crate-name bug --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=74 --crate-type bin --emit=dep-info,metadata -C embed-bitcode=no -C debuginfo=2 -C metadata=0d4d339d7aa03dff -C extra-filename=-0d4d339d7aa03dff --out-dir /home/justin/tmp/bug/target/debug/deps -C incremental=/home/justin/tmp/bug/target/debug/incremental -L dependency=/home/justin/tmp/bug/target/debug/deps` (signal: 6, SIGABRT: process abort signal)

Thanks all for maintaining Rust, by the way.

@justinpombrio justinpombrio added the C-bug Category: This is a bug. label Jan 21, 2023
@compiler-errors
Copy link
Member

Thanks!

@matthiaskrgr matthiaskrgr added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jan 21, 2023
@clubby789
Copy link
Contributor

searched nightlies: from nightly-2022-12-01 to nightly-2023-01-21
regressed nightly: nightly-2023-01-07
searched commit range: 388538f...0fb8b72
regressed commit: 1146560

bisected with cargo-bisect-rustc v0.6.5

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

cargo bisect-rustc ice --start 2022-12-1 

@compiler-errors
Copy link
Member

compiler-errors commented Jan 21, 2023

It's #106400, i'll fix it unless someone beats me to it since I'm busy this weekend

@justinpombrio
Copy link
Author

Hi @estebank it's Justin from Commure 👋. I found a compiler panic you made 😀

@compiler-errors compiler-errors self-assigned this Jan 21, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 23, 2023
…ush, r=estebank

Fix escaping inference var ICE in `point_at_expr_source_of_inferred_type`

Fixes rust-lang#107158

`point_at_expr_source_of_inferred_type` uses `lookup_probe` to adjust the self type of a method receiver -- but that method returns inference variables from inside a probe. That means that the ty vars are no longer valid, so we can't use any infcx methods on them.

Also, pass some extra span info to hack a quick solution to bad labels, resulting in this diagnostic improvement:

```rust
fn example2() {
    let mut x = vec![1];
    x.push("");
}
```

```diff
  error[E0308]: mismatched types
   --> src/main.rs:5:12
    |
  5 |     x.push("");
    |       ---- ^^
    |       |    |
    |       |    expected integer, found `&str`
-   |       |    this is of type `&'static str`, which causes `x` to be inferred as `Vec<{integer}>`
    |       arguments to this method are incorrect
```
(since that "which causes `x` to be inferred as `Vec<{integer}>` part is wrong)

r? `@estebank`

(we really should make this code better in general, cc rust-lang#106590, but that's a bit bigger issue that needs some more thinking about)
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 25, 2023
…ush, r=estebank

Fix escaping inference var ICE in `point_at_expr_source_of_inferred_type`

Fixes rust-lang#107158

`point_at_expr_source_of_inferred_type` uses `lookup_probe` to adjust the self type of a method receiver -- but that method returns inference variables from inside a probe. That means that the ty vars are no longer valid, so we can't use any infcx methods on them.

Also, pass some extra span info to hack a quick solution to bad labels, resulting in this diagnostic improvement:

```rust
fn example2() {
    let mut x = vec![1];
    x.push("");
}
```

```diff
  error[E0308]: mismatched types
   --> src/main.rs:5:12
    |
  5 |     x.push("");
    |       ---- ^^
    |       |    |
    |       |    expected integer, found `&str`
-   |       |    this is of type `&'static str`, which causes `x` to be inferred as `Vec<{integer}>`
    |       arguments to this method are incorrect
```
(since that "which causes `x` to be inferred as `Vec<{integer}>` part is wrong)

r? ``@estebank``

(we really should make this code better in general, cc rust-lang#106590, but that's a bit bigger issue that needs some more thinking about)
@bors bors closed this as completed in 5bc4980 Jan 26, 2023
@estebank
Copy link
Contributor

@justinpombrio sorry for causing you trouble 😅

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) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants