Repository: rust
Issue: error: compiler panic "could not compile `syn` (lib)"
Labels: I-ICE,T-compiler,C-bug,S-needs-repro

<!--
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

Received a compiler error compiling `rsql` on Ubuntu 24.04; the output for the build can be found here: https://github.com/theseus-rs/rsql/actions/runs/12363542400/job/34505446462?pr=238


### 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.83.0 (90b35a623 2024-11-26)
binary: rustc
commit-hash: 90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf
commit-date: 2024-11-26
host: x86_64-unknown-linux-gnu
release: 1.83.0
LLVM version: 19.1.1
```

### Error output

```
thread 'rustc' panicked at compiler/rustc_symbol_mangling/src/v0.rs:244:17:
assertion `left == right` failed
  left: std::option::Option<(lifetime::Lifetime, buffer::Cursor<'{erased}>)>
 right: std::option::Option<(lifetime::Lifetime, buffer::Cursor<'{erased}>)>
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed::<rustc_middle::ty::Ty, rustc_middle::ty::Ty>
   4: <rustc_symbol_mangling::v0::SymbolMangler as rustc_middle::ty::print::Printer>::print_impl_path
   5: <rustc_symbol_mangling::v0::SymbolMangler as rustc_middle::ty::print::Printer>::print_def_path
   6: <rustc_symbol_mangling::v0::SymbolMangler as rustc_middle::ty::print::Printer>::print_def_path
   7: rustc_symbol_mangling::v0::mangle
   8: rustc_symbol_mangling::symbol_name_provider
      [... omitted 1 frame ...]
   9: rustc_monomorphize::partitioning::assert_symbols_are_distinct::<core::slice::iter::Iter<rustc_middle::mir::mono::MonoItem>>
  10: rustc_monomorphize::partitioning::collect_and_partition_mono_items
      [... omitted 2 frames ...]
  11: rustc_codegen_ssa::back::symbol_export::exported_symbols_provider_local
      [... omitted 2 frames ...]
  12: <rustc_metadata::rmeta::encoder::EncodeContext>::encode_crate_root
  13: rustc_metadata::rmeta::encoder::encode_metadata
  14: rustc_metadata::fs::encode_and_write_metadata
  15: <rustc_interface::queries::Linker>::codegen_and_build_linker
  16: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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.83.0 (90b35a623 2024-11-26) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C instrument-coverage

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [symbol_name] computing the symbol for `<core::option::Option<(lifetime::Lifetime, buffer::Cursor<'_>)> as core::ops::try_trait::FromResidual<core::option::Option<core::convert::Infallible>>>::from_residual`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
#2 [exported_symbols] collecting exported symbols for crate `0`
end of query stack
error: could not compile `syn` (lib)

Caused by:
  process didn't exit successfully: `/home/bheineman/.rustup/toolchains/1.83.0-x86_64-unknown-linux-gnu/bin/rustc --crate-name syn --edition=[201](https://github.com/theseus-rs/rsql/actions/runs/12363542400/job/34505446462?pr=238#step:7:202)8 /home/bheineman/.cargo/registry/src/index.crates.io-6f17d22bba15001f/syn-1.0.109/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no --cfg 'feature="clone-impls"' --cfg 'feature="default"' --cfg 'feature="derive"' --cfg 'feature="extra-traits"' --cfg 'feature="full"' --cfg 'feature="parsing"' --cfg 'feature="printing"' --cfg 'feature="proc-macro"' --cfg 'feature="quote"' --cfg 'feature="visit-mut"' --check-cfg 'cfg(docsrs)' --check-cfg 'cfg(feature, values("clone-impls", "default", "derive", "extra-traits", "fold", "full", "parsing", "printing", "proc-macro", "quote", "test", "visit", "visit-mut"))' -C metadata=51f7b7ab389b85a5 -C extra-filename=-51f7b7ab389b85a5 --out-dir /home/bheineman/development/actions-runner/_work/rsql/rsql/target/llvm-cov-target/debug/deps -L dependency=/home/bheineman/development/actions-runner/_work/rsql/rsql/target/llvm-cov-target/debug/deps --extern proc_macro2=/home/bheineman/development/actions-runner/_work/rsql/rsql/target/llvm-cov-target/debug/deps/libproc_macro2-2f42fe115b49d460.rmeta --extern quote=/home/bheineman/development/actions-runner/_work/rsql/rsql/target/llvm-cov-target/debug/deps/libquote-3f4b264c9933d899.rmeta --extern unicode_ident=/home/bheineman/development/actions-runner/_work/rsql/rsql/target/llvm-cov-target/debug/deps/libunicode_ident-fd3aa6049a7e9b09.rmeta --cap-lints allow -C instrument-coverage --cfg=coverage --cfg=trybuild_no_target --cfg syn_disable_nightly_tests` (exit status: 101)
warning: build failed, waiting for other jobs to finish...
error: process didn't exit successfully: `/home/bheineman/.rustup/toolchains/1.83.0-x86_64-unknown-linux-gnu/bin/cargo test --tests --manifest-path /home/bheineman/development/actions-runner/_work/rsql/rsql/Cargo.toml --target-dir /home/bheineman/development/actions-runner/_work/rsql/rsql/target/llvm-cov-target --workspace --jobs 2` (exit status: 101)
Error: Process completed with exit code 1.
```

<!--
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>

```
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed::<rustc_middle::ty::Ty, rustc_middle::ty::Ty>
   4: <rustc_symbol_mangling::v0::SymbolMangler as rustc_middle::ty::print::Printer>::print_impl_path
   5: <rustc_symbol_mangling::v0::SymbolMangler as rustc_middle::ty::print::Printer>::print_def_path
   6: <rustc_symbol_mangling::v0::SymbolMangler as rustc_middle::ty::print::Printer>::print_def_path
   7: rustc_symbol_mangling::v0::mangle
   8: rustc_symbol_mangling::symbol_name_provider
      [... omitted 1 frame ...]
   9: rustc_monomorphize::partitioning::assert_symbols_are_distinct::<core::slice::iter::Iter<rustc_middle::mir::mono::MonoItem>>
  10: rustc_monomorphize::partitioning::collect_and_partition_mono_items
      [... omitted 2 frames ...]
  11: rustc_codegen_ssa::back::symbol_export::exported_symbols_provider_local
      [... omitted 2 frames ...]
  12: <rustc_metadata::rmeta::encoder::EncodeContext>::encode_crate_root
  13: rustc_metadata::rmeta::encoder::encode_metadata
  14: rustc_metadata::fs::encode_and_write_metadata
  15: <rustc_interface::queries::Linker>::codegen_and_build_linker
  16: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
```

</p>
</details>