Skip to content

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

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

Open
matthiaskrgr opened this issue Apr 21, 2025 · 2 comments
Open
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. 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):

struct QualifiedError<E>(E);

impl<E, T> From<E> for QualifiedError<T>
where
    E:,
    for<'any> &'any mut (): Clone,
{
}

fn infallible() -> Result<(), std::convert::Infallible> {
    Ok(())
}

fn main() {
    let x = || -> Result<_, QualifiedError<_>> {
        infallible()?;
        Ok(())
    };
}

original:

struct QualifiedError<E>(E);

impl<E, T> From<E> for QualifiedError<T>
where
    E: std::error::Error,
    for<'any> &'any mut (): Clone,
{
    fn from(e: E) -> QualifiedError<T> impl TensorOp<Item = ()> + 'a
}

fn infallible() -> Result<(), std::convert::Infallible> {
    Ok(())
}

fn main() {
    let x = || -> Result<_, QualifiedError<_>> {
        infallible()?;
        Ok(())
        //~^ ERROR type annotations needed
    };
}

Version information

rustc 1.88.0-nightly (b8005bff3 2025-04-20)
binary: rustc
commit-hash: b8005bff3248cfc6e327faf4fa631ac49bb49ba9
commit-date: 2025-04-20
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

error[E0119]: conflicting implementations of trait `From<QualifiedError<_>>` for type `QualifiedError<_>`
 --> /tmp/icemaker_global_tempdir.fJzGYJtIgRNC/rustc_testrunner_tmpdir_reporting.kWZMAN4HkmBg/mvce.rs:3:1
  |
3 | / impl<E, T> From<E> for QualifiedError<T>
4 | | where
5 | |     E:,
6 | |     for<'any> &'any mut (): Clone,
  | |__________________________________^
  |
  = note: conflicting implementation in crate `core`:
          - impl<T> From<T> for T;
  = note: upstream crates may add a new impl of trait `std::clone::Clone` for type `&'any mut ()` in future versions


thread 'rustc' panicked at compiler/rustc_middle/src/ty/predicate.rs:510:9:
`<&'any mut () as std::convert::From<std::convert::Infallible>>` has escaping bound vars, so it cannot be wrapped in a dummy binder.
stack backtrace:
   0:     0x7b8c086bfa13 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hd3d6a01c34b68e33
   1:     0x7b8c08e05b07 - core::fmt::write::hc8609d2830ea7209
   2:     0x7b8c0a2a2b11 - std::io::Write::write_fmt::h5803b161d154e6bb
   3:     0x7b8c086bf872 - std::sys::backtrace::BacktraceLock::print::h7d1ba71c4ac8a197
   4:     0x7b8c086c31ea - std::panicking::default_hook::{{closure}}::h81636b35691bb80d
   5:     0x7b8c086c2d6f - std::panicking::default_hook::h3d6df3ec9a366961
   6:     0x7b8c077439a3 - std[a4b1c5db45b5369]::panicking::update_hook::<alloc[a753183b20116edd]::boxed::Box<rustc_driver_impl[64822a3bbb8e5a99]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7b8c086c3a63 - std::panicking::rust_panic_with_hook::hc0072f606cfb3c45
   8:     0x7b8c086c375a - std::panicking::begin_panic_handler::{{closure}}::h9dfbf037bfb6d7d4
   9:     0x7b8c086bfee9 - std::sys::backtrace::__rust_end_short_backtrace::hdeb7489c831217fd
  10:     0x7b8c086c341d - __rustc[d3657d69ef8eb27f]::rust_begin_unwind
  11:     0x7b8c05086440 - core::panicking::panic_fmt::h3cd888558dd93878
  12:     0x7b8c0abff2ef - <rustc_middle[105e55ff3e6629a7]::ty::predicate::Predicate as rustc_type_ir[4f792327c2094bfd]::upcast::UpcastFrom<rustc_middle[105e55ff3e6629a7]::ty::context::TyCtxt, rustc_type_ir[4f792327c2094bfd]::predicate::TraitRef<rustc_middle[105e55ff3e6629a7]::ty::context::TyCtxt>>>::upcast_from.cold
  13:     0x7b8c0858bd4b - <rustc_infer[bae4521fee5667b7]::infer::InferCtxt as rustc_trait_selection[b7ee8536d1549794]::infer::InferCtxtExt>::type_implements_trait::<[rustc_middle[105e55ff3e6629a7]::ty::Ty; 2usize]>
  14:     0x7b8c084ed23c - <rustc_trait_selection[b7ee8536d1549794]::error_reporting::TypeErrCtxt>::try_conversion_context
  15:     0x7b8c084e7670 - <rustc_trait_selection[b7ee8536d1549794]::error_reporting::TypeErrCtxt>::report_selection_error
  16:     0x7b8c085484fe - <rustc_trait_selection[b7ee8536d1549794]::error_reporting::TypeErrCtxt>::report_fulfillment_errors
  17:     0x7b8c08f26b48 - <rustc_hir_typeck[d228e38d1a961d74]::fn_ctxt::FnCtxt>::try_structurally_resolve_type
  18:     0x7b8c08f3bbf8 - <rustc_hir_typeck[d228e38d1a961d74]::coercion::CoerceMany<rustc_hir[409be6f9bedee7de]::hir::Arm>>::coerce_inner::<<rustc_hir_typeck[d228e38d1a961d74]::fn_ctxt::FnCtxt>::check_expr_match::{closure#0}::{closure#1}>
  19:     0x7b8c09ba9934 - <rustc_hir_typeck[d228e38d1a961d74]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  20:     0x7b8c09b9b17c - <rustc_hir_typeck[d228e38d1a961d74]::fn_ctxt::FnCtxt>::check_expr_block
  21:     0x7b8c09ba5f7f - <rustc_hir_typeck[d228e38d1a961d74]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  22:     0x7b8c09401f84 - rustc_hir_typeck[d228e38d1a961d74]::check::check_fn
  23:     0x7b8c09a9b0c3 - <rustc_hir_typeck[d228e38d1a961d74]::fn_ctxt::FnCtxt>::check_expr_closure
  24:     0x7b8c09baad0e - <rustc_hir_typeck[d228e38d1a961d74]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  25:     0x7b8c08efbbc9 - <rustc_hir_typeck[d228e38d1a961d74]::fn_ctxt::FnCtxt>::check_decl
  26:     0x7b8c09b9c255 - <rustc_hir_typeck[d228e38d1a961d74]::fn_ctxt::FnCtxt>::check_expr_block
  27:     0x7b8c09ba5f7f - <rustc_hir_typeck[d228e38d1a961d74]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  28:     0x7b8c09401f84 - rustc_hir_typeck[d228e38d1a961d74]::check::check_fn
  29:     0x7b8c093ef49a - rustc_hir_typeck[d228e38d1a961d74]::typeck_with_inspect::{closure#0}
  30:     0x7b8c093ee1b6 - rustc_query_impl[f9677782d554bbe0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f9677782d554bbe0]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[105e55ff3e6629a7]::query::erase::Erased<[u8; 8usize]>>
  31:     0x7b8c09085e2c - rustc_query_system[6c94265d9bb07c02]::query::plumbing::try_execute_query::<rustc_query_impl[f9677782d554bbe0]::DynamicConfig<rustc_data_structures[d346d185fbcc034d]::vec_cache::VecCache<rustc_span[f33b24d4c40821a8]::def_id::LocalDefId, rustc_middle[105e55ff3e6629a7]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[6c94265d9bb07c02]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[f9677782d554bbe0]::plumbing::QueryCtxt, false>
  32:     0x7b8c0908588b - rustc_query_impl[f9677782d554bbe0]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  33:     0x7b8c09084308 - rustc_hir_analysis[c91f60f1cedeb164]::check_crate
  34:     0x7b8c097ba674 - rustc_interface[87387720858aeda]::passes::run_required_analyses
  35:     0x7b8c09a1e41e - rustc_interface[87387720858aeda]::passes::analysis
  36:     0x7b8c09a1e3ed - rustc_query_impl[f9677782d554bbe0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f9677782d554bbe0]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[105e55ff3e6629a7]::query::erase::Erased<[u8; 0usize]>>
  37:     0x7b8c09e0db3d - rustc_query_system[6c94265d9bb07c02]::query::plumbing::try_execute_query::<rustc_query_impl[f9677782d554bbe0]::DynamicConfig<rustc_query_system[6c94265d9bb07c02]::query::caches::SingleCache<rustc_middle[105e55ff3e6629a7]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[f9677782d554bbe0]::plumbing::QueryCtxt, false>
  38:     0x7b8c09e0d838 - rustc_query_impl[f9677782d554bbe0]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  39:     0x7b8c0a11ee3e - rustc_interface[87387720858aeda]::passes::create_and_enter_global_ctxt::<core[89ea4ceba863dd14]::option::Option<rustc_interface[87387720858aeda]::queries::Linker>, rustc_driver_impl[64822a3bbb8e5a99]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  40:     0x7b8c09f55404 - rustc_interface[87387720858aeda]::interface::run_compiler::<(), rustc_driver_impl[64822a3bbb8e5a99]::run_compiler::{closure#0}>::{closure#1}
  41:     0x7b8c09cecd68 - std[a4b1c5db45b5369]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[87387720858aeda]::util::run_in_thread_with_globals<rustc_interface[87387720858aeda]::util::run_in_thread_pool_with_globals<rustc_interface[87387720858aeda]::interface::run_compiler<(), rustc_driver_impl[64822a3bbb8e5a99]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  42:     0x7b8c09ced1b4 - <<std[a4b1c5db45b5369]::thread::Builder>::spawn_unchecked_<rustc_interface[87387720858aeda]::util::run_in_thread_with_globals<rustc_interface[87387720858aeda]::util::run_in_thread_pool_with_globals<rustc_interface[87387720858aeda]::interface::run_compiler<(), rustc_driver_impl[64822a3bbb8e5a99]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[89ea4ceba863dd14]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x7b8c09cee5b7 - std::sys::pal::unix::thread::Thread::new::thread_start::h763527da6478f178
  44:     0x7b8c03ca370a - <unknown>
  45:     0x7b8c03d27aac - <unknown>
  46:                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 (b8005bff3 2025-04-20) running on x86_64-unknown-linux-gnu

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

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

@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 21, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 21, 2025
@matthiaskrgr
Copy link
Member Author

struct a;
impl From for a where for<'any> &'any mut (): Clone {}
fn b() -> Result<(), std::convert::Infallible> {
    || -> Result<_, a> { b()? }
}

@matthiaskrgr
Copy link
Member Author

bisects to #137245

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants