Skip to content
New issue

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

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

Already on GitHub? # to your account

ICE: WellFormed(T) has escaping bound vars, so it cannot be wrapped in a dummy binder. #108191

Closed
matthiaskrgr opened this issue Feb 17, 2023 · 2 comments · Fixed by #108553
Closed
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

Code

#![feature(non_lifetime_binders)]
#![feature(generic_const_exprs)]
#![crate_type = "lib"]

fn foo<T>(ExactSizeIterator: T) -> usize
where
    for<'a> &'a T:  ,
    for<T> <&'a [<&'a [u32; 1] as IntoIterator>::IntoIter; ExactSizeIterator: T] as IntoIterator>::IntoIter: ExactSizeIterator,
{}

Meta

rustc --version --verbose:

rustc 1.69.0-nightly (9aa5c24b7 2023-02-17)
binary: rustc
commit-hash: 9aa5c24b7d763fb98d998819571128ff2eb8a3ca
commit-date: 2023-02-17
host: x86_64-unknown-linux-gnu
release: 1.69.0-nightly
LLVM version: 15.0.7

Error output

error[E0261]: use of undeclared lifetime name `'a`
 --> d28cc4a400eddc53a0435322d1fa5d60230fffb0.rs:8:14
  |
8 |     for<T> <&'a [<&'a [u32; 1] as IntoIterator>::IntoIter; ExactSizeIterator: T] as IntoIterator>::IntoIter: ExactSizeIterator,
  |              ^^ undeclared lifetime
  |
  = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
help: consider making the bound lifetime-generic with a new `'a` lifetime
  |
8 |     for<'a, T> <&'a [<&'a [u32; 1] as IntoIterator>::IntoIter; ExactSizeIterator: T] as IntoIterator>::IntoIter: ExactSizeIterator,
  |         +++
help: consider introducing lifetime `'a` here
  |
5 | fn foo<'a, T>(ExactSizeIterator: T) -> usize
  |        +++

error[E0261]: use of undeclared lifetime name `'a`
 --> d28cc4a400eddc53a0435322d1fa5d60230fffb0.rs:8:20
  |
8 |     for<T> <&'a [<&'a [u32; 1] as IntoIterator>::IntoIter; ExactSizeIterator: T] as IntoIterator>::IntoIter: ExactSizeIterator,
  |                    ^^ undeclared lifetime
  |
help: consider making the bound lifetime-generic with a new `'a` lifetime
  |
8 |     for<'a, T> <&'a [<&'a [u32; 1] as IntoIterator>::IntoIter; ExactSizeIterator: T] as IntoIterator>::IntoIter: ExactSizeIterator,
  |         +++
help: consider introducing lifetime `'a` here
  |
5 | fn foo<'a, T>(ExactSizeIterator: T) -> usize
  |        +++

error[E0423]: expected value, found trait `ExactSizeIterator`
 --> d28cc4a400eddc53a0435322d1fa5d60230fffb0.rs:8:60
  |
8 |     for<T> <&'a [<&'a [u32; 1] as IntoIterator>::IntoIter; ExactSizeIterator: T] as IntoIterator>::IntoIter: ExactSizeIterator,
  |                                                            ^^^^^^^^^^^^^^^^^ expecting a type here because of type ascription

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

warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> d28cc4a400eddc53a0435322d1fa5d60230fffb0.rs:2:12
  |
2 | #![feature(generic_const_exprs)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
Backtrace


thread 'rustc' panicked at '`WellFormed(T)` has escaping bound vars, so it cannot be wrapped in a dummy binder.', compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs:486:13
stack backtrace:
   0:     0x7fb88dd13a5a - std::backtrace_rs::backtrace::libunwind::trace::hf4a48a91b677bc8d
                               at /rustc/9aa5c24b7d763fb98d998819571128ff2eb8a3ca/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fb88dd13a5a - std::backtrace_rs::backtrace::trace_unsynchronized::h52302266f2c9e2af
                               at /rustc/9aa5c24b7d763fb98d998819571128ff2eb8a3ca/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fb88dd13a5a - std::sys_common::backtrace::_print_fmt::h00aaca457620efb0
                               at /rustc/9aa5c24b7d763fb98d998819571128ff2eb8a3ca/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7fb88dd13a5a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h6d9f10455e422cbd
                               at /rustc/9aa5c24b7d763fb98d998819571128ff2eb8a3ca/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fb88dd739ae - core::fmt::write::h065585aa0e682316
                               at /rustc/9aa5c24b7d763fb98d998819571128ff2eb8a3ca/library/core/src/fmt/mod.rs:1232:17
   5:     0x7fb88dd03e05 - std::io::Write::write_fmt::h54937c0abd9a719d
                               at /rustc/9aa5c24b7d763fb98d998819571128ff2eb8a3ca/library/std/src/io/mod.rs:1684:15
   6:     0x7fb88dd13825 - std::sys_common::backtrace::_print::h0141838be2b7fc59
                               at /rustc/9aa5c24b7d763fb98d998819571128ff2eb8a3ca/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7fb88dd13825 - std::sys_common::backtrace::print::h422705047959e0cf
                               at /rustc/9aa5c24b7d763fb98d998819571128ff2eb8a3ca/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7fb88dd1659f - std::panicking::default_hook::{{closure}}::h04c227824228bc2c
                               at /rustc/9aa5c24b7d763fb98d998819571128ff2eb8a3ca/library/std/src/panicking.rs:267:22
   9:     0x7fb88dd162db - std::panicking::default_hook::h1a17cdb165515d8b
                               at /rustc/9aa5c24b7d763fb98d998819571128ff2eb8a3ca/library/std/src/panicking.rs:286:9
  10:     0x7fb88ca60224 - rustc_driver_impl[9b756e32c0d38789]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7fb88dd16ddd - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h7593a5eec671dafe
                               at /rustc/9aa5c24b7d763fb98d998819571128ff2eb8a3ca/library/alloc/src/boxed.rs:2002:9
  12:     0x7fb88dd16ddd - std::panicking::rust_panic_with_hook::h815681ed9ae37db1
                               at /rustc/9aa5c24b7d763fb98d998819571128ff2eb8a3ca/library/std/src/panicking.rs:692:13
  13:     0x7fb88dd16b59 - std::panicking::begin_panic_handler::{{closure}}::h2a0c3307e4bad14b
                               at /rustc/9aa5c24b7d763fb98d998819571128ff2eb8a3ca/library/std/src/panicking.rs:579:13
  14:     0x7fb88dd13ec6 - std::sys_common::backtrace::__rust_end_short_backtrace::hb59a12f53d5a254d
                               at /rustc/9aa5c24b7d763fb98d998819571128ff2eb8a3ca/library/std/src/sys_common/backtrace.rs:137:18
  15:     0x7fb88dd16862 - rust_begin_unwind
                               at /rustc/9aa5c24b7d763fb98d998819571128ff2eb8a3ca/library/std/src/panicking.rs:575:5
  16:     0x7fb88dd70353 - core::panicking::panic_fmt::hd1ca061751c01e2a
                               at /rustc/9aa5c24b7d763fb98d998819571128ff2eb8a3ca/library/core/src/panicking.rs:64:14
  17:     0x7fb88adff682 - <rustc_hir_typeck[2a4a381332c8299]::fn_ctxt::FnCtxt>::register_wf_obligation
  18:     0x7fb88adff3e3 - <rustc_hir_typeck[2a4a381332c8299]::fn_ctxt::FnCtxt>::to_ty
  19:     0x7fb88adff27a - <rustc_hir_typeck[2a4a381332c8299]::fn_ctxt::FnCtxt>::to_ty_saving_user_provided_ty
  20:     0x7fb88adf6d8d - <rustc_hir_typeck[2a4a381332c8299]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  21:     0x7fb88afb243b - <rustc_hir_typeck[2a4a381332c8299]::fn_ctxt::FnCtxt>::check_expr_coercable_to_type
  22:     0x7fb88af80a3f - <rustc_hir_typeck[2a4a381332c8299]::inherited::InheritedBuilder>::enter::<rustc_hir_typeck[2a4a381332c8299]::typeck_with_fallback<rustc_hir_typeck[2a4a381332c8299]::typeck::{closure#0}>::{closure#0}::{closure#1}, &rustc_middle[b5631d71f72482ee]::ty::typeck_results::TypeckResults>
  23:     0x7fb88af74a66 - rustc_hir_typeck[2a4a381332c8299]::typeck
  24:     0x7fb88af73163 - rustc_query_system[2b3be6912aef78d5]::query::plumbing::try_execute_query::<rustc_query_impl[a3402ef8368c6710]::queries::typeck, rustc_query_impl[a3402ef8368c6710]::plumbing::QueryCtxt>
  25:     0x7fb88c45b9b4 - <rustc_query_impl[a3402ef8368c6710]::Queries as rustc_middle[b5631d71f72482ee]::ty::query::QueryEngine>::typeck
  26:     0x7fb88ba6be84 - rustc_mir_build[f41718743f8b2dbe]::thir::cx::thir_body
  27:     0x7fb88ba646fa - rustc_query_system[2b3be6912aef78d5]::query::plumbing::try_execute_query::<rustc_query_impl[a3402ef8368c6710]::queries::thir_body, rustc_query_impl[a3402ef8368c6710]::plumbing::QueryCtxt>
  28:     0x7fb88c45570d - <rustc_query_impl[a3402ef8368c6710]::Queries as rustc_middle[b5631d71f72482ee]::ty::query::QueryEngine>::thir_body
  29:     0x7fb88b832aef - rustc_query_system[2b3be6912aef78d5]::query::plumbing::try_execute_query::<rustc_query_impl[a3402ef8368c6710]::queries::thir_abstract_const, rustc_query_impl[a3402ef8368c6710]::plumbing::QueryCtxt>
  30:     0x7fb88c455ade - <rustc_query_impl[a3402ef8368c6710]::Queries as rustc_middle[b5631d71f72482ee]::ty::query::QueryEngine>::thir_abstract_const
  31:     0x7fb88ab6545e - <rustc_middle[b5631d71f72482ee]::ty::context::TyCtxt>::bound_abstract_const
  32:     0x7fb88ab650ca - <<rustc_middle[b5631d71f72482ee]::ty::context::TyCtxt>::expand_abstract_consts::Expander as rustc_type_ir[327ad7f49bc4b943]::fold::TypeFolder<rustc_middle[b5631d71f72482ee]::ty::context::TyCtxt>>::fold_const
  33:     0x7fb88ada1c27 - rustc_trait_selection[7215420893b05e21]::traits::const_evaluatable::is_const_evaluatable
  34:     0x7fb88acf3900 - <rustc_trait_selection[7215420893b05e21]::traits::fulfill::FulfillProcessor as rustc_data_structures[6722e53fadb3415d]::obligation_forest::ObligationProcessor>::process_obligation
  35:     0x7fb88aced26f - <rustc_data_structures[6722e53fadb3415d]::obligation_forest::ObligationForest<rustc_trait_selection[7215420893b05e21]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[7215420893b05e21]::traits::fulfill::FulfillProcessor>
  36:     0x7fb88b514b70 - <rustc_trait_selection[7215420893b05e21]::traits::engine::ObligationCtxt>::select_all_or_error
  37:     0x7fb88b511aa8 - rustc_hir_analysis[90a2d534158d44df]::check::wfcheck::check_item_fn
  38:     0x7fb88b50cde1 - rustc_hir_analysis[90a2d534158d44df]::check::wfcheck::check_well_formed
  39:     0x7fb88b1ac415 - rustc_query_system[2b3be6912aef78d5]::query::plumbing::get_query::<rustc_query_impl[a3402ef8368c6710]::queries::check_well_formed, rustc_query_impl[a3402ef8368c6710]::plumbing::QueryCtxt, rustc_middle[b5631d71f72482ee]::dep_graph::dep_node::DepKind>
  40:     0x7fb88be27ba6 - rustc_data_structures[6722e53fadb3415d]::sync::par_for_each_in::<&[rustc_hir[c7d6b754e828c199]::hir::ItemId], <rustc_middle[b5631d71f72482ee]::hir::ModuleItems>::par_items<rustc_hir_analysis[90a2d534158d44df]::check::wfcheck::check_mod_type_wf::{closure#0}>::{closure#0}>
  41:     0x7fb88be27860 - rustc_hir_analysis[90a2d534158d44df]::check::wfcheck::check_mod_type_wf
  42:     0x7fb88c01971f - rustc_query_system[2b3be6912aef78d5]::query::plumbing::try_execute_query::<rustc_query_impl[a3402ef8368c6710]::queries::check_mod_type_wf, rustc_query_impl[a3402ef8368c6710]::plumbing::QueryCtxt>
  43:     0x7fb88c0192fd - <rustc_query_impl[a3402ef8368c6710]::Queries as rustc_middle[b5631d71f72482ee]::ty::query::QueryEngine>::check_mod_type_wf
  44:     0x7fb88bd70224 - std[92d2792449a90a80]::panicking::try::<(), core[d0f7fc72c0be1fb4]::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures[6722e53fadb3415d]::sync::par_for_each_in<&[rustc_hir[c7d6b754e828c199]::hir_id::OwnerId], <rustc_middle[b5631d71f72482ee]::hir::map::Map>::par_for_each_module<rustc_hir_analysis[90a2d534158d44df]::check_crate::{closure#5}::{closure#0}::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}>>
  45:     0x7fb88af080f8 - rustc_data_structures[6722e53fadb3415d]::sync::par_for_each_in::<&[rustc_hir[c7d6b754e828c199]::hir_id::OwnerId], <rustc_middle[b5631d71f72482ee]::hir::map::Map>::par_for_each_module<rustc_hir_analysis[90a2d534158d44df]::check_crate::{closure#5}::{closure#0}::{closure#0}>::{closure#0}>
  46:     0x7fb88af07f80 - <rustc_session[1c603fdce436292a]::session::Session>::track_errors::<rustc_hir_analysis[90a2d534158d44df]::check_crate::{closure#5}, ()>
  47:     0x7fb88af05258 - rustc_hir_analysis[90a2d534158d44df]::check_crate
  48:     0x7fb88aefad72 - rustc_interface[828b714f964ce1da]::passes::analysis
  49:     0x7fb88c24d4f2 - rustc_query_system[2b3be6912aef78d5]::query::plumbing::try_execute_query::<rustc_query_impl[a3402ef8368c6710]::queries::analysis, rustc_query_impl[a3402ef8368c6710]::plumbing::QueryCtxt>
  50:     0x7fb88c4550fa - <rustc_query_impl[a3402ef8368c6710]::Queries as rustc_middle[b5631d71f72482ee]::ty::query::QueryEngine>::analysis
  51:     0x7fb88bc75a23 - <rustc_interface[828b714f964ce1da]::queries::QueryResult<&rustc_middle[b5631d71f72482ee]::ty::context::GlobalCtxt>>::enter::<core[d0f7fc72c0be1fb4]::result::Result<(), rustc_errors[c2c7aee1e156d1f6]::ErrorGuaranteed>, rustc_driver_impl[9b756e32c0d38789]::run_compiler::{closure#1}::{closure#2}::{closure#3}>
  52:     0x7fb88bc74bf4 - <rustc_interface[828b714f964ce1da]::interface::Compiler>::enter::<rustc_driver_impl[9b756e32c0d38789]::run_compiler::{closure#1}::{closure#2}, core[d0f7fc72c0be1fb4]::result::Result<core[d0f7fc72c0be1fb4]::option::Option<rustc_interface[828b714f964ce1da]::queries::Linker>, rustc_errors[c2c7aee1e156d1f6]::ErrorGuaranteed>>
  53:     0x7fb88bc6fe14 - rustc_span[65551fbbac8b0f76]::with_source_map::<core[d0f7fc72c0be1fb4]::result::Result<(), rustc_errors[c2c7aee1e156d1f6]::ErrorGuaranteed>, rustc_interface[828b714f964ce1da]::interface::run_compiler<core[d0f7fc72c0be1fb4]::result::Result<(), rustc_errors[c2c7aee1e156d1f6]::ErrorGuaranteed>, rustc_driver_impl[9b756e32c0d38789]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  54:     0x7fb88bc6f924 - <scoped_tls[18b6b4dd1216e2e8]::ScopedKey<rustc_span[65551fbbac8b0f76]::SessionGlobals>>::set::<rustc_interface[828b714f964ce1da]::interface::run_compiler<core[d0f7fc72c0be1fb4]::result::Result<(), rustc_errors[c2c7aee1e156d1f6]::ErrorGuaranteed>, rustc_driver_impl[9b756e32c0d38789]::run_compiler::{closure#1}>::{closure#0}, core[d0f7fc72c0be1fb4]::result::Result<(), rustc_errors[c2c7aee1e156d1f6]::ErrorGuaranteed>>
  55:     0x7fb88bc6f022 - std[92d2792449a90a80]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[828b714f964ce1da]::util::run_in_thread_pool_with_globals<rustc_interface[828b714f964ce1da]::interface::run_compiler<core[d0f7fc72c0be1fb4]::result::Result<(), rustc_errors[c2c7aee1e156d1f6]::ErrorGuaranteed>, rustc_driver_impl[9b756e32c0d38789]::run_compiler::{closure#1}>::{closure#0}, core[d0f7fc72c0be1fb4]::result::Result<(), rustc_errors[c2c7aee1e156d1f6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d0f7fc72c0be1fb4]::result::Result<(), rustc_errors[c2c7aee1e156d1f6]::ErrorGuaranteed>>
  56:     0x7fb88bc6edcc - <<std[92d2792449a90a80]::thread::Builder>::spawn_unchecked_<rustc_interface[828b714f964ce1da]::util::run_in_thread_pool_with_globals<rustc_interface[828b714f964ce1da]::interface::run_compiler<core[d0f7fc72c0be1fb4]::result::Result<(), rustc_errors[c2c7aee1e156d1f6]::ErrorGuaranteed>, rustc_driver_impl[9b756e32c0d38789]::run_compiler::{closure#1}>::{closure#0}, core[d0f7fc72c0be1fb4]::result::Result<(), rustc_errors[c2c7aee1e156d1f6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d0f7fc72c0be1fb4]::result::Result<(), rustc_errors[c2c7aee1e156d1f6]::ErrorGuaranteed>>::{closure#1} as core[d0f7fc72c0be1fb4]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  57:     0x7fb88dd20c63 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h24b1cedbd344db9f
                               at /rustc/9aa5c24b7d763fb98d998819571128ff2eb8a3ca/library/alloc/src/boxed.rs:1988:9
  58:     0x7fb88dd20c63 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb7ac28b0dfacf269
                               at /rustc/9aa5c24b7d763fb98d998819571128ff2eb8a3ca/library/alloc/src/boxed.rs:1988:9
  59:     0x7fb88dd20c63 - std::sys::unix::thread::Thread::new::thread_start::h67c8d237baa6ad51
                               at /rustc/9aa5c24b7d763fb98d998819571128ff2eb8a3ca/library/std/src/sys/unix/thread.rs:108:17
  60:     0x7fb88968fbb5 - <unknown>
  61:     0x7fb889711d90 - <unknown>
  62:                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: rustc 1.69.0-nightly (9aa5c24b7 2023-02-17) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `foo::{constant#1}`
#1 [thir_body] building THIR for `foo::{constant#1}`
#2 [thir_abstract_const] building an abstract representation for `foo::{constant#1}`
#3 [check_well_formed] checking that `foo` is well-formed
#4 [check_mod_type_wf] checking that types are well-formed in top-level module
#5 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors; 2 warnings emitted

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

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Feb 17, 2023
@compiler-errors
Copy link
Member

This could really use minimization :/

@estebank estebank added the F-non_lifetime_binders `#![feature(non_lifetime_binders)]` label Feb 18, 2023
@compiler-errors
Copy link
Member

Minimized:

#![feature(non_lifetime_binders, generic_const_exprs)]

fn foo() -> usize
where
    for<T> [i32; 0: T]:,
{}

fn main() {}

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 3, 2023
…in-anon-ct, r=petrochenkov

Deny capturing late-bound non-lifetime param in anon const

Introduce a new AnonConstBoundary so we can detect when we capture a late-bound non-lifetime param with `non_lifetime_binders` enabled.

In the future, we could technically do something like introduce an early-bound parameter on the anon const, and stick the late-bound param in its substs (kinda like how we turn late-bound lifetimes in opaques into early-bound ones). But for now, just deny it so we don't ICE.

Fixes rust-lang#108191
@bors bors closed this as completed in 44e794f Mar 3, 2023
@compiler-errors compiler-errors self-assigned this Mar 16, 2023
# for free to join this conversation on GitHub. Already have an account? # 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.

3 participants