rust-lang / rust

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

ICE: `expected type for param` #112822

Closed matthiaskrgr closed 10 months ago

matthiaskrgr commented 1 year ago

Code

#![feature(const_trait_impl)]

const fn test() -> impl ~const Fn() {
    const move || {
        let sl: &[u8] = b"foo";

        match sl {
            [first, remainder @ ..] => {
                assert_eq!(first, &b'f');
            }
            [] => panic!(),
        }
    }
}

Meta

rustc --version --verbose:

rustc 1.72.0-nightly (2d0aa5768 2023-06-18)
binary: rustc
commit-hash: 2d0aa57684e10f7b3d3fe740ee18d431181583ad
commit-date: 2023-06-18
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.5

Error output

error[E0658]: const closures are experimental
 --> treereduce.out:4:5
  |
4 |     const move || {
  |     ^^^^^
  |
  = note: see issue #106003 <https://github.com/rust-lang/rust/issues/106003> for more information
  = help: add `#![feature(const_closures)]` to the crate attributes to enable

error[E0601]: `main` function not found in crate `treereduce`
  --> treereduce.out:14:2
   |
14 | }
   |  ^ consider adding a `main` function to `treereduce.out`

warning: unused variable: `remainder`
 --> treereduce.out:8:21
  |
8 |             [first, remainder @ ..] => {
  |                     ^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_remainder`
  |
  = note: `#[warn(unused_variables)]` on by default
Backtrace

``` error: internal compiler error: compiler/rustc_middle/src/ty/subst.rs:400:45: expected type for param #0 in [ReEarlyBound(0, '_), ReEarlyBound(1, '_), A, B] thread 'rustc' panicked at 'Box', /rustc/2d0aa57684e10f7b3d3fe740ee18d431181583ad/compiler/rustc_errors/src/lib.rs:1650:9 stack backtrace: 0: 0x7f6f3b367e11 - std::backtrace_rs::backtrace::libunwind::trace::h184786643c1f8146 at /rustc/2d0aa57684e10f7b3d3fe740ee18d431181583ad/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5 1: 0x7f6f3b367e11 - std::backtrace_rs::backtrace::trace_unsynchronized::h10cef21dd42edd42 at /rustc/2d0aa57684e10f7b3d3fe740ee18d431181583ad/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7f6f3b367e11 - std::sys_common::backtrace::_print_fmt::hca8722c6f82eccd9 at /rustc/2d0aa57684e10f7b3d3fe740ee18d431181583ad/library/std/src/sys_common/backtrace.rs:65:5 3: 0x7f6f3b367e11 - ::fmt::h4b170c65cdf95c48 at /rustc/2d0aa57684e10f7b3d3fe740ee18d431181583ad/library/std/src/sys_common/backtrace.rs:44:22 4: 0x7f6f3b3c94bf - core::fmt::rt::Argument::fmt::h7e50834cab28e102 at /rustc/2d0aa57684e10f7b3d3fe740ee18d431181583ad/library/core/src/fmt/rt.rs:138:9 5: 0x7f6f3b3c94bf - core::fmt::write::h8bd64fe81f89dd81 at /rustc/2d0aa57684e10f7b3d3fe740ee18d431181583ad/library/core/src/fmt/mod.rs:1094:21 6: 0x7f6f3b35a977 - std::io::Write::write_fmt::hc75a842b3ecac8bc at /rustc/2d0aa57684e10f7b3d3fe740ee18d431181583ad/library/std/src/io/mod.rs:1714:15 7: 0x7f6f3b367c25 - std::sys_common::backtrace::_print::hdb7a31bd8c54eb49 at /rustc/2d0aa57684e10f7b3d3fe740ee18d431181583ad/library/std/src/sys_common/backtrace.rs:47:5 8: 0x7f6f3b367c25 - std::sys_common::backtrace::print::hbcf968a4222dc0b5 at /rustc/2d0aa57684e10f7b3d3fe740ee18d431181583ad/library/std/src/sys_common/backtrace.rs:34:9 9: 0x7f6f3b36a9d3 - std::panicking::default_hook::{{closure}}::h02987b13cfa1387d at /rustc/2d0aa57684e10f7b3d3fe740ee18d431181583ad/library/std/src/panicking.rs:269:22 10: 0x7f6f3b36a764 - std::panicking::default_hook::hcb3fd44404995c49 at /rustc/2d0aa57684e10f7b3d3fe740ee18d431181583ad/library/std/src/panicking.rs:288:9 11: 0x7f6f3e5abd6b - >::call_once::{shim:vtable#0} 12: 0x7f6f3b36b1fe - as core::ops::function::Fn>::call::hec1e31de726d1657 at /rustc/2d0aa57684e10f7b3d3fe740ee18d431181583ad/library/alloc/src/boxed.rs:2007:9 13: 0x7f6f3b36b1fe - std::panicking::rust_panic_with_hook::h223f39091438ac61 at /rustc/2d0aa57684e10f7b3d3fe740ee18d431181583ad/library/std/src/panicking.rs:709:13 14: 0x7f6f3eaae8d1 - std[755122e38bdf80bb]::panicking::begin_panic::::{closure#0} 15: 0x7f6f3eaad526 - std[755122e38bdf80bb]::sys_common::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 16: 0x7f6f3eb42666 - std[755122e38bdf80bb]::panicking::begin_panic:: 17: 0x7f6f3eaaa2e4 - ::bug:: 18: 0x7f6f3eaaa166 - ::bug:: 19: 0x7f6f3eafd5fc - rustc_middle[56c503886228b671]::util::bug::opt_span_bug_fmt::::{closure#0} 20: 0x7f6f3eafa49a - rustc_middle[56c503886228b671]::ty::context::tls::with_opt::::{closure#0}, !>::{closure#0} 21: 0x7f6f3eafa46a - rustc_middle[56c503886228b671]::ty::context::tls::with_context_opt::::{closure#0}, !>::{closure#0}, !> 22: 0x7f6f3c8ef2bd - rustc_middle[56c503886228b671]::util::bug::bug_fmt 23: 0x7f6f3eae0a41 - rustc_middle[56c503886228b671]::util::call_kind::call_kind 24: 0x7f6f3e505ee3 - ::build_error 25: 0x7f6f3e549982 - ::check_op_spanned:: 26: 0x7f6f3d7fb233 - ::visit_terminator 27: 0x7f6f3d7f692b - ::visit_basic_block_data 28: 0x7f6f3d7f5435 - ::check_body 29: 0x7f6f3c7f145f - rustc_query_impl[e44c98b80a645267]::plumbing::__rust_begin_short_backtrace::> 30: 0x7f6f3d55075f - rustc_query_system[ba457099f14053e9]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[e44c98b80a645267]::plumbing::QueryCtxt, false> 31: 0x7f6f3d550488 - rustc_query_impl[e44c98b80a645267]::query_impl::mir_const_qualif::get_query_non_incr::__rust_end_short_backtrace 32: 0x7f6f3c92f979 - rustc_mir_transform[eaefbefc809602b3]::mir_promoted 33: 0x7f6f3c605921 - rustc_query_impl[e44c98b80a645267]::plumbing::__rust_begin_short_backtrace::> 34: 0x7f6f3ce71efa - rustc_query_system[ba457099f14053e9]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[e44c98b80a645267]::plumbing::QueryCtxt, false> 35: 0x7f6f3df173f5 - rustc_query_impl[e44c98b80a645267]::query_impl::mir_promoted::get_query_non_incr::__rust_end_short_backtrace 36: 0x7f6f3d41c37c - rustc_borrowck[cf2d7fd60d38cc0f]::mir_borrowck 37: 0x7f6f3c6125ee - rustc_query_impl[e44c98b80a645267]::plumbing::__rust_begin_short_backtrace::> 38: 0x7f6f3c6125be - >::call_once 39: 0x7f6f3c6d14cd - rustc_query_system[ba457099f14053e9]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[e44c98b80a645267]::plumbing::QueryCtxt, false> 40: 0x7f6f3df197ff - rustc_query_impl[e44c98b80a645267]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace 41: 0x7f6f3d7c71bf - ::prove_closure_bounds 42: 0x7f6f3d7973cf - ::typeck_mir 43: 0x7f6f3d44ed78 - rustc_borrowck[cf2d7fd60d38cc0f]::type_check::type_check 44: 0x7f6f3d4345d2 - rustc_borrowck[cf2d7fd60d38cc0f]::nll::compute_regions 45: 0x7f6f3d41e489 - rustc_borrowck[cf2d7fd60d38cc0f]::do_mir_borrowck 46: 0x7f6f3d41c780 - rustc_borrowck[cf2d7fd60d38cc0f]::mir_borrowck 47: 0x7f6f3c6125ee - rustc_query_impl[e44c98b80a645267]::plumbing::__rust_begin_short_backtrace::> 48: 0x7f6f3c6125be - >::call_once 49: 0x7f6f3c6d14cd - rustc_query_system[ba457099f14053e9]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[e44c98b80a645267]::plumbing::QueryCtxt, false> 50: 0x7f6f3df197ff - rustc_query_impl[e44c98b80a645267]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace 51: 0x7f6f3d753ee5 - rustc_hir_analysis[eb0d24a920376e7]::collect::type_of::opaque::find_opaque_ty_constraints_for_rpit 52: 0x7f6f3d750fef - rustc_hir_analysis[eb0d24a920376e7]::collect::type_of::type_of 53: 0x7f6f3c72635e - rustc_query_impl[e44c98b80a645267]::plumbing::__rust_begin_short_backtrace::> 54: 0x7f6f3c726090 - >::call_once 55: 0x7f6f3c60cb35 - rustc_query_system[ba457099f14053e9]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[e44c98b80a645267]::plumbing::QueryCtxt, false> 56: 0x7f6f3df16421 - rustc_query_impl[e44c98b80a645267]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace 57: 0x7f6f3d694e66 - rustc_middle[56c503886228b671]::query::plumbing::query_get_at::>> 58: 0x7f6f3d68cdcf - rustc_hir_analysis[eb0d24a920376e7]::check::check::check_mod_item_types 59: 0x7f6f3d21438c - rustc_query_impl[e44c98b80a645267]::plumbing::__rust_begin_short_backtrace::> 60: 0x7f6f3d21436e - >::call_once 61: 0x7f6f3cc4397f - rustc_query_system[ba457099f14053e9]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[e44c98b80a645267]::plumbing::QueryCtxt, false> 62: 0x7f6f3df21b92 - rustc_query_impl[e44c98b80a645267]::query_impl::check_mod_item_types::get_query_non_incr::__rust_end_short_backtrace 63: 0x7f6f3d9c1187 - ::for_each_module:: 64: 0x7f6f3d9c099d - ::time::<(), rustc_hir_analysis[eb0d24a920376e7]::check_crate::{closure#6}> 65: 0x7f6f3d9bee67 - rustc_hir_analysis[eb0d24a920376e7]::check_crate 66: 0x7f6f3d9b280a - rustc_interface[e3841d12b9b221e7]::passes::analysis 67: 0x7f6f3da2350a - rustc_query_impl[e44c98b80a645267]::plumbing::__rust_begin_short_backtrace::> 68: 0x7f6f3da234f9 - >::call_once 69: 0x7f6f3dc3f0f8 - rustc_query_system[ba457099f14053e9]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[e44c98b80a645267]::plumbing::QueryCtxt, false> 70: 0x7f6f3dc3eed7 - rustc_query_impl[e44c98b80a645267]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 71: 0x7f6f3dad6115 - ::enter::> 72: 0x7f6f3dad57bc - ::enter::, rustc_span[1e0547ff349d1bca]::ErrorGuaranteed>> 73: 0x7f6f3dad2e21 - std[755122e38bdf80bb]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[7175fdba515aac6e]::run_compiler::{closure#1}>::{closure#0}, core[baaa20f768102eef]::result::Result<(), rustc_span[1e0547ff349d1bca]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[baaa20f768102eef]::result::Result<(), rustc_span[1e0547ff349d1bca]::ErrorGuaranteed>> 74: 0x7f6f3dad25a5 - <::spawn_unchecked_, rustc_driver_impl[7175fdba515aac6e]::run_compiler::{closure#1}>::{closure#0}, core[baaa20f768102eef]::result::Result<(), rustc_span[1e0547ff349d1bca]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[baaa20f768102eef]::result::Result<(), rustc_span[1e0547ff349d1bca]::ErrorGuaranteed>>::{closure#1} as core[baaa20f768102eef]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 75: 0x7f6f3b375685 - as core::ops::function::FnOnce>::call_once::h59d6baf462325ed4 at /rustc/2d0aa57684e10f7b3d3fe740ee18d431181583ad/library/alloc/src/boxed.rs:1993:9 76: 0x7f6f3b375685 - as core::ops::function::FnOnce>::call_once::h4eca0dd82537346f at /rustc/2d0aa57684e10f7b3d3fe740ee18d431181583ad/library/alloc/src/boxed.rs:1993:9 77: 0x7f6f3b375685 - std::sys::unix::thread::Thread::new::thread_start::h38e13b8ca4256fdb at /rustc/2d0aa57684e10f7b3d3fe740ee18d431181583ad/library/std/src/sys/unix/thread.rs:108:17 78: 0x7f6f3b0d444b - 79: 0x7f6f3b157e40 - 80: 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.72.0-nightly (2d0aa5768 2023-06-18) running on x86_64-unknown-linux-gnu query stack during panic: #0 [mir_const_qualif] const checking `test::{closure#0}` #1 [mir_promoted] promoting constants in MIR for `test::{closure#0}` #2 [mir_borrowck] borrow-checking `test::{closure#0}` #3 [mir_borrowck] borrow-checking `test` #4 [type_of] computing type of `test::{opaque#0}` #5 [check_mod_item_types] checking item types in top-level module #6 [analysis] running analysis passes on this crate end of query stack error: aborting due to 3 previous errors; 1 warning emitted ```

matthiaskrgr commented 1 year ago

Regression in nightly-2023-02-05 Regression in 886b2c3e005b153b3c8263f48193e0df7de0f5b3 https://github.com/rust-lang/rust/pull/107551 cc @fee1-dead

JohnTitor commented 1 year ago

Fixed on the latest nightly, marking as E-needs-test @rustbot labels: +E-needs-test

fee1-dead commented 1 year ago

I don't think this is actually fixed, just that the ICE cannot be triggered currently, but might resurface when the effects feature is fully implemented.