Skip to content
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

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

Closed
matthiaskrgr opened this issue Apr 3, 2025 · 1 comment · Fixed by #139346
Closed

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

matthiaskrgr opened this issue Apr 3, 2025 · 1 comment · Fixed by #139346
Assignees
Labels
C-bug Category: This is a bug. F-non_lifetime_binders `#![feature(non_lifetime_binders)]` 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):

#![feature(non_lifetime_binders)]
trait v0 {}
fn kind()  -> (dyn v0<'static, > impl for<v4> v0<v4>) {}

original:

#![feature(non_lifetime_binders)]
trait v0 {}
fn kind()  -> (dyn v0<'static, > impl for<v4> v0<v4>) {}

fn main() {}

Version information

rustc 1.88.0-nightly (946aea0b3 2025-04-03)
binary: rustc
commit-hash: 946aea0b3d9f43e57953ce5094d8e4a2a244ce71
commit-date: 2025-04-03
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2

Possibly related line of code:

.expect_clause()
}
}
impl<'tcx> UpcastFrom<TyCtxt<'tcx>, PredicateKind<'tcx>> for Predicate<'tcx> {
fn upcast_from(from: PredicateKind<'tcx>, tcx: TyCtxt<'tcx>) -> Self {
ty::Binder::dummy(from).upcast(tcx)
}
}
impl<'tcx> UpcastFrom<TyCtxt<'tcx>, ty::Binder<'tcx, PredicateKind<'tcx>>> for Predicate<'tcx> {
fn upcast_from(from: ty::Binder<'tcx, PredicateKind<'tcx>>, tcx: TyCtxt<'tcx>) -> Self {
tcx.mk_predicate(from)

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

Program output

error: expected one of `)`, `+`, `,`, or `::`, found keyword `impl`
 --> /tmp/icemaker_global_tempdir.ShOGs7fNRhWu/rustc_testrunner_tmpdir_reporting.uYRB9lC4sTQY/mvce.rs:3:34
  |
3 | fn kind()  -> (dyn v0<'static, > impl for<v4> v0<v4>) {}
  |                                 -^^^^ expected one of `)`, `+`, `,`, or `::`
  |                                 |
  |                                 help: missing `,`

warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.ShOGs7fNRhWu/rustc_testrunner_tmpdir_reporting.uYRB9lC4sTQY/mvce.rs:1:12
  |
1 | #![feature(non_lifetime_binders)]
  |            ^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
  = note: `#[warn(incomplete_features)]` on by default

warning: trait `v0` should have an upper camel case name
 --> /tmp/icemaker_global_tempdir.ShOGs7fNRhWu/rustc_testrunner_tmpdir_reporting.uYRB9lC4sTQY/mvce.rs:2:7
  |
2 | trait v0 {}
  |       ^^ help: convert the identifier to upper camel case (notice the capitalization): `V0`
  |
  = note: `#[warn(non_camel_case_types)]` on by default

warning: type parameter `v4` should have an upper camel case name
 --> /tmp/icemaker_global_tempdir.ShOGs7fNRhWu/rustc_testrunner_tmpdir_reporting.uYRB9lC4sTQY/mvce.rs:3:43
  |
3 | fn kind()  -> (dyn v0<'static, > impl for<v4> v0<v4>) {}
  |                                           ^^ help: convert the identifier to upper camel case (notice the capitalization): `V4`

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.ShOGs7fNRhWu/rustc_testrunner_tmpdir_reporting.uYRB9lC4sTQY/mvce.rs:3:57
  |
3 | fn kind()  -> (dyn v0<'static, > impl for<v4> v0<v4>) {}
  |                                                         ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.ShOGs7fNRhWu/rustc_testrunner_tmpdir_reporting.uYRB9lC4sTQY/mvce.rs`

error[E0107]: trait takes 0 lifetime arguments but 1 lifetime argument was supplied
 --> /tmp/icemaker_global_tempdir.ShOGs7fNRhWu/rustc_testrunner_tmpdir_reporting.uYRB9lC4sTQY/mvce.rs:3:20
  |
3 | fn kind()  -> (dyn v0<'static, > impl for<v4> v0<v4>) {}
  |                    ^^----------- help: remove the unnecessary generics
  |                    |
  |                    expected 0 lifetime arguments
  |
note: trait defined here, with 0 lifetime parameters
 --> /tmp/icemaker_global_tempdir.ShOGs7fNRhWu/rustc_testrunner_tmpdir_reporting.uYRB9lC4sTQY/mvce.rs:2:7
  |
2 | trait v0 {}
  |       ^^

error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied
 --> /tmp/icemaker_global_tempdir.ShOGs7fNRhWu/rustc_testrunner_tmpdir_reporting.uYRB9lC4sTQY/mvce.rs:3:47
  |
3 | fn kind()  -> (dyn v0<'static, > impl for<v4> v0<v4>) {}
  |                                               ^^---- help: remove the unnecessary generics
  |                                               |
  |                                               expected 0 generic arguments
  |
note: trait defined here, with 0 generic parameters
 --> /tmp/icemaker_global_tempdir.ShOGs7fNRhWu/rustc_testrunner_tmpdir_reporting.uYRB9lC4sTQY/mvce.rs:2:7
  |
2 | trait v0 {}
  |       ^^


thread 'rustc' panicked at compiler/rustc_middle/src/ty/predicate.rs:468:9:
`WellFormed(^"v4")` has escaping bound vars, so it cannot be wrapped in a dummy binder.
stack backtrace:
   0:     0x731e3246bf43 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hde263b85c5db2e5f
   1:     0x731e32c06111 - core::fmt::write::h9b8038f00f576ae0
   2:     0x731e34099291 - std::io::Write::write_fmt::hf04ec7828273ae13
   3:     0x731e3246bda2 - std::sys::backtrace::BacktraceLock::print::h944578450d8a8c30
   4:     0x731e3246f88a - std::panicking::default_hook::{{closure}}::h4e55257e05dc0eaf
   5:     0x731e3246f40f - std::panicking::default_hook::h79a253b530fabb9d
   6:     0x731e314e7930 - std[f6562b0534d53c43]::panicking::update_hook::<alloc[e2be6985779dab61]::boxed::Box<rustc_driver_impl[1b5918a4900d57a3]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x731e32470103 - std::panicking::rust_panic_with_hook::h4b5a473804813370
   8:     0x731e3246fdfa - std::panicking::begin_panic_handler::{{closure}}::h4734d8630efce563
   9:     0x731e3246c419 - std::sys::backtrace::__rust_end_short_backtrace::hf5306bd179a9758e
  10:     0x731e3246fabd - __rustc[7a6e3b08990bd1b9]::rust_begin_unwind
  11:     0x731e2eea1530 - core::panicking::panic_fmt::h23b650f0efa75d6d
  12:     0x731e347ac81d - <rustc_middle[26df542b903f2b2a]::ty::predicate::Predicate as rustc_type_ir[d2925d285d1bace9]::upcast::UpcastFrom<rustc_middle[26df542b903f2b2a]::ty::context::TyCtxt, rustc_type_ir[d2925d285d1bace9]::predicate_kind::PredicateKind<rustc_middle[26df542b903f2b2a]::ty::context::TyCtxt>>>::upcast_from.cold
  13:     0x731e315cde97 - <rustc_infer[5ec55a8f82fe16e]::traits::Obligation<rustc_middle[26df542b903f2b2a]::ty::predicate::Predicate>>::with_depth::<rustc_type_ir[d2925d285d1bace9]::predicate_kind::PredicateKind<rustc_middle[26df542b903f2b2a]::ty::context::TyCtxt>>
  14:     0x731e316e04f9 - <rustc_hir_analysis[e7d0ddac047c6029]::hir_wf_check::diagnostic_hir_wf_check::HirWfCheck as rustc_hir[7d99c1a77ed599c4]::intravisit::Visitor>::visit_ty
  15:     0x731e315e3d55 - rustc_hir[7d99c1a77ed599c4]::intravisit::walk_generic_args::<rustc_hir_analysis[e7d0ddac047c6029]::hir_wf_check::diagnostic_hir_wf_check::HirWfCheck>
  16:     0x731e315e38a5 - rustc_hir[7d99c1a77ed599c4]::intravisit::walk_param_bound::<rustc_hir_analysis[e7d0ddac047c6029]::hir_wf_check::diagnostic_hir_wf_check::HirWfCheck>
  17:     0x731e316e080e - <rustc_hir_analysis[e7d0ddac047c6029]::hir_wf_check::diagnostic_hir_wf_check::HirWfCheck as rustc_hir[7d99c1a77ed599c4]::intravisit::Visitor>::visit_ty
  18:     0x731e316e0958 - <rustc_hir_analysis[e7d0ddac047c6029]::hir_wf_check::diagnostic_hir_wf_check::HirWfCheck as rustc_hir[7d99c1a77ed599c4]::intravisit::Visitor>::visit_ty
  19:     0x731e316dfd77 - rustc_hir_analysis[e7d0ddac047c6029]::hir_wf_check::diagnostic_hir_wf_check
  20:     0x731e31f6000f - rustc_query_impl[a177b0cf2514e65]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a177b0cf2514e65]::query_impl::diagnostic_hir_wf_check::dynamic_query::{closure#2}::{closure#0}, rustc_middle[26df542b903f2b2a]::query::erase::Erased<[u8; 8usize]>>
  21:     0x731e31f385d3 - <rustc_query_impl[a177b0cf2514e65]::query_impl::diagnostic_hir_wf_check::dynamic_query::{closure#2} as core[dcee7a2746af8d03]::ops::function::FnOnce<(rustc_middle[26df542b903f2b2a]::ty::context::TyCtxt, (rustc_middle[26df542b903f2b2a]::ty::predicate::Predicate, rustc_middle[26df542b903f2b2a]::traits::WellFormedLoc))>>::call_once
  22:     0x731e31ea47f2 - rustc_query_system[d06e27ff9a2bb429]::query::plumbing::try_execute_query::<rustc_query_impl[a177b0cf2514e65]::DynamicConfig<rustc_query_system[d06e27ff9a2bb429]::query::caches::DefaultCache<(rustc_middle[26df542b903f2b2a]::ty::predicate::Predicate, rustc_middle[26df542b903f2b2a]::traits::WellFormedLoc), rustc_middle[26df542b903f2b2a]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a177b0cf2514e65]::plumbing::QueryCtxt, false>
  23:     0x731e31f9a0c0 - rustc_query_impl[a177b0cf2514e65]::query_impl::diagnostic_hir_wf_check::get_query_non_incr::__rust_end_short_backtrace
  24:     0x731e322846b5 - <rustc_trait_selection[b2017cfa88f3bdb1]::error_reporting::TypeErrCtxt>::report_selection_error
  25:     0x731e322e61df - <rustc_trait_selection[b2017cfa88f3bdb1]::error_reporting::TypeErrCtxt>::report_fulfillment_errors
  26:     0x731e33253000 - rustc_hir_analysis[e7d0ddac047c6029]::check::wfcheck::check_item_fn
  27:     0x731e3333c0e2 - rustc_hir_analysis[e7d0ddac047c6029]::check::wfcheck::check_well_formed
  28:     0x731e3333a251 - rustc_query_impl[a177b0cf2514e65]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a177b0cf2514e65]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[26df542b903f2b2a]::query::erase::Erased<[u8; 1usize]>>
  29:     0x731e33339afa - rustc_query_system[d06e27ff9a2bb429]::query::plumbing::try_execute_query::<rustc_query_impl[a177b0cf2514e65]::DynamicConfig<rustc_data_structures[a49c47847d07a40c]::vec_cache::VecCache<rustc_span[f4fedfef03388269]::def_id::LocalDefId, rustc_middle[26df542b903f2b2a]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[d06e27ff9a2bb429]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[a177b0cf2514e65]::plumbing::QueryCtxt, false>
  30:     0x731e333395d7 - rustc_query_impl[a177b0cf2514e65]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  31:     0x731e33336a6d - rustc_hir_analysis[e7d0ddac047c6029]::check::wfcheck::check_mod_type_wf
  32:     0x731e33336895 - rustc_query_impl[a177b0cf2514e65]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a177b0cf2514e65]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[26df542b903f2b2a]::query::erase::Erased<[u8; 1usize]>>
  33:     0x731e33c09759 - rustc_query_system[d06e27ff9a2bb429]::query::plumbing::try_execute_query::<rustc_query_impl[a177b0cf2514e65]::DynamicConfig<rustc_query_system[d06e27ff9a2bb429]::query::caches::DefaultCache<rustc_span[f4fedfef03388269]::def_id::LocalModDefId, rustc_middle[26df542b903f2b2a]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a177b0cf2514e65]::plumbing::QueryCtxt, false>
  34:     0x731e33c094ca - rustc_query_impl[a177b0cf2514e65]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  35:     0x731e32ebae57 - rustc_hir_analysis[e7d0ddac047c6029]::check_crate
  36:     0x731e32f7425d - rustc_interface[e6a7fad6374939eb]::passes::run_required_analyses
  37:     0x731e33c0329e - rustc_interface[e6a7fad6374939eb]::passes::analysis
  38:     0x731e33c03273 - rustc_query_impl[a177b0cf2514e65]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a177b0cf2514e65]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[26df542b903f2b2a]::query::erase::Erased<[u8; 0usize]>>
  39:     0x731e33bca483 - rustc_query_system[d06e27ff9a2bb429]::query::plumbing::try_execute_query::<rustc_query_impl[a177b0cf2514e65]::DynamicConfig<rustc_query_system[d06e27ff9a2bb429]::query::caches::SingleCache<rustc_middle[26df542b903f2b2a]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[a177b0cf2514e65]::plumbing::QueryCtxt, false>
  40:     0x731e33bca17e - rustc_query_impl[a177b0cf2514e65]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  41:     0x731e33d7448d - rustc_interface[e6a7fad6374939eb]::passes::create_and_enter_global_ctxt::<core[dcee7a2746af8d03]::option::Option<rustc_interface[e6a7fad6374939eb]::queries::Linker>, rustc_driver_impl[1b5918a4900d57a3]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  42:     0x731e33da722a - rustc_interface[e6a7fad6374939eb]::interface::run_compiler::<(), rustc_driver_impl[1b5918a4900d57a3]::run_compiler::{closure#0}>::{closure#1}
  43:     0x731e33ba4b88 - std[f6562b0534d53c43]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[e6a7fad6374939eb]::util::run_in_thread_with_globals<rustc_interface[e6a7fad6374939eb]::util::run_in_thread_pool_with_globals<rustc_interface[e6a7fad6374939eb]::interface::run_compiler<(), rustc_driver_impl[1b5918a4900d57a3]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  44:     0x731e33ba5474 - <<std[f6562b0534d53c43]::thread::Builder>::spawn_unchecked_<rustc_interface[e6a7fad6374939eb]::util::run_in_thread_with_globals<rustc_interface[e6a7fad6374939eb]::util::run_in_thread_pool_with_globals<rustc_interface[e6a7fad6374939eb]::interface::run_compiler<(), rustc_driver_impl[1b5918a4900d57a3]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[dcee7a2746af8d03]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  45:     0x731e33ba6877 - std::sys::pal::unix::thread::Thread::new::thread_start::hc68e48949b6c9c5b
  46:     0x731e2daa370a - <unknown>
  47:     0x731e2db27aac - <unknown>
  48:                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 (946aea0b3 2025-04-03) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [diagnostic_hir_wf_check] performing HIR wf-checking for predicate `Binder { value: TraitPredicate(<dyn v0 as core::marker::Sized>, polarity:Positive), bound_vars: [] }` at item `Param { function: DefId(0:4 ~ mvce[4bf8]::kind), param_idx: 0 }`
#1 [check_well_formed] checking that `kind` is well-formed
#2 [check_mod_type_wf] checking that types are well-formed in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors; 3 warnings emitted

Some errors have detailed explanations: E0107, E0601.
For more information about an error, try `rustc --explain E0107`.

@rustbot label +F-non_lifetime_binders

@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 3, 2025
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. F-non_lifetime_binders `#![feature(non_lifetime_binders)]` labels Apr 3, 2025
@matthiaskrgr
Copy link
Member Author

yeet

#![feature(non_lifetime_binders)]
trait A {}
fn b() -> (dyn A impl for<C> A<C>) {}

@compiler-errors compiler-errors self-assigned this Apr 4, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 7, 2025
…r-diag-hir-wf-check, r=oli-obk

Don't construct preds w escaping bound vars in `diagnostic_hir_wf_check`

See comment inline.

Fixes rust-lang#139330

r? oli-obk
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 7, 2025
…r-diag-hir-wf-check, r=oli-obk

Don't construct preds w escaping bound vars in `diagnostic_hir_wf_check`

See comment inline.

Fixes rust-lang#139330

r? oli-obk
Zalathar added a commit to Zalathar/rust that referenced this issue Apr 8, 2025
…r-diag-hir-wf-check, r=oli-obk

Don't construct preds w escaping bound vars in `diagnostic_hir_wf_check`

See comment inline.

Fixes rust-lang#139330

r? oli-obk
@bors bors closed this as completed in 133cec7 Apr 8, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 8, 2025
Rollup merge of rust-lang#139346 - compiler-errors:non-lifetime-binder-diag-hir-wf-check, r=oli-obk

Don't construct preds w escaping bound vars in `diagnostic_hir_wf_check`

See comment inline.

Fixes rust-lang#139330

r? oli-obk
@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
C-bug Category: This is a bug. F-non_lifetime_binders `#![feature(non_lifetime_binders)]` 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
Development

Successfully merging a pull request may close this issue.

4 participants