Skip to content

ICE: cannot convert ReLateParam to a region vid #125873

Closed
@matthiaskrgr

Description

auto-reduced (treereduce-rust):

fn foo() {
    let a = for<'a> |b: &'a ()| -> &'a () {
        const {
            let awd = ();
            let _: &'a () = &awd;
        };
        b
    };
}

original:

#![feature(closure_lifetime_binder, inline_const)]

fn foo() {
    let a = for<'a> |b: &'a ()| -> &'a () {
        const {
            let awd = ();
            let _: &'a () = &awd;
        };
        b
    };
}

Version information

rustc 1.80.0-nightly (0038c0210 2024-06-01)
binary: rustc
commit-hash: 0038c021031ce9f1ec2329469c8d85d0e681ef8f
commit-date: 2024-06-01
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.6

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zincremental-verify-ich=yes -Cincremental=<dir> -Cdebuginfo=2

Program output

error[E0658]: `for<...>` binders for closures are experimental
 --> /tmp/icemaker_global_tempdir.ledqKm8PA2CJ/rustc_testrunner_tmpdir_reporting.FfdctbYqxtky/mvce.rs:2:13
  |
2 |     let a = for<'a> |b: &'a ()| -> &'a () {
  |             ^^^^^^^
  |
  = note: see issue #97362 <https://github.com/rust-lang/rust/issues/97362> for more information
  = help: add `#![feature(closure_lifetime_binder)]` to the crate attributes to enable
  = note: this compiler was built on 2024-06-01; consider upgrading it if it is out of date
  = help: consider removing `for<...>`

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

warning: unused variable: `a`
 --> /tmp/icemaker_global_tempdir.ledqKm8PA2CJ/rustc_testrunner_tmpdir_reporting.FfdctbYqxtky/mvce.rs:2:9
  |
2 |     let a = for<'a> |b: &'a ()| -> &'a () {
  |         ^ help: if this is intentional, prefix it with an underscore: `_a`
  |
  = note: `#[warn(unused_variables)]` on by default

error: internal compiler error: compiler/rustc_borrowck/src/universal_regions.rs:880:36: cannot convert `ReLateParam(DefId(0:4 ~ mvce[0f62]::foo::{closure#0}), BrNamed(DefId(0:5 ~ mvce[0f62]::foo::{closure#0}::'a), 'a))` to a region vid

thread 'rustc' panicked at compiler/rustc_borrowck/src/universal_regions.rs:880:36:
Box<dyn Any>
stack backtrace:
   0:     0x78411bf79cc5 - std::backtrace_rs::backtrace::libunwind::trace::he42dbd6b585695a2
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x78411bf79cc5 - std::backtrace_rs::backtrace::trace_unsynchronized::he16000ea60a912d9
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x78411bf79cc5 - std::sys_common::backtrace::_print_fmt::h66ed1913530aa332
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x78411bf79cc5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4c845af9af61c9f6
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x78411bfca46b - core::fmt::rt::Argument::fmt::h76a6a089a8bf7b9e
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/core/src/fmt/rt.rs:165:63
   5:     0x78411bfca46b - core::fmt::write::h713abc82305939ad
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/core/src/fmt/mod.rs:1168:21
   6:     0x78411bf6ea4f - std::io::Write::write_fmt::hd65fb68dbcd2831c
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/std/src/io/mod.rs:1835:15
   7:     0x78411bf79a9e - std::sys_common::backtrace::_print::hd11b2dfc947c3c27
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x78411bf79a9e - std::sys_common::backtrace::print::h91e6f5059325feb3
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x78411bf7c4d9 - std::panicking::default_hook::{{closure}}::hfdb9c1cec82aff8b
  10:     0x78411bf7c27a - std::panicking::default_hook::hb086bae11ee046f4
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/std/src/panicking.rs:298:9
  11:     0x784118749fa0 - std[63b5957b5a953143]::panicking::update_hook::<alloc[cae7206fa00581b7]::boxed::Box<rustc_driver_impl[8353f43e004ca277]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x78411bf7cc0b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h9fe9d644c417a734
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/alloc/src/boxed.rs:2077:9
  13:     0x78411bf7cc0b - std::panicking::rust_panic_with_hook::h40c11300784b4c18
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/std/src/panicking.rs:799:13
  14:     0x78411877a024 - std[63b5957b5a953143]::panicking::begin_panic::<rustc_errors[3d0e8a3aa076f483]::ExplicitBug>::{closure#0}
  15:     0x784118776956 - std[63b5957b5a953143]::sys_common::backtrace::__rust_end_short_backtrace::<std[63b5957b5a953143]::panicking::begin_panic<rustc_errors[3d0e8a3aa076f483]::ExplicitBug>::{closure#0}, !>
  16:     0x784118771d36 - std[63b5957b5a953143]::panicking::begin_panic::<rustc_errors[3d0e8a3aa076f483]::ExplicitBug>
  17:     0x784118783481 - <rustc_errors[3d0e8a3aa076f483]::diagnostic::BugAbort as rustc_errors[3d0e8a3aa076f483]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  18:     0x784118c771ec - rustc_middle[6c616825b0bcdb80]::util::bug::opt_span_bug_fmt::<rustc_span[25512e2860c1584]::span_encoding::Span>::{closure#0}
  19:     0x784118c5b05a - rustc_middle[6c616825b0bcdb80]::ty::context::tls::with_opt::<rustc_middle[6c616825b0bcdb80]::util::bug::opt_span_bug_fmt<rustc_span[25512e2860c1584]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  20:     0x784118c5aefb - rustc_middle[6c616825b0bcdb80]::ty::context::tls::with_context_opt::<rustc_middle[6c616825b0bcdb80]::ty::context::tls::with_opt<rustc_middle[6c616825b0bcdb80]::util::bug::opt_span_bug_fmt<rustc_span[25512e2860c1584]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  21:     0x784116f28730 - rustc_middle[6c616825b0bcdb80]::util::bug::bug_fmt
  22:     0x784119d0accf - <rustc_borrowck[62809d0db1a30fbb]::type_check::TypeChecker>::push_region_constraints
  23:     0x78411aa7e8df - <rustc_borrowck[62809d0db1a30fbb]::type_check::TypeChecker>::ascribe_user_type
  24:     0x7841177fc232 - rustc_borrowck[62809d0db1a30fbb]::type_check::type_check
  25:     0x784116f8ee02 - rustc_borrowck[62809d0db1a30fbb]::nll::compute_regions
  26:     0x78411ab5222c - rustc_borrowck[62809d0db1a30fbb]::do_mir_borrowck
  27:     0x78411ab444cc - rustc_query_impl[cd510f8c05a0ea8a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[cd510f8c05a0ea8a]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[6c616825b0bcdb80]::query::erase::Erased<[u8; 8usize]>>
  28:     0x78411a2038c2 - rustc_query_system[93cd2bfd03b3866f]::query::plumbing::try_execute_query::<rustc_query_impl[cd510f8c05a0ea8a]::DynamicConfig<rustc_query_system[93cd2bfd03b3866f]::query::caches::VecCache<rustc_span[25512e2860c1584]::def_id::LocalDefId, rustc_middle[6c616825b0bcdb80]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[cd510f8c05a0ea8a]::plumbing::QueryCtxt, true>
  29:     0x78411a172074 - rustc_query_impl[cd510f8c05a0ea8a]::query_impl::mir_borrowck::get_query_incr::__rust_end_short_backtrace
  30:     0x784119ea1260 - rustc_middle[6c616825b0bcdb80]::query::plumbing::query_get_at::<rustc_query_system[93cd2bfd03b3866f]::query::caches::VecCache<rustc_span[25512e2860c1584]::def_id::LocalDefId, rustc_middle[6c616825b0bcdb80]::query::erase::Erased<[u8; 8usize]>>>
  31:     0x784119ea12ce - <rustc_borrowck[62809d0db1a30fbb]::type_check::TypeChecker>::prove_closure_bounds
  32:     0x784119edd3db - <rustc_borrowck[62809d0db1a30fbb]::type_check::TypeChecker>::typeck_mir
  33:     0x7841177fc2ef - rustc_borrowck[62809d0db1a30fbb]::type_check::type_check
  34:     0x784116f8ee02 - rustc_borrowck[62809d0db1a30fbb]::nll::compute_regions
  35:     0x78411ab5222c - rustc_borrowck[62809d0db1a30fbb]::do_mir_borrowck
  36:     0x78411ab444cc - rustc_query_impl[cd510f8c05a0ea8a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[cd510f8c05a0ea8a]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[6c616825b0bcdb80]::query::erase::Erased<[u8; 8usize]>>
  37:     0x78411a2038c2 - rustc_query_system[93cd2bfd03b3866f]::query::plumbing::try_execute_query::<rustc_query_impl[cd510f8c05a0ea8a]::DynamicConfig<rustc_query_system[93cd2bfd03b3866f]::query::caches::VecCache<rustc_span[25512e2860c1584]::def_id::LocalDefId, rustc_middle[6c616825b0bcdb80]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[cd510f8c05a0ea8a]::plumbing::QueryCtxt, true>
  38:     0x78411a172074 - rustc_query_impl[cd510f8c05a0ea8a]::query_impl::mir_borrowck::get_query_incr::__rust_end_short_backtrace
  39:     0x784119ea1260 - rustc_middle[6c616825b0bcdb80]::query::plumbing::query_get_at::<rustc_query_system[93cd2bfd03b3866f]::query::caches::VecCache<rustc_span[25512e2860c1584]::def_id::LocalDefId, rustc_middle[6c616825b0bcdb80]::query::erase::Erased<[u8; 8usize]>>>
  40:     0x784119ea12ce - <rustc_borrowck[62809d0db1a30fbb]::type_check::TypeChecker>::prove_closure_bounds
  41:     0x784119ed3d3a - <rustc_borrowck[62809d0db1a30fbb]::type_check::TypeChecker>::typeck_mir
  42:     0x7841177fc2ef - rustc_borrowck[62809d0db1a30fbb]::type_check::type_check
  43:     0x784116f8ee02 - rustc_borrowck[62809d0db1a30fbb]::nll::compute_regions
  44:     0x78411ab5222c - rustc_borrowck[62809d0db1a30fbb]::do_mir_borrowck
  45:     0x78411ab444cc - rustc_query_impl[cd510f8c05a0ea8a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[cd510f8c05a0ea8a]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[6c616825b0bcdb80]::query::erase::Erased<[u8; 8usize]>>
  46:     0x78411a2038c2 - rustc_query_system[93cd2bfd03b3866f]::query::plumbing::try_execute_query::<rustc_query_impl[cd510f8c05a0ea8a]::DynamicConfig<rustc_query_system[93cd2bfd03b3866f]::query::caches::VecCache<rustc_span[25512e2860c1584]::def_id::LocalDefId, rustc_middle[6c616825b0bcdb80]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[cd510f8c05a0ea8a]::plumbing::QueryCtxt, true>
  47:     0x78411a172074 - rustc_query_impl[cd510f8c05a0ea8a]::query_impl::mir_borrowck::get_query_incr::__rust_end_short_backtrace
  48:     0x78411a15e584 - rustc_interface[68582a38c0a5d471]::passes::analysis
  49:     0x78411a15d71b - rustc_query_impl[cd510f8c05a0ea8a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[cd510f8c05a0ea8a]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[6c616825b0bcdb80]::query::erase::Erased<[u8; 1usize]>>
  50:     0x78411a9a004e - rustc_query_system[93cd2bfd03b3866f]::query::plumbing::try_execute_query::<rustc_query_impl[cd510f8c05a0ea8a]::DynamicConfig<rustc_query_system[93cd2bfd03b3866f]::query::caches::SingleCache<rustc_middle[6c616825b0bcdb80]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[cd510f8c05a0ea8a]::plumbing::QueryCtxt, true>
  51:     0x78411a99fc7a - rustc_query_impl[cd510f8c05a0ea8a]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  52:     0x78411a7df0e0 - rustc_interface[68582a38c0a5d471]::interface::run_compiler::<core[b73d62a4aa8e98c4]::result::Result<(), rustc_span[25512e2860c1584]::ErrorGuaranteed>, rustc_driver_impl[8353f43e004ca277]::run_compiler::{closure#0}>::{closure#1}
  53:     0x78411a7cab89 - std[63b5957b5a953143]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[68582a38c0a5d471]::util::run_in_thread_with_globals<rustc_interface[68582a38c0a5d471]::util::run_in_thread_pool_with_globals<rustc_interface[68582a38c0a5d471]::interface::run_compiler<core[b73d62a4aa8e98c4]::result::Result<(), rustc_span[25512e2860c1584]::ErrorGuaranteed>, rustc_driver_impl[8353f43e004ca277]::run_compiler::{closure#0}>::{closure#1}, core[b73d62a4aa8e98c4]::result::Result<(), rustc_span[25512e2860c1584]::ErrorGuaranteed>>::{closure#0}, core[b73d62a4aa8e98c4]::result::Result<(), rustc_span[25512e2860c1584]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b73d62a4aa8e98c4]::result::Result<(), rustc_span[25512e2860c1584]::ErrorGuaranteed>>
  54:     0x78411a7ca940 - <<std[63b5957b5a953143]::thread::Builder>::spawn_unchecked_<rustc_interface[68582a38c0a5d471]::util::run_in_thread_with_globals<rustc_interface[68582a38c0a5d471]::util::run_in_thread_pool_with_globals<rustc_interface[68582a38c0a5d471]::interface::run_compiler<core[b73d62a4aa8e98c4]::result::Result<(), rustc_span[25512e2860c1584]::ErrorGuaranteed>, rustc_driver_impl[8353f43e004ca277]::run_compiler::{closure#0}>::{closure#1}, core[b73d62a4aa8e98c4]::result::Result<(), rustc_span[25512e2860c1584]::ErrorGuaranteed>>::{closure#0}, core[b73d62a4aa8e98c4]::result::Result<(), rustc_span[25512e2860c1584]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b73d62a4aa8e98c4]::result::Result<(), rustc_span[25512e2860c1584]::ErrorGuaranteed>>::{closure#2} as core[b73d62a4aa8e98c4]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  55:     0x78411bf86bfb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd9dcc2087244c614
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/alloc/src/boxed.rs:2063:9
  56:     0x78411bf86bfb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1ce3b5bddc9a8858
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/alloc/src/boxed.rs:2063:9
  57:     0x78411bf86bfb - std::sys::pal::unix::thread::Thread::new::thread_start::h3072c5274e382bf5
                               at /rustc/0038c021031ce9f1ec2329469c8d85d0e681ef8f/library/std/src/sys/pal/unix/thread.rs:108:17
  58:     0x7841154aa1cf - <unknown>
  59:     0x78411552b6ec - <unknown>
  60:                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: please make sure that you have updated to the latest nightly

note: rustc 1.80.0-nightly (0038c0210 2024-06-01) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z incremental-verify-ich=yes -C incremental=[REDACTED] -C debuginfo=2

query stack during panic:
#0 [mir_borrowck] borrow-checking `foo::{constant#0}`
#1 [mir_borrowck] borrow-checking `foo::{closure#0}`
end of query stack
error: aborting due to 3 previous errors; 1 warning emitted

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

@rustbot label +F-closure_lifetime_binder +F-inline_const

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.F-closure_lifetime_binder`#![feature(closure_lifetime_binder)]`F-inline_constInline constants (aka: const blocks, const expressions, anonymous constants)I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-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