rust-lang / rust-lang/rust-analyzer

panic: unreachable: const eval

Open
#22,950 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug I-panic
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

pub mod empty {
    #[derive(Clone, Copy)]
    enum Void {}

    #[derive(Clone, Copy)]
    pub struct Empty(Void);
}

const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];

fn main() {
    BAR;
}

rust-analyzer analysis-stats . --run-all-ide-things

Database loaded:     579.84ms, 229minstr, 48mb (metadata 287.33ms, 1010kinstr, 151kb; build 33.08ms, 180kinstr, 2144b)
  item trees: 1
  dependency lines of code: 1_467_433, item trees: 2_948
  dependency item stats: traits: 848, impl: 9_686, mods: 3_059, macro calls: 5_580, macro rules: 1_054
Item Tree Collection: 4.30s, 23ginstr, 427mb
  Total Statistics:
    crates: 1, mods: 2, decls: 7, bodies: 4, adts: 2, consts: 1, signatures: 10, variants: 1
  Workspace:
    traits: 0, macro_rules macros: 0, proc_macros: 0
    lines of code: 13, item trees: 1
    usages: traits: 0, impl: 0, mods: 1, macro calls: 0, macro rules: 0
  Dependencies:
    lines of code: 1_467_433, item trees: 2_948
    declarations: traits: 848, impl: 9_686, mods: 3_059, macro calls: 5_580, macro rules: 1_054
Item Collection:     2.56s, 11ginstr, 179mb
Crate lang items:    438.20ms, 2474minstr, 31mb
Expression Store Lowering: 263.13µs, 402kinstr, 7kb
  exprs: 8, ??ty: 0 (0%), ?ty: 0 (0%), !ty: 0
  pats: 0, ??ty: 0 (100%), ?ty: 0 (100%), !ty: 0
  panics: 0
Inference:           311.82ms, 1347minstr, 35mb
MIR lowering:        257.28µs, 395kinstr, 34kb
Mir failed bodies: 0 (0%)
Data layouts:        69.03µs, 59kinstr, 177kb
Failed data layouts: 0 (0%)
0/1 0% const eval: ra::BAR
thread 'main' (1775730) panicked at src/tools/rust-analyzer/crates/hir-ty/src/utils.rs:104:45:
internal error: entered unreachable code
stack backtrace:
   0:     0x7fa7d5ca6246 - <<std[74eb2aff46e51e81]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[7aff35c028b048a4]::fmt::Display>::fmt
   1:     0x7fa7d640ad52 - core[7aff35c028b048a4]::fmt::write
   2:     0x7fa7d5cbb38c - <std[74eb2aff46e51e81]::sys::stdio::unix::Stderr as core[7aff35c028b048a4]::io::write::Write>::write_fmt
   3:     0x7fa7d5c77e7a - std[74eb2aff46e51e81]::panicking::default_hook::{closure#0}
   4:     0x7fa7d5c988e3 - std[74eb2aff46e51e81]::panicking::default_hook
   5:     0x7fa7d5c98d4b - std[74eb2aff46e51e81]::panicking::panic_with_hook
   6:     0x7fa7d5c77f64 - std[74eb2aff46e51e81]::panicking::panic_handler::{closure#0}
   7:     0x7fa7d5c6f3e9 - std[74eb2aff46e51e81]::sys::backtrace::__rust_end_short_backtrace::<std[74eb2aff46e51e81]::panicking::panic_handler::{closure#0}, !>
   8:     0x7fa7d5c7988d - __rustc[49844a0cf2bb6b0d]::rust_begin_unwind
   9:     0x7fa7d2a33c7c - core[7aff35c028b048a4]::panicking::panic_fmt
  10:     0x7fa7d2df2952 - core[7aff35c028b048a4]::panicking::panic
  11:     0x562d57cbe765 - hir_ty[f58a0abe133f1c00]::utils::detect_variant_from_bytes
  12:     0x562d57cf05f2 - <hir_ty[f58a0abe133f1c00]::mir::eval::Evaluator>::create_memory_map::rec
  13:     0x562d57cf11e2 - <hir_ty[f58a0abe133f1c00]::mir::eval::Evaluator>::create_memory_map::rec
  14:     0x562d57cf0f1b - <hir_ty[f58a0abe133f1c00]::mir::eval::Evaluator>::create_memory_map::rec
  15:     0x562d57cdc47f - hir_ty[f58a0abe133f1c00]::mir::eval::interpret_mir
  16:     0x562d57d5dab8 - <hir_ty[f58a0abe133f1c00]::consteval::const_eval::_::const_eval_query_Configuration_ as salsa[8774cceebe7971b6]::function::Configuration>::execute
  17:     0x562d57b7d10b - <salsa[8774cceebe7971b6]::function::IngredientImpl<hir_ty[f58a0abe133f1c00]::consteval::const_eval::_::const_eval_query_Configuration_>>::execute
  18:     0x562d57ccd72c - hir_ty[f58a0abe133f1c00]::consteval::const_eval
  19:     0x562d5892bed6 - <rust_analyzer[f1820004a41e425c]::cli::flags::AnalysisStats>::run::{closure#3}
  20:     0x562d58987762 - <rust_analyzer[f1820004a41e425c]::cli::flags::AnalysisStats>::run
  21:     0x562d58bc6fd6 - rust_analyzer[c4fd19d1c3329aa5]::main
  22:     0x562d58bc3373 - std[74eb2aff46e51e81]::sys::backtrace::__rust_begin_short_backtrace::<fn() -> core[7aff35c028b048a4]::result::Result<std[74eb2aff46e51e81]::process::ExitCode, anyhow[f3ff20ce718c24c8]::Error>, core[7aff35c028b048a4]::result::Result<std[74eb2aff46e51e81]::process::ExitCode, anyhow[f3ff20ce718c24c8]::Error>>
  23:     0x562d58bc50d2 - std[74eb2aff46e51e81]::rt::lang_start::<core[7aff35c028b048a4]::result::Result<std[74eb2aff46e51e81]::process::ExitCode, anyhow[f3ff20ce718c24c8]::Error>>::{closure#0}
  24:     0x7fa7d7503553 - std[74eb2aff46e51e81]::rt::lang_start_internal
  25:     0x562d58bddb68 - main
  26:     0x7fa7d0a27741 - <unknown>
  27:     0x7fa7d0a27879 - __libc_start_main
  28:     0x562d574c1ed9 - <unknown>
  29:                0x0 - <unknown>

rust-analyzer 1.99.0-nightly (26ae60a 2026-07-28)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with rust-analyzer analysis-stats . --run-all-ide-things using the provided Rust snippet. Start at crates/hir-ty/src/utils.rs, especially detect_variant_from_bytes, and follow its call from Evaluator::create_memory_map. Done means the input no longer causes an internal panic during const evaluation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.