Skip to content

ICE: cannot convert 'a/#1 to a region vid #146956

@rucsesec

Description

@rucsesec

I believe it is a duplicate of #131295, but there seem to be some differences. It doesn't require the use of "async" and "trait object (dyn)". The issue can also be triggered by using "opaque type (impl trait)" in a regular function.

Code

#![feature(generic_const_exprs)]

trait MyTrait<T> {}

fn bug<'a>() -> impl MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
    todo!()
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.92.0-nightly (dd7fda570 2025-09-20)
binary: rustc
commit-hash: dd7fda570040e8a736f7d8bc28ddd1b444aabc82
commit-date: 2025-09-20
host: x86_64-unknown-linux-gnu
release: 1.92.0-nightly
LLVM version: 21.1.1

Error output

warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> <source>: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[E0277]: the trait bound `!: MyTrait<[(); { |x: &'a u32| { x }; 4 }]>` is not satisfied
 --> <source>:5:17
  |
5 | fn bug<'a>() -> impl MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
  |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MyTrait<[(); { |x: &'a u32| { x }; 4 }]>` is not implemented for `!`
6 |     todo!()
  |     ------- return type was inferred to be `!` here
  |
help: this trait has no implementations, consider adding one
 --> <source>:3:1
  |
3 | trait MyTrait<T> {}
  | ^^^^^^^^^^^^^^^^

error: internal compiler error: compiler/rustc_borrowck/src/universal_regions.rs:930:36: cannot convert `'a/#1` to a region vid


thread 'rustc' (3) panicked at compiler/rustc_borrowck/src/universal_regions.rs:930:36:
Box<dyn Any>
Backtrace

stack backtrace:
   0:     0x7e68c6405953 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h1d9a860939142303
   1:     0x7e68c6c01fc4 - core::fmt::write::h4cde2f6e6eca889f
   2:     0x7e68c63ba5f1 - std::io::Write::write_fmt::hbbb02a45894db6e0
   3:     0x7e68c63cb5d2 - std::sys::backtrace::BacktraceLock::print::hfcdaff63564fa703
   4:     0x7e68c63d1539 - std::panicking::default_hook::{{closure}}::hcc588fdbd9e0eddf
   5:     0x7e68c63d1063 - std::panicking::default_hook::h21841b6cba7fa436
   6:     0x7e68c53f5bd7 - std[6c96415bc1a38016]::panicking::update_hook::<alloc[c6e2df4d00e1f0b6]::boxed::Box<rustc_driver_impl[459800387efcc559]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7e68c63d195f - std::panicking::panic_with_hook::hedf05123aa8b61bb
   8:     0x7e68c5432471 - std[6c96415bc1a38016]::panicking::begin_panic::<rustc_errors[af568b6d67acca2f]::ExplicitBug>::{closure#0}
   9:     0x7e68c5425c86 - std[6c96415bc1a38016]::sys::backtrace::__rust_end_short_backtrace::<std[6c96415bc1a38016]::panicking::begin_panic<rustc_errors[af568b6d67acca2f]::ExplicitBug>::{closure#0}, !>
  10:     0x7e68c5423729 - std[6c96415bc1a38016]::panicking::begin_panic::<rustc_errors[af568b6d67acca2f]::ExplicitBug>
  11:     0x7e68c543db61 - <rustc_errors[af568b6d67acca2f]::diagnostic::BugAbort as rustc_errors[af568b6d67acca2f]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x7e68c59cfdba - rustc_middle[e11099e36afb5411]::util::bug::opt_span_bug_fmt::<rustc_span[9408016a182fdcc0]::span_encoding::Span>::{closure#0}
  13:     0x7e68c59cff7a - rustc_middle[e11099e36afb5411]::ty::context::tls::with_opt::<rustc_middle[e11099e36afb5411]::util::bug::opt_span_bug_fmt<rustc_span[9408016a182fdcc0]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7e68c59beb4b - rustc_middle[e11099e36afb5411]::ty::context::tls::with_context_opt::<rustc_middle[e11099e36afb5411]::ty::context::tls::with_opt<rustc_middle[e11099e36afb5411]::util::bug::opt_span_bug_fmt<rustc_span[9408016a182fdcc0]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7e68c3ab9200 - rustc_middle[e11099e36afb5411]::util::bug::bug_fmt
  16:     0x7e68c74fcef6 - <rustc_borrowck[dd44c889f7481f64]::type_check::constraint_conversion::ConstraintConversion>::convert_all
  17:     0x7e68c72bde9d - <rustc_borrowck[dd44c889f7481f64]::type_check::TypeChecker>::ascribe_user_type_skip_wf
  18:     0x7e68c75658aa - rustc_borrowck[dd44c889f7481f64]::type_check::type_check
  19:     0x7e68c7db5e40 - <rustc_borrowck[dd44c889f7481f64]::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
  20:     0x7e68c7dae417 - rustc_borrowck[dd44c889f7481f64]::mir_borrowck
  21:     0x7e68c7dae1dd - rustc_query_impl[8ceca73aa722394f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8ceca73aa722394f]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e11099e36afb5411]::query::erase::Erased<[u8; 8usize]>>
  22:     0x7e68c6de74c4 - rustc_query_system[44f2cb83942a7389]::query::plumbing::try_execute_query::<rustc_query_impl[8ceca73aa722394f]::DynamicConfig<rustc_data_structures[e568e5fb65a8620a]::vec_cache::VecCache<rustc_span[9408016a182fdcc0]::def_id::LocalDefId, rustc_middle[e11099e36afb5411]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[44f2cb83942a7389]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[8ceca73aa722394f]::plumbing::QueryCtxt, false>
  23:     0x7e68c6debe09 - rustc_query_impl[8ceca73aa722394f]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  24:     0x7e68c6debfbc - <rustc_middle[e11099e36afb5411]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[f4ad0248271d71d8]::passes::run_required_analyses::{closure#1}::{closure#0}>::{closure#0}
  25:     0x7e68c6de93cc - rustc_interface[f4ad0248271d71d8]::passes::analysis
  26:     0x7e68c6de886d - rustc_query_impl[8ceca73aa722394f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8ceca73aa722394f]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e11099e36afb5411]::query::erase::Erased<[u8; 0usize]>>
  27:     0x7e68c7c65526 - rustc_query_system[44f2cb83942a7389]::query::plumbing::try_execute_query::<rustc_query_impl[8ceca73aa722394f]::DynamicConfig<rustc_query_system[44f2cb83942a7389]::query::caches::SingleCache<rustc_middle[e11099e36afb5411]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[8ceca73aa722394f]::plumbing::QueryCtxt, false>
  28:     0x7e68c7c6517c - rustc_query_impl[8ceca73aa722394f]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7e68c7e72d4f - rustc_interface[f4ad0248271d71d8]::passes::create_and_enter_global_ctxt::<core[88dcab6addd45e6c]::option::Option<rustc_interface[f4ad0248271d71d8]::queries::Linker>, rustc_driver_impl[459800387efcc559]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  30:     0x7e68c7de96be - rustc_interface[f4ad0248271d71d8]::interface::run_compiler::<(), rustc_driver_impl[459800387efcc559]::run_compiler::{closure#0}>::{closure#1}
  31:     0x7e68c7d482f8 - std[6c96415bc1a38016]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[f4ad0248271d71d8]::util::run_in_thread_with_globals<rustc_interface[f4ad0248271d71d8]::util::run_in_thread_pool_with_globals<rustc_interface[f4ad0248271d71d8]::interface::run_compiler<(), rustc_driver_impl[459800387efcc559]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  32:     0x7e68c7d47fdc - <<std[6c96415bc1a38016]::thread::Builder>::spawn_unchecked_<rustc_interface[f4ad0248271d71d8]::util::run_in_thread_with_globals<rustc_interface[f4ad0248271d71d8]::util::run_in_thread_pool_with_globals<rustc_interface[f4ad0248271d71d8]::interface::run_compiler<(), rustc_driver_impl[459800387efcc559]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[88dcab6addd45e6c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x7e68c7d4e68d - std::sys::thread::unix::Thread::new::thread_start::hb28ad79a6a69b48c
  34:     0x7e68c1494ac3 - <unknown>
  35:     0x7e68c1526850 - <unknown>
  36:                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: please attach the file at `/app/rustc-ice-2025-09-24T03_08_10-1.txt` to your bug report

note: compiler flags: -C debuginfo=2 --crate-type bin -C linker=/opt/compiler-explorer/gcc-15.2.0/bin/gcc

query stack during panic:
#0 [mir_borrowck] borrow-checking `bug::{opaque#0}::{constant#0}`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0277`.```

</p>
</details>

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-generic_const_exprs`#![feature(generic_const_exprs)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-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