Skip to content

ICE: has escaping bound vars, so it cannot be wrapped in a dummy binder. #139538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
matthiaskrgr opened this issue Apr 8, 2025 · 0 comments · Fixed by #139541
Closed

ICE: has escaping bound vars, so it cannot be wrapped in a dummy binder. #139538

matthiaskrgr opened this issue Apr 8, 2025 · 0 comments · Fixed by #139541
Labels
-Zvalidate-mir Unstable option: MIR validation C-bug Category: This is a bug. F-transmutability `#![feature(transmutability)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

mod assert {
    use std::mem::{Assume, TransmuteFrom};

    pub fn Eq<Src, Dst>()
    where
        for<'a> &'a i32: TransmuteFrom<&'a &'a u8>,
    {
    }
}

original:

#![feature(transmutability)]
mod assert {
    use std::mem::{Assume, TransmuteFrom};

    pub fn Eq<Src, Dst>()
    where
        for<'a> &'a i32: TransmuteFrom<&'a &'a u8, { Assume::LIFETIMES }>,
    {}
}

fn main() {
    assert::is_transmutable::<&'static mut bool, &'static mut u8>() // An uninitialized byte is never a valid initialized byte.
}

Version information

rustc 1.88.0-nightly (f820b75fe 2025-04-08)
binary: rustc
commit-hash: f820b75feef00654924c9351a2faca8d34818339
commit-date: 2025-04-08
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2

Possibly related line of code:

tcx.mk_predicate(from.map_bound(|clause| PredicateKind::Clause(clause))).expect_clause()
}
}
impl<'tcx> UpcastFrom<TyCtxt<'tcx>, TraitRef<'tcx>> for Predicate<'tcx> {
fn upcast_from(from: TraitRef<'tcx>, tcx: TyCtxt<'tcx>) -> Self {
ty::Binder::dummy(from).upcast(tcx)
}
}
impl<'tcx> UpcastFrom<TyCtxt<'tcx>, TraitRef<'tcx>> for Clause<'tcx> {
fn upcast_from(from: TraitRef<'tcx>, tcx: TyCtxt<'tcx>) -> Self {
let p: Predicate<'tcx> = from.upcast(tcx);

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

warning: unused import: `Assume`
 --> /tmp/icemaker_global_tempdir.RFrjpFwaQw0Y/rustc_testrunner_tmpdir_reporting.lvU8HTDAX63w/mvce.rs:2:20
  |
2 |     use std::mem::{Assume, TransmuteFrom};
  |                    ^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.RFrjpFwaQw0Y/rustc_testrunner_tmpdir_reporting.lvU8HTDAX63w/mvce.rs:9:2
  |
9 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.RFrjpFwaQw0Y/rustc_testrunner_tmpdir_reporting.lvU8HTDAX63w/mvce.rs`

error[E0658]: use of unstable library feature `transmutability`
 --> /tmp/icemaker_global_tempdir.RFrjpFwaQw0Y/rustc_testrunner_tmpdir_reporting.lvU8HTDAX63w/mvce.rs:2:20
  |
2 |     use std::mem::{Assume, 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 2025-04-08; consider upgrading it if it is out of date

error[E0658]: use of unstable library feature `transmutability`
 --> /tmp/icemaker_global_tempdir.RFrjpFwaQw0Y/rustc_testrunner_tmpdir_reporting.lvU8HTDAX63w/mvce.rs:2:28
  |
2 |     use std::mem::{Assume, 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 2025-04-08; consider upgrading it if it is out of date

error[E0658]: use of unstable library feature `transmutability`
 --> /tmp/icemaker_global_tempdir.RFrjpFwaQw0Y/rustc_testrunner_tmpdir_reporting.lvU8HTDAX63w/mvce.rs:6:26
  |
6 |         for<'a> &'a i32: TransmuteFrom<&'a &'a u8>,
  |                          ^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = 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 2025-04-08; consider upgrading it if it is out of date


thread 'rustc' panicked at compiler/rustc_middle/src/ty/predicate.rs:510:9:
`<&'a u8 as std::marker::Freeze>` has escaping bound vars, so it cannot be wrapped in a dummy binder.
stack backtrace:
   0:     0x79293b0a4dc3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hdbd77ff8b2b4625d
   1:     0x79293b8060d1 - core::fmt::write::h59ddf58c32ba8370
   2:     0x79293c94ccd1 - std::io::Write::write_fmt::hd978f7148dbf4f94
   3:     0x79293b0a4c22 - std::sys::backtrace::BacktraceLock::print::haa162a292a95f004
   4:     0x79293b0a870a - std::panicking::default_hook::{{closure}}::h648e12101ccbca91
   5:     0x79293b0a828f - std::panicking::default_hook::h01d889849cf2590e
   6:     0x79293a0fe953 - std[c70faf4444c356cf]::panicking::update_hook::<alloc[26dac2529edcf36b]::boxed::Box<rustc_driver_impl[31967e99e58374d9]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x79293b0a8f83 - std::panicking::rust_panic_with_hook::h611dda71d5135552
   8:     0x79293b0a8c7a - std::panicking::begin_panic_handler::{{closure}}::h387e63b926b726e3
   9:     0x79293b0a5289 - std::sys::backtrace::__rust_end_short_backtrace::h4b522480d1ebfbf4
  10:     0x79293b0a893d - __rustc[66ac2f581dc52575]::rust_begin_unwind
  11:     0x792937a96af0 - core::panicking::panic_fmt::h346c412299a9954e
  12:     0x79293d63cbef - <rustc_middle[ebbb3d5645075279]::ty::predicate::Predicate as rustc_type_ir[90e471eab3b07150]::upcast::UpcastFrom<rustc_middle[ebbb3d5645075279]::ty::context::TyCtxt, rustc_type_ir[90e471eab3b07150]::predicate::TraitRef<rustc_middle[ebbb3d5645075279]::ty::context::TyCtxt>>>::upcast_from.cold
  13:     0x79293adc3d9c - <rustc_infer[e1534b85a75186ba]::traits::Obligation<rustc_middle[ebbb3d5645075279]::ty::predicate::Predicate>>::with_depth::<rustc_type_ir[90e471eab3b07150]::predicate::TraitRef<rustc_middle[ebbb3d5645075279]::ty::context::TyCtxt>>
  14:     0x79293af738e3 - <rustc_trait_selection[bf33ff605ac02ad3]::traits::select::SelectionContext>::confirm_transmutability_candidate::flatten_answer_tree
  15:     0x79293b93ce3c - <rustc_trait_selection[bf33ff605ac02ad3]::traits::select::SelectionContext>::confirm_candidate
  16:     0x79293b9a0f53 - <rustc_trait_selection[bf33ff605ac02ad3]::traits::select::SelectionContext>::evaluate_candidate::{closure#0}::{closure#0}
  17:     0x79293b9a3d72 - <rustc_trait_selection[bf33ff605ac02ad3]::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
  18:     0x79293b9727c5 - <rustc_trait_selection[bf33ff605ac02ad3]::traits::select::SelectionContext>::evaluate_root_obligation
  19:     0x79293b970f39 - rustc_traits[e4f8648fe5aebaf8]::evaluate_obligation::evaluate_obligation
  20:     0x79293b970a29 - rustc_query_impl[773a75df8eb5b81d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[773a75df8eb5b81d]::query_impl::evaluate_obligation::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ebbb3d5645075279]::query::erase::Erased<[u8; 2usize]>>
  21:     0x79293c056a76 - rustc_query_system[23f296fe80b9d1a]::query::plumbing::try_execute_query::<rustc_query_impl[773a75df8eb5b81d]::DynamicConfig<rustc_query_system[23f296fe80b9d1a]::query::caches::DefaultCache<rustc_type_ir[90e471eab3b07150]::canonical::CanonicalQueryInput<rustc_middle[ebbb3d5645075279]::ty::context::TyCtxt, rustc_middle[ebbb3d5645075279]::ty::ParamEnvAnd<rustc_middle[ebbb3d5645075279]::ty::predicate::Predicate>>, rustc_middle[ebbb3d5645075279]::query::erase::Erased<[u8; 2usize]>>, false, false, false>, rustc_query_impl[773a75df8eb5b81d]::plumbing::QueryCtxt, true>
  22:     0x79293c055726 - rustc_query_impl[773a75df8eb5b81d]::query_impl::evaluate_obligation::get_query_incr::__rust_end_short_backtrace
  23:     0x79293caa6e6c - <rustc_trait_selection[bf33ff605ac02ad3]::traits::fulfill::FulfillProcessor>::process_trait_obligation
  24:     0x79293c1fa242 - <rustc_trait_selection[bf33ff605ac02ad3]::traits::fulfill::FulfillProcessor as rustc_data_structures[371315f59bf8c1a7]::obligation_forest::ObligationProcessor>::process_obligation
  25:     0x79293b807c88 - <rustc_data_structures[371315f59bf8c1a7]::obligation_forest::ObligationForest<rustc_trait_selection[bf33ff605ac02ad3]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[bf33ff605ac02ad3]::traits::fulfill::FulfillProcessor>
  26:     0x79293bf86916 - rustc_trait_selection[bf33ff605ac02ad3]::traits::impossible_predicates
  27:     0x79293bf858ef - <rustc_mir_transform[3ded69e58d16e7b9]::impossible_predicates::ImpossiblePredicates as rustc_mir_transform[3ded69e58d16e7b9]::pass_manager::MirPass>::run_pass
  28:     0x79293b80c0e8 - rustc_mir_transform[3ded69e58d16e7b9]::run_analysis_to_runtime_passes
  29:     0x79293ba1471e - rustc_mir_transform[3ded69e58d16e7b9]::mir_drops_elaborated_and_const_checked
  30:     0x79293ba14119 - rustc_query_impl[773a75df8eb5b81d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[773a75df8eb5b81d]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ebbb3d5645075279]::query::erase::Erased<[u8; 8usize]>>
  31:     0x79293ba0c19b - rustc_query_system[23f296fe80b9d1a]::query::plumbing::try_execute_query::<rustc_query_impl[773a75df8eb5b81d]::DynamicConfig<rustc_data_structures[371315f59bf8c1a7]::vec_cache::VecCache<rustc_span[7e698d9580936219]::def_id::LocalDefId, rustc_middle[ebbb3d5645075279]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[23f296fe80b9d1a]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[773a75df8eb5b81d]::plumbing::QueryCtxt, true>
  32:     0x79293bb37c92 - rustc_query_impl[773a75df8eb5b81d]::query_impl::mir_drops_elaborated_and_const_checked::get_query_incr::__rust_end_short_backtrace
  33:     0x79293c3017ab - rustc_interface[6d50c1beb4a63bd8]::passes::run_required_analyses
  34:     0x79293c83985e - rustc_interface[6d50c1beb4a63bd8]::passes::analysis
  35:     0x79293c839833 - rustc_query_impl[773a75df8eb5b81d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[773a75df8eb5b81d]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ebbb3d5645075279]::query::erase::Erased<[u8; 0usize]>>
  36:     0x79293c8360fd - rustc_query_system[23f296fe80b9d1a]::query::plumbing::try_execute_query::<rustc_query_impl[773a75df8eb5b81d]::DynamicConfig<rustc_query_system[23f296fe80b9d1a]::query::caches::SingleCache<rustc_middle[ebbb3d5645075279]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[773a75df8eb5b81d]::plumbing::QueryCtxt, true>
  37:     0x79293c835a21 - rustc_query_impl[773a75df8eb5b81d]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  38:     0x79293cb2190b - rustc_interface[6d50c1beb4a63bd8]::passes::create_and_enter_global_ctxt::<core[69ddc073adf9e1df]::option::Option<rustc_interface[6d50c1beb4a63bd8]::queries::Linker>, rustc_driver_impl[31967e99e58374d9]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  39:     0x79293c95da39 - rustc_interface[6d50c1beb4a63bd8]::interface::run_compiler::<(), rustc_driver_impl[31967e99e58374d9]::run_compiler::{closure#0}>::{closure#1}
  40:     0x79293c7b5c85 - std[c70faf4444c356cf]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[6d50c1beb4a63bd8]::util::run_in_thread_with_globals<rustc_interface[6d50c1beb4a63bd8]::util::run_in_thread_pool_with_globals<rustc_interface[6d50c1beb4a63bd8]::interface::run_compiler<(), rustc_driver_impl[31967e99e58374d9]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  41:     0x79293c7b656b - <<std[c70faf4444c356cf]::thread::Builder>::spawn_unchecked_<rustc_interface[6d50c1beb4a63bd8]::util::run_in_thread_with_globals<rustc_interface[6d50c1beb4a63bd8]::util::run_in_thread_pool_with_globals<rustc_interface[6d50c1beb4a63bd8]::interface::run_compiler<(), rustc_driver_impl[31967e99e58374d9]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[69ddc073adf9e1df]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  42:     0x79293c7b7977 - std::sys::pal::unix::thread::Thread::new::thread_start::h04ddb6eb66f748e1
  43:     0x79293665d70a - <unknown>
  44:     0x7929366e1aac - <unknown>
  45:                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.88.0-nightly (f820b75fe 2025-04-08) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z incremental-verify-ich=yes -C incremental=[REDACTED] -C debuginfo=2 -C link-dead-code=true -Z validate-mir

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `for<'a> &'a i32: core::mem::transmutability::TransmuteFrom<&'a &'a u8, core::mem::transmutability::Assume { alignment: false, lifetimes: false, safety: false, validity: false }>`
#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `assert::Eq`
#2 [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: E0601, E0658.
For more information about an error, try `rustc --explain E0601`.

@rustbot label +F-transmutability +-Zvalidate-mir

@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 8, 2025
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. -Zvalidate-mir Unstable option: MIR validation F-transmutability `#![feature(transmutability)]` labels Apr 8, 2025
@bors bors closed this as completed in 8a64ba5 Apr 9, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 9, 2025
Rollup merge of rust-lang#139541 - compiler-errors:transmute, r=lcnr

Instantiate higher-ranked transmute goal w/ placeholders before emitting sub-obligations

This avoids an ICE where we weren't keeping track of bound variables correctly in the `Freeze` obligations we emit for transmute goals. We could use `rebind` instead on that goal, but I think it's better just to instantiate the binder.

Fixes rust-lang#139538

r? `@lcnr` or reassign
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Zvalidate-mir Unstable option: MIR validation C-bug Category: This is a bug. F-transmutability `#![feature(transmutability)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
3 participants