rust-lang / rust-lang/rust

[ICE]: `should have resolved vars before calling`

Open
#153,006 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-transmutability I-ICE needs-triage T-compiler WG-trait-system-refactor
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

auto-reduced (treereduce-rust):

//@compile-flags: -Znext-solver=globally
use std::mem::TransmuteFrom;
fn foo<const ASSUME: u8>()
where
    u8: TransmuteFrom<u8, ASSUME>,
{
}
fn main() {
    foo()
}

original:

#![feature(transmutability)]
use std::mem::TransmuteFrom;
fn foo<const ASSUME: u8>()
where
    u8: TransmuteFrom<u8, ASSUME>,
{
}
fn main() {
    foo()
}

Version information

rustc 1.95.0-nightly (1500f0f47 2026-02-22)
binary: rustc
commit-hash: 1500f0f47f5fe8ddcd6528f6c6c031b210b4eac5
commit-date: 2026-02-22
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 22.1.0

Possibly related line of code:
https://github.com/rust-lang/rust/blob/1500f0f47f5fe8ddcd6528f6c6c031b210b4eac5/compiler/rustc_trait_selection/src/traits/structural_normalize.rs#L29-L41

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Znext-solver=globally

Program output

error[E0658]: use of unstable library feature `transmutability`
 --> /tmp/icemaker_global_tempdir.bEz3nnIpkwl3/rustc_testrunner_tmpdir_reporting.MKlGUYiYI9Yj/mvce.rs:1:5
  |
1 | use std::mem::TransmuteFrom;
  |     ^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #99571 <https://github.com/rust-lang/rust/issues/99571> for more information
  = help: add `#![feature(transmutability)]` to the crate attributes to enable
  = note: this compiler was built on 2026-02-22; consider upgrading it if it is out of date

error[E0658]: use of unstable library feature `transmutability`
 --> /tmp/icemaker_global_tempdir.bEz3nnIpkwl3/rustc_testrunner_tmpdir_reporting.MKlGUYiYI9Yj/mvce.rs:4:9
  |
4 |     u8: TransmuteFrom<u8, ASSUME>,
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #99571 <https://github.com/rust-lang/rust/issues/99571> for more information
  = help: add `#![feature(transmutability)]` to the crate attributes to enable
  = note: this compiler was built on 2026-02-22; consider upgrading it if it is out of date

error: the constant `ASSUME` is not of type `Assume`
  --> /tmp/icemaker_global_tempdir.bEz3nnIpkwl3/rustc_testrunner_tmpdir_reporting.MKlGUYiYI9Yj/mvce.rs:4:9
   |
 4 |     u8: TransmuteFrom<u8, ASSUME>,
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Assume`, found `u8`
   |
note: required by a const generic parameter in `TransmuteFrom`
  --> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/mem/transmutability.rs:91:37
   |
91 | pub unsafe trait TransmuteFrom<Src, const ASSUME: Assume = { Assume::NOTHING }>
   |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this const generic parameter in `TransmuteFrom`


thread 'rustc' (483470) panicked at /rustc-dev/1500f0f47f5fe8ddcd6528f6c6c031b210b4eac5/compiler/rustc_trait_selection/src/traits/structural_normalize.rs:35:9:
should have resolved vars before calling
stack backtrace:
   0:     0x7f051c1b80eb - <<std[8fa6c4d7877d9fa6]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[8d2c922a005dfed9]::fmt::Display>::fmt
   1:     0x7f051c821648 - core[8d2c922a005dfed9]::fmt::write
   2:     0x7f051c1cf0f6 - <std[8fa6c4d7877d9fa6]::sys::stdio::unix::Stderr as std[8fa6c4d7877d9fa6]::io::Write>::write_fmt
   3:     0x7f051c18e1d8 - std[8fa6c4d7877d9fa6]::panicking::default_hook::{closure#0}
   4:     0x7f051c1ab553 - std[8fa6c4d7877d9fa6]::panicking::default_hook
   5:     0x7f051b184080 - std[8fa6c4d7877d9fa6]::panicking::update_hook::<alloc[e536beed0316d181]::boxed::Box<rustc_driver_impl[f1389595c05d78d8]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f051c1ab832 - std[8fa6c4d7877d9fa6]::panicking::panic_with_hook
   7:     0x7f051c18e2ca - std[8fa6c4d7877d9fa6]::panicking::panic_handler::{closure#0}
   8:     0x7f051c184fe9 - std[8fa6c4d7877d9fa6]::sys::backtrace::__rust_end_short_backtrace::<std[8fa6c4d7877d9fa6]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f051c18fcfd - __rustc[d7af78fd024a5d6e]::rust_begin_unwind
  10:     0x7f05195ed78c - core[8d2c922a005dfed9]::panicking::panic_fmt
  11:     0x7f051bf19e86 - <rustc_infer[48338ecaa753e2f9]::infer::at::At as rustc_trait_selection[ffc7478ef7c84f11]::traits::structural_normalize::StructurallyNormalizeExt>::structurally_normalize_term::<rustc_infer[48338ecaa753e2f9]::traits::engine::ScrubbedTraitError>
  12:     0x7f051bfb67d0 - <rustc_trait_selection[ffc7478ef7c84f11]::traits::engine::ObligationCtxt>::structurally_normalize_const
  13:     0x7f051bfac868 - <rustc_trait_selection[ffc7478ef7c84f11]::error_reporting::TypeErrCtxt>::select_transmute_obligation_for_reporting
  14:     0x7f051bf89cd9 - <rustc_trait_selection[ffc7478ef7c84f11]::error_reporting::TypeErrCtxt>::report_selection_error
  15:     0x7f051aa6d7d6 - <rustc_trait_selection[ffc7478ef7c84f11]::error_reporting::TypeErrCtxt>::report_fulfillment_errors
  16:     0x7f051cc5c6f3 - <rustc_hir_typeck[aadce8c622caaa3b]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  17:     0x7f051cc6e431 - <rustc_hir_typeck[aadce8c622caaa3b]::fn_ctxt::FnCtxt>::check_expr_call
  18:     0x7f051cc59890 - <rustc_hir_typeck[aadce8c622caaa3b]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  19:     0x7f051cc53a70 - <rustc_hir_typeck[aadce8c622caaa3b]::fn_ctxt::FnCtxt>::check_expr_block
  20:     0x7f051cc59817 - <rustc_hir_typeck[aadce8c622caaa3b]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  21:     0x7f051cc28610 - rustc_hir_typeck[aadce8c622caaa3b]::check::check_fn
  22:     0x7f051d5f1332 - rustc_hir_typeck[aadce8c622caaa3b]::typeck_with_inspect::{closure#0}
  23:     0x7f051d5efd72 - rustc_query_impl[cec139e1f3385ac4]::query_impl::typeck::invoke_provider_fn::__rust_begin_short_backtrace
  24:     0x7f051cfb853e - rustc_query_impl[cec139e1f3385ac4]::execution::try_execute_query::<rustc_data_structures[1a0237db0a3cda6a]::vec_cache::VecCache<rustc_span[8a11d63785993c5a]::def_id::LocalDefId, rustc_middle[60c2cf3af82b0a08]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[60c2cf3af82b0a08]::dep_graph::graph::DepNodeIndex>, {rustc_query_impl[cec139e1f3385ac4]::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: false }}, false>
  25:     0x7f051cfb8109 - rustc_query_impl[cec139e1f3385ac4]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  26:     0x7f051cfb1b4e - <rustc_middle[60c2cf3af82b0a08]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[a8016fad3afadedb]::check_crate::{closure#2}>::{closure#0}
  27:     0x7f051cfb156e - rustc_hir_analysis[a8016fad3afadedb]::check_crate
  28:     0x7f051cfb50ac - rustc_interface[b6ce98af9df5606d]::passes::analysis
  29:     0x7f051d9e1499 - rustc_query_impl[cec139e1f3385ac4]::execution::try_execute_query::<rustc_middle[60c2cf3af82b0a08]::query::caches::SingleCache<rustc_middle[60c2cf3af82b0a08]::query::erase::ErasedData<[u8; 0usize]>>, {rustc_query_impl[cec139e1f3385ac4]::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: false }}, false>
  30:     0x7f051d9e10c8 - rustc_query_impl[cec139e1f3385ac4]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  31:     0x7f051da2088b - rustc_interface[b6ce98af9df5606d]::interface::run_compiler::<(), rustc_driver_impl[f1389595c05d78d8]::run_compiler::{closure#0}>::{closure#1}
  32:     0x7f051d9d09fe - std[8fa6c4d7877d9fa6]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[b6ce98af9df5606d]::util::run_in_thread_with_globals<rustc_interface[b6ce98af9df5606d]::util::run_in_thread_pool_with_globals<rustc_interface[b6ce98af9df5606d]::interface::run_compiler<(), rustc_driver_impl[f1389595c05d78d8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  33:     0x7f051d9d10e0 - <std[8fa6c4d7877d9fa6]::thread::lifecycle::spawn_unchecked<rustc_interface[b6ce98af9df5606d]::util::run_in_thread_with_globals<rustc_interface[b6ce98af9df5606d]::util::run_in_thread_pool_with_globals<rustc_interface[b6ce98af9df5606d]::interface::run_compiler<(), rustc_driver_impl[f1389595c05d78d8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[8d2c922a005dfed9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  34:     0x7f051d9d1f6c - <std[8fa6c4d7877d9fa6]::sys::thread::unix::Thread>::new::thread_start
  35:     0x7f05174a598b - <unknown>
  36:     0x7f0517529a0c - <unknown>
  37:                0x0 - <unknown>

error: the compiler unexpectedly panicked. This is a bug

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: rustc 1.95.0-nightly (1500f0f47 2026-02-22) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z next-solver=globally -Z dump-mir-dir=dir

query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0658`.

@rustbot label +F-transmutability +WG-trait-system-refactor

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

Start with compiler/rustc_trait_selection/src/traits/structural_normalize.rs around the referenced line, then reproduce the ICE with the reduced code and -Znext-solver=globally. Trace the structural normalization and transmute-obligation reporting paths shown in the backtrace; done means this input reports diagnostics without panicking.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.