Repository: rust
Issue: error: could not compile `clap`: `'MemDecoder exhausted', compiler/rustc_serialize/src/opaque.rs:352:9`
Labels: I-ICE,T-compiler,S-waiting-on-author,C-bug,S-needs-repro

I create a new empty rust project. I only add clap under [dependencies] like this into Cargo.toml. But when I run cargo build, there is an error. 
### Code

```  
1 [package]
  2 name = "hello_world"
  3 version = "0.1.0"
  4 edition = "2021"
  5 
  6 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
  7 
  8 [dependencies]
  9 
 10 clap = { version = "4.4.2", features = ["derive"] }
```


### Meta

`rustc --version --verbose`:
```
rustc 1.72.0 (5680fa18f 2023-08-23)
cargo 1.72.0 (103a7ff2e 2023-08-15)
```
It also exist in nighty and beta version.

### Error output

```
$ cargo build
   Compiling clap v4.4.2
thread 'rustc' panicked at 'MemDecoder exhausted', compiler/rustc_serialize/src/opaque.rs:352:9
stack backtrace:
   0:     0x7f8ed4834b61 - std::backtrace_rs::backtrace::libunwind::trace::he648b5c8dd376705
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f8ed4834b61 - std::backtrace_rs::backtrace::trace_unsynchronized::h5da3e203eef39e9f
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f8ed4834b61 - std::sys_common::backtrace::_print_fmt::h8d28d3f20588ae4c
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f8ed4834b61 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd9a5b0c9c6b058c0
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f8ed489b77f - core::fmt::rt::Argument::fmt::h0afc04119f252b53
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/fmt/rt.rs:138:9
   5:     0x7f8ed489b77f - core::fmt::write::h50b1b3e73851a6fe
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/fmt/mod.rs:1094:21
   6:     0x7f8ed48274a7 - std::io::Write::write_fmt::h184eaf275e4484f0
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/io/mod.rs:1714:15
   7:     0x7f8ed4834975 - std::sys_common::backtrace::_print::hf58c3a5a25090e71
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f8ed4834975 - std::sys_common::backtrace::print::hb9cf0a7c7f077819
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f8ed4837753 - std::panicking::default_hook::{{closure}}::h066adb2e3f3e2c07
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:269:22
  10:     0x7f8ed48374e4 - std::panicking::default_hook::h277fa2776900ff14
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:288:9
  11:     0x7f8ed364056b - <rustc_driver_impl[10725d833993dc31]::install_ice_hook::{closure#0} as core[f12ae36cc2e1ecf0]::ops::function::FnOnce<(&core[f12ae36cc2e1ecf0]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  12:     0x7f8ed4837f7e - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h09cad52ea08435f2
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/alloc/src/boxed.rs:2007:9
  13:     0x7f8ed4837f7e - std::panicking::rust_panic_with_hook::hceaf38da6d9db792
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:709:13
  14:     0x7f8ed4837cc1 - std::panicking::begin_panic_handler::{{closure}}::h2bce3ed2516af7df
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:595:13
  15:     0x7f8ed4834fc6 - std::sys_common::backtrace::__rust_end_short_backtrace::h090f3faf8f98a395
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/sys_common/backtrace.rs:151:18
  16:     0x7f8ed4837a52 - rust_begin_unwind
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:593:5
  17:     0x7f8ed48979f3 - core::panicking::panic_fmt::h4ec8274704d163a3
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/panicking.rs:67:14
  18:     0x7f8ed4084f8a - <rustc_serialize[42a6bc6c87d9c952]::opaque::MemDecoder>::decoder_exhausted
  19:     0x7f8ed17cd68a - <alloc[adbc6fffff8d40a5]::string::String as rustc_serialize[42a6bc6c87d9c952]::serialize::Decodable<rustc_metadata[b86bf7e30d297efc]::rmeta::decoder::DecodeContext>>::decode
  20:     0x7f8ed29ecd1b - <rustc_metadata[b86bf7e30d297efc]::locator::CrateLocator>::extract_one
  21:     0x7f8ed29ec316 - <rustc_metadata[b86bf7e30d297efc]::locator::CrateLocator>::extract_lib
  22:     0x7f8ed29e8d2b - <rustc_metadata[b86bf7e30d297efc]::locator::CrateLocator>::maybe_load_library_crate
  23:     0x7f8ed29e7140 - <rustc_metadata[b86bf7e30d297efc]::creader::CrateLoader>::load
  24:     0x7f8ed29e2c14 - <rustc_metadata[b86bf7e30d297efc]::creader::CrateLoader>::maybe_resolve_crate
  25:     0x7f8ed26e96a2 - <rustc_resolve[ce4e00308278261e]::Resolver>::early_resolve_ident_in_lexical_scope
  26:     0x7f8ed199c0dc - <rustc_resolve[ce4e00308278261e]::Resolver>::resolve_ident_in_module_unadjusted_ext
  27:     0x7f8ed216b982 - <rustc_resolve[ce4e00308278261e]::Resolver>::resolve_import::{closure#0}
  28:     0x7f8ed21657d0 - <rustc_resolve[ce4e00308278261e]::Resolver as rustc_expand[2551adda1704db0c]::base::ResolverExpand>::resolve_imports
  29:     0x7f8ed201c051 - <rustc_expand[2551adda1704db0c]::expand::MacroExpander>::fully_expand_fragment
  30:     0x7f8ed2714307 - <rustc_expand[2551adda1704db0c]::expand::MacroExpander>::expand_crate
  31:     0x7f8ed2713730 - <rustc_session[c98e5f13e8087e38]::session::Session>::time::<rustc_ast[2602dd4bdaa32052]::ast::Crate, rustc_interface[7e6a9899d53a1fe5]::passes::configure_and_expand::{closure#1}>
  32:     0x7f8ed26bf8d8 - rustc_interface[7e6a9899d53a1fe5]::passes::resolver_for_lowering
  33:     0x7f8ed2a56d2a - rustc_query_impl[7f6201a046a7a363]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7f6201a046a7a363]::query_impl::resolver_for_lowering::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4cadb439cfabc8cf]::query::erase::Erased<[u8; 8usize]>>
  34:     0x7f8ed2a56d19 - <rustc_query_impl[7f6201a046a7a363]::query_impl::resolver_for_lowering::dynamic_query::{closure#2} as core[f12ae36cc2e1ecf0]::ops::function::FnOnce<(rustc_middle[4cadb439cfabc8cf]::ty::context::TyCtxt, ())>>::call_once
  35:     0x7f8ed299dd7c - rustc_query_system[5a9d202ec1d2890c]::query::plumbing::try_execute_query::<rustc_query_impl[7f6201a046a7a363]::DynamicConfig<rustc_query_system[5a9d202ec1d2890c]::query::caches::SingleCache<rustc_middle[4cadb439cfabc8cf]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[7f6201a046a7a363]::plumbing::QueryCtxt, false>
  36:     0x7f8ed2f86d67 - rustc_query_impl[7f6201a046a7a363]::query_impl::resolver_for_lowering::get_query_non_incr::__rust_end_short_backtrace
  37:     0x7f8ed2b06f80 - <rustc_interface[7e6a9899d53a1fe5]::queries::QueryResult<&rustc_middle[4cadb439cfabc8cf]::ty::context::GlobalCtxt>>::enter::<&rustc_data_structures[cf1e21f3f9509cab]::steal::Steal<(rustc_middle[4cadb439cfabc8cf]::ty::ResolverAstLowering, alloc[adbc6fffff8d40a5]::rc::Rc<rustc_ast[2602dd4bdaa32052]::ast::Crate>)>, rustc_driver_impl[10725d833993dc31]::run_compiler::{closure#1}::{closure#2}::{closure#2}>
  38:     0x7f8ed2b059bb - <rustc_interface[7e6a9899d53a1fe5]::interface::Compiler>::enter::<rustc_driver_impl[10725d833993dc31]::run_compiler::{closure#1}::{closure#2}, core[f12ae36cc2e1ecf0]::result::Result<core[f12ae36cc2e1ecf0]::option::Option<rustc_interface[7e6a9899d53a1fe5]::queries::Linker>, rustc_span[14af2d27fb997609]::ErrorGuaranteed>>
  39:     0x7f8ed2b02cc5 - rustc_span[14af2d27fb997609]::set_source_map::<core[f12ae36cc2e1ecf0]::result::Result<(), rustc_span[14af2d27fb997609]::ErrorGuaranteed>, rustc_interface[7e6a9899d53a1fe5]::interface::run_compiler<core[f12ae36cc2e1ecf0]::result::Result<(), rustc_span[14af2d27fb997609]::ErrorGuaranteed>, rustc_driver_impl[10725d833993dc31]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  40:     0x7f8ed2b02736 - <scoped_tls[a7f541bbfecfca9d]::ScopedKey<rustc_span[14af2d27fb997609]::SessionGlobals>>::set::<rustc_interface[7e6a9899d53a1fe5]::interface::run_compiler<core[f12ae36cc2e1ecf0]::result::Result<(), rustc_span[14af2d27fb997609]::ErrorGuaranteed>, rustc_driver_impl[10725d833993dc31]::run_compiler::{closure#1}>::{closure#0}, core[f12ae36cc2e1ecf0]::result::Result<(), rustc_span[14af2d27fb997609]::ErrorGuaranteed>>
  41:     0x7f8ed2b01cfc - std[7c7acd4e376d60d3]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[7e6a9899d53a1fe5]::util::run_in_thread_pool_with_globals<rustc_interface[7e6a9899d53a1fe5]::interface::run_compiler<core[f12ae36cc2e1ecf0]::result::Result<(), rustc_span[14af2d27fb997609]::ErrorGuaranteed>, rustc_driver_impl[10725d833993dc31]::run_compiler::{closure#1}>::{closure#0}, core[f12ae36cc2e1ecf0]::result::Result<(), rustc_span[14af2d27fb997609]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f12ae36cc2e1ecf0]::result::Result<(), rustc_span[14af2d27fb997609]::ErrorGuaranteed>>
  42:     0x7f8ed2e7a305 - <<std[7c7acd4e376d60d3]::thread::Builder>::spawn_unchecked_<rustc_interface[7e6a9899d53a1fe5]::util::run_in_thread_pool_with_globals<rustc_interface[7e6a9899d53a1fe5]::interface::run_compiler<core[f12ae36cc2e1ecf0]::result::Result<(), rustc_span[14af2d27fb997609]::ErrorGuaranteed>, rustc_driver_impl[10725d833993dc31]::run_compiler::{closure#1}>::{closure#0}, core[f12ae36cc2e1ecf0]::result::Result<(), rustc_span[14af2d27fb997609]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f12ae36cc2e1ecf0]::result::Result<(), rustc_span[14af2d27fb997609]::ErrorGuaranteed>>::{closure#1} as core[f12ae36cc2e1ecf0]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x7f8ed4842435 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc0b1022758ecac73
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/alloc/src/boxed.rs:1993:9
  44:     0x7f8ed4842435 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h0c9654ebe7ad657e
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/alloc/src/boxed.rs:1993:9
  45:     0x7f8ed4842435 - std::sys::unix::thread::Thread::new::thread_start::h04c8e9c7d83d3bd5
                               at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/sys/unix/thread.rs:108:17
  46:     0x7f8ecfdb76ba - start_thread
  47:     0x7f8ecfaed4dd - clone
  48:                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: rustc 1.72.0 (5680fa18f 2023-08-23) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [resolver_for_lowering] getting the resolver for lowering
end of query stack
error: could not compile `clap` (lib)
```