Repository: rust
Issue: ICE: `None` in `rustc_hir_typeck` due to malformed attribute
Labels: I-ICE,T-compiler,C-bug,F-rustc_attrs,S-bug-has-test,requires-internal-features

<!--
[31mICE[0m: Rustc ./a.rs '' 'thread 'rustc' panicked at compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs:395:43: 'called `Option::unwrap()` on a `None` value'', 'thread 'rustc' panicked at compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs:395:43: 'called `Option::unwrap()` on a `None` value''
File: /tmp/im/a.rs
-->

auto-reduced (treereduce-rust):
````rust
#![rustc_never_type_options(: Unsize<U> = "hi")]

fn main() {}


````

original:
````rust
//
// issue: rust-lang/rust#120600

#![allow(internal_features)]
#![feature("{}", <Foo as T>::Assoc::cake())]
#![rustc_never_type_options(: Unsize<U> = "hi")]

fn ice(a: !) {
    2_usize + (loop {});
}

fn main() {}

````

Version information
````
rustc 1.79.0-nightly (7bb4f0889 2024-04-24)
binary: rustc
commit-hash: 7bb4f0889e8b133c5b03c46f31f2ae6432c00219
commit-date: 2024-04-24
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.4

````

Command:
`/home/matthias/.rustup/toolchains/master/bin/rustc `

<!--
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>Program output</strong></summary>
<p>

```
error: expected unsuffixed literal or identifier, found `:`
 --> /tmp/icemaker_global_tempdir.EufKbBnTYnxL/rustc_testrunner_tmpdir_reporting.QmhD5w5eupoC/mvce.rs:3:29
  |
3 | #![rustc_never_type_options(: Unsize<U> = "hi")]
  |                             ^

error[E0658]: `rustc_never_type_options` is used to experiment with never type fallback and work on never type stabilization, and will never be stable
 --> /tmp/icemaker_global_tempdir.EufKbBnTYnxL/rustc_testrunner_tmpdir_reporting.QmhD5w5eupoC/mvce.rs:3:1
  |
3 | #![rustc_never_type_options(: Unsize<U> = "hi")]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
  = note: this compiler was built on 2024-04-24; consider upgrading it if it is out of date

thread 'rustc' panicked at compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs:395:43:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x70c3e25da145 - std::backtrace_rs::backtrace::libunwind::trace::h86d426b17d4e2e3d
                               at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x70c3e25da145 - std::backtrace_rs::backtrace::trace_unsynchronized::h8c0ef1d148b9d940
                               at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x70c3e25da145 - std::sys_common::backtrace::_print_fmt::he2abce7aa62cdc3a
                               at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x70c3e25da145 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h0c9241533158777f
                               at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x70c3e262921b - core::fmt::rt::Argument::fmt::h733dbde17a4a7d04
                               at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/core/src/fmt/rt.rs:165:63
   5:     0x70c3e262921b - core::fmt::write::h03896a7fdcd4b82f
                               at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/core/src/fmt/mod.rs:1157:21
   6:     0x70c3e25ced4f - std::io::Write::write_fmt::hd74e7c0305df2660
                               at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/io/mod.rs:1832:15
   7:     0x70c3e25d9f1e - std::sys_common::backtrace::_print::hea8c9c28ab87b1b7
                               at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x70c3e25d9f1e - std::sys_common::backtrace::print::hd4bb5623fa4b8de6
                               at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x70c3e25dc889 - std::panicking::default_hook::{{closure}}::h4623b55631f16943
  10:     0x70c3e25dc5cd - std::panicking::default_hook::he5d3fa1d7e671103
                               at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/panicking.rs:298:9
  11:     0x70c3dee456ab - std[73cef507c0358b10]::panicking::update_hook::<alloc[3ec83808c4b91c16]::boxed::Box<rustc_driver_impl[2d410f393cf62b06]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x70c3e25dcf86 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h8ef97572a456b9c7
                               at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/alloc/src/boxed.rs:2036:9
  13:     0x70c3e25dcf86 - std::panicking::rust_panic_with_hook::h1e2384e63ce90283
                               at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/panicking.rs:799:13
  14:     0x70c3e25dccfb - std::panicking::begin_panic_handler::{{closure}}::h8399fde27d16fbcc
                               at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/panicking.rs:656:13
  15:     0x70c3e25da609 - std::sys_common::backtrace::__rust_end_short_backtrace::hbc2e58d3e2bbc56f
                               at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x70c3e25dca67 - rust_begin_unwind
                               at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/panicking.rs:652:5
  17:     0x70c3e26256e3 - core::panicking::panic_fmt::h1b24b925c3ff40f0
                               at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/core/src/panicking.rs:72:14
  18:     0x70c3e262578c - core::panicking::panic::hc98b4908cef81389
                               at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/core/src/panicking.rs:146:5
  19:     0x70c3e2625469 - core::option::unwrap_failed::h547512c5c65004d9
                               at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/core/src/option.rs:1984:5
  20:     0x70c3e0528691 - <rustc_hir_typeck[3cef36dd3b13bfec]::fn_ctxt::FnCtxt>::new
  21:     0x70c3e05290ef - rustc_hir_typeck[3cef36dd3b13bfec]::typeck
  22:     0x70c3e0528dbd - rustc_query_impl[e8a6f5b0469e51af]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e8a6f5b0469e51af]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[65b49a3b5d6c0d49]::query::erase::Erased<[u8; 8usize]>>
  23:     0x70c3e05e8531 - rustc_query_system[ccb87b148b9f71e3]::query::plumbing::try_execute_query::<rustc_query_impl[e8a6f5b0469e51af]::DynamicConfig<rustc_query_system[ccb87b148b9f71e3]::query::caches::VecCache<rustc_span[ec1f1d58828cad2c]::def_id::LocalDefId, rustc_middle[65b49a3b5d6c0d49]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[e8a6f5b0469e51af]::plumbing::QueryCtxt, false>
  24:     0x70c3e05e725c - rustc_query_impl[e8a6f5b0469e51af]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  25:     0x70c3e05e6e94 - <rustc_middle[65b49a3b5d6c0d49]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[4525919e9da128a7]::check_crate::{closure#4}>::{closure#0}
  26:     0x70c3e05e5b8d - rustc_hir_analysis[4525919e9da128a7]::check_crate
  27:     0x70c3e05ef507 - rustc_interface[b73225351c325ab5]::passes::analysis
  28:     0x70c3e05ef055 - rustc_query_impl[e8a6f5b0469e51af]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e8a6f5b0469e51af]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[65b49a3b5d6c0d49]::query::erase::Erased<[u8; 1usize]>>
  29:     0x70c3e0fbe665 - rustc_query_system[ccb87b148b9f71e3]::query::plumbing::try_execute_query::<rustc_query_impl[e8a6f5b0469e51af]::DynamicConfig<rustc_query_system[ccb87b148b9f71e3]::query::caches::SingleCache<rustc_middle[65b49a3b5d6c0d49]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[e8a6f5b0469e51af]::plumbing::QueryCtxt, false>
  30:     0x70c3e0fbe3c9 - rustc_query_impl[e8a6f5b0469e51af]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  31:     0x70c3e0e45993 - rustc_interface[b73225351c325ab5]::interface::run_compiler::<core[dad89120088e7e02]::result::Result<(), rustc_span[ec1f1d58828cad2c]::ErrorGuaranteed>, rustc_driver_impl[2d410f393cf62b06]::run_compiler::{closure#0}>::{closure#1}
  32:     0x70c3e0e2f8e7 - std[73cef507c0358b10]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[b73225351c325ab5]::util::run_in_thread_with_globals<rustc_interface[b73225351c325ab5]::util::run_in_thread_pool_with_globals<rustc_interface[b73225351c325ab5]::interface::run_compiler<core[dad89120088e7e02]::result::Result<(), rustc_span[ec1f1d58828cad2c]::ErrorGuaranteed>, rustc_driver_impl[2d410f393cf62b06]::run_compiler::{closure#0}>::{closure#1}, core[dad89120088e7e02]::result::Result<(), rustc_span[ec1f1d58828cad2c]::ErrorGuaranteed>>::{closure#0}, core[dad89120088e7e02]::result::Result<(), rustc_span[ec1f1d58828cad2c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dad89120088e7e02]::result::Result<(), rustc_span[ec1f1d58828cad2c]::ErrorGuaranteed>>
  33:     0x70c3e0e2f6aa - <<std[73cef507c0358b10]::thread::Builder>::spawn_unchecked_<rustc_interface[b73225351c325ab5]::util::run_in_thread_with_globals<rustc_interface[b73225351c325ab5]::util::run_in_thread_pool_with_globals<rustc_interface[b73225351c325ab5]::interface::run_compiler<core[dad89120088e7e02]::result::Result<(), rustc_span[ec1f1d58828cad2c]::ErrorGuaranteed>, rustc_driver_impl[2d410f393cf62b06]::run_compiler::{closure#0}>::{closure#1}, core[dad89120088e7e02]::result::Result<(), rustc_span[ec1f1d58828cad2c]::ErrorGuaranteed>>::{closure#0}, core[dad89120088e7e02]::result::Result<(), rustc_span[ec1f1d58828cad2c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dad89120088e7e02]::result::Result<(), rustc_span[ec1f1d58828cad2c]::ErrorGuaranteed>>::{closure#2} as core[dad89120088e7e02]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  34:     0x70c3e25e6e1b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3679caeb60ab03c2
                               at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/alloc/src/boxed.rs:2022:9
  35:     0x70c3e25e6e1b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h7e27b57c37e0ef1f
                               at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/alloc/src/boxed.rs:2022:9
  36:     0x70c3e25e6e1b - std::sys::pal::unix::thread::Thread::new::thread_start::he8797429d1c20e6e
                               at /rustc/7bb4f0889e8b133c5b03c46f31f2ae6432c00219/library/std/src/sys/pal/unix/thread.rs:108:17
  37:     0x70c3e238555a - <unknown>
  38:     0x70c3e2402a3c - <unknown>
  39:                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: rustc 1.79.0-nightly (7bb4f0889 2024-04-24) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0658`.

```

</p>
</details>

<!--
query stack:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate

-->
@rustbot label +F-"{}" +F-<Foo as T>::Assoc::cake