Skip to content

called Option::unwrap() on a None value in compiler/rustc_hir_analysis/src/delegation.rs #128810

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
Naserume opened this issue Aug 8, 2024 · 1 comment · Fixed by #129168
Closed
Assignees
Labels
A-HIR Area: The high-level intermediate representation (HIR) C-bug Category: This is a bug. F-fn_delegation `#![feature(fn_delegation)]` 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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Naserume
Copy link

Naserume commented Aug 8, 2024

Code

#![feature(fn_delegation)]

use std::marker::PhantomData;

pub struct InvariantRef<'a, T: ?Sized>(&'a T, PhantomData<&'a mut &'a T>);

impl<'a> InvariantRef<'a, ()> {
    pub const NEW: Self = InvariantRef::new(&());
}

trait Trait {
    fn foo(&self) -> u8 { 0 }
}

struct Z(u8);

impl Trait for Z {
    reuse <u8 as Trait>::{foo} { &const { InvariantRef::<'a>::NEW } }
}

fn main() { }

Meta

rustc --version --verbose:

rustc 1.82.0-nightly (60d146580 2024-08-06)
binary: rustc
commit-hash: 60d146580c10036ce89e019422c6bc2fd9729b65
commit-date: 2024-08-06
host: x86_64-apple-darwin
release: 1.82.0-nightly
LLVM version: 19.1.0

Error output

error[E0261]: use of undeclared lifetime name `'a`
  --> ./1E910.rs:18:58
   |
18 |     reuse <u8 as Trait>::{foo} { &const { InvariantRef::<'a>::NEW } }
   |                                                          ^^ undeclared lifetime
   |
help: consider introducing lifetime `'a` here
   |
18 |     reuse <u8 as Trait>::{foo'a, } { &const { InvariantRef::<'a>::NEW } }
   |                              +++
help: consider introducing lifetime `'a` here
   |
17 | impl<'a> Trait for Z {
   |     ++++

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

error[E0599]: no function or associated item named `new` found for struct `InvariantRef` in the current scope
 --> ./1E910.rs:8:41
  |
5 | pub struct InvariantRef<'a, T: ?Sized>(&'a T, PhantomData<&'a mut &'a T>);
  | -------------------------------------- function or associated item `new` not found for this struct
...
8 |     pub const NEW: Self = InvariantRef::new(&());
  |                                         ^^^ function or associated item not found in `InvariantRef<'_, _>`

Backtrace

thread 'rustc' panicked at compiler/rustc_hir_analysis/src/delegation.rs:245:58:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:        0x104af3eb7 - std::backtrace::Backtrace::create::hab0b2157d02f6e92
   1:        0x104af3e05 - std::backtrace::Backtrace::force_capture::h20bc09614659a271
   2:        0x10e16f2b4 - std[513de39480af1bab]::panicking::update_hook::<alloc[88fbee91b568d05e]::boxed::Box<rustc_driver_impl[1a7a7dac5035a0ee]::install_ice_hook::{closure#0}>>::{closure#0}
   3:        0x104b0ded0 - std::panicking::rust_panic_with_hook::h68d7251319b974a6
   4:        0x104b0d722 - std::panicking::begin_panic_handler::{{closure}}::ha88851b9fb268d98
   5:        0x104b0acd9 - std::sys::backtrace::__rust_end_short_backtrace::h5540b8654da0543b
   6:        0x104b0d39c - _rust_begin_unwind
   7:        0x104b74aea - core::panicking::panic_fmt::h6a779485efe923d2
   8:        0x104b74b94 - core::panicking::panic::h222bc2761b0de3d1
   9:        0x104b74a38 - core::option::unwrap_failed::h5fc060f6c9bf92ba
  10:        0x10e5127d2 - rustc_hir_analysis[540b4a187aa4fa02]::delegation::inherit_sig_for_delegation_item
  11:        0x10f81956b - rustc_query_impl[db7d5818ebb544c0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[db7d5818ebb544c0]::query_impl::inherit_sig_for_delegation_item::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 16usize]>>
  12:        0x10f7e0b9e - <rustc_query_impl[db7d5818ebb544c0]::query_impl::inherit_sig_for_delegation_item::dynamic_query::{closure#2} as core[31c80208252ed77d]::ops::function::FnOnce<(rustc_middle[ef4ebef1f35b9a45]::ty::context::TyCtxt, rustc_span[af5dc13a57d4458]::def_id::LocalDefId)>>::call_once
  13:        0x10f6933e5 - rustc_query_system[9c8bd583e072577f]::query::plumbing::try_execute_query::<rustc_query_impl[db7d5818ebb544c0]::DynamicConfig<rustc_query_system[9c8bd583e072577f]::query::caches::VecCache<rustc_span[af5dc13a57d4458]::def_id::LocalDefId, rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[db7d5818ebb544c0]::plumbing::QueryCtxt, false>
  14:        0x10f867b57 - rustc_query_impl[db7d5818ebb544c0]::query_impl::inherit_sig_for_delegation_item::get_query_non_incr::__rust_end_short_backtrace
  15:        0x10e5a21f7 - <dyn rustc_hir_analysis[540b4a187aa4fa02]::hir_ty_lowering::HirTyLowerer>::lower_ty_common::{closure#0}
  16:        0x10e86bad0 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::suggest_missing_return_type
  17:        0x10e7585aa - <rustc_hir_typeck[d66b43df352b27be]::coercion::CoerceMany<rustc_hir[53162fccad4b280c]::hir::Expr>>::report_return_mismatched_types
  18:        0x10e7b5007 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_block_with_expected
  19:        0x10e76f684 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  20:        0x10e84e499 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_kind
  21:        0x10e76f684 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  22:        0x10e84bd10 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_kind
  23:        0x10e76f684 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  24:        0x10e7a47cb - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_argument_types
  25:        0x10e743e5d - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::confirm_builtin_call
  26:        0x10e8549ab - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_kind
  27:        0x10e76f684 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  28:        0x10e7b3904 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_block_with_expected
  29:        0x10e76f684 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  30:        0x10e7718b3 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_return_expr
  31:        0x10e836ccc - rustc_hir_typeck[d66b43df352b27be]::check::check_fn
  32:        0x10e8317e8 - rustc_hir_typeck[d66b43df352b27be]::typeck
  33:        0x10f819e5c - rustc_query_impl[db7d5818ebb544c0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[db7d5818ebb544c0]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 8usize]>>
  34:        0x10f68ed4e - rustc_query_system[9c8bd583e072577f]::query::plumbing::try_execute_query::<rustc_query_impl[db7d5818ebb544c0]::DynamicConfig<rustc_query_system[9c8bd583e072577f]::query::caches::VecCache<rustc_hir[53162fccad4b280c]::hir_id::OwnerId, rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[db7d5818ebb544c0]::plumbing::QueryCtxt, false>
  35:        0x10f83dde1 - rustc_query_impl[db7d5818ebb544c0]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  36:        0x10e4081a6 - <rustc_middle[ef4ebef1f35b9a45]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[540b4a187aa4fa02]::check_crate::{closure#4}>::{closure#0}
  37:        0x10e570d1c - rustc_hir_analysis[540b4a187aa4fa02]::check_crate
  38:        0x10eab2f98 - rustc_interface[55f0bb586236ba3f]::passes::run_required_analyses
  39:        0x10eab5463 - rustc_interface[55f0bb586236ba3f]::passes::analysis
  40:        0x10f819f0c - rustc_query_impl[db7d5818ebb544c0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[db7d5818ebb544c0]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 1usize]>>
  41:        0x10f5f8d8e - rustc_query_system[9c8bd583e072577f]::query::plumbing::try_execute_query::<rustc_query_impl[db7d5818ebb544c0]::DynamicConfig<rustc_query_system[9c8bd583e072577f]::query::caches::SingleCache<rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[db7d5818ebb544c0]::plumbing::QueryCtxt, false>
  42:        0x10f82445d - rustc_query_impl[db7d5818ebb544c0]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  43:        0x10e119c67 - <rustc_interface[55f0bb586236ba3f]::queries::QueryResult<&rustc_middle[ef4ebef1f35b9a45]::ty::context::GlobalCtxt>>::enter::<core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>, rustc_driver_impl[1a7a7dac5035a0ee]::run_compiler::{closure#0}::{closure#1}::{closure#5}>
  44:        0x10e1765a9 - rustc_interface[55f0bb586236ba3f]::interface::run_compiler::<core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>, rustc_driver_impl[1a7a7dac5035a0ee]::run_compiler::{closure#0}>::{closure#1}
  45:        0x10e1619c1 - std[513de39480af1bab]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[55f0bb586236ba3f]::util::run_in_thread_with_globals<rustc_interface[55f0bb586236ba3f]::util::run_in_thread_pool_with_globals<rustc_interface[55f0bb586236ba3f]::interface::run_compiler<core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>, rustc_driver_impl[1a7a7dac5035a0ee]::run_compiler::{closure#0}>::{closure#1}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#0}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>
  46:        0x10e178a06 - <<std[513de39480af1bab]::thread::Builder>::spawn_unchecked_<rustc_interface[55f0bb586236ba3f]::util::run_in_thread_with_globals<rustc_interface[55f0bb586236ba3f]::util::run_in_thread_pool_with_globals<rustc_interface[55f0bb586236ba3f]::interface::run_compiler<core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>, rustc_driver_impl[1a7a7dac5035a0ee]::run_compiler::{closure#0}>::{closure#1}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#0}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#1} as core[31c80208252ed77d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  47:        0x104b16afb - std::sys::pal::unix::thread::Thread::new::thread_start::h38612934f7248e43
  48:     0x7ff801f5318b - __pthread_start


rustc version: 1.82.0-nightly (60d146580 2024-08-06)
platform: x86_64-apple-darwin

query stack during panic:
#0 [inherit_sig_for_delegation_item] inheriting delegation signature
#1 [typeck] type-checking `<impl at ./1E910.rs:17:1: 17:17>::foo`
#2 [analysis] running analysis passes on this crate
end of query stack

Note

ICE location

pub(crate) fn inherit_sig_for_delegation_item<'tcx>(
tcx: TyCtxt<'tcx>,
def_id: LocalDefId,
) -> &'tcx [Ty<'tcx>] {
let sig_id = tcx.hir().opt_delegation_sig_id(def_id).unwrap();
let caller_sig = tcx.fn_sig(sig_id);
if let Err(err) = check_constraints(tcx, def_id, sig_id) {
let sig_len = caller_sig.instantiate_identity().skip_binder().inputs().len() + 1;
let err_type = Ty::new_error(tcx, err);
return tcx.arena.alloc_from_iter((0..sig_len).map(|_| err_type));
}

@rustbot label +F-fn_delegation

@Naserume Naserume added C-bug Category: This is a bug. 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. labels Aug 8, 2024
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. F-fn_delegation `#![feature(fn_delegation)]` labels Aug 8, 2024
@Naserume
Copy link
Author

Naserume commented Aug 8, 2024

Adding more methods in trait creates more ICE 👀

#![feature(fn_delegation)]

use std::marker::PhantomData;

pub struct InvariantRef<'a, T: ?Sized>(&'a T, PhantomData<&'a mut &'a T>);

impl<'a> InvariantRef<'a, ()> {
    pub const NEW: Self = InvariantRef::new(&());
}

trait Trait {
    fn foo(&self) -> u8 { 0 }
    fn bar(&self) -> u8 { 1 }
    fn meh(&self) -> u8 { 2 }
}

struct Z(u8);

impl Trait for Z {
    reuse <u8 as Trait>::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } }
}

fn main() { }
Backtrace

thread 'rustc' panicked at compiler/rustc_hir_analysis/src/delegation.rs:245:58:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:        0x1057f3eb7 - std::backtrace::Backtrace::create::hab0b2157d02f6e92
   1:        0x1057f3e05 - std::backtrace::Backtrace::force_capture::h20bc09614659a271
   2:        0x10ee6f2b4 - std[513de39480af1bab]::panicking::update_hook::<alloc[88fbee91b568d05e]::boxed::Box<rustc_driver_impl[1a7a7dac5035a0ee]::install_ice_hook::{closure#0}>>::{closure#0}
   3:        0x10580ded0 - std::panicking::rust_panic_with_hook::h68d7251319b974a6
   4:        0x10580d722 - std::panicking::begin_panic_handler::{{closure}}::ha88851b9fb268d98
   5:        0x10580acd9 - std::sys::backtrace::__rust_end_short_backtrace::h5540b8654da0543b
   6:        0x10580d39c - _rust_begin_unwind
   7:        0x105874aea - core::panicking::panic_fmt::h6a779485efe923d2
   8:        0x105874b94 - core::panicking::panic::h222bc2761b0de3d1
   9:        0x105874a38 - core::option::unwrap_failed::h5fc060f6c9bf92ba
  10:        0x10f2127d2 - rustc_hir_analysis[540b4a187aa4fa02]::delegation::inherit_sig_for_delegation_item
  11:        0x11051956b - rustc_query_impl[db7d5818ebb544c0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[db7d5818ebb544c0]::query_impl::inherit_sig_for_delegation_item::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 16usize]>>
  12:        0x1104e0b9e - <rustc_query_impl[db7d5818ebb544c0]::query_impl::inherit_sig_for_delegation_item::dynamic_query::{closure#2} as core[31c80208252ed77d]::ops::function::FnOnce<(rustc_middle[ef4ebef1f35b9a45]::ty::context::TyCtxt, rustc_span[af5dc13a57d4458]::def_id::LocalDefId)>>::call_once
  13:        0x1103933e5 - rustc_query_system[9c8bd583e072577f]::query::plumbing::try_execute_query::<rustc_query_impl[db7d5818ebb544c0]::DynamicConfig<rustc_query_system[9c8bd583e072577f]::query::caches::VecCache<rustc_span[af5dc13a57d4458]::def_id::LocalDefId, rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[db7d5818ebb544c0]::plumbing::QueryCtxt, false>
  14:        0x110567b57 - rustc_query_impl[db7d5818ebb544c0]::query_impl::inherit_sig_for_delegation_item::get_query_non_incr::__rust_end_short_backtrace
  15:        0x10f2a21f7 - <dyn rustc_hir_analysis[540b4a187aa4fa02]::hir_ty_lowering::HirTyLowerer>::lower_ty_common::{closure#0}
  16:        0x10f56bad0 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::suggest_missing_return_type
  17:        0x10f4585aa - <rustc_hir_typeck[d66b43df352b27be]::coercion::CoerceMany<rustc_hir[53162fccad4b280c]::hir::Expr>>::report_return_mismatched_types
  18:        0x10f4b5007 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_block_with_expected
  19:        0x10f46f684 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  20:        0x10f54e499 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_kind
  21:        0x10f46f684 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  22:        0x10f54bd10 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_kind
  23:        0x10f46f684 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  24:        0x10f4a47cb - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_argument_types
  25:        0x10f443e5d - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::confirm_builtin_call
  26:        0x10f5549ab - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_kind
  27:        0x10f46f684 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  28:        0x10f4b3904 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_block_with_expected
  29:        0x10f46f684 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  30:        0x10f4718b3 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_return_expr
  31:        0x10f536ccc - rustc_hir_typeck[d66b43df352b27be]::check::check_fn
  32:        0x10f5317e8 - rustc_hir_typeck[d66b43df352b27be]::typeck
  33:        0x110519e5c - rustc_query_impl[db7d5818ebb544c0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[db7d5818ebb544c0]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 8usize]>>
  34:        0x11038ed4e - rustc_query_system[9c8bd583e072577f]::query::plumbing::try_execute_query::<rustc_query_impl[db7d5818ebb544c0]::DynamicConfig<rustc_query_system[9c8bd583e072577f]::query::caches::VecCache<rustc_hir[53162fccad4b280c]::hir_id::OwnerId, rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[db7d5818ebb544c0]::plumbing::QueryCtxt, false>
  35:        0x11053dde1 - rustc_query_impl[db7d5818ebb544c0]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  36:        0x10f1081a6 - <rustc_middle[ef4ebef1f35b9a45]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[540b4a187aa4fa02]::check_crate::{closure#4}>::{closure#0}
  37:        0x10f270d1c - rustc_hir_analysis[540b4a187aa4fa02]::check_crate
  38:        0x10f7b2f98 - rustc_interface[55f0bb586236ba3f]::passes::run_required_analyses
  39:        0x10f7b5463 - rustc_interface[55f0bb586236ba3f]::passes::analysis
  40:        0x110519f0c - rustc_query_impl[db7d5818ebb544c0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[db7d5818ebb544c0]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 1usize]>>
  41:        0x1102f8d8e - rustc_query_system[9c8bd583e072577f]::query::plumbing::try_execute_query::<rustc_query_impl[db7d5818ebb544c0]::DynamicConfig<rustc_query_system[9c8bd583e072577f]::query::caches::SingleCache<rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[db7d5818ebb544c0]::plumbing::QueryCtxt, false>
  42:        0x11052445d - rustc_query_impl[db7d5818ebb544c0]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  43:        0x10ee19c67 - <rustc_interface[55f0bb586236ba3f]::queries::QueryResult<&rustc_middle[ef4ebef1f35b9a45]::ty::context::GlobalCtxt>>::enter::<core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>, rustc_driver_impl[1a7a7dac5035a0ee]::run_compiler::{closure#0}::{closure#1}::{closure#5}>
  44:        0x10ee765a9 - rustc_interface[55f0bb586236ba3f]::interface::run_compiler::<core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>, rustc_driver_impl[1a7a7dac5035a0ee]::run_compiler::{closure#0}>::{closure#1}
  45:        0x10ee619c1 - std[513de39480af1bab]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[55f0bb586236ba3f]::util::run_in_thread_with_globals<rustc_interface[55f0bb586236ba3f]::util::run_in_thread_pool_with_globals<rustc_interface[55f0bb586236ba3f]::interface::run_compiler<core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>, rustc_driver_impl[1a7a7dac5035a0ee]::run_compiler::{closure#0}>::{closure#1}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#0}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>
  46:        0x10ee78a06 - <<std[513de39480af1bab]::thread::Builder>::spawn_unchecked_<rustc_interface[55f0bb586236ba3f]::util::run_in_thread_with_globals<rustc_interface[55f0bb586236ba3f]::util::run_in_thread_pool_with_globals<rustc_interface[55f0bb586236ba3f]::interface::run_compiler<core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>, rustc_driver_impl[1a7a7dac5035a0ee]::run_compiler::{closure#0}>::{closure#1}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#0}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#1} as core[31c80208252ed77d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  47:        0x105816afb - std::sys::pal::unix::thread::Thread::new::thread_start::h38612934f7248e43
  48:     0x7ff801f5318b - __pthread_start


rustc version: 1.82.0-nightly (60d146580 2024-08-06)
platform: x86_64-apple-darwin

query stack during panic:
#0 [inherit_sig_for_delegation_item] inheriting delegation signature
#1 [typeck] type-checking `<impl at ./1E910.rs:19:1: 19:17>::foo`
#2 [analysis] running analysis passes on this crate
end of query stack
thread 'rustc' panicked at compiler/rustc_hir_analysis/src/delegation.rs:245:58:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:        0x1057f3eb7 - std::backtrace::Backtrace::create::hab0b2157d02f6e92
   1:        0x1057f3e05 - std::backtrace::Backtrace::force_capture::h20bc09614659a271
   2:        0x10ee6f2b4 - std[513de39480af1bab]::panicking::update_hook::<alloc[88fbee91b568d05e]::boxed::Box<rustc_driver_impl[1a7a7dac5035a0ee]::install_ice_hook::{closure#0}>>::{closure#0}
   3:        0x10580ded0 - std::panicking::rust_panic_with_hook::h68d7251319b974a6
   4:        0x10580d722 - std::panicking::begin_panic_handler::{{closure}}::ha88851b9fb268d98
   5:        0x10580acd9 - std::sys::backtrace::__rust_end_short_backtrace::h5540b8654da0543b
   6:        0x10580d39c - _rust_begin_unwind
   7:        0x105874aea - core::panicking::panic_fmt::h6a779485efe923d2
   8:        0x105874b94 - core::panicking::panic::h222bc2761b0de3d1
   9:        0x105874a38 - core::option::unwrap_failed::h5fc060f6c9bf92ba
  10:        0x10f2127d2 - rustc_hir_analysis[540b4a187aa4fa02]::delegation::inherit_sig_for_delegation_item
  11:        0x11051956b - rustc_query_impl[db7d5818ebb544c0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[db7d5818ebb544c0]::query_impl::inherit_sig_for_delegation_item::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 16usize]>>
  12:        0x1104e0b9e - <rustc_query_impl[db7d5818ebb544c0]::query_impl::inherit_sig_for_delegation_item::dynamic_query::{closure#2} as core[31c80208252ed77d]::ops::function::FnOnce<(rustc_middle[ef4ebef1f35b9a45]::ty::context::TyCtxt, rustc_span[af5dc13a57d4458]::def_id::LocalDefId)>>::call_once
  13:        0x1103933e5 - rustc_query_system[9c8bd583e072577f]::query::plumbing::try_execute_query::<rustc_query_impl[db7d5818ebb544c0]::DynamicConfig<rustc_query_system[9c8bd583e072577f]::query::caches::VecCache<rustc_span[af5dc13a57d4458]::def_id::LocalDefId, rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[db7d5818ebb544c0]::plumbing::QueryCtxt, false>
  14:        0x110567b57 - rustc_query_impl[db7d5818ebb544c0]::query_impl::inherit_sig_for_delegation_item::get_query_non_incr::__rust_end_short_backtrace
  15:        0x10f2a21f7 - <dyn rustc_hir_analysis[540b4a187aa4fa02]::hir_ty_lowering::HirTyLowerer>::lower_ty_common::{closure#0}
  16:        0x10f56bad0 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::suggest_missing_return_type
  17:        0x10f4585aa - <rustc_hir_typeck[d66b43df352b27be]::coercion::CoerceMany<rustc_hir[53162fccad4b280c]::hir::Expr>>::report_return_mismatched_types
  18:        0x10f4b5007 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_block_with_expected
  19:        0x10f46f684 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  20:        0x10f54e499 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_kind
  21:        0x10f46f684 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  22:        0x10f54bd10 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_kind
  23:        0x10f46f684 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  24:        0x10f4a47cb - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_argument_types
  25:        0x10f443e5d - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::confirm_builtin_call
  26:        0x10f5549ab - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_kind
  27:        0x10f46f684 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  28:        0x10f4b3904 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_block_with_expected
  29:        0x10f46f684 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  30:        0x10f4718b3 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_return_expr
  31:        0x10f536ccc - rustc_hir_typeck[d66b43df352b27be]::check::check_fn
  32:        0x10f5317e8 - rustc_hir_typeck[d66b43df352b27be]::typeck
  33:        0x110519e5c - rustc_query_impl[db7d5818ebb544c0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[db7d5818ebb544c0]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 8usize]>>
  34:        0x11038ed4e - rustc_query_system[9c8bd583e072577f]::query::plumbing::try_execute_query::<rustc_query_impl[db7d5818ebb544c0]::DynamicConfig<rustc_query_system[9c8bd583e072577f]::query::caches::VecCache<rustc_hir[53162fccad4b280c]::hir_id::OwnerId, rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[db7d5818ebb544c0]::plumbing::QueryCtxt, false>
  35:        0x11053dde1 - rustc_query_impl[db7d5818ebb544c0]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  36:        0x10f1081a6 - <rustc_middle[ef4ebef1f35b9a45]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[540b4a187aa4fa02]::check_crate::{closure#4}>::{closure#0}
  37:        0x10f270d1c - rustc_hir_analysis[540b4a187aa4fa02]::check_crate
  38:        0x10f7b2f98 - rustc_interface[55f0bb586236ba3f]::passes::run_required_analyses
  39:        0x10f7b5463 - rustc_interface[55f0bb586236ba3f]::passes::analysis
  40:        0x110519f0c - rustc_query_impl[db7d5818ebb544c0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[db7d5818ebb544c0]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 1usize]>>
  41:        0x1102f8d8e - rustc_query_system[9c8bd583e072577f]::query::plumbing::try_execute_query::<rustc_query_impl[db7d5818ebb544c0]::DynamicConfig<rustc_query_system[9c8bd583e072577f]::query::caches::SingleCache<rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[db7d5818ebb544c0]::plumbing::QueryCtxt, false>
  42:        0x11052445d - rustc_query_impl[db7d5818ebb544c0]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  43:        0x10ee19c67 - <rustc_interface[55f0bb586236ba3f]::queries::QueryResult<&rustc_middle[ef4ebef1f35b9a45]::ty::context::GlobalCtxt>>::enter::<core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>, rustc_driver_impl[1a7a7dac5035a0ee]::run_compiler::{closure#0}::{closure#1}::{closure#5}>
  44:        0x10ee765a9 - rustc_interface[55f0bb586236ba3f]::interface::run_compiler::<core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>, rustc_driver_impl[1a7a7dac5035a0ee]::run_compiler::{closure#0}>::{closure#1}
  45:        0x10ee619c1 - std[513de39480af1bab]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[55f0bb586236ba3f]::util::run_in_thread_with_globals<rustc_interface[55f0bb586236ba3f]::util::run_in_thread_pool_with_globals<rustc_interface[55f0bb586236ba3f]::interface::run_compiler<core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>, rustc_driver_impl[1a7a7dac5035a0ee]::run_compiler::{closure#0}>::{closure#1}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#0}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>
  46:        0x10ee78a06 - <<std[513de39480af1bab]::thread::Builder>::spawn_unchecked_<rustc_interface[55f0bb586236ba3f]::util::run_in_thread_with_globals<rustc_interface[55f0bb586236ba3f]::util::run_in_thread_pool_with_globals<rustc_interface[55f0bb586236ba3f]::interface::run_compiler<core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>, rustc_driver_impl[1a7a7dac5035a0ee]::run_compiler::{closure#0}>::{closure#1}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#0}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#1} as core[31c80208252ed77d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  47:        0x105816afb - std::sys::pal::unix::thread::Thread::new::thread_start::h38612934f7248e43
  48:     0x7ff801f5318b - __pthread_start


query stack during panic:
#0 [inherit_sig_for_delegation_item] inheriting delegation signature
#1 [typeck] type-checking `<impl at ./1E910.rs:19:1: 19:17>::bar`
#2 [analysis] running analysis passes on this crate
end of query stack
thread 'rustc' panicked at compiler/rustc_hir_analysis/src/delegation.rs:245:58:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:        0x1057f3eb7 - std::backtrace::Backtrace::create::hab0b2157d02f6e92
   1:        0x1057f3e05 - std::backtrace::Backtrace::force_capture::h20bc09614659a271
   2:        0x10ee6f2b4 - std[513de39480af1bab]::panicking::update_hook::<alloc[88fbee91b568d05e]::boxed::Box<rustc_driver_impl[1a7a7dac5035a0ee]::install_ice_hook::{closure#0}>>::{closure#0}
   3:        0x10580ded0 - std::panicking::rust_panic_with_hook::h68d7251319b974a6
   4:        0x10580d722 - std::panicking::begin_panic_handler::{{closure}}::ha88851b9fb268d98
   5:        0x10580acd9 - std::sys::backtrace::__rust_end_short_backtrace::h5540b8654da0543b
   6:        0x10580d39c - _rust_begin_unwind
   7:        0x105874aea - core::panicking::panic_fmt::h6a779485efe923d2
   8:        0x105874b94 - core::panicking::panic::h222bc2761b0de3d1
   9:        0x105874a38 - core::option::unwrap_failed::h5fc060f6c9bf92ba
  10:        0x10f2127d2 - rustc_hir_analysis[540b4a187aa4fa02]::delegation::inherit_sig_for_delegation_item
  11:        0x11051956b - rustc_query_impl[db7d5818ebb544c0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[db7d5818ebb544c0]::query_impl::inherit_sig_for_delegation_item::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 16usize]>>
  12:        0x1104e0b9e - <rustc_query_impl[db7d5818ebb544c0]::query_impl::inherit_sig_for_delegation_item::dynamic_query::{closure#2} as core[31c80208252ed77d]::ops::function::FnOnce<(rustc_middle[ef4ebef1f35b9a45]::ty::context::TyCtxt, rustc_span[af5dc13a57d4458]::def_id::LocalDefId)>>::call_once
  13:        0x1103933e5 - rustc_query_system[9c8bd583e072577f]::query::plumbing::try_execute_query::<rustc_query_impl[db7d5818ebb544c0]::DynamicConfig<rustc_query_system[9c8bd583e072577f]::query::caches::VecCache<rustc_span[af5dc13a57d4458]::def_id::LocalDefId, rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[db7d5818ebb544c0]::plumbing::QueryCtxt, false>
  14:        0x110567b57 - rustc_query_impl[db7d5818ebb544c0]::query_impl::inherit_sig_for_delegation_item::get_query_non_incr::__rust_end_short_backtrace
  15:        0x10f2a21f7 - <dyn rustc_hir_analysis[540b4a187aa4fa02]::hir_ty_lowering::HirTyLowerer>::lower_ty_common::{closure#0}
  16:        0x10f56bad0 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::suggest_missing_return_type
  17:        0x10f4585aa - <rustc_hir_typeck[d66b43df352b27be]::coercion::CoerceMany<rustc_hir[53162fccad4b280c]::hir::Expr>>::report_return_mismatched_types
  18:        0x10f4b5007 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_block_with_expected
  19:        0x10f46f684 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  20:        0x10f54e499 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_kind
  21:        0x10f46f684 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  22:        0x10f54bd10 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_kind
  23:        0x10f46f684 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  24:        0x10f4a47cb - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_argument_types
  25:        0x10f443e5d - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::confirm_builtin_call
  26:        0x10f5549ab - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_kind
  27:        0x10f46f684 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  28:        0x10f4b3904 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_block_with_expected
  29:        0x10f46f684 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  30:        0x10f4718b3 - <rustc_hir_typeck[d66b43df352b27be]::fn_ctxt::FnCtxt>::check_return_expr
  31:        0x10f536ccc - rustc_hir_typeck[d66b43df352b27be]::check::check_fn
  32:        0x10f5317e8 - rustc_hir_typeck[d66b43df352b27be]::typeck
  33:        0x110519e5c - rustc_query_impl[db7d5818ebb544c0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[db7d5818ebb544c0]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 8usize]>>
  34:        0x11038ed4e - rustc_query_system[9c8bd583e072577f]::query::plumbing::try_execute_query::<rustc_query_impl[db7d5818ebb544c0]::DynamicConfig<rustc_query_system[9c8bd583e072577f]::query::caches::VecCache<rustc_hir[53162fccad4b280c]::hir_id::OwnerId, rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[db7d5818ebb544c0]::plumbing::QueryCtxt, false>
  35:        0x11053dde1 - rustc_query_impl[db7d5818ebb544c0]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  36:        0x10f1081a6 - <rustc_middle[ef4ebef1f35b9a45]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[540b4a187aa4fa02]::check_crate::{closure#4}>::{closure#0}
  37:        0x10f270d1c - rustc_hir_analysis[540b4a187aa4fa02]::check_crate
  38:        0x10f7b2f98 - rustc_interface[55f0bb586236ba3f]::passes::run_required_analyses
  39:        0x10f7b5463 - rustc_interface[55f0bb586236ba3f]::passes::analysis
  40:        0x110519f0c - rustc_query_impl[db7d5818ebb544c0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[db7d5818ebb544c0]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 1usize]>>
  41:        0x1102f8d8e - rustc_query_system[9c8bd583e072577f]::query::plumbing::try_execute_query::<rustc_query_impl[db7d5818ebb544c0]::DynamicConfig<rustc_query_system[9c8bd583e072577f]::query::caches::SingleCache<rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[db7d5818ebb544c0]::plumbing::QueryCtxt, false>
  42:        0x11052445d - rustc_query_impl[db7d5818ebb544c0]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  43:        0x10ee19c67 - <rustc_interface[55f0bb586236ba3f]::queries::QueryResult<&rustc_middle[ef4ebef1f35b9a45]::ty::context::GlobalCtxt>>::enter::<core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>, rustc_driver_impl[1a7a7dac5035a0ee]::run_compiler::{closure#0}::{closure#1}::{closure#5}>
  44:        0x10ee765a9 - rustc_interface[55f0bb586236ba3f]::interface::run_compiler::<core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>, rustc_driver_impl[1a7a7dac5035a0ee]::run_compiler::{closure#0}>::{closure#1}
  45:        0x10ee619c1 - std[513de39480af1bab]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[55f0bb586236ba3f]::util::run_in_thread_with_globals<rustc_interface[55f0bb586236ba3f]::util::run_in_thread_pool_with_globals<rustc_interface[55f0bb586236ba3f]::interface::run_compiler<core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>, rustc_driver_impl[1a7a7dac5035a0ee]::run_compiler::{closure#0}>::{closure#1}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#0}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>
  46:        0x10ee78a06 - <<std[513de39480af1bab]::thread::Builder>::spawn_unchecked_<rustc_interface[55f0bb586236ba3f]::util::run_in_thread_with_globals<rustc_interface[55f0bb586236ba3f]::util::run_in_thread_pool_with_globals<rustc_interface[55f0bb586236ba3f]::interface::run_compiler<core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>, rustc_driver_impl[1a7a7dac5035a0ee]::run_compiler::{closure#0}>::{closure#1}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#0}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#1} as core[31c80208252ed77d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  47:        0x105816afb - std::sys::pal::unix::thread::Thread::new::thread_start::h38612934f7248e43
  48:     0x7ff801f5318b - __pthread_start


query stack during panic:
#0 [inherit_sig_for_delegation_item] inheriting delegation signature
#1 [typeck] type-checking `<impl at ./1E910.rs:19:1: 19:17>::meh`
#2 [analysis] running analysis passes on this crate
end of query stack

@jieyouxu jieyouxu added the A-HIR Area: The high-level intermediate representation (HIR) label Aug 13, 2024
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Aug 16, 2024
@BoxyUwU BoxyUwU self-assigned this Aug 16, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 16, 2024
…r=compiler-errors

Return correct HirId when finding body owner in diagnostics

Fixes rust-lang#129145
Fixes rust-lang#128810

r? `@compiler-errors`

```rust
fn generic<const N: u32>() {}

trait Collate<const A: u32> {
    type Pass;
    fn collate(self) -> Self::Pass;
}

impl<const B: u32> Collate<B> for i32 {
    type Pass = ();
    fn collate(self) -> Self::Pass {
        generic::<{ true }>()
        //~^ ERROR: mismatched types
    }
}
```

When type checking the `{ true }` anon const we would error with a type mismatch. This then results in diagnostics code attempting to check whether its due to a type mismatch with the return type. That logic was implemented by walking up the hir until we reached the body owner, except instead of using the `enclosing_body_owner` function it special cased various hir nodes incorrectly resulting in us walking out of the anon const and stopping at `fn collate` instead.

This then resulted in diagnostics logic inside of the anon consts `ParamEnv` attempting to do trait solving involving the `<i32 as Collate<B>>::Pass` type which ICEs because it is in the wrong environment.

I have rewritten this function to just walk up until it hits the `enclosing_body_owner` and made some other changes since I found this pretty hard to read/understand. Hopefully it's easier to understand now, it also makes it more obvious that this is not implemented in a very principled way and is definitely missing cases :)
tgross35 added a commit to tgross35/rust that referenced this issue Aug 17, 2024
…r=compiler-errors

Return correct HirId when finding body owner in diagnostics

Fixes rust-lang#129145
Fixes rust-lang#128810

r? ``@compiler-errors``

```rust
fn generic<const N: u32>() {}

trait Collate<const A: u32> {
    type Pass;
    fn collate(self) -> Self::Pass;
}

impl<const B: u32> Collate<B> for i32 {
    type Pass = ();
    fn collate(self) -> Self::Pass {
        generic::<{ true }>()
        //~^ ERROR: mismatched types
    }
}
```

When type checking the `{ true }` anon const we would error with a type mismatch. This then results in diagnostics code attempting to check whether its due to a type mismatch with the return type. That logic was implemented by walking up the hir until we reached the body owner, except instead of using the `enclosing_body_owner` function it special cased various hir nodes incorrectly resulting in us walking out of the anon const and stopping at `fn collate` instead.

This then resulted in diagnostics logic inside of the anon consts `ParamEnv` attempting to do trait solving involving the `<i32 as Collate<B>>::Pass` type which ICEs because it is in the wrong environment.

I have rewritten this function to just walk up until it hits the `enclosing_body_owner` and made some other changes since I found this pretty hard to read/understand. Hopefully it's easier to understand now, it also makes it more obvious that this is not implemented in a very principled way and is definitely missing cases :)
@bors bors closed this as completed in ddbbda4 Aug 17, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Aug 17, 2024
Rollup merge of rust-lang#129168 - BoxyUwU:mismatched_ty_correct_id, r=compiler-errors

Return correct HirId when finding body owner in diagnostics

Fixes rust-lang#129145
Fixes rust-lang#128810

r? ```@compiler-errors```

```rust
fn generic<const N: u32>() {}

trait Collate<const A: u32> {
    type Pass;
    fn collate(self) -> Self::Pass;
}

impl<const B: u32> Collate<B> for i32 {
    type Pass = ();
    fn collate(self) -> Self::Pass {
        generic::<{ true }>()
        //~^ ERROR: mismatched types
    }
}
```

When type checking the `{ true }` anon const we would error with a type mismatch. This then results in diagnostics code attempting to check whether its due to a type mismatch with the return type. That logic was implemented by walking up the hir until we reached the body owner, except instead of using the `enclosing_body_owner` function it special cased various hir nodes incorrectly resulting in us walking out of the anon const and stopping at `fn collate` instead.

This then resulted in diagnostics logic inside of the anon consts `ParamEnv` attempting to do trait solving involving the `<i32 as Collate<B>>::Pass` type which ICEs because it is in the wrong environment.

I have rewritten this function to just walk up until it hits the `enclosing_body_owner` and made some other changes since I found this pretty hard to read/understand. Hopefully it's easier to understand now, it also makes it more obvious that this is not implemented in a very principled way and is definitely missing cases :)
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 17, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-HIR Area: The high-level intermediate representation (HIR) C-bug Category: This is a bug. F-fn_delegation `#![feature(fn_delegation)]` 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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants