Skip to content

ICE: cannot have escaping bound var in self type of Obligation( #112735

Closed
@matthiaskrgr

Description

Code

rustc file.rs --crate-type lib

#![feature(non_lifetime_binders)]

fn auto_trait()
where
    for<T> T:PartialEq + PartialOrd,
{}

Meta

rustc --version --verbose:

rustc 1.72.0-nightly (1d7d82472 2023-06-17)
binary: rustc
commit-hash: 1d7d82472617a4a0fea59c7e239c8a48c8ac5c34
commit-date: 2023-06-17
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.5

Error output

<output>
Backtrace

error: internal compiler error: compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs:427:36: cannot have escaping bound var in self type of Obligation(predicate=Binder(TraitPredicate(<T as std::cmp::PartialOrd>, polarity:Positive), [Ty(Param(DefId(0:4 ~ treereduce[ce19]::auto_trait::T), "T"))]), depth=0)

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/1d7d82472617a4a0fea59c7e239c8a48c8ac5c34/compiler/rustc_errors/src/lib.rs:994:33
stack backtrace:
   0:     0x7ff9cc768821 - std::backtrace_rs::backtrace::libunwind::trace::h6e3584f9aa263648
                               at /rustc/1d7d82472617a4a0fea59c7e239c8a48c8ac5c34/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7ff9cc768821 - std::backtrace_rs::backtrace::trace_unsynchronized::h7cba45a2d56b3723
                               at /rustc/1d7d82472617a4a0fea59c7e239c8a48c8ac5c34/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7ff9cc768821 - std::sys_common::backtrace::_print_fmt::hb3e5f2b800058c47
                               at /rustc/1d7d82472617a4a0fea59c7e239c8a48c8ac5c34/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7ff9cc768821 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc6fcd56f05592786
                               at /rustc/1d7d82472617a4a0fea59c7e239c8a48c8ac5c34/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7ff9cc7c9b2f - core::fmt::rt::Argument::fmt::hb8b6762d96a2930c
                               at /rustc/1d7d82472617a4a0fea59c7e239c8a48c8ac5c34/library/core/src/fmt/rt.rs:138:9
   5:     0x7ff9cc7c9b2f - core::fmt::write::ha824b1be2c398991
                               at /rustc/1d7d82472617a4a0fea59c7e239c8a48c8ac5c34/library/core/src/fmt/mod.rs:1094:21
   6:     0x7ff9cc75ba31 - std::io::Write::write_fmt::h4bbc557c498e18be
                               at /rustc/1d7d82472617a4a0fea59c7e239c8a48c8ac5c34/library/std/src/io/mod.rs:1713:15
   7:     0x7ff9cc768635 - std::sys_common::backtrace::_print::hb6a2afc924d1ac9a
                               at /rustc/1d7d82472617a4a0fea59c7e239c8a48c8ac5c34/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7ff9cc768635 - std::sys_common::backtrace::print::h39a60e9b1dd2b988
                               at /rustc/1d7d82472617a4a0fea59c7e239c8a48c8ac5c34/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7ff9cc76b317 - std::panicking::default_hook::{{closure}}::hf1636ea70b88baf6
  10:     0x7ff9cc76b104 - std::panicking::default_hook::h25db0e741a15cb6c
                               at /rustc/1d7d82472617a4a0fea59c7e239c8a48c8ac5c34/library/std/src/panicking.rs:288:9
  11:     0x7ff9cf9c105b - <rustc_driver_impl[9fb98086b5dc1b8]::install_ice_hook::{closure#0} as core[5a025f5ac19a3684]::ops::function::FnOnce<(&core[5a025f5ac19a3684]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  12:     0x7ff9cc76ba5d - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hb67fc0de76dc4685
                               at /rustc/1d7d82472617a4a0fea59c7e239c8a48c8ac5c34/library/alloc/src/boxed.rs:1999:9
  13:     0x7ff9cc76ba5d - std::panicking::rust_panic_with_hook::h6c10fd1f40066f99
                               at /rustc/1d7d82472617a4a0fea59c7e239c8a48c8ac5c34/library/std/src/panicking.rs:709:13
  14:     0x7ff9d0528f71 - std[5e6a7ab4ec51e2fa]::panicking::begin_panic::<rustc_errors[db6e693a4d78f721]::ExplicitBug>::{closure#0}
  15:     0x7ff9d05225e6 - std[5e6a7ab4ec51e2fa]::sys_common::backtrace::__rust_end_short_backtrace::<std[5e6a7ab4ec51e2fa]::panicking::begin_panic<rustc_errors[db6e693a4d78f721]::ExplicitBug>::{closure#0}, !>
  16:     0x7ff9d0546236 - std[5e6a7ab4ec51e2fa]::panicking::begin_panic::<rustc_errors[db6e693a4d78f721]::ExplicitBug>
  17:     0x7ff9d050837e - <rustc_errors[db6e693a4d78f721]::HandlerInner>::span_bug::<rustc_span[7bbc48c8a570ee79]::span_encoding::Span, alloc[31842ca5441cdb56]::string::String>
  18:     0x7ff9d050820d - <rustc_errors[db6e693a4d78f721]::Handler>::span_bug::<rustc_span[7bbc48c8a570ee79]::span_encoding::Span, alloc[31842ca5441cdb56]::string::String>
  19:     0x7ff9d05290dd - rustc_middle[c2d4873b804b2cf0]::util::bug::opt_span_bug_fmt::<rustc_span[7bbc48c8a570ee79]::span_encoding::Span>::{closure#0}
  20:     0x7ff9d052910a - rustc_middle[c2d4873b804b2cf0]::ty::context::tls::with_opt::<rustc_middle[c2d4873b804b2cf0]::util::bug::opt_span_bug_fmt<rustc_span[7bbc48c8a570ee79]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7ff9d05228da - rustc_middle[c2d4873b804b2cf0]::ty::context::tls::with_context_opt::<rustc_middle[c2d4873b804b2cf0]::ty::context::tls::with_opt<rustc_middle[c2d4873b804b2cf0]::util::bug::opt_span_bug_fmt<rustc_span[7bbc48c8a570ee79]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7ff9d0522644 - rustc_middle[c2d4873b804b2cf0]::util::bug::span_bug_fmt::<rustc_span[7bbc48c8a570ee79]::span_encoding::Span>
  23:     0x7ff9ce349c0f - <rustc_trait_selection[4e524418529800ad]::traits::select::SelectionContext>::reject_fn_ptr_impls
  24:     0x7ff9ce33d6c7 - <rustc_middle[c2d4873b804b2cf0]::ty::context::TyCtxt>::for_each_relevant_impl_treating_projections::<<rustc_trait_selection[4e524418529800ad]::traits::select::SelectionContext>::assemble_candidates_from_impls::{closure#0}>
  25:     0x7ff9ce323dba - <rustc_trait_selection[4e524418529800ad]::traits::select::SelectionContext>::candidate_from_obligation_no_cache
  26:     0x7ff9ce321ebe - <rustc_query_system[fd595a8868fcd518]::dep_graph::graph::DepGraph<rustc_middle[c2d4873b804b2cf0]::dep_graph::dep_node::DepKind>>::with_anon_task::<rustc_middle[c2d4873b804b2cf0]::ty::context::TyCtxt, <rustc_trait_selection[4e524418529800ad]::traits::select::SelectionContext>::in_task<<rustc_trait_selection[4e524418529800ad]::traits::select::SelectionContext>::candidate_from_obligation::{closure#0}::{closure#0}, core[5a025f5ac19a3684]::result::Result<core[5a025f5ac19a3684]::option::Option<rustc_middle[c2d4873b804b2cf0]::traits::select::SelectionCandidate>, rustc_middle[c2d4873b804b2cf0]::traits::SelectionError>>::{closure#0}, core[5a025f5ac19a3684]::result::Result<core[5a025f5ac19a3684]::option::Option<rustc_middle[c2d4873b804b2cf0]::traits::select::SelectionCandidate>, rustc_middle[c2d4873b804b2cf0]::traits::SelectionError>>
  27:     0x7ff9ce31ced4 - <rustc_trait_selection[4e524418529800ad]::traits::select::SelectionContext>::evaluate_stack
  28:     0x7ff9ce7eed22 - <rustc_trait_selection[4e524418529800ad]::traits::select::SelectionContext>::evaluate_predicate_recursively
  29:     0x7ff9ce4c63a4 - rustc_traits[dc642ba4683ad1c5]::evaluate_obligation::evaluate_obligation
  30:     0x7ff9cd9d8ce2 - rustc_query_impl[7260f550d3fae5ad]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7260f550d3fae5ad]::query_impl::evaluate_obligation::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c2d4873b804b2cf0]::query::erase::Erased<[u8; 2usize]>>
  31:     0x7ff9cde88879 - rustc_query_system[fd595a8868fcd518]::query::plumbing::try_execute_query::<rustc_query_impl[7260f550d3fae5ad]::DynamicConfig<rustc_query_system[fd595a8868fcd518]::query::caches::DefaultCache<rustc_middle[c2d4873b804b2cf0]::infer::canonical::Canonical<rustc_middle[c2d4873b804b2cf0]::ty::ParamEnvAnd<rustc_middle[c2d4873b804b2cf0]::ty::Predicate>>, rustc_middle[c2d4873b804b2cf0]::query::erase::Erased<[u8; 2usize]>>, false, false, false>, rustc_query_impl[7260f550d3fae5ad]::plumbing::QueryCtxt, false>
  32:     0x7ff9cde8850c - rustc_query_impl[7260f550d3fae5ad]::query_impl::evaluate_obligation::get_query_non_incr::__rust_end_short_backtrace
  33:     0x7ff9cdc73594 - <rustc_infer[ff7eecd220d88775]::infer::InferCtxt as rustc_trait_selection[4e524418529800ad]::traits::query::evaluate_obligation::InferCtxtExt>::predicate_must_hold_considering_regions
  34:     0x7ff9cdc20469 - <rustc_trait_selection[4e524418529800ad]::traits::fulfill::FulfillProcessor as rustc_data_structures[e37b372447d28214]::obligation_forest::ObligationProcessor>::process_obligation
  35:     0x7ff9cdc16124 - <rustc_data_structures[e37b372447d28214]::obligation_forest::ObligationForest<rustc_trait_selection[4e524418529800ad]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[4e524418529800ad]::traits::fulfill::FulfillProcessor>
  36:     0x7ff9ce008a43 - rustc_trait_selection[4e524418529800ad]::traits::impossible_predicates
  37:     0x7ff9ce00716d - rustc_mir_transform[b7e5622fbd6928b5]::mir_drops_elaborated_and_const_checked
  38:     0x7ff9cda2fa3e - rustc_query_impl[7260f550d3fae5ad]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7260f550d3fae5ad]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c2d4873b804b2cf0]::query::erase::Erased<[u8; 8usize]>>
  39:     0x7ff9cda2fa0e - <rustc_query_impl[7260f550d3fae5ad]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2} as core[5a025f5ac19a3684]::ops::function::FnOnce<(rustc_middle[c2d4873b804b2cf0]::ty::context::TyCtxt, rustc_span[7bbc48c8a570ee79]::def_id::LocalDefId)>>::call_once
  40:     0x7ff9cdad2d4d - rustc_query_system[fd595a8868fcd518]::query::plumbing::try_execute_query::<rustc_query_impl[7260f550d3fae5ad]::DynamicConfig<rustc_query_system[fd595a8868fcd518]::query::caches::VecCache<rustc_span[7bbc48c8a570ee79]::def_id::LocalDefId, rustc_middle[c2d4873b804b2cf0]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[7260f550d3fae5ad]::plumbing::QueryCtxt, false>
  41:     0x7ff9cf32ed3f - rustc_query_impl[7260f550d3fae5ad]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
  42:     0x7ff9cedd9fe9 - <rustc_session[5d8f1134011332b9]::session::Session>::time::<(), rustc_interface[75da62af7afad68]::passes::analysis::{closure#2}>
  43:     0x7ff9cedd5845 - rustc_interface[75da62af7afad68]::passes::analysis
  44:     0x7ff9cee3d1aa - rustc_query_impl[7260f550d3fae5ad]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7260f550d3fae5ad]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c2d4873b804b2cf0]::query::erase::Erased<[u8; 1usize]>>
  45:     0x7ff9cee3d199 - <rustc_query_impl[7260f550d3fae5ad]::query_impl::analysis::dynamic_query::{closure#2} as core[5a025f5ac19a3684]::ops::function::FnOnce<(rustc_middle[c2d4873b804b2cf0]::ty::context::TyCtxt, ())>>::call_once
  46:     0x7ff9cf057ae8 - rustc_query_system[fd595a8868fcd518]::query::plumbing::try_execute_query::<rustc_query_impl[7260f550d3fae5ad]::DynamicConfig<rustc_query_system[fd595a8868fcd518]::query::caches::SingleCache<rustc_middle[c2d4873b804b2cf0]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[7260f550d3fae5ad]::plumbing::QueryCtxt, false>
  47:     0x7ff9cf0578c7 - rustc_query_impl[7260f550d3fae5ad]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  48:     0x7ff9ceef4ca5 - <rustc_middle[c2d4873b804b2cf0]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[9fb98086b5dc1b8]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[5a025f5ac19a3684]::result::Result<(), rustc_span[7bbc48c8a570ee79]::ErrorGuaranteed>>
  49:     0x7ff9ceef3c06 - rustc_span[7bbc48c8a570ee79]::set_source_map::<core[5a025f5ac19a3684]::result::Result<(), rustc_span[7bbc48c8a570ee79]::ErrorGuaranteed>, rustc_interface[75da62af7afad68]::interface::run_compiler<core[5a025f5ac19a3684]::result::Result<(), rustc_span[7bbc48c8a570ee79]::ErrorGuaranteed>, rustc_driver_impl[9fb98086b5dc1b8]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  50:     0x7ff9ceeec3f9 - <scoped_tls[5be461245172b0fd]::ScopedKey<rustc_span[7bbc48c8a570ee79]::SessionGlobals>>::set::<rustc_interface[75da62af7afad68]::interface::run_compiler<core[5a025f5ac19a3684]::result::Result<(), rustc_span[7bbc48c8a570ee79]::ErrorGuaranteed>, rustc_driver_impl[9fb98086b5dc1b8]::run_compiler::{closure#1}>::{closure#0}, core[5a025f5ac19a3684]::result::Result<(), rustc_span[7bbc48c8a570ee79]::ErrorGuaranteed>>
  51:     0x7ff9ceeeb9f6 - std[5e6a7ab4ec51e2fa]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[75da62af7afad68]::util::run_in_thread_pool_with_globals<rustc_interface[75da62af7afad68]::interface::run_compiler<core[5a025f5ac19a3684]::result::Result<(), rustc_span[7bbc48c8a570ee79]::ErrorGuaranteed>, rustc_driver_impl[9fb98086b5dc1b8]::run_compiler::{closure#1}>::{closure#0}, core[5a025f5ac19a3684]::result::Result<(), rustc_span[7bbc48c8a570ee79]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5a025f5ac19a3684]::result::Result<(), rustc_span[7bbc48c8a570ee79]::ErrorGuaranteed>>
  52:     0x7ff9ceeeb7a5 - <<std[5e6a7ab4ec51e2fa]::thread::Builder>::spawn_unchecked_<rustc_interface[75da62af7afad68]::util::run_in_thread_pool_with_globals<rustc_interface[75da62af7afad68]::interface::run_compiler<core[5a025f5ac19a3684]::result::Result<(), rustc_span[7bbc48c8a570ee79]::ErrorGuaranteed>, rustc_driver_impl[9fb98086b5dc1b8]::run_compiler::{closure#1}>::{closure#0}, core[5a025f5ac19a3684]::result::Result<(), rustc_span[7bbc48c8a570ee79]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5a025f5ac19a3684]::result::Result<(), rustc_span[7bbc48c8a570ee79]::ErrorGuaranteed>>::{closure#1} as core[5a025f5ac19a3684]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  53:     0x7ff9cc775f55 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3b57fe0fe8253eda
                               at /rustc/1d7d82472617a4a0fea59c7e239c8a48c8ac5c34/library/alloc/src/boxed.rs:1985:9
  54:     0x7ff9cc775f55 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6eac2c7c988070fa
                               at /rustc/1d7d82472617a4a0fea59c7e239c8a48c8ac5c34/library/alloc/src/boxed.rs:1985:9
  55:     0x7ff9cc775f55 - std::sys::unix::thread::Thread::new::thread_start::h8d73f1104f34aa7b
                               at /rustc/1d7d82472617a4a0fea59c7e239c8a48c8ac5c34/library/std/src/sys/unix/thread.rs:108:17
  56:     0x7ff9cc4d644b - <unknown>
  57:     0x7ff9cc559e40 - <unknown>
  58:                0x0 - <unknown>

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: rustc 1.72.0-nightly (1d7d82472 2023-06-17) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `T: core::cmp::PartialOrd`
#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `auto_trait`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error; 1 warning emitted

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-non_lifetime_binders`#![feature(non_lifetime_binders)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions