[ICE]: expected region for `'_/#0` ('_/#0/0) but found Type(&'?2 &'?3 A<B>) when instantiating args=[&'?2 &'?3 A<B>]

オープン
#166,661 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
1〜2日
初心者へのやさしさ
52/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust
領域
compilers

調査の方向性

Start with the minimal Rust example in the issue and reproduce the ICE on the reported nightly; the backtrace points to rustc_hir_typeck method error reporting, especially create_no_assoc_err and report_no_match_method_error. Trace how the method lookup failure reaches binder argument instantiation, then add a regression test that compiles the example without an ICE. Done when rustc reports a normal diagnostic or successfully compiles the case.

索引モデルが issue の本文から書いたものです。

説明

A-diagnostics C-bug I-ICE I-should-error P-medium regression-from-stable-to-nightly T-compiler
Code
pub struct A<T>(T);
impl<T> A<T> { pub fn get(&self) -> &T { &self.0 } }
pub struct B;
pub struct P<const N: usize> { banks: [&'static A<B>; N] }
impl<const N: usize> P<N> {
    fn bank(&self, bank: u32) -> Option<&'static B> {
        Some(self.banks.get(bank as usize).copied().flatten()?.get())
    }
}

Playground link: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=dd083152473873491be411760402b4c9

Meta

rustc --version --verbose:

rustc 1.102.0-nightly (6c709eb42 2026-11-25) running on x86_64-unknown-linux-gnu
Error output
   Compiling playground v0.0.1 (/playground)

thread 'rustc' (35) panicked at /rustc-dev/6c709eb428d472a3c3d93681c1ba37d44a1c27cf/compiler/rustc_type_ir/src/binder.rs:862:9:
expected region for `'_/#0` ('_/#0/0) but found Type(&'?2 &'?3 A<B>) when instantiating args=[&'?2 &'?3 A<B>]
stack backtrace:
   0:     0x77cbdcc00b46 - <<std[7996f217f76eae40]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[349f372d9411a47f]::fmt::Display>::fmt
   1:     0x77cbdd79128f - core[349f372d9411a47f]::fmt::write
   2:     0x77cbdcc14b5c - <std[7996f217f76eae40]::sys::stdio::unix::Stderr as core[349f372d9411a47f]::io::write::Write>::write_fmt
   3:     0x77cbdcbd1f6a - std[7996f217f76eae40]::panicking::default_hook::{closure#0}
   4:     0x77cbdcbf4614 - std[7996f217f76eae40]::panicking::default_hook
   5:     0x77cbdb9374c1 - std[7996f217f76eae40]::panicking::update_hook::<alloc[4cd4321077e91eef]::boxed::Box<rustc_driver_impl[66eae6890348dd2b]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x77cbdcbf4ab2 - std[7996f217f76eae40]::panicking::panic_with_hook
   7:     0x77cbdcbd2022 - std[7996f217f76eae40]::panicking::panic_handler::{closure#0}
   8:     0x77cbdcbc9459 - std[7996f217f76eae40]::sys::backtrace::__rust_end_short_backtrace::<std[7996f217f76eae40]::panicking::panic_handler::{closure#0}, !>
   9:     0x77cbdcbd3d7d - __rustc[349f372d9411a47f]::rust_begin_unwind
  10:     0x77cbd94516ec - core[349f372d9411a47f]::panicking::panic_fmt
  11:     0x77cbdc041c41 - <rustc_type_ir[82e2de7369a8557d]::binder::ArgFolder<rustc_middle[ec142d33e8c5eb95]::ty::context::TyCtxt>>::region_param_expected
  12:     0x77cbdd3bbd01 - <rustc_type_ir[82e2de7369a8557d]::binder::ArgFolder<rustc_middle[ec142d33e8c5eb95]::ty::context::TyCtxt> as rustc_type_ir[82e2de7369a8557d]::fold::TypeFolder<rustc_middle[ec142d33e8c5eb95]::ty::context::TyCtxt>>::fold_ty
  13:     0x77cbdd3b902e - <rustc_type_ir[82e2de7369a8557d]::binder::ArgFolder<rustc_middle[ec142d33e8c5eb95]::ty::context::TyCtxt> as rustc_type_ir[82e2de7369a8557d]::fold::TypeFolder<rustc_middle[ec142d33e8c5eb95]::ty::context::TyCtxt>>::fold_ty
  14:     0x77cbdbbfed3a - <rustc_type_ir[82e2de7369a8557d]::binder::EarlyBinder<rustc_middle[ec142d33e8c5eb95]::ty::context::TyCtxt, rustc_type_ir[82e2de7369a8557d]::binder::Binder<rustc_middle[ec142d33e8c5eb95]::ty::context::TyCtxt, rustc_type_ir[82e2de7369a8557d]::ty_kind::FnSig<rustc_middle[ec142d33e8c5eb95]::ty::context::TyCtxt>>>>::instantiate::<rustc_middle[ec142d33e8c5eb95]::ty::generic_args::GenericArgs>
  15:     0x77cbdbce74de - <rustc_hir_typeck[24480ade3ee83d5d]::fn_ctxt::FnCtxt>::create_no_assoc_err
  16:     0x77cbdbcf7427 - <rustc_hir_typeck[24480ade3ee83d5d]::fn_ctxt::FnCtxt>::report_no_match_method_error
  17:     0x77cbdbce9d62 - <rustc_hir_typeck[24480ade3ee83d5d]::fn_ctxt::FnCtxt>::report_method_error
  18:     0x77cbdd332401 - <rustc_hir_typeck[24480ade3ee83d5d]::fn_ctxt::FnCtxt>::check_expr_method_call
  19:     0x77cbdd30c47f - <rustc_hir_typeck[24480ade3ee83d5d]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  20:     0x77cbdd362e0b - <rustc_hir_typeck[24480ade3ee83d5d]::fn_ctxt::FnCtxt>::check_expr_call
  21:     0x77cbdd30beed - <rustc_hir_typeck[24480ade3ee83d5d]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  22:     0x77cbdd47e13f - <rustc_hir_typeck[24480ade3ee83d5d]::fn_ctxt::FnCtxt>::check_expr_match
  23:     0x77cbdd30d644 - <rustc_hir_typeck[24480ade3ee83d5d]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  24:     0x77cbdd330a93 - <rustc_hir_typeck[24480ade3ee83d5d]::fn_ctxt::FnCtxt>::check_expr_method_call
  25:     0x77cbdd30c47f - <rustc_hir_typeck[24480ade3ee83d5d]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  26:     0x77cbdd362e0b - <rustc_hir_typeck[24480ade3ee83d5d]::fn_ctxt::FnCtxt>::check_expr_call
  27:     0x77cbdd30beed - <rustc_hir_typeck[24480ade3ee83d5d]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  28:     0x77cbdd4717d9 - <rustc_hir_typeck[24480ade3ee83d5d]::fn_ctxt::FnCtxt>::check_expr_block
  29:     0x77cbdd30c459 - <rustc_hir_typeck[24480ade3ee83d5d]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  30:     0x77cbdd478bed - rustc_hir_typeck[24480ade3ee83d5d]::check::check_fn
  31:     0x77cbde686314 - rustc_hir_typeck[24480ade3ee83d5d]::typeck_with_inspect::{closure#0}
  32:     0x77cbde684730 - rustc_query_impl[bf4840ef505b608b]::query_vtables::typeck_root::invoke_provider_fn::__rust_begin_short_backtrace
  33:     0x77cbdd93f84e - rustc_query_impl[bf4840ef505b608b]::execution::try_execute_query::<rustc_data_structures[6e9be8c11e50cfc1]::vec_cache::VecCache<rustc_span[bd609e2a3d3feb5f]::def_id::LocalDefId, rustc_middle[ec142d33e8c5eb95]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[ec142d33e8c5eb95]::dep_graph::graph::DepNodeIndex>, false>
  34:     0x77cbdd93f4a7 - rustc_query_impl[bf4840ef505b608b]::query_vtables::typeck_root::execute_query_non_incr::__rust_end_short_backtrace
  35:     0x77cbdd943143 - <rustc_middle[ec142d33e8c5eb95]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[a71b221c99bbd271]::check_crate::{closure#1}>::{closure#0}
  36:     0x77cbdbb8cb58 - <rustc_thread_pool[85a0ebbc3632f168]::job::HeapJob<<rustc_thread_pool[85a0ebbc3632f168]::scope::Scope>::spawn<rustc_data_structures[6e9be8c11e50cfc1]::sync::parallel::par_range_internal<rustc_data_structures[6e9be8c11e50cfc1]::sync::parallel::par_for_each_in<rustc_span[bd609e2a3d3feb5f]::def_id::LocalDefId, [rustc_span[bd609e2a3d3feb5f]::def_id::LocalDefId], <rustc_middle[ec142d33e8c5eb95]::ty::context::TyCtxt>::par_hir_body_owners<rustc_hir_analysis[a71b221c99bbd271]::check_crate::{closure#1}>::{closure#0}>::{closure#0}::{closure#0}>::{closure#1}::{closure#0}>::{closure#0}> as rustc_thread_pool[85a0ebbc3632f168]::job::Job>::execute
  37:     0x77cbde9d96be - <rustc_thread_pool[85a0ebbc3632f168]::registry::WorkerThread>::wait_or_steal_until_cold
  38:     0x77cbde9da821 - <rustc_thread_pool[85a0ebbc3632f168]::registry::ThreadBuilder>::run
  39:     0x77cbde9da66c - std[7996f217f76eae40]::sys::backtrace::__rust_begin_short_backtrace::<<rustc_thread_pool[85a0ebbc3632f168]::ThreadPoolBuilder>::build_scoped<rustc_interface[280c944d458a3ff4]::util::run_in_thread_pool_with_globals<rustc_interface[280c944d458a3ff4]::interface::run_compiler<(), rustc_driver_impl[66eae6890348dd2b]::compiler_entrypoint::{closure#0}>::{closure#2}, ()>::{closure#6}::{closure#0}::{closure#0}, rustc_interface[280c944d458a3ff4]::util::run_in_thread_pool_with_globals<rustc_interface[280c944d458a3ff4]::interface::run_compiler<(), rustc_driver_impl[66eae6890348dd2b]::compiler_entrypoint::{closure#0}>::{closure#2}, ()>::{closure#6}::{closure#0}::{closure#1}, ()>::{closure#0}::{closure#0}::{closure#0}, ()>
  40:     0x77cbde9da4fa - <std[7996f217f76eae40]::thread::lifecycle::spawn_unchecked<<rustc_thread_pool[85a0ebbc3632f168]::ThreadPoolBuilder>::build_scoped<rustc_interface[280c944d458a3ff4]::util::run_in_thread_pool_with_globals<rustc_interface[280c944d458a3ff4]::interface::run_compiler<(), rustc_driver_impl[66eae6890348dd2b]::compiler_entrypoint::{closure#0}>::{closure#2}, ()>::{closure#6}::{closure#0}::{closure#0}, rustc_interface[280c944d458a3ff4]::util::run_in_thread_pool_with_globals<rustc_interface[280c944d458a3ff4]::interface::run_compiler<(), rustc_driver_impl[66eae6890348dd2b]::compiler_entrypoint::{closure#0}>::{closure#2}, ()>::{closure#6}::{closure#0}::{closure#1}, ()>::{closure#0}::{closure#0}::{closure#0}, ()>::{closure#1} as core[349f372d9411a47f]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  41:     0x77cbde55c0a9 - <std[7996f217f76eae40]::sys::thread::unix::Thread>::new::thread_start
  42:     0x77cbd7689b64 - <unknown>
  43:     0x77cbd7716c84 - clone
  44:                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: please make sure that you have updated to the latest nightly

note: please attach the file at `/playground/rustc-ice-2026-11-27T15_42_37-31.txt` to your bug report

note: rustc 1.102.0-nightly (6c709eb42 2026-11-25) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -Z embed-metadata=no -C embed-bitcode=no -C codegen-units=1 -C debuginfo=line-tables-only

note: some of the compiler flags provided by cargo are hidden


Backtrace

<backtrace>

主要言語
Rust
スター
123k
フォーク
16.6k
平均マージ
2日 17時間
マージ済み PR(30日)
532

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

rust-lang/rust のほかの issue

rust-lang/rust の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。