Skip to content

ICE: cannot convert ReEarlyParam(DefId(0:11 ~ crash[8cfd]::{impl#0}::y::{opaque#0}::'_), 3, '_) to a region vid #121574

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

Closed
matthiaskrgr opened this issue Feb 25, 2024 · 1 comment · Fixed by #125501
Labels
C-bug Category: This is a bug. F-generic_const_exprs `#![feature(generic_const_exprs)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue 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(generic_const_exprs)]

impl<const Z: usize> X<Z> {
    pub fn y<'a, U: 'a>(&'a self) -> impl Iterator<Item = impl Iterator<Item = [u8; Z]> + '_> {}
}

original:

#![feature(generic_const_exprs)]
pub struct DimName<const N: usize> {}
impl<const Z: usize> X<Z> {
    pub fn y<'a, U: 'a>(&'a self) -> impl Iterator<Item = impl Iterator<Item = [u8; Z]> + '_> {
        "0".as_bytes(move |_| (0..1).map(move |_| loop {}))
    }
}

Version information

rustc 1.78.0-nightly (8f359beca 2024-02-23)
binary: rustc
commit-hash: 8f359beca4e58bc3ae795a666301a8f47023044c
commit-date: 2024-02-23
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

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

Program output

error[E0412]: cannot find type `X` in this scope
 --> /tmp/icemaker_global_tempdir.sibW0J2m6Q7v/rustc_testrunner_tmpdir_reporting.Ixcc7s4ac9zG/mvce.rs:3:22
  |
3 | impl<const Z: usize> X<Z> {
  |                      ^ not found in this scope

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

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.sibW0J2m6Q7v/rustc_testrunner_tmpdir_reporting.Ixcc7s4ac9zG/mvce.rs:5:2
  |
5 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.sibW0J2m6Q7v/rustc_testrunner_tmpdir_reporting.Ixcc7s4ac9zG/mvce.rs`

error[E0277]: `()` is not an iterator
 --> /tmp/icemaker_global_tempdir.sibW0J2m6Q7v/rustc_testrunner_tmpdir_reporting.Ixcc7s4ac9zG/mvce.rs:4:38
  |
4 |     pub fn y<'a, U: 'a>(&'a self) -> impl Iterator<Item = impl Iterator<Item = [u8; Z]> + '_> {}
  |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator
  |
  = help: the trait `Iterator` is not implemented for `()`

error: internal compiler error: compiler/rustc_borrowck/src/universal_regions.rs:879:36: cannot convert `ReEarlyParam(DefId(0:11 ~ mvce[3a1b]::{impl#0}::y::{opaque#0}::'_), 3, '_)` to a region vid

thread 'rustc' panicked at compiler/rustc_middle/src/util/bug.rs:35:44:
Box<dyn Any>
stack backtrace:
   0:     0x7eff44263af6 - std::backtrace_rs::backtrace::libunwind::trace::h4d16db2f784877bc
                               at /rustc/8f359beca4e58bc3ae795a666301a8f47023044c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7eff44263af6 - std::backtrace_rs::backtrace::trace_unsynchronized::h584b4a9b0240fa46
                               at /rustc/8f359beca4e58bc3ae795a666301a8f47023044c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7eff44263af6 - std::sys_common::backtrace::_print_fmt::hd30229489add2f78
                               at /rustc/8f359beca4e58bc3ae795a666301a8f47023044c/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7eff44263af6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2c0d00d6b7d69808
                               at /rustc/8f359beca4e58bc3ae795a666301a8f47023044c/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7eff442b4a7c - core::fmt::rt::Argument::fmt::hff9bfb4853f651d7
                               at /rustc/8f359beca4e58bc3ae795a666301a8f47023044c/library/core/src/fmt/rt.rs:142:9
   5:     0x7eff442b4a7c - core::fmt::write::h3421d3f24b10b162
                               at /rustc/8f359beca4e58bc3ae795a666301a8f47023044c/library/core/src/fmt/mod.rs:1120:17
   6:     0x7eff442584bf - std::io::Write::write_fmt::hec18e9e87db322bb
                               at /rustc/8f359beca4e58bc3ae795a666301a8f47023044c/library/std/src/io/mod.rs:1846:15
   7:     0x7eff442638a4 - std::sys_common::backtrace::_print::hec336a3777e68e7b
                               at /rustc/8f359beca4e58bc3ae795a666301a8f47023044c/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7eff442638a4 - std::sys_common::backtrace::print::hde3a6d5d13170337
                               at /rustc/8f359beca4e58bc3ae795a666301a8f47023044c/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7eff442665eb - std::panicking::default_hook::{{closure}}::h4a4905d59aca1811
  10:     0x7eff44266339 - std::panicking::default_hook::h33a18ce8d018f6fd
                               at /rustc/8f359beca4e58bc3ae795a666301a8f47023044c/library/std/src/panicking.rs:292:9
  11:     0x7eff40e8467c - std[d1f7731e2ff5974d]::panicking::update_hook::<alloc[6711342ad6595d8]::boxed::Box<rustc_driver_impl[db1009755931a507]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7eff44266d50 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h923e5082c0e2f790
                               at /rustc/8f359beca4e58bc3ae795a666301a8f47023044c/library/alloc/src/boxed.rs:2030:9
  13:     0x7eff44266d50 - std::panicking::rust_panic_with_hook::he294011ca89c3e63
                               at /rustc/8f359beca4e58bc3ae795a666301a8f47023044c/library/std/src/panicking.rs:783:13
  14:     0x7eff40eb0d24 - std[d1f7731e2ff5974d]::panicking::begin_panic::<rustc_errors[8efb6f95facf2fed]::ExplicitBug>::{closure#0}
  15:     0x7eff40eadc46 - std[d1f7731e2ff5974d]::sys_common::backtrace::__rust_end_short_backtrace::<std[d1f7731e2ff5974d]::panicking::begin_panic<rustc_errors[8efb6f95facf2fed]::ExplicitBug>::{closure#0}, !>
  16:     0x7eff40ead926 - std[d1f7731e2ff5974d]::panicking::begin_panic::<rustc_errors[8efb6f95facf2fed]::ExplicitBug>
  17:     0x7eff40eba711 - <rustc_errors[8efb6f95facf2fed]::diagnostic::BugAbort as rustc_errors[8efb6f95facf2fed]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7eff41291f9c - <rustc_errors[8efb6f95facf2fed]::DiagCtxt>::bug::<alloc[6711342ad6595d8]::string::String>
  19:     0x7eff41336d6b - rustc_middle[10e0138f1f482b76]::util::bug::opt_span_bug_fmt::<rustc_span[6ccc48fe7a4f1f83]::span_encoding::Span>::{closure#0}
  20:     0x7eff4131a5ba - rustc_middle[10e0138f1f482b76]::ty::context::tls::with_opt::<rustc_middle[10e0138f1f482b76]::util::bug::opt_span_bug_fmt<rustc_span[6ccc48fe7a4f1f83]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7eff4131a438 - rustc_middle[10e0138f1f482b76]::ty::context::tls::with_context_opt::<rustc_middle[10e0138f1f482b76]::ty::context::tls::with_opt<rustc_middle[10e0138f1f482b76]::util::bug::opt_span_bug_fmt<rustc_span[6ccc48fe7a4f1f83]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7eff3f751440 - rustc_middle[10e0138f1f482b76]::util::bug::bug_fmt
  23:     0x7eff4384c71c - <rustc_borrowck[aaa85fbefb30244]::universal_regions::UniversalRegionIndices>::to_region_vid.cold.0
  24:     0x7eff3fcbe77d - rustc_borrowck[aaa85fbefb30244]::type_check::type_check
  25:     0x7eff3fca27fc - rustc_borrowck[aaa85fbefb30244]::nll::compute_regions
  26:     0x7eff42fec06b - rustc_borrowck[aaa85fbefb30244]::do_mir_borrowck
  27:     0x7eff42fdea9e - rustc_borrowck[aaa85fbefb30244]::mir_borrowck
  28:     0x7eff42fde557 - rustc_query_impl[5f3fca9184d705d1]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5f3fca9184d705d1]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[10e0138f1f482b76]::query::erase::Erased<[u8; 8usize]>>
  29:     0x7eff4246bc30 - rustc_query_system[3c44b3ad726fdf36]::query::plumbing::try_execute_query::<rustc_query_impl[5f3fca9184d705d1]::DynamicConfig<rustc_query_system[3c44b3ad726fdf36]::query::caches::VecCache<rustc_span[6ccc48fe7a4f1f83]::def_id::LocalDefId, rustc_middle[10e0138f1f482b76]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[5f3fca9184d705d1]::plumbing::QueryCtxt, false>
  30:     0x7eff4246b80c - rustc_query_impl[5f3fca9184d705d1]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  31:     0x7eff42dedecc - rustc_interface[94ec20dfe64cdcea]::passes::analysis
  32:     0x7eff42ded9d9 - rustc_query_impl[5f3fca9184d705d1]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5f3fca9184d705d1]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[10e0138f1f482b76]::query::erase::Erased<[u8; 1usize]>>
  33:     0x7eff42f25643 - rustc_query_system[3c44b3ad726fdf36]::query::plumbing::try_execute_query::<rustc_query_impl[5f3fca9184d705d1]::DynamicConfig<rustc_query_system[3c44b3ad726fdf36]::query::caches::SingleCache<rustc_middle[10e0138f1f482b76]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[5f3fca9184d705d1]::plumbing::QueryCtxt, false>
  34:     0x7eff42f253bf - rustc_query_impl[5f3fca9184d705d1]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7eff42f34896 - rustc_interface[94ec20dfe64cdcea]::interface::run_compiler::<core[bd87c62ae3a7b4ee]::result::Result<(), rustc_span[6ccc48fe7a4f1f83]::ErrorGuaranteed>, rustc_driver_impl[db1009755931a507]::run_compiler::{closure#0}>::{closure#0}
  36:     0x7eff431caa4d - std[d1f7731e2ff5974d]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[94ec20dfe64cdcea]::util::run_in_thread_with_globals<rustc_interface[94ec20dfe64cdcea]::util::run_in_thread_pool_with_globals<rustc_interface[94ec20dfe64cdcea]::interface::run_compiler<core[bd87c62ae3a7b4ee]::result::Result<(), rustc_span[6ccc48fe7a4f1f83]::ErrorGuaranteed>, rustc_driver_impl[db1009755931a507]::run_compiler::{closure#0}>::{closure#0}, core[bd87c62ae3a7b4ee]::result::Result<(), rustc_span[6ccc48fe7a4f1f83]::ErrorGuaranteed>>::{closure#0}, core[bd87c62ae3a7b4ee]::result::Result<(), rustc_span[6ccc48fe7a4f1f83]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[bd87c62ae3a7b4ee]::result::Result<(), rustc_span[6ccc48fe7a4f1f83]::ErrorGuaranteed>>
  37:     0x7eff431ca87a - <<std[d1f7731e2ff5974d]::thread::Builder>::spawn_unchecked_<rustc_interface[94ec20dfe64cdcea]::util::run_in_thread_with_globals<rustc_interface[94ec20dfe64cdcea]::util::run_in_thread_pool_with_globals<rustc_interface[94ec20dfe64cdcea]::interface::run_compiler<core[bd87c62ae3a7b4ee]::result::Result<(), rustc_span[6ccc48fe7a4f1f83]::ErrorGuaranteed>, rustc_driver_impl[db1009755931a507]::run_compiler::{closure#0}>::{closure#0}, core[bd87c62ae3a7b4ee]::result::Result<(), rustc_span[6ccc48fe7a4f1f83]::ErrorGuaranteed>>::{closure#0}, core[bd87c62ae3a7b4ee]::result::Result<(), rustc_span[6ccc48fe7a4f1f83]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[bd87c62ae3a7b4ee]::result::Result<(), rustc_span[6ccc48fe7a4f1f83]::ErrorGuaranteed>>::{closure#1} as core[bd87c62ae3a7b4ee]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x7eff44270725 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h11737601996c7bc7
                               at /rustc/8f359beca4e58bc3ae795a666301a8f47023044c/library/alloc/src/boxed.rs:2016:9
  39:     0x7eff44270725 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb64bc4a2c7899523
                               at /rustc/8f359beca4e58bc3ae795a666301a8f47023044c/library/alloc/src/boxed.rs:2016:9
  40:     0x7eff44270725 - std::sys::pal::unix::thread::Thread::new::thread_start::h9f6bca54366231ee
                               at /rustc/8f359beca4e58bc3ae795a666301a8f47023044c/library/std/src/sys/pal/unix/thread.rs:108:17
  41:     0x7eff3dea955a - <unknown>
  42:     0x7eff3df26a3c - <unknown>
  43:                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.78.0-nightly (8f359beca 2024-02-23) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_borrowck] borrow-checking `<impl at /tmp/icemaker_global_tempdir.sibW0J2m6Q7v/rustc_testrunner_tmpdir_reporting.Ixcc7s4ac9zG/mvce.rs:3:1: 3:26>::y::{constant#0}`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors; 1 warning emitted

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

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

#120550 cc @oli-obk

@jieyouxu jieyouxu added S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 26, 2024
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Apr 15, 2024
@bors bors closed this as completed in 104e1a4 May 24, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue May 24, 2024
Rollup merge of rust-lang#125501 - compiler-errors:opaque-opaque-anon-ct, r=BoxyUwU

Resolve anon const's parent predicates to direct parent instead of opaque's parent

When an anon const is inside of an opaque, rust-lang#99801 added a hack to resolve the anon const's parent predicates *not* to the opaque's predicates, but to the opaque's *parent's* predicates. This is insufficient when considering nested opaques.

This means that the `predicates_of` an anon const might reference duplicated lifetimes (installed by `compute_bidirectional_outlives_predicates`) when computing known outlives in MIR borrowck, leading to these ICEs:
Fixes rust-lang#121574
Fixes rust-lang#118403

~~Instead, we should be using the `OpaqueTypeOrigin` to acquire the owner item (fn/type alias/etc) of the opaque, whose predicates we're fine to mention.~~

~~I think it's a bit sketchy that we're doing this at all, tbh; I think it *should* be fine for the anon const to inherit the predicates of the opaque it's located inside. However, that would also mean that we need to make sure the `generics_of` that anon const line up in the same way.~~

~~None of this is important to solve right now; I just want to fix these ICEs so we can land rust-lang#125468, which accidentally fixes these issues in a different and unrelated way.~~

edit: We don't need this special case anyways because we install the right parent item in `generics_of` anyways:
https://github.com/rust-lang/rust/blob/213ad10c8f0fc275648552366275dc4e07f97462/compiler/rustc_hir_analysis/src/collect/generics_of.rs#L150

r? `@BoxyUwU`
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. F-generic_const_exprs `#![feature(generic_const_exprs)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
3 participants