Skip to content

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

Backlog

Description

@xobs

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>

Activity

  1. added
    I-ICE
    T-compiler
    C-bug
    on Nov 27, 2026
  2. added
    needs-triage
    on Nov 27, 2026
  3. seritools commented on Nov 27, 2026

    @seritools
    Contributor

    output on beta/stable/pre-regression:

    error[E0599]: no method named `flatten` found for enum `Option<&A<B>>` in the current scope
      --> src/lib.rs:13:53
       |
    13 |         Some(self.banks.get(bank as usize).copied().flatten()?.get())
       |                                                     ^^^^^^^ `Option<&A<B>>` is not an iterator
       |
    help: call `.into_iter()` first
       |
    13 |         Some(self.banks.get(bank as usize).copied().into_iter().flatten()?.get())
       |                                                     ++++++++++++
    
    For more information about this error, try `rustc --explain E0599`.
    error: could not compile `ice-melter` (lib) due to 1 previous error
    

    bisected with cargo bisect-rustc --start=2026-11-13 --regress ice:

    Regression in d521bfb. Note that if it is a legacy rollup build, it might be available in rust-lang-ci@d521bfb.
    The PR introducing the regression in this rollup is #166006: Detect method shadowed by another when accessing a field or calling method that isn't found in method chain (CC @estebank)

    searched nightlies: from nightly-2026-11-13 to nightly-2026-11-26
    regressed nightly: nightly-2026-11-19
    searched commit range: 59cbdee...65ce861
    regressed commit: 412be32

    bisected with cargo-bisect-rustc v0.6.12

    Host triple: x86_64-unknown-linux-gnu
    Reproduce with:

    cargo bisect-rustc --start=2026-11-13 --regress ice 
  4. estebank commented on Nov 27, 2026

    @estebank
    Contributor

    Cc #166275
    Should be fixed by #166338

  5. added
    A-diagnostics
    P-medium
    regression-from-stable-to-nightly
    I-should-error
    and removed
    needs-triage
    on Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsC-bugI-ICEI-should-errorP-mediumT-compilerregression-from-stable-to-nightly

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions