Skip to content

Passing array of return to a function with wrong number/type of arguments causes an ICE #98897

Description

@WaffleLapkin

Found this one while researching for #98894, probably has a related cause (since #92364 diagnostics call check_expr a second time which confuses the compiler). This is an ICE though so opening a dedicated issue.

cc @compiler-errors

Code

(|_, ()| ())([return, ()]);

Bisection

searched nightlies: from nightly-2022-04-10 to nightly-2022-05-09
regressed nightly: nightly-2022-04-17
searched commit range: 3f391b8...878c783
regressed commit: 07bb916

bisected with cargo-bisect-rustc v0.6.3

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

cargo bisect-rustc --regress=ice --end=2022-05-09

src/main.rs:

fn main() {
    (|_, ()| ())([return, ()]);
}

Meta

rustc --version --verbose:

rustc 1.64.0-nightly (20a6f3a8a 2022-06-25)
binary: rustc
commit-hash: 20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753
commit-date: 2022-06-25
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.5

Error output

thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `WarnedAlways`,
 right: `Maybe`', compiler/rustc_typeck/src/check/expr.rs:1309:13
Backtrace

thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `WarnedAlways`,
 right: `Maybe`', compiler/rustc_typeck/src/check/expr.rs:1309:13
stack backtrace:
   0:     0x7ff5b409e18d - std::backtrace_rs::backtrace::libunwind::trace::hb1109710b5bac759
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7ff5b409e18d - std::backtrace_rs::backtrace::trace_unsynchronized::h785364b6aed0029a
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7ff5b409e18d - std::sys_common::backtrace::_print_fmt::h74f64f39298dd76e
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7ff5b409e18d - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h496e3b79162d5554
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7ff5b40f9f7c - core::fmt::write::hab33fa5859262fe7
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/core/src/fmt/mod.rs:1197:17
   5:     0x7ff5b408f801 - std::io::Write::write_fmt::h1710e3e0ee173be1
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/io/mod.rs:1672:15
   6:     0x7ff5b40a0e55 - std::sys_common::backtrace::_print::h2a4a41c4c8a478e3
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7ff5b40a0e55 - std::sys_common::backtrace::print::h04d400740890388f
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7ff5b40a0e55 - std::panicking::default_hook::{{closure}}::h33882b41ce9ace17
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/panicking.rs:295:22
   9:     0x7ff5b40a0b76 - std::panicking::default_hook::hed13b5f1fa769ff8
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/panicking.rs:314:9
  10:     0x7ff5b490f804 - rustc_driver[2985e0c6160588b5]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7ff5b40a152a - std::panicking::rust_panic_with_hook::hfb6f3749c685320d
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/panicking.rs:702:17
  12:     0x7ff5b40a1367 - std::panicking::begin_panic_handler::{{closure}}::h99f3f91cb6d654a6
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/panicking.rs:588:13
  13:     0x7ff5b409e644 - std::sys_common::backtrace::__rust_end_short_backtrace::h1d5304cdf1728a1c
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7ff5b40a1099 - rust_begin_unwind
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/panicking.rs:584:5
  15:     0x7ff5b4066263 - core::panicking::panic_fmt::hce2c0129c83bc4c4
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/core/src/panicking.rs:142:14
  16:     0x7ff5b40f6d28 - core::panicking::assert_failed_inner::h34a537bd3d0af8b9
  17:     0x7ff5b4cab2dc - core[1c8f1df5a59aa66f]::panicking::assert_failed::<rustc_typeck[9766a23a180a54e4]::check::diverges::Diverges, rustc_typeck[9766a23a180a54e4]::check::diverges::Diverges>
  18:     0x7ff5b5f0663d - <rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::FnCtxt>::check_expr_kind
  19:     0x7ff5b4d3f886 - <core[1c8f1df5a59aa66f]::iter::adapters::map::Map<core[1c8f1df5a59aa66f]::ops::range::Range<usize>, <rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::arg_matrix::ArgMatrix>::new<<rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::FnCtxt>::check_argument_types::{closure#3}>::{closure#0}::{closure#0}> as core[1c8f1df5a59aa66f]::iter::traits::iterator::Iterator>::fold::<(), core[1c8f1df5a59aa66f]::iter::traits::iterator::Iterator::for_each::call<rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::arg_matrix::Compatibility, <alloc[318c0fc51e3c1903]::vec::Vec<rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::arg_matrix::Compatibility> as alloc[318c0fc51e3c1903]::vec::spec_extend::SpecExtend<rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::arg_matrix::Compatibility, core[1c8f1df5a59aa66f]::iter::adapters::map::Map<core[1c8f1df5a59aa66f]::ops::range::Range<usize>, <rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::arg_matrix::ArgMatrix>::new<<rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::FnCtxt>::check_argument_types::{closure#3}>::{closure#0}::{closure#0}>>>::spec_extend::{closure#0}>::{closure#0}>
  20:     0x7ff5b4d2c567 - <alloc[318c0fc51e3c1903]::vec::Vec<rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::arg_matrix::Compatibility> as alloc[318c0fc51e3c1903]::vec::spec_from_iter::SpecFromIter<rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::arg_matrix::Compatibility, core[1c8f1df5a59aa66f]::iter::adapters::map::Map<core[1c8f1df5a59aa66f]::ops::range::Range<usize>, <rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::arg_matrix::ArgMatrix>::new<<rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::FnCtxt>::check_argument_types::{closure#3}>::{closure#0}::{closure#0}>>>::from_iter
  21:     0x7ff5b4d3f684 - <core[1c8f1df5a59aa66f]::iter::adapters::map::Map<core[1c8f1df5a59aa66f]::ops::range::Range<usize>, <rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::arg_matrix::ArgMatrix>::new<<rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::FnCtxt>::check_argument_types::{closure#3}>::{closure#0}> as core[1c8f1df5a59aa66f]::iter::traits::iterator::Iterator>::fold::<(), core[1c8f1df5a59aa66f]::iter::traits::iterator::Iterator::for_each::call<alloc[318c0fc51e3c1903]::vec::Vec<rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::arg_matrix::Compatibility>, <alloc[318c0fc51e3c1903]::vec::Vec<alloc[318c0fc51e3c1903]::vec::Vec<rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::arg_matrix::Compatibility>> as alloc[318c0fc51e3c1903]::vec::spec_extend::SpecExtend<alloc[318c0fc51e3c1903]::vec::Vec<rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::arg_matrix::Compatibility>, core[1c8f1df5a59aa66f]::iter::adapters::map::Map<core[1c8f1df5a59aa66f]::ops::range::Range<usize>, <rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::arg_matrix::ArgMatrix>::new<<rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::FnCtxt>::check_argument_types::{closure#3}>::{closure#0}>>>::spec_extend::{closure#0}>::{closure#0}>
  22:     0x7ff5b4d24f95 - <alloc[318c0fc51e3c1903]::vec::Vec<alloc[318c0fc51e3c1903]::vec::Vec<rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::arg_matrix::Compatibility>> as alloc[318c0fc51e3c1903]::vec::spec_from_iter::SpecFromIter<alloc[318c0fc51e3c1903]::vec::Vec<rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::arg_matrix::Compatibility>, core[1c8f1df5a59aa66f]::iter::adapters::map::Map<core[1c8f1df5a59aa66f]::ops::range::Range<usize>, <rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::arg_matrix::ArgMatrix>::new<<rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::FnCtxt>::check_argument_types::{closure#3}>::{closure#0}>>>::from_iter
  23:     0x7ff5b4cb73f1 - <rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::arg_matrix::ArgMatrix>::new::<<rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::FnCtxt>::check_argument_types::{closure#3}>
  24:     0x7ff5b5ed1726 - <rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::FnCtxt>::check_argument_types
  25:     0x7ff5b5eaf244 - <rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::FnCtxt>::check_call
  26:     0x7ff5b5f00b55 - <rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::FnCtxt>::check_expr_kind
  27:     0x7ff5b5effbf0 - <rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  28:     0x7ff5b5eed616 - <rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::FnCtxt>::check_stmt
  29:     0x7ff5b5eeec57 - <rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::FnCtxt>::check_block_with_expected
  30:     0x7ff5b5f00ec3 - <rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::FnCtxt>::check_expr_kind
  31:     0x7ff5b5effbf0 - <rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  32:     0x7ff5b5f31c06 - rustc_typeck[9766a23a180a54e4]::check::check::check_fn
  33:     0x7ff5b5fc63fe - <rustc_infer[fac6976779193def]::infer::InferCtxtBuilder>::enter::<&rustc_middle[e91eda85edc2d458]::ty::context::TypeckResults, <rustc_typeck[9766a23a180a54e4]::check::inherited::InheritedBuilder>::enter<rustc_typeck[9766a23a180a54e4]::check::typeck_with_fallback<rustc_typeck[9766a23a180a54e4]::check::typeck::{closure#0}>::{closure#1}, &rustc_middle[e91eda85edc2d458]::ty::context::TypeckResults>::{closure#0}>
  34:     0x7ff5b5f507ba - rustc_typeck[9766a23a180a54e4]::check::typeck
  35:     0x7ff5b6507984 - rustc_query_system[a80f8bd821f477c6]::query::plumbing::try_execute_query::<rustc_query_impl[bc93cb9e73dff18e]::plumbing::QueryCtxt, rustc_query_system[a80f8bd821f477c6]::query::caches::DefaultCache<rustc_span[8b48bd2bfbcc9443]::def_id::LocalDefId, &rustc_middle[e91eda85edc2d458]::ty::context::TypeckResults>>
  36:     0x7ff5b64ddcde - <rustc_query_impl[bc93cb9e73dff18e]::Queries as rustc_middle[e91eda85edc2d458]::ty::query::QueryEngine>::typeck
  37:     0x7ff5b5f5094f - rustc_typeck[9766a23a180a54e4]::check::typeck
  38:     0x7ff5b6507984 - rustc_query_system[a80f8bd821f477c6]::query::plumbing::try_execute_query::<rustc_query_impl[bc93cb9e73dff18e]::plumbing::QueryCtxt, rustc_query_system[a80f8bd821f477c6]::query::caches::DefaultCache<rustc_span[8b48bd2bfbcc9443]::def_id::LocalDefId, &rustc_middle[e91eda85edc2d458]::ty::context::TypeckResults>>
  39:     0x7ff5b64ddcde - <rustc_query_impl[bc93cb9e73dff18e]::Queries as rustc_middle[e91eda85edc2d458]::ty::query::QueryEngine>::typeck
  40:     0x7ff5b5fed5b8 - <rustc_middle[e91eda85edc2d458]::hir::map::Map>::par_body_owners::<rustc_typeck[9766a23a180a54e4]::check::typeck_item_bodies::{closure#0}>
  41:     0x7ff5b6da51fc - rustc_typeck[9766a23a180a54e4]::check::typeck_item_bodies
  42:     0x7ff5b709f75c - rustc_query_system[a80f8bd821f477c6]::query::plumbing::try_execute_query::<rustc_query_impl[bc93cb9e73dff18e]::plumbing::QueryCtxt, rustc_query_system[a80f8bd821f477c6]::query::caches::DefaultCache<(), ()>>
  43:     0x7ff5b70ccac1 - rustc_query_system[a80f8bd821f477c6]::query::plumbing::get_query::<rustc_query_impl[bc93cb9e73dff18e]::queries::typeck_item_bodies, rustc_query_impl[bc93cb9e73dff18e]::plumbing::QueryCtxt>
  44:     0x7ff5b6dcadf3 - <rustc_session[a46327cfa276e5ae]::session::Session>::time::<(), rustc_typeck[9766a23a180a54e4]::check_crate::{closure#7}>
  45:     0x7ff5b6dc1573 - rustc_typeck[9766a23a180a54e4]::check_crate
  46:     0x7ff5b6b33067 - rustc_interface[3f74620ae1096927]::passes::analysis
  47:     0x7ff5b7094c8f - rustc_query_system[a80f8bd821f477c6]::query::plumbing::try_execute_query::<rustc_query_impl[bc93cb9e73dff18e]::plumbing::QueryCtxt, rustc_query_system[a80f8bd821f477c6]::query::caches::DefaultCache<(), core[1c8f1df5a59aa66f]::result::Result<(), rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>>>
  48:     0x7ff5b70df01e - rustc_query_system[a80f8bd821f477c6]::query::plumbing::get_query::<rustc_query_impl[bc93cb9e73dff18e]::queries::analysis, rustc_query_impl[bc93cb9e73dff18e]::plumbing::QueryCtxt>
  49:     0x7ff5b6b16e37 - <rustc_interface[3f74620ae1096927]::passes::QueryContext>::enter::<rustc_driver[2985e0c6160588b5]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[1c8f1df5a59aa66f]::result::Result<(), rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>>
  50:     0x7ff5b6b0111f - <rustc_interface[3f74620ae1096927]::interface::Compiler>::enter::<rustc_driver[2985e0c6160588b5]::run_compiler::{closure#1}::{closure#2}, core[1c8f1df5a59aa66f]::result::Result<core[1c8f1df5a59aa66f]::option::Option<rustc_interface[3f74620ae1096927]::queries::Linker>, rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>>
  51:     0x7ff5b6afa64f - rustc_span[8b48bd2bfbcc9443]::with_source_map::<core[1c8f1df5a59aa66f]::result::Result<(), rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>, rustc_interface[3f74620ae1096927]::interface::create_compiler_and_run<core[1c8f1df5a59aa66f]::result::Result<(), rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>, rustc_driver[2985e0c6160588b5]::run_compiler::{closure#1}>::{closure#1}>
  52:     0x7ff5b6b01fb2 - <scoped_tls[3b74a2cd32801712]::ScopedKey<rustc_span[8b48bd2bfbcc9443]::SessionGlobals>>::set::<rustc_interface[3f74620ae1096927]::interface::run_compiler<core[1c8f1df5a59aa66f]::result::Result<(), rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>, rustc_driver[2985e0c6160588b5]::run_compiler::{closure#1}>::{closure#0}, core[1c8f1df5a59aa66f]::result::Result<(), rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>>
  53:     0x7ff5b6b174bf - std[183c58237bb308d2]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3f74620ae1096927]::util::run_in_thread_pool_with_globals<rustc_interface[3f74620ae1096927]::interface::run_compiler<core[1c8f1df5a59aa66f]::result::Result<(), rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>, rustc_driver[2985e0c6160588b5]::run_compiler::{closure#1}>::{closure#0}, core[1c8f1df5a59aa66f]::result::Result<(), rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>>::{closure#0}, core[1c8f1df5a59aa66f]::result::Result<(), rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>>
  54:     0x7ff5b6b176a9 - <<std[183c58237bb308d2]::thread::Builder>::spawn_unchecked_<rustc_interface[3f74620ae1096927]::util::run_in_thread_pool_with_globals<rustc_interface[3f74620ae1096927]::interface::run_compiler<core[1c8f1df5a59aa66f]::result::Result<(), rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>, rustc_driver[2985e0c6160588b5]::run_compiler::{closure#1}>::{closure#0}, core[1c8f1df5a59aa66f]::result::Result<(), rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>>::{closure#0}, core[1c8f1df5a59aa66f]::result::Result<(), rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>>::{closure#1} as core[1c8f1df5a59aa66f]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  55:     0x7ff5b40ab463 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha4ec43e0ec331bcb
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/alloc/src/boxed.rs:1951:9
  56:     0x7ff5b40ab463 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5e13b6a1911b918e
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/alloc/src/boxed.rs:1951:9
  57:     0x7ff5b40ab463 - std::sys::unix::thread::Thread::new::thread_start::h21c45ad5909aa02c
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/sys/unix/thread.rs:108:17
  58:     0x7ff5b3c8c54d - <unknown>
  59:     0x7ff5b3d11874 - clone
  60:                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.64.0-nightly (20a6f3a8a 2022-06-25) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `main`
#1 [typeck] type-checking `main::{closure#0}`
#2 [typeck_item_bodies] type-checking all item bodies
#3 [analysis] running analysis passes on this crate
end of query stack

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions