rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.98k stars 12.68k forks source link

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

Closed matthiaskrgr closed 1 year ago

matthiaskrgr commented 1 year ago

Code

#![feature(generic_const_exprs)]
fn bug<'a>()
where
    for<'b> [(); {
        let x: &'b ();
        0
    }]:
{}

Meta

rustc --version --verbose:

rustc 1.71.0-nightly (2f6bc5d25 2023-05-09)
binary: rustc
commit-hash: 2f6bc5d259e7ab25ddfdd33de53b892770218918
commit-date: 2023-05-09
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.2

Error output

<output>
Backtrace

``` warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes --> treereduce.out:1:12 | 1 | #![feature(generic_const_exprs)] | ^^^^^^^^^^^^^^^^^^^ | = note: see issue #76560 for more information = note: `#[warn(incomplete_features)]` on by default error[E0601]: `main` function not found in crate `treereduce` --> treereduce.out:8:3 | 8 | {} | ^ consider adding a `main` function to `treereduce.out` thread 'rustc' panicked at '`WellFormed(&'b ())` has escaping bound vars, so it cannot be wrapped in a dummy binder.', compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs:483:13 stack backtrace: 0: 0x7faad236a481 - std::backtrace_rs::backtrace::libunwind::trace::h28494931c73179b2 at /rustc/2f6bc5d259e7ab25ddfdd33de53b892770218918/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5 1: 0x7faad236a481 - std::backtrace_rs::backtrace::trace_unsynchronized::h9032c52edccf7bd1 at /rustc/2f6bc5d259e7ab25ddfdd33de53b892770218918/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7faad236a481 - std::sys_common::backtrace::_print_fmt::hd90562e967f4e4e1 at /rustc/2f6bc5d259e7ab25ddfdd33de53b892770218918/library/std/src/sys_common/backtrace.rs:65:5 3: 0x7faad236a481 - ::fmt::h113657117676131e at /rustc/2f6bc5d259e7ab25ddfdd33de53b892770218918/library/std/src/sys_common/backtrace.rs:44:22 4: 0x7faad23ca84f - core::fmt::rt::Argument::fmt::hd56cdfa11c364505 at /rustc/2f6bc5d259e7ab25ddfdd33de53b892770218918/library/core/src/fmt/rt.rs:138:9 5: 0x7faad23ca84f - core::fmt::write::h24c20284e5d6be9e at /rustc/2f6bc5d259e7ab25ddfdd33de53b892770218918/library/core/src/fmt/mod.rs:1094:21 6: 0x7faad235d6e1 - std::io::Write::write_fmt::hbf02c94f0e7342d1 at /rustc/2f6bc5d259e7ab25ddfdd33de53b892770218918/library/std/src/io/mod.rs:1712:15 7: 0x7faad236a295 - std::sys_common::backtrace::_print::he85212e2c716c859 at /rustc/2f6bc5d259e7ab25ddfdd33de53b892770218918/library/std/src/sys_common/backtrace.rs:47:5 8: 0x7faad236a295 - std::sys_common::backtrace::print::h888aaf3ad10f084e at /rustc/2f6bc5d259e7ab25ddfdd33de53b892770218918/library/std/src/sys_common/backtrace.rs:34:9 9: 0x7faad236cf17 - std::panicking::default_hook::{{closure}}::hba0edb58dc223add 10: 0x7faad236cd04 - std::panicking::default_hook::h1555b8bada2010d7 at /rustc/2f6bc5d259e7ab25ddfdd33de53b892770218918/library/std/src/panicking.rs:288:9 11: 0x7faad55d593b - >::call_once::{shim:vtable#0} 12: 0x7faad236d637 - as core::ops::function::Fn>::call::h07438796673f3d04 at /rustc/2f6bc5d259e7ab25ddfdd33de53b892770218918/library/alloc/src/boxed.rs:1999:9 13: 0x7faad236d637 - std::panicking::rust_panic_with_hook::h72a06453beb2cbcb at /rustc/2f6bc5d259e7ab25ddfdd33de53b892770218918/library/std/src/panicking.rs:695:13 14: 0x7faad236d3b7 - std::panicking::begin_panic_handler::{{closure}}::h0281d6cc05cfd2a4 at /rustc/2f6bc5d259e7ab25ddfdd33de53b892770218918/library/std/src/panicking.rs:582:13 15: 0x7faad236a8c6 - std::sys_common::backtrace::__rust_end_short_backtrace::h1c79565770be27d9 at /rustc/2f6bc5d259e7ab25ddfdd33de53b892770218918/library/std/src/sys_common/backtrace.rs:150:18 16: 0x7faad236d122 - rust_begin_unwind at /rustc/2f6bc5d259e7ab25ddfdd33de53b892770218918/library/std/src/panicking.rs:578:5 17: 0x7faad23c6ad3 - core::panicking::panic_fmt::he6a2fe7a1b635de3 at /rustc/2f6bc5d259e7ab25ddfdd33de53b892770218918/library/core/src/panicking.rs:67:14 18: 0x7faad3b101ac - ::register_wf_obligation 19: 0x7faad3b0ff35 - ::to_ty 20: 0x7faad368eba5 - ::visit_local 21: 0x7faad368d3f9 - ::visit_expr 22: 0x7faad3c11411 - rustc_hir_typeck[7fb44c8b93f9310b]::typeck 23: 0x7faad3c06d32 - rustc_query_system[ffc3e6874545e2cc]::query::plumbing::try_execute_query:: 24: 0x7faad3c069c5 - rustc_query_impl[677774657eb92e7b]::get_query::typeck 25: 0x7faad3f45e8b - rustc_mir_build[9b43786a7326c032]::thir::cx::thir_body 26: 0x7faad3f43fcc - rustc_query_system[ffc3e6874545e2cc]::query::plumbing::try_execute_query:: 27: 0x7faad3f43c65 - rustc_query_impl[677774657eb92e7b]::get_query::thir_body 28: 0x7faad46598b6 - rustc_query_system[ffc3e6874545e2cc]::query::plumbing::try_execute_query:: 29: 0x7faad465846a - rustc_query_impl[677774657eb92e7b]::get_query::thir_abstract_const 30: 0x7faad4a5f212 - rustc_middle[8c6563ccb890ccc7]::ty::query::query_get_at::>> 31: 0x7faad3662a38 - <::expand_abstract_consts::Expander as rustc_type_ir[a2a3eb09eb372e2d]::fold::TypeFolder>::fold_const 32: 0x7faad3829887 - rustc_trait_selection[430f5fa6108926ed]::traits::const_evaluatable::is_const_evaluatable 33: 0x7faad37bc0d2 - ::process_obligation 34: 0x7faad37b17c4 - >::process_obligations:: 35: 0x7faad393f62b - ::select_all_or_error 36: 0x7faad40e11c7 - rustc_hir_analysis[22ad3c510546d4fc]::check::wfcheck::check_item_fn 37: 0x7faad40dd6ea - rustc_hir_analysis[22ad3c510546d4fc]::check::wfcheck::check_well_formed 38: 0x7faad3970403 - rustc_query_system[ffc3e6874545e2cc]::query::plumbing::try_execute_query:: 39: 0x7faad49b15e7 - rustc_data_structures[78003e5995acb4f0]::sync::par_for_each_in::<&[rustc_hir[98be715f7d0986d7]::hir::ItemId], ::par_items::{closure#0}> 40: 0x7faad49b11fa - rustc_hir_analysis[22ad3c510546d4fc]::check::wfcheck::check_mod_type_wf 41: 0x7faad4c33dc1 - rustc_query_system[ffc3e6874545e2cc]::query::plumbing::try_execute_query:: 42: 0x7faad4c33a01 - rustc_query_impl[677774657eb92e7b]::get_query::check_mod_type_wf 43: 0x7faad4a03b97 - rustc_data_structures[78003e5995acb4f0]::sync::par_for_each_in::<&[rustc_hir[98be715f7d0986d7]::hir_id::OwnerId], ::par_for_each_module::{closure#0}> 44: 0x7faad4a00b17 - rustc_hir_analysis[22ad3c510546d4fc]::check_crate 45: 0x7faad49f43c0 - rustc_interface[e0c448f9df8a7367]::passes::analysis 46: 0x7faad4d421f7 - rustc_query_system[ffc3e6874545e2cc]::query::plumbing::try_execute_query:: 47: 0x7faad4d41f13 - rustc_query_impl[677774657eb92e7b]::get_query::analysis 48: 0x7faad47c4d8f - ::enter::> 49: 0x7faad47c3e6f - ::enter::, rustc_span[f344ead202b2f728]::ErrorGuaranteed>> 50: 0x7faad47c150b - std[9a33fd118bee7e76]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[c1e8e7e9cc0f0224]::run_compiler::{closure#1}>::{closure#0}, core[75e04f0db769f8d6]::result::Result<(), rustc_span[f344ead202b2f728]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[75e04f0db769f8d6]::result::Result<(), rustc_span[f344ead202b2f728]::ErrorGuaranteed>> 51: 0x7faad4eab7c5 - <::spawn_unchecked_, rustc_driver_impl[c1e8e7e9cc0f0224]::run_compiler::{closure#1}>::{closure#0}, core[75e04f0db769f8d6]::result::Result<(), rustc_span[f344ead202b2f728]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[75e04f0db769f8d6]::result::Result<(), rustc_span[f344ead202b2f728]::ErrorGuaranteed>>::{closure#1} as core[75e04f0db769f8d6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 52: 0x7faad2377ae5 - as core::ops::function::FnOnce>::call_once::h71c821b130855373 at /rustc/2f6bc5d259e7ab25ddfdd33de53b892770218918/library/alloc/src/boxed.rs:1985:9 53: 0x7faad2377ae5 - as core::ops::function::FnOnce>::call_once::h1701cec9acb1061c at /rustc/2f6bc5d259e7ab25ddfdd33de53b892770218918/library/alloc/src/boxed.rs:1985:9 54: 0x7faad2377ae5 - std::sys::unix::thread::Thread::new::thread_start::h6dd5ef62dde103f1 at /rustc/2f6bc5d259e7ab25ddfdd33de53b892770218918/library/std/src/sys/unix/thread.rs:108:17 55: 0x7faad2114bb5 - 56: 0x7faad2196d90 - 57: 0x0 - 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.71.0-nightly (2f6bc5d25 2023-05-09) running on x86_64-unknown-linux-gnu query stack during panic: #0 [typeck] type-checking `bug::{constant#0}` #1 [thir_body] building THIR for `bug::{constant#0}` #2 [thir_abstract_const] building an abstract representation for `bug::{constant#0}` #3 [check_well_formed] checking that `bug` 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 previous error; 1 warning emitted For more information about this error, try `rustc --explain E0601`. ```

BoxyUwU commented 1 year ago

dupe of #83993