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 usize, got Const` #113021

Closed matthiaskrgr closed 1 year ago

matthiaskrgr commented 1 year ago

Code

#![feature(generic_const_exprs)]

pub async fn something(path: &[[usize; N_ISLANDS]; PrivateStruct]) -> usize {
    match path {
        [] | _ => 0,
    }
}

pub fn main() {}

Meta

rustc --version --verbose:

rustc 1.72.0-nightly (22e9fe644 2023-06-23)
binary: rustc
commit-hash: 22e9fe644ea710eec50cb0aabcae7fa8dd9fd675
commit-date: 2023-06-23
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.5

Error output

error[E0670]: `async fn` is not permitted in Rust 2015
 --> 063C62043B0E0550CF8DB5A3E283C6D530D674D10E7B87DEBB6545F792710536.rs:3:5
  |
3 | pub async fn something(path: &[[usize; N_ISLANDS]; PrivateStruct]) -> usize {
  |     ^^^^^ to use `async fn`, switch to Rust 2018 or later
  |
  = help: pass `--edition 2021` to `rustc`
  = note: for more on editions, read https://doc.rust-lang.org/edition-guide

error[E0425]: cannot find value `N_ISLANDS` in this scope
 --> 063C62043B0E0550CF8DB5A3E283C6D530D674D10E7B87DEBB6545F792710536.rs:3:40
  |
3 | pub async fn something(path: &[[usize; N_ISLANDS]; PrivateStruct]) -> usize {
  |                                        ^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `PrivateStruct` in this scope
 --> 063C62043B0E0550CF8DB5A3E283C6D530D674D10E7B87DEBB6545F792710536.rs:3:52
  |
3 | pub async fn something(path: &[[usize; N_ISLANDS]; PrivateStruct]) -> usize {
  |                                                    ^^^^^^^^^^^^^ not found in this scope

warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> 063C62043B0E0550CF8DB5A3E283C6D530D674D10E7B87DEBB6545F792710536.rs:1:12
  |
1 | #![feature(generic_const_exprs)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
  = note: `#[warn(incomplete_features)]` on by default
Backtrace

``` error: internal compiler error: /rustc/22e9fe644ea710eec50cb0aabcae7fa8dd9fd675/compiler/rustc_middle/src/ty/consts.rs:238:32: expected usize, got Const { ty: usize, kind: Unevaluated([], DefId(0:5 ~ 063C62043B0E0550CF8DB5A3E283C6D530D674D10E7B87DEBB6545F792710536[8e5e]::something::{constant#1})) } thread 'rustc' panicked at 'Box', /rustc/22e9fe644ea710eec50cb0aabcae7fa8dd9fd675/compiler/rustc_errors/src/lib.rs:1650:9 stack backtrace: 0: 0x7fc4ff041e31 - std::backtrace_rs::backtrace::libunwind::trace::h45c8b5b393354aaa at /rustc/22e9fe644ea710eec50cb0aabcae7fa8dd9fd675/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5 1: 0x7fc4ff041e31 - std::backtrace_rs::backtrace::trace_unsynchronized::hc5cde6aeff03cc23 at /rustc/22e9fe644ea710eec50cb0aabcae7fa8dd9fd675/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7fc4ff041e31 - std::sys_common::backtrace::_print_fmt::h86fd79bdeff6c899 at /rustc/22e9fe644ea710eec50cb0aabcae7fa8dd9fd675/library/std/src/sys_common/backtrace.rs:65:5 3: 0x7fc4ff041e31 - ::fmt::h0f1168665e8c8865 at /rustc/22e9fe644ea710eec50cb0aabcae7fa8dd9fd675/library/std/src/sys_common/backtrace.rs:44:22 4: 0x7fc4ff0a35df - core::fmt::rt::Argument::fmt::hfed1a51422c978b7 at /rustc/22e9fe644ea710eec50cb0aabcae7fa8dd9fd675/library/core/src/fmt/rt.rs:138:9 5: 0x7fc4ff0a35df - core::fmt::write::h4dfc2a0c62cf3fd6 at /rustc/22e9fe644ea710eec50cb0aabcae7fa8dd9fd675/library/core/src/fmt/mod.rs:1094:21 6: 0x7fc4ff034967 - std::io::Write::write_fmt::ha45cc30dd6a81686 at /rustc/22e9fe644ea710eec50cb0aabcae7fa8dd9fd675/library/std/src/io/mod.rs:1714:15 7: 0x7fc4ff041c45 - std::sys_common::backtrace::_print::h14294ae8d055d04e at /rustc/22e9fe644ea710eec50cb0aabcae7fa8dd9fd675/library/std/src/sys_common/backtrace.rs:47:5 8: 0x7fc4ff041c45 - std::sys_common::backtrace::print::hf007ea148056754d at /rustc/22e9fe644ea710eec50cb0aabcae7fa8dd9fd675/library/std/src/sys_common/backtrace.rs:34:9 9: 0x7fc4ff0449f3 - std::panicking::default_hook::{{closure}}::h12f0e86c17019fae at /rustc/22e9fe644ea710eec50cb0aabcae7fa8dd9fd675/library/std/src/panicking.rs:269:22 10: 0x7fc4ff044784 - std::panicking::default_hook::h3e363e70e8823128 at /rustc/22e9fe644ea710eec50cb0aabcae7fa8dd9fd675/library/std/src/panicking.rs:288:9 11: 0x7fc4fde03eab - rustc_driver_impl[1ee18bc64acaad37]::install_ice_hook::{closure#0} 12: 0x7fc4ff04521e - as core::ops::function::Fn>::call::h6345ba7ef09e0a3b at /rustc/22e9fe644ea710eec50cb0aabcae7fa8dd9fd675/library/alloc/src/boxed.rs:2007:9 13: 0x7fc4ff04521e - std::panicking::rust_panic_with_hook::he3112cb9ec41f5a5 at /rustc/22e9fe644ea710eec50cb0aabcae7fa8dd9fd675/library/std/src/panicking.rs:709:13 14: 0x7fc4fe3d4581 - std[590ba7ead67831d4]::panicking::begin_panic::::{closure#0} 15: 0x7fc4fe3d1856 - std[590ba7ead67831d4]::sys_common::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 16: 0x7fc4fe3c2ce6 - std[590ba7ead67831d4]::panicking::begin_panic:: 17: 0x7fc4fe325a14 - ::bug:: 18: 0x7fc4fe325896 - ::bug:: 19: 0x7fc4fe34870c - rustc_middle[aeb3147772634dcd]::util::bug::opt_span_bug_fmt::::{closure#0} 20: 0x7fc4fe34776a - rustc_middle[aeb3147772634dcd]::ty::context::tls::with_opt::::{closure#0}, !>::{closure#0} 21: 0x7fc4fe34773a - rustc_middle[aeb3147772634dcd]::ty::context::tls::with_context_opt::::{closure#0}, !>::{closure#0}, !> 22: 0x7fc4fc1c42ad - rustc_middle[aeb3147772634dcd]::util::bug::bug_fmt 23: 0x7fc4fcf40615 - ::prefix_slice_suffix 24: 0x7fc4fcf44bc7 - ::simplify_candidate 25: 0x7fc4fcf4092e - >, ::create_or_subcandidates::{closure#0}> as core[db7c5f9f8e26b951]::iter::traits::iterator::Iterator>::fold::<(), core[db7c5f9f8e26b951]::iter::traits::iterator::Iterator::for_each::call>::extend_trusted>, ::create_or_subcandidates::{closure#0}>>::{closure#0}>::{closure#0}> 26: 0x7fc4fcf3ff95 - as alloc[2c2f5c796e500044]::vec::spec_from_iter::SpecFromIter>, ::create_or_subcandidates::{closure#0}>>>::from_iter 27: 0x7fc4fcf3c06e - ::match_candidates 28: 0x7fc4fc22b377 - ::lower_match_tree 29: 0x7fc4fc208540 - ::expr_into_dest 30: 0x7fc4fc2064eb - ::expr_into_dest 31: 0x7fc4fc237ddc - ::ast_block_stmts 32: 0x7fc4fc22a1d3 - ::ast_block 33: 0x7fc4fc2073c2 - ::expr_into_dest 34: 0x7fc4fc2064eb - ::expr_into_dest 35: 0x7fc4fc2064eb - ::expr_into_dest 36: 0x7fc4fc208c9d - ::expr_into_dest 37: 0x7fc4fc2064eb - ::expr_into_dest 38: 0x7fc4fc237ddc - ::ast_block_stmts 39: 0x7fc4fc22a1d3 - ::ast_block 40: 0x7fc4fc2073c2 - ::expr_into_dest 41: 0x7fc4fc2064eb - ::expr_into_dest 42: 0x7fc4fc2064eb - ::expr_into_dest 43: 0x7fc4fccedef5 - rustc_mir_build[c1d3f5d6f149c6f6]::build::mir_built 44: 0x7fc4fbe32e6c - rustc_query_impl[30672f8f3d90a755]::plumbing::__rust_begin_short_backtrace::> 45: 0x7fc4fbe32e4e - >::call_once 46: 0x7fc4fbf265ad - rustc_query_system[29d9bde875297da0]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[30672f8f3d90a755]::plumbing::QueryCtxt, false> 47: 0x7fc4fd789dc1 - rustc_query_impl[30672f8f3d90a755]::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace 48: 0x7fc4fcf73de4 - rustc_mir_transform[ea407ab7eecac49d]::check_unsafety::unsafety_check_result 49: 0x7fc4fbe32eac - rustc_query_impl[30672f8f3d90a755]::plumbing::__rust_begin_short_backtrace::> 50: 0x7fc4fbe32e8e - >::call_once 51: 0x7fc4fbf265ad - rustc_query_system[29d9bde875297da0]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[30672f8f3d90a755]::plumbing::QueryCtxt, false> 52: 0x7fc4fd784db1 - rustc_query_impl[30672f8f3d90a755]::query_impl::unsafety_check_result::get_query_non_incr::__rust_end_short_backtrace 53: 0x7fc4fcf77394 - rustc_mir_transform[ea407ab7eecac49d]::check_unsafety::unsafety_check_result 54: 0x7fc4fbe32eac - rustc_query_impl[30672f8f3d90a755]::plumbing::__rust_begin_short_backtrace::> 55: 0x7fc4fbe32e8e - >::call_once 56: 0x7fc4fbf265ad - rustc_query_system[29d9bde875297da0]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[30672f8f3d90a755]::plumbing::QueryCtxt, false> 57: 0x7fc4fd784db1 - rustc_query_impl[30672f8f3d90a755]::query_impl::unsafety_check_result::get_query_non_incr::__rust_end_short_backtrace 58: 0x7fc4fd1345e4 - rustc_mir_transform[ea407ab7eecac49d]::mir_const 59: 0x7fc4fbe3e3ce - rustc_query_impl[30672f8f3d90a755]::plumbing::__rust_begin_short_backtrace::> 60: 0x7fc4fbe3e39e - >::call_once 61: 0x7fc4fbf265ad - rustc_query_system[29d9bde875297da0]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[30672f8f3d90a755]::plumbing::QueryCtxt, false> 62: 0x7fc4fd7842a1 - rustc_query_impl[30672f8f3d90a755]::query_impl::mir_const::get_query_non_incr::__rust_end_short_backtrace 63: 0x7fc4fc01258a - rustc_mir_transform[ea407ab7eecac49d]::mir_promoted 64: 0x7fc4fbe32f01 - rustc_query_impl[30672f8f3d90a755]::plumbing::__rust_begin_short_backtrace::> 65: 0x7fc4fc6cc5aa - rustc_query_system[29d9bde875297da0]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[30672f8f3d90a755]::plumbing::QueryCtxt, false> 66: 0x7fc4fd77f367 - rustc_query_impl[30672f8f3d90a755]::query_impl::mir_promoted::get_query_non_incr::__rust_end_short_backtrace 67: 0x7fc4fc702a2c - rustc_borrowck[5b525c22e5b16615]::mir_borrowck 68: 0x7fc4fbe3e42e - rustc_query_impl[30672f8f3d90a755]::plumbing::__rust_begin_short_backtrace::> 69: 0x7fc4fbe3e3fe - >::call_once 70: 0x7fc4fbf265ad - rustc_query_system[29d9bde875297da0]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[30672f8f3d90a755]::plumbing::QueryCtxt, false> 71: 0x7fc4fd7850f1 - rustc_query_impl[30672f8f3d90a755]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace 72: 0x7fc4fcfa6e3e - rustc_hir_analysis[bed39c5e84d3e350]::collect::type_of::opaque::find_opaque_ty_constraints_for_rpit 73: 0x7fc4fcfa3a04 - rustc_hir_analysis[bed39c5e84d3e350]::collect::type_of::type_of 74: 0x7fc4fbf52a33 - rustc_query_impl[30672f8f3d90a755]::plumbing::__rust_begin_short_backtrace::> 75: 0x7fc4fbf529f0 - >::call_once 76: 0x7fc4fbe3d515 - rustc_query_system[29d9bde875297da0]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[30672f8f3d90a755]::plumbing::QueryCtxt, false> 77: 0x7fc4fd783d73 - rustc_query_impl[30672f8f3d90a755]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace 78: 0x7fc4fcddad50 - rustc_middle[aeb3147772634dcd]::query::plumbing::query_get_at::>> 79: 0x7fc4fcdd4ca4 - rustc_hir_analysis[bed39c5e84d3e350]::check::check::check_mod_item_types 80: 0x7fc4fcad91fc - rustc_query_impl[30672f8f3d90a755]::plumbing::__rust_begin_short_backtrace::> 81: 0x7fc4fcad91de - >::call_once 82: 0x7fc4fc4f518f - rustc_query_system[29d9bde875297da0]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[30672f8f3d90a755]::plumbing::QueryCtxt, false> 83: 0x7fc4fd76fc04 - rustc_query_impl[30672f8f3d90a755]::query_impl::check_mod_item_types::get_query_non_incr::__rust_end_short_backtrace 84: 0x7fc4fd298f57 - ::for_each_module:: 85: 0x7fc4fd29832d - ::time::<(), rustc_hir_analysis[bed39c5e84d3e350]::check_crate::{closure#6}> 86: 0x7fc4fd296ff7 - rustc_hir_analysis[bed39c5e84d3e350]::check_crate 87: 0x7fc4fd28fb6a - rustc_interface[3e44238a9783f3c8]::passes::analysis 88: 0x7fc4fd2dc83a - rustc_query_impl[30672f8f3d90a755]::plumbing::__rust_begin_short_backtrace::> 89: 0x7fc4fd2dc829 - >::call_once 90: 0x7fc4fd471c18 - rustc_query_system[29d9bde875297da0]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[30672f8f3d90a755]::plumbing::QueryCtxt, false> 91: 0x7fc4fd4719e9 - rustc_query_impl[30672f8f3d90a755]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 92: 0x7fc4fd428485 - ::enter::> 93: 0x7fc4fd003f4b - ::enter::, rustc_span[8155bebf48a1eb91]::ErrorGuaranteed>> 94: 0x7fc4fcfffd99 - rustc_span[8155bebf48a1eb91]::set_source_map::, rustc_interface[3e44238a9783f3c8]::interface::run_compiler, rustc_driver_impl[1ee18bc64acaad37]::run_compiler::{closure#1}>::{closure#0}::{closure#0}> 95: 0x7fc4fcfff8c5 - >::set::, rustc_driver_impl[1ee18bc64acaad37]::run_compiler::{closure#1}>::{closure#0}, core[db7c5f9f8e26b951]::result::Result<(), rustc_span[8155bebf48a1eb91]::ErrorGuaranteed>> 96: 0x7fc4fcffeee6 - std[590ba7ead67831d4]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[1ee18bc64acaad37]::run_compiler::{closure#1}>::{closure#0}, core[db7c5f9f8e26b951]::result::Result<(), rustc_span[8155bebf48a1eb91]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[db7c5f9f8e26b951]::result::Result<(), rustc_span[8155bebf48a1eb91]::ErrorGuaranteed>> 97: 0x7fc4fd673945 - <::spawn_unchecked_, rustc_driver_impl[1ee18bc64acaad37]::run_compiler::{closure#1}>::{closure#0}, core[db7c5f9f8e26b951]::result::Result<(), rustc_span[8155bebf48a1eb91]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[db7c5f9f8e26b951]::result::Result<(), rustc_span[8155bebf48a1eb91]::ErrorGuaranteed>>::{closure#1} as core[db7c5f9f8e26b951]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 98: 0x7fc4ff04f695 - as core::ops::function::FnOnce>::call_once::h2e6f8aee19cb9bca at /rustc/22e9fe644ea710eec50cb0aabcae7fa8dd9fd675/library/alloc/src/boxed.rs:1993:9 99: 0x7fc4ff04f695 - as core::ops::function::FnOnce>::call_once::h4548c5cdbeb5a136 at /rustc/22e9fe644ea710eec50cb0aabcae7fa8dd9fd675/library/alloc/src/boxed.rs:1993:9 100: 0x7fc4ff04f695 - std::sys::unix::thread::Thread::new::thread_start::h57734a91bfb8a041 at /rustc/22e9fe644ea710eec50cb0aabcae7fa8dd9fd675/library/std/src/sys/unix/thread.rs:108:17 101: 0x7fc4faa9d44b - 102: 0x7fc4fab20e40 - 103: 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 (22e9fe644 2023-06-23) running on x86_64-unknown-linux-gnu query stack during panic: #0 [mir_built] building MIR for `something::{closure#0}` #1 [unsafety_check_result] unsafety-checking `something::{closure#0}` #2 [unsafety_check_result] unsafety-checking `something` #3 [mir_const] preparing `something` for borrow checking #4 [mir_promoted] promoting constants in MIR for `something` #5 [mir_borrowck] borrow-checking `something` #6 [type_of] computing type of `something::{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 4 previous errors; 1 warning emitted Some errors have detailed explanations: E0425, E0670. For more information about an error, try `rustc --explain E0425`. ```

BoxyUwU commented 1 year ago

cc @clubby789

clubby789 commented 1 year ago

This also ICEs on stable with the same error, so I don't think this is related to any of my recent changes at a glance. Having a look at it though

matthiaskrgr commented 1 year ago

Regression in nightly-2021-09-01 commit[0] 2021-08-30: Auto merge of #88466 - sexxi-goose:issue-88372, r=nikomatsakis commit[1] 2021-08-30: Auto merge of #88369 - lcnr:cec-rename, r=oli-obk commit[2] 2021-08-31: Auto merge of #88100 - HTG-YT:edition2021-compopt-stabilization, r=m-ou-se commit[3] 2021-08-31: Auto merge of #88414 - Aaron1011:guess-foreign-head-span, r=estebank commit[4] 2021-08-31: Auto merge of #88467 - sexxi-goose:issue-88431, r=nikomatsakis commit[5] 2021-08-31: Auto merge of #88491 - RalfJung:miri, r=RalfJung commit[6] 2021-08-31: Auto merge of #88527 - m-ou-se:rollup-az6xtc5, r=m-ou-se commit[7] 2021-08-31: Auto merge of #88535 - m-ou-se:rollup-jeusxbo, r=m-ou-se commit[8] 2021-08-31: Auto merge of #88506 - Mark-Simulacrum:fix-rlibs, r=ehuss

clubby789 commented 1 year ago

update const generics feature gates

I suspect that might be a false positive bisect?

matthiaskrgr commented 1 year ago

ah meh, probably, if the feature gate was renamed or something, the code with the "new" feature gate might no longer trigger the ice once needed the old feature gate -_-

syvb commented 1 year ago

Bisected to nightly-2022-11-27, probably caused by #99798.

cargo-bisect-rustc output ``` commit[0] 2022-11-25: Auto merge of #104902 - matthiaskrgr:rollup-oo27a4u, r=matthiaskrgr commit[1] 2022-11-25: Auto merge of #99798 - JulianKnodt:ac1, r=BoxyUwU commit[2] 2022-11-26: Auto merge of #104431 - alistair23:alistair/rv64-profiler, r=Mark-Simulacrum commit[3] 2022-11-26: Auto merge of #104730 - petrochenkov:modchild5, r=cjgillot commit[4] 2022-11-26: Auto merge of #103556 - clubby789:specialize-option-partial-eq, r=scottmcm commit[5] 2022-11-26: Auto merge of #104935 - matthiaskrgr:rollup-nuca86l, r=matthiaskrgr commit[6] 2022-11-26: Auto merge of #104731 - compiler-errors:early-binder-iter-size-hint, r=cjgillot commit[7] 2022-11-26: Auto merge of #104945 - GuillaumeGomez:rollup-ygzbpbe, r=GuillaumeGomez ```