rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.15k stars 12.56k forks source link

ICE: gce: `expected type of closure to be a closure` #119316

Open matthiaskrgr opened 9 months ago

matthiaskrgr commented 9 months ago

auto-reduced (treereduce-rust):

#![feature(generic_const_exprs)]

async fn foo<'a>() {
    let _data = &mut [0u8; { N + (|| 42)() }];
}

original:

// edition:2018
//~^ ERROR overly complex generic constant

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

#[allow(unused)]
async fn foo<'a>() {
    let _data = &mut [0u8; { N + (|| 42)() }];
    bar().await
}

async fn bar() {}

fn main() {}

Version information

rustc 1.77.0-nightly (1ab783112 2023-12-26)
binary: rustc
commit-hash: 1ab783112ab4e4807304dbd249b39771246013ef
commit-date: 2023-12-26
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

Command: /home/matthias/.rustup/toolchains/master/bin/rustc --edition=2021

Program output

``` error[E0425]: cannot find value `N` in this scope --> /tmp/icemaker_global_tempdir.Y0ACAS7jpz8y/rustc_testrunner_tmpdir_reporting.1VBmKbaJnVwY/mvce.rs:4:30 | 4 | let _data = &mut [0u8; { N + (|| 42)() }]; | ^ not found in this scope | help: you might be missing a const parameter | 3 | async fn foo<'a, const N: /* Type */>() { | +++++++++++++++++++++ warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes --> /tmp/icemaker_global_tempdir.Y0ACAS7jpz8y/rustc_testrunner_tmpdir_reporting.1VBmKbaJnVwY/mvce.rs:1:12 | 1 | #![feature(generic_const_exprs)] | ^^^^^^^^^^^^^^^^^^^ | = note: see issue #76560 for more information = note: `#[warn(incomplete_features)]` on by default error[E0601]: `main` function not found in crate `mvce` --> /tmp/icemaker_global_tempdir.Y0ACAS7jpz8y/rustc_testrunner_tmpdir_reporting.1VBmKbaJnVwY/mvce.rs:5:2 | 5 | } | ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.Y0ACAS7jpz8y/rustc_testrunner_tmpdir_reporting.1VBmKbaJnVwY/mvce.rs` error: internal compiler error: compiler/rustc_mir_build/src/build/mod.rs:660:17: expected type of closure to be a closure thread 'rustc' panicked at /rustc/1ab783112ab4e4807304dbd249b39771246013ef/compiler/rustc_errors/src/lib.rs:1068:30: Box stack backtrace: 0: 0x7f491dd8b6f6 - std::backtrace_rs::backtrace::libunwind::trace::h348a88e16d87236b at /rustc/1ab783112ab4e4807304dbd249b39771246013ef/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5 1: 0x7f491dd8b6f6 - std::backtrace_rs::backtrace::trace_unsynchronized::h171f2dab50688579 at /rustc/1ab783112ab4e4807304dbd249b39771246013ef/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7f491dd8b6f6 - std::sys_common::backtrace::_print_fmt::h724e5f353211a3ca at /rustc/1ab783112ab4e4807304dbd249b39771246013ef/library/std/src/sys_common/backtrace.rs:68:5 3: 0x7f491dd8b6f6 - ::fmt::h8b1913887ba5f5d5 at /rustc/1ab783112ab4e4807304dbd249b39771246013ef/library/std/src/sys_common/backtrace.rs:44:22 4: 0x7f491ddddf40 - core::fmt::rt::Argument::fmt::hf0fd130f7eae4c3d at /rustc/1ab783112ab4e4807304dbd249b39771246013ef/library/core/src/fmt/rt.rs:142:9 5: 0x7f491ddddf40 - core::fmt::write::h7efccb50bbeb8f2d at /rustc/1ab783112ab4e4807304dbd249b39771246013ef/library/core/src/fmt/mod.rs:1120:17 6: 0x7f491dd7f4af - std::io::Write::write_fmt::h577ca6f5235179c1 at /rustc/1ab783112ab4e4807304dbd249b39771246013ef/library/std/src/io/mod.rs:1810:15 7: 0x7f491dd8b4d4 - std::sys_common::backtrace::_print::hfd3fc853dd8f2062 at /rustc/1ab783112ab4e4807304dbd249b39771246013ef/library/std/src/sys_common/backtrace.rs:47:5 8: 0x7f491dd8b4d4 - std::sys_common::backtrace::print::hdd9ab79ba605a33e at /rustc/1ab783112ab4e4807304dbd249b39771246013ef/library/std/src/sys_common/backtrace.rs:34:9 9: 0x7f491dd8e267 - std::panicking::default_hook::{{closure}}::h55227ff383d43da6 10: 0x7f491dd8dfc9 - std::panicking::default_hook::h222f998032d4fac5 at /rustc/1ab783112ab4e4807304dbd249b39771246013ef/library/std/src/panicking.rs:292:9 11: 0x7f4920b5217c - std[515df92f1d858cd0]::panicking::update_hook::>::{closure#0} 12: 0x7f491dd8e9b6 - as core::ops::function::Fn>::call::h44a4b3682f15b897 at /rustc/1ab783112ab4e4807304dbd249b39771246013ef/library/alloc/src/boxed.rs:2029:9 13: 0x7f491dd8e9b6 - std::panicking::rust_panic_with_hook::h5f6eebb2178f45a7 at /rustc/1ab783112ab4e4807304dbd249b39771246013ef/library/std/src/panicking.rs:783:13 14: 0x7f4920b8b284 - std[515df92f1d858cd0]::panicking::begin_panic::::{closure#0} 15: 0x7f4920b879c6 - std[515df92f1d858cd0]::sys_common::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 16: 0x7f4920b87376 - std[515df92f1d858cd0]::panicking::begin_panic:: 17: 0x7f4920b962b1 - ::emit_producing_guarantee 18: 0x7f4920f6a29e - ::bug:: 19: 0x7f492100587b - rustc_middle[85a1c30f749671d0]::util::bug::opt_span_bug_fmt::::{closure#0} 20: 0x7f4920fef2ba - rustc_middle[85a1c30f749671d0]::ty::context::tls::with_opt::::{closure#0}, !>::{closure#0} 21: 0x7f4920fef158 - rustc_middle[85a1c30f749671d0]::ty::context::tls::with_context_opt::::{closure#0}, !>::{closure#0}, !> 22: 0x7f491ef8d8f0 - rustc_middle[85a1c30f749671d0]::util::bug::bug_fmt 23: 0x7f492105ced0 - rustc_mir_build[a60f727047e47965]::build::construct_error 24: 0x7f49220c2c6c - rustc_mir_build[a60f727047e47965]::build::mir_built 25: 0x7f49220c152d - rustc_query_impl[5e0167d86f023dad]::plumbing::__rust_begin_short_backtrace::> 26: 0x7f4921ffdf43 - rustc_query_system[c02ec8f8ee4628cc]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[5e0167d86f023dad]::plumbing::QueryCtxt, false> 27: 0x7f4921ffd8d0 - rustc_query_impl[5e0167d86f023dad]::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace 28: 0x7f491f39ea6e - rustc_mir_transform[385e435f7f981c0e]::check_unsafety::unsafety_check_result 29: 0x7f4921ffdcc7 - rustc_query_impl[5e0167d86f023dad]::plumbing::__rust_begin_short_backtrace::> 30: 0x7f4921ffdf43 - rustc_query_system[c02ec8f8ee4628cc]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[5e0167d86f023dad]::plumbing::QueryCtxt, false> 31: 0x7f4921ffda50 - rustc_query_impl[5e0167d86f023dad]::query_impl::unsafety_check_result::get_query_non_incr::__rust_end_short_backtrace 32: 0x7f4921ffef39 - rustc_mir_transform[385e435f7f981c0e]::mir_const 33: 0x7f4921ffee67 - rustc_query_impl[5e0167d86f023dad]::plumbing::__rust_begin_short_backtrace::> 34: 0x7f4921ffdf43 - rustc_query_system[c02ec8f8ee4628cc]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[5e0167d86f023dad]::plumbing::QueryCtxt, false> 35: 0x7f4921ffd990 - rustc_query_impl[5e0167d86f023dad]::query_impl::mir_const::get_query_non_incr::__rust_end_short_backtrace 36: 0x7f49200f15fc - rustc_mir_transform[385e435f7f981c0e]::mir_promoted 37: 0x7f49223f4f92 - rustc_query_impl[5e0167d86f023dad]::plumbing::__rust_begin_short_backtrace::> 38: 0x7f49223f525c - rustc_query_system[c02ec8f8ee4628cc]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[5e0167d86f023dad]::plumbing::QueryCtxt, false> 39: 0x7f49223f4e93 - rustc_query_impl[5e0167d86f023dad]::query_impl::mir_promoted::get_query_non_incr::__rust_end_short_backtrace 40: 0x7f4922d01830 - rustc_borrowck[40a8cab8ead5325]::mir_borrowck 41: 0x7f4922d01779 - rustc_query_impl[5e0167d86f023dad]::plumbing::__rust_begin_short_backtrace::> 42: 0x7f4921ffdf43 - rustc_query_system[c02ec8f8ee4628cc]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[5e0167d86f023dad]::plumbing::QueryCtxt, false> 43: 0x7f4921ffdb10 - rustc_query_impl[5e0167d86f023dad]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace 44: 0x7f4922e173b6 - ::check 45: 0x7f49203f4335 - ::visit_expr 46: 0x7f49203f43f3 - ::visit_expr 47: 0x7f4922de827b - ::visit_block 48: 0x7f4922de7449 - rustc_hir_analysis[60cf2858bdf10ca1]::collect::type_of::type_of_opaque 49: 0x7f4922de6eb9 - rustc_query_impl[5e0167d86f023dad]::plumbing::__rust_begin_short_backtrace::> 50: 0x7f4921e88f94 - rustc_query_system[c02ec8f8ee4628cc]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[5e0167d86f023dad]::plumbing::QueryCtxt, false> 51: 0x7f4922e448de - rustc_query_impl[5e0167d86f023dad]::query_impl::type_of_opaque::get_query_non_incr::__rust_end_short_backtrace 52: 0x7f4921f5acbc - rustc_middle[85a1c30f749671d0]::query::plumbing::query_get_at::>> 53: 0x7f4920225ac1 - rustc_hir_analysis[60cf2858bdf10ca1]::collect::type_of::type_of 54: 0x7f4921e8a0fe - rustc_query_impl[5e0167d86f023dad]::plumbing::__rust_begin_short_backtrace::> 55: 0x7f4921e88f94 - rustc_query_system[c02ec8f8ee4628cc]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[5e0167d86f023dad]::plumbing::QueryCtxt, false> 56: 0x7f4921e88b5d - rustc_query_impl[5e0167d86f023dad]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace 57: 0x7f4921f5acbc - rustc_middle[85a1c30f749671d0]::query::plumbing::query_get_at::>> 58: 0x7f4922aa57be - rustc_hir_analysis[60cf2858bdf10ca1]::check::check::check_item_type 59: 0x7f4922a9f5cb - rustc_hir_analysis[60cf2858bdf10ca1]::check::check::check_mod_item_types 60: 0x7f4922a9f56b - rustc_query_impl[5e0167d86f023dad]::plumbing::__rust_begin_short_backtrace::> 61: 0x7f4922a0773b - rustc_query_system[c02ec8f8ee4628cc]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[5e0167d86f023dad]::plumbing::QueryCtxt, false> 62: 0x7f4922a07117 - rustc_query_impl[5e0167d86f023dad]::query_impl::check_mod_item_types::get_query_non_incr::__rust_end_short_backtrace 63: 0x7f4922449c28 - rustc_hir_analysis[60cf2858bdf10ca1]::check_crate 64: 0x7f4922869fa9 - rustc_interface[590166dac91109dc]::passes::analysis 65: 0x7f4922869bdd - rustc_query_impl[5e0167d86f023dad]::plumbing::__rust_begin_short_backtrace::> 66: 0x7f4922dc4024 - rustc_query_system[c02ec8f8ee4628cc]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[5e0167d86f023dad]::plumbing::QueryCtxt, false> 67: 0x7f4922dc3e15 - rustc_query_impl[5e0167d86f023dad]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 68: 0x7f4922e4b652 - rustc_interface[590166dac91109dc]::interface::run_compiler::, rustc_driver_impl[e1d0187348731265]::run_compiler::{closure#0}>::{closure#0} 69: 0x7f4922dd3186 - std[515df92f1d858cd0]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[e1d0187348731265]::run_compiler::{closure#0}>::{closure#0}, core[40851f48e2bf7378]::result::Result<(), rustc_span[1ae6d8cb2a21d896]::ErrorGuaranteed>>::{closure#0}, core[40851f48e2bf7378]::result::Result<(), rustc_span[1ae6d8cb2a21d896]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[40851f48e2bf7378]::result::Result<(), rustc_span[1ae6d8cb2a21d896]::ErrorGuaranteed>> 70: 0x7f4922dd2fb3 - <::spawn_unchecked_, rustc_driver_impl[e1d0187348731265]::run_compiler::{closure#0}>::{closure#0}, core[40851f48e2bf7378]::result::Result<(), rustc_span[1ae6d8cb2a21d896]::ErrorGuaranteed>>::{closure#0}, core[40851f48e2bf7378]::result::Result<(), rustc_span[1ae6d8cb2a21d896]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[40851f48e2bf7378]::result::Result<(), rustc_span[1ae6d8cb2a21d896]::ErrorGuaranteed>>::{closure#1} as core[40851f48e2bf7378]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 71: 0x7f491dd988e5 - as core::ops::function::FnOnce>::call_once::h48c7d1fd92d8d424 at /rustc/1ab783112ab4e4807304dbd249b39771246013ef/library/alloc/src/boxed.rs:2015:9 72: 0x7f491dd988e5 - as core::ops::function::FnOnce>::call_once::h03f9c0e83ae2d107 at /rustc/1ab783112ab4e4807304dbd249b39771246013ef/library/alloc/src/boxed.rs:2015:9 73: 0x7f491dd988e5 - std::sys::unix::thread::Thread::new::thread_start::ha200406fab7d0f9d at /rustc/1ab783112ab4e4807304dbd249b39771246013ef/library/std/src/sys/unix/thread.rs:108:17 74: 0x7f491db849eb - 75: 0x7f491dc087cc - 76: 0x0 - 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.77.0-nightly (1ab783112 2023-12-26) running on x86_64-unknown-linux-gnu note: compiler flags: -Z dump-mir-dir=dir query stack during panic: #0 [mir_built] building MIR for `foo::{closure#0}::{constant#0}::{closure#0}` #1 [unsafety_check_result] unsafety-checking `foo::{closure#0}::{constant#0}::{closure#0}` #2 [mir_const] preparing `foo::{closure#0}::{constant#0}::{closure#0}` for borrow checking #3 [mir_promoted] promoting constants in MIR for `foo::{closure#0}::{constant#0}::{closure#0}` #4 [mir_borrowck] borrow-checking `foo::{closure#0}::{constant#0}::{closure#0}` #5 [type_of_opaque] computing type of opaque `foo::{opaque#0}` #6 [type_of] computing type of `foo::{opaque#0}` #7 [check_mod_item_types] checking item types in top-level module #8 [analysis] running analysis passes on this crate end of query stack error: aborting due to 3 previous errors; 1 warning emitted Some errors have detailed explanations: E0425, E0601. For more information about an error, try `rustc --explain E0425`. ```

matthiaskrgr commented 9 months ago

Regression in nightly-2022-12-09

found 3 bors merge commits in the specified range commit[0] 2022-12-07: Auto merge of #103459 - ChrisDenton:propagate-nulls, r=thomcc commit[1] 2022-12-08: Auto merge of #105425 - matthiaskrgr:rollup-3ngvxmt, r=matthiaskrgr commit[2] 2022-12-08: Auto merge of #105415 - nikic:update-llvm-10, r=cuviper ERROR: no CI builds available between 01fbc5ae789fc0c7a2da71d3cd908451f175e4eb and 7632db0e87d8adccc9a83a47795c9411b1455855 within last 167 days

maybe https://github.com/rust-lang/rust/pull/105400 ?