Repository: rust
Issue: ICE:  `explicit index of non-indexable type`
Labels: I-ICE,T-compiler,C-bug,requires-nightly,S-bug-has-test,requires-incomplete-features,F-deref_patterns

<!--
Thank you for finding an Internal Compiler Error! 🧊  If possible, try to provide
a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for
how to create smaller examples.
http://blog.pnkfx.org/blog/2019/11/18/rust-bug-minimization-patterns/
-->

### Code

```Rust
#![feature(deref_patterns)]
#![allow(incomplete_features)]

fn simple_vec(vec: Vec<u32>) -> u32 {
    match vec {
        deref!([]) => 100,
        _ => 2000,
    }
}

fn main() {}

```


### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version --verbose`:
```
rustc 1.80.0-nightly (ba956ef4b 2024-05-13)
binary: rustc
commit-hash: ba956ef4b00c91579cff9b2220358ee3a46d982f
commit-date: 2024-05-13
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.4
```

### Error output

```
<output>
```

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary><strong>Backtrace</strong></summary>
<p>

```
error: internal compiler error: /rustc/ba956ef4b00c91579cff9b2220358ee3a46d982f/compiler/rustc_hir_typeck/src/expr_use_visitor.rs:218:9: explicit index of non-indexable type
 --> bindings.rs:6:16
  |
6 |         deref!([]) => 100,
  |                ^^

thread 'rustc' panicked at /rustc/ba956ef4b00c91579cff9b2220358ee3a46d982f/compiler/rustc_hir_typeck/src/expr_use_visitor.rs:218:9:
Box<dyn Any>
stack backtrace:
   0:     0x702057e81e55 - std::backtrace_rs::backtrace::libunwind::trace::he1c8af16e60d8ac3
                               at /rustc/ba956ef4b00c91579cff9b2220358ee3a46d982f/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x702057e81e55 - std::backtrace_rs::backtrace::trace_unsynchronized::h0ff4fb4d1fb1eafe
                               at /rustc/ba956ef4b00c91579cff9b2220358ee3a46d982f/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x702057e81e55 - std::sys_common::backtrace::_print_fmt::hda02bf9854ed434b
                               at /rustc/ba956ef4b00c91579cff9b2220358ee3a46d982f/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x702057e81e55 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2f1348356d4dd5a6
                               at /rustc/ba956ef4b00c91579cff9b2220358ee3a46d982f/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x702057ed116b - core::fmt::rt::Argument::fmt::hdfc187d135a92cff
                               at /rustc/ba956ef4b00c91579cff9b2220358ee3a46d982f/library/core/src/fmt/rt.rs:165:63
   5:     0x702057ed116b - core::fmt::write::h2e66cd8a0d755998
                               at /rustc/ba956ef4b00c91579cff9b2220358ee3a46d982f/library/core/src/fmt/mod.rs:1169:21
   6:     0x702057e76bef - std::io::Write::write_fmt::ha6594d6d0318bd63
                               at /rustc/ba956ef4b00c91579cff9b2220358ee3a46d982f/library/std/src/io/mod.rs:1835:15
   7:     0x702057e81c2e - std::sys_common::backtrace::_print::h7b339c0ab962de77
                               at /rustc/ba956ef4b00c91579cff9b2220358ee3a46d982f/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x702057e81c2e - std::sys_common::backtrace::print::hde9837078a8d5e94
                               at /rustc/ba956ef4b00c91579cff9b2220358ee3a46d982f/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x702057e84649 - std::panicking::default_hook::{{closure}}::h0f2e3d59d4fc9781
  10:     0x702057e8438d - std::panicking::default_hook::h9944960cd621bbba
                               at /rustc/ba956ef4b00c91579cff9b2220358ee3a46d982f/library/std/src/panicking.rs:298:9
  11:     0x7020548eb64f - std[2aee1e20eb236dda]::panicking::update_hook::<alloc[322764ce6b1abc47]::boxed::Box<rustc_driver_impl[b3f759d8272e082a]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x702057e84d7b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h63db09f1011a40db
                               at /rustc/ba956ef4b00c91579cff9b2220358ee3a46d982f/library/alloc/src/boxed.rs:2036:9
  13:     0x702057e84d7b - std::panicking::rust_panic_with_hook::hd5c6a18d84f2558b
                               at /rustc/ba956ef4b00c91579cff9b2220358ee3a46d982f/library/std/src/panicking.rs:799:13
  14:     0x70205491b944 - std[2aee1e20eb236dda]::panicking::begin_panic::<rustc_errors[1fa39940d3d52013]::ExplicitBug>::{closure#0}
  15:     0x7020549182e6 - std[2aee1e20eb236dda]::sys_common::backtrace::__rust_end_short_backtrace::<std[2aee1e20eb236dda]::panicking::begin_panic<rustc_errors[1fa39940d3d52013]::ExplicitBug>::{closure#0}, !>
  16:     0x702054913856 - std[2aee1e20eb236dda]::panicking::begin_panic::<rustc_errors[1fa39940d3d52013]::ExplicitBug>
  17:     0x702054924be1 - <rustc_errors[1fa39940d3d52013]::diagnostic::BugAbort as rustc_errors[1fa39940d3d52013]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  18:     0x61c9ff1057c8 - <rustc_errors[1fa39940d3d52013]::DiagCtxt>::span_bug::<rustc_span[18b9f7b309fe5dcc]::span_encoding::Span, alloc[322764ce6b1abc47]::string::String>
  19:     0x61c9ff212ccb - rustc_middle[6763d32431b5f193]::util::bug::opt_span_bug_fmt::<rustc_span[18b9f7b309fe5dcc]::span_encoding::Span>::{closure#0}
  20:     0x61c9ff2148aa - rustc_middle[6763d32431b5f193]::ty::context::tls::with_opt::<rustc_middle[6763d32431b5f193]::util::bug::opt_span_bug_fmt<rustc_span[18b9f7b309fe5dcc]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x61c9ff1c6b9b - rustc_middle[6763d32431b5f193]::ty::context::tls::with_context_opt::<rustc_middle[6763d32431b5f193]::ty::context::tls::with_opt<rustc_middle[6763d32431b5f193]::util::bug::opt_span_bug_fmt<rustc_span[18b9f7b309fe5dcc]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x61c9ff1c423a - rustc_middle[6763d32431b5f193]::util::bug::span_bug_fmt::<rustc_span[18b9f7b309fe5dcc]::span_encoding::Span>
  23:     0x61c9ff1dfc1e - <(&rustc_lint[935797b976454209]::context::LateContext, rustc_span[18b9f7b309fe5dcc]::def_id::LocalDefId) as rustc_hir_typeck[9965755b35d13bf6]::expr_use_visitor::TypeInformationCtxt>::report_error::<&str>
  24:     0x61c9ff1079b0 - <rustc_hir_typeck[9965755b35d13bf6]::expr_use_visitor::ExprUseVisitor<(&rustc_lint[935797b976454209]::context::LateContext, rustc_span[18b9f7b309fe5dcc]::def_id::LocalDefId), &mut clippy_lints[7545ccafa66a19d7]::needless_pass_by_value::MovedVariablesCtxt>>::cat_pattern::<<rustc_hir_typeck[9965755b35d13bf6]::expr_use_visitor::ExprUseVisitor<(&rustc_lint[935797b976454209]::context::LateContext, rustc_span[18b9f7b309fe5dcc]::def_id::LocalDefId), &mut clippy_lints[7545ccafa66a19d7]::needless_pass_by_value::MovedVariablesCtxt>>::maybe_read_scrutinee<core[5a1853d728d4f28b]::slice::iter::Iter<rustc_hir[c63ce795a895b78]::hir::Pat>>::{closure#0}>
  25:     0x61c9ff1074a3 - <rustc_hir_typeck[9965755b35d13bf6]::expr_use_visitor::ExprUseVisitor<(&rustc_lint[935797b976454209]::context::LateContext, rustc_span[18b9f7b309fe5dcc]::def_id::LocalDefId), &mut clippy_lints[7545ccafa66a19d7]::needless_pass_by_value::MovedVariablesCtxt>>::cat_pattern::<<rustc_hir_typeck[9965755b35d13bf6]::expr_use_visitor::ExprUseVisitor<(&rustc_lint[935797b976454209]::context::LateContext, rustc_span[18b9f7b309fe5dcc]::def_id::LocalDefId), &mut clippy_lints[7545ccafa66a19d7]::needless_pass_by_value::MovedVariablesCtxt>>::maybe_read_scrutinee<core[5a1853d728d4f28b]::slice::iter::Iter<rustc_hir[c63ce795a895b78]::hir::Pat>>::{closure#0}>
  26:     0x61c9ff258793 - <rustc_hir_typeck[9965755b35d13bf6]::expr_use_visitor::ExprUseVisitor<(&rustc_lint[935797b976454209]::context::LateContext, rustc_span[18b9f7b309fe5dcc]::def_id::LocalDefId), &mut clippy_lints[7545ccafa66a19d7]::escape::EscapeDelegate>>::walk_expr
  27:     0x61c9ff25721c - <rustc_hir_typeck[9965755b35d13bf6]::expr_use_visitor::ExprUseVisitor<(&rustc_lint[935797b976454209]::context::LateContext, rustc_span[18b9f7b309fe5dcc]::def_id::LocalDefId), &mut clippy_lints[7545ccafa66a19d7]::escape::EscapeDelegate>>::consume_expr
  28:     0x61c9ff25858e - <rustc_hir_typeck[9965755b35d13bf6]::expr_use_visitor::ExprUseVisitor<(&rustc_lint[935797b976454209]::context::LateContext, rustc_span[18b9f7b309fe5dcc]::def_id::LocalDefId), &mut clippy_lints[7545ccafa66a19d7]::escape::EscapeDelegate>>::walk_expr
  29:     0x61c9ff25721c - <rustc_hir_typeck[9965755b35d13bf6]::expr_use_visitor::ExprUseVisitor<(&rustc_lint[935797b976454209]::context::LateContext, rustc_span[18b9f7b309fe5dcc]::def_id::LocalDefId), &mut clippy_lints[7545ccafa66a19d7]::escape::EscapeDelegate>>::consume_expr
  30:     0x61c9ff3132c8 - <clippy_lints[7545ccafa66a19d7]::escape::BoxedLocal as rustc_lint[935797b976454209]::passes::LateLintPass>::check_fn
  31:     0x702054cc2c75 - <rustc_lint[935797b976454209]::late::LateContextAndPass<rustc_lint[935797b976454209]::late::RuntimeCombinedLateLintPass> as rustc_hir[c63ce795a895b78]::intravisit::Visitor>::visit_fn
  32:     0x702054cb1ff5 - <rustc_lint[935797b976454209]::late::LateContextAndPass<rustc_lint[935797b976454209]::late::RuntimeCombinedLateLintPass> as rustc_hir[c63ce795a895b78]::intravisit::Visitor>::visit_nested_item
  33:     0x70205677c12a - rustc_lint[935797b976454209]::late::check_crate::{closure#0}
  34:     0x70205677c373 - rustc_lint[935797b976454209]::late::check_crate
  35:     0x702056782b93 - rustc_interface[378bc30a20028389]::passes::analysis
  36:     0x70205678209b - rustc_query_impl[829470001f3ffad1]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[829470001f3ffad1]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[6763d32431b5f193]::query::erase::Erased<[u8; 1usize]>>
  37:     0x702056a02ca5 - rustc_query_system[f6e0b1d5265b4ecc]::query::plumbing::try_execute_query::<rustc_query_impl[829470001f3ffad1]::DynamicConfig<rustc_query_system[f6e0b1d5265b4ecc]::query::caches::SingleCache<rustc_middle[6763d32431b5f193]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[829470001f3ffad1]::plumbing::QueryCtxt, false>
  38:     0x702056a02a09 - rustc_query_impl[829470001f3ffad1]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  39:     0x70205683ee0e - rustc_interface[378bc30a20028389]::interface::run_compiler::<core[5a1853d728d4f28b]::result::Result<(), rustc_span[18b9f7b309fe5dcc]::ErrorGuaranteed>, rustc_driver_impl[b3f759d8272e082a]::run_compiler::{closure#0}>::{closure#1}
  40:     0x702056804a89 - std[2aee1e20eb236dda]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[378bc30a20028389]::util::run_in_thread_with_globals<rustc_interface[378bc30a20028389]::util::run_in_thread_pool_with_globals<rustc_interface[378bc30a20028389]::interface::run_compiler<core[5a1853d728d4f28b]::result::Result<(), rustc_span[18b9f7b309fe5dcc]::ErrorGuaranteed>, rustc_driver_impl[b3f759d8272e082a]::run_compiler::{closure#0}>::{closure#1}, core[5a1853d728d4f28b]::result::Result<(), rustc_span[18b9f7b309fe5dcc]::ErrorGuaranteed>>::{closure#0}, core[5a1853d728d4f28b]::result::Result<(), rustc_span[18b9f7b309fe5dcc]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5a1853d728d4f28b]::result::Result<(), rustc_span[18b9f7b309fe5dcc]::ErrorGuaranteed>>
  41:     0x702056804836 - <<std[2aee1e20eb236dda]::thread::Builder>::spawn_unchecked_<rustc_interface[378bc30a20028389]::util::run_in_thread_with_globals<rustc_interface[378bc30a20028389]::util::run_in_thread_pool_with_globals<rustc_interface[378bc30a20028389]::interface::run_compiler<core[5a1853d728d4f28b]::result::Result<(), rustc_span[18b9f7b309fe5dcc]::ErrorGuaranteed>, rustc_driver_impl[b3f759d8272e082a]::run_compiler::{closure#0}>::{closure#1}, core[5a1853d728d4f28b]::result::Result<(), rustc_span[18b9f7b309fe5dcc]::ErrorGuaranteed>>::{closure#0}, core[5a1853d728d4f28b]::result::Result<(), rustc_span[18b9f7b309fe5dcc]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5a1853d728d4f28b]::result::Result<(), rustc_span[18b9f7b309fe5dcc]::ErrorGuaranteed>>::{closure#2} as core[5a1853d728d4f28b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  42:     0x702057e8ec1b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1118031ec204f534
                               at /rustc/ba956ef4b00c91579cff9b2220358ee3a46d982f/library/alloc/src/boxed.rs:2022:9
  43:     0x702057e8ec1b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h46a265d132dda3f6
                               at /rustc/ba956ef4b00c91579cff9b2220358ee3a46d982f/library/alloc/src/boxed.rs:2022:9
  44:     0x702057e8ec1b - std::sys::pal::unix::thread::Thread::new::thread_start::hfd925ddaab3cb24c
                               at /rustc/ba956ef4b00c91579cff9b2220358ee3a46d982f/library/std/src/sys/pal/unix/thread.rs:108:17
  45:     0x7020515bb55a - <unknown>
  46:     0x702051638a3c - <unknown>
  47:                0x0 - <unknown>

note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new?template=ice.yml

note: please make sure that you have updated to the latest nightly

note: please attach the file at `/tmp/im/rustc-ice-2024-05-13T04_58_48-1069588.txt` to your bug report

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
note: Clippy version: clippy 0.1.80 (ba956ef 2024-05-13)

error: aborting due to 1 previous error; 1 warning emitted
```

</p>
</details>