Closed
Description
Code
(reduced)
fn as_chunks<const N: usize>() -> [u8; N] {
loop {
break;
}
}
fn main() {}
Original Code
//@ check-pass
//
// Instead of checking that an error occurs without the feature gate,
fn as_chunks<const N: usize>() -> [u8; N] {
loop {
let _r = &[D(log, 30),
D(log, 31),
{ D(log, 32); break; },
D(log, 33)][..];
}
}
fn main() {
let [_, _] = as_chunks();
}
- Guess that the original ICE-triggering code is mixture of following test files:
Meta
rustc --version --verbose
:
rustc 1.79.0-nightly (0bf471f33 2024-04-13)
binary: rustc
commit-hash: 0bf471f339837af930ec90ef5e1e9cb232e99f29
commit-date: 2024-04-13
host: aarch64-apple-darwin
release: 1.79.0-nightly
LLVM version: 18.1.3
Command
rustc
Error output
<output>
Backtrace
error: internal compiler error: /rustc/0bf471f339837af930ec90ef5e1e9cb232e99f29/compiler/rustc_middle/src/ty/consts.rs:437:32: expected usize, got N/#0: usize
thread 'rustc' panicked at /rustc/0bf471f339837af930ec90ef5e1e9cb232e99f29/compiler/rustc_middle/src/ty/consts.rs:437:32:
Box<dyn Any>
stack backtrace:
0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
2: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
3: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
4: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
5: rustc_middle::util::bug::bug_fmt
6: rustc_hir_analysis::check::ty_kind_suggestion
7: <rustc_hir_typeck::coercion::CoerceMany<&rustc_hir::hir::Expr>>::coerce_inner::<<rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_break::{closure#2}>
8: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_kind
9: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
10: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_stmt
11: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_block_with_expected
12: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_kind
13: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
14: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_block_with_expected
15: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
16: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_return_expr
17: rustc_hir_typeck::check::check_fn
18: rustc_hir_typeck::typeck
[... omitted 2 frames ...]
19: <rustc_middle::hir::map::Map>::par_body_owners::<rustc_hir_analysis::check_crate::{closure#4}>::{closure#0}
20: <rustc_data_structures::sync::parallel::ParallelGuard>::run::<(), rustc_data_structures::sync::parallel::enabled::par_for_each_in<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], <rustc_middle::hir::map::Map>::par_body_owners<rustc_hir_analysis::check_crate::{closure#4}>::{closure#0}>::{closure#0}::{closure#0}::{closure#0}>
21: rustc_hir_analysis::check_crate
22: rustc_interface::passes::analysis
[... omitted 2 frames ...]
23: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#0}::{closure#1}::{closure#3}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
24: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#0}::{closure#1}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
25: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}::{closure#0}>
26: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
27: rustc_span::create_session_globals_then::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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: please make sure that you have updated to the latest nightly
note: please attach the file at `/Users/jisukbyun/workspace/placeholder/0413_rust/rustc-ice-2024-04-14T03_01_42-57049.txt` to your bug report
query stack during panic:
#0 [typeck] type-checking `as_chunks`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 1 previous error
Note
-
ICE-location:
compiler/rustc_middle/src/ty/consts.rs, Line-437, fn eval_target_usize
rust/compiler/rustc_middle/src/ty/consts.rs
Lines 433 to 438 in 0bf471f
-
Closed Issue ICE:
expected usize, got UnevaluatedConst
#116186 has identical ICE-location,compiler/rustc_middle/src/ty/consts.rs, Line-375, fn eval_target_usize
Metadata
Metadata
Assignees
Labels
Area: const generics (parameters and arguments)Area: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Category: This is a bug.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Status: A Minimal Complete and Verifiable Example has been found for this issueRelevant to the compiler team, which will review and decide on the PR/issue.