Skip to content

ICE: GCE: should never serialize an ErrorGuaranteed #136894

@fmease

Description

@fmease

Reproducer

#![feature(generic_const_exprs)]
#![crate_type = "lib"]
#![allow(incomplete_features, dead_code)]

struct X<T>([(); f::<T>()]) where [(); f::<T>()]:;

const fn f<T>() -> usize { panic!() }

Compiler Output (Sans Backtrace)

error[E0080]: evaluation of `X::<T>::0::{constant#0}` failed
 --> file.rs:7:28
  |
7 | const fn f<T>() -> usize { panic!() }
  |                            ^^^^^^^^ the evaluated program panicked at 'explicit panic', file.rs:7:28
  |
note: inside `f::<T>`
 --> file.rs:7:28
  |
7 | const fn f<T>() -> usize { panic!() }
  |                            ^^^^^^^^
note: inside `X::<T>::0::{constant#0}`
 --> file.rs:5:18
  |
5 | struct X<T>([(); f::<T>()]) where [(); f::<T>()]:;
  |                  ^^^^^^^^
  = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)


thread 'rustc' panicked at /rustc/8239a37f9c0951a037cfc51763ea52a20e71e6bd/compiler/rustc_span/src/lib.rs:2665:9:
should never serialize an `ErrorGuaranteed`, as we do not write metadata or incremental caches in case errors occurred

Backtrace

stack backtrace:
   0:     0x7a9e3ae2f180 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h81d5cbdf1b69611b
   1:     0x7a9e3b614826 - core::fmt::write::h004effb614950758
   2:     0x7a9e3c93a951 - std::io::Write::write_fmt::h71b393f1dd6d3556
   3:     0x7a9e3ae2efe2 - std::sys::backtrace::BacktraceLock::print::ha1521ca4cee64882
   4:     0x7a9e3ae31462 - std::panicking::default_hook::{{closure}}::h4131e4b424b71f39
   5:     0x7a9e3ae312ea - std::panicking::default_hook::hb9ab590f893fbc38
   6:     0x7a9e39f891a9 - std[3aba936f908a5414]::panicking::update_hook::<alloc[63d497d918fea2c7]::boxed::Box<rustc_driver_impl[721d5621d7af7046]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7a9e3ae31fa3 - std::panicking::rust_panic_with_hook::h6c45a78eda21d529
   8:     0x7a9e3ae31c66 - std::panicking::begin_panic_handler::{{closure}}::hf7369b9b7411c9ce
   9:     0x7a9e3ae2f669 - std::sys::backtrace::__rust_end_short_backtrace::hea30991d3cd62b9b
  10:     0x7a9e3ae3195d - rust_begin_unwind
  11:     0x7a9e37a55520 - core::panicking::panic_fmt::hc1e066b7e640f877
  12:     0x7a9e3cd62ecc - <rustc_type_ir[dd9c929f2a6045ff]::const_kind::ConstKind<rustc_middle[7bd58a081650d673]::ty::context::TyCtxt> as rustc_serialize[cbdad422c51ca922]::serialize::Encodable<rustc_metadata[140e3238f6966a11]::rmeta::encoder::EncodeContext>>::encode.cold
  13:     0x7a9e3ba2bf37 - rustc_middle[7bd58a081650d673]::ty::codec::encode_with_shorthand::<rustc_metadata[140e3238f6966a11]::rmeta::encoder::EncodeContext, rustc_middle[7bd58a081650d673]::ty::Ty, <rustc_metadata[140e3238f6966a11]::rmeta::encoder::EncodeContext as rustc_type_ir[dd9c929f2a6045ff]::codec::TyEncoder>::type_shorthands>
  14:     0x7a9e3c19d9fd - <rustc_middle[7bd58a081650d673]::mir::Body as rustc_serialize[cbdad422c51ca922]::serialize::Encodable<rustc_metadata[140e3238f6966a11]::rmeta::encoder::EncodeContext>>::encode
  15:     0x7a9e3c184fdc - <rustc_metadata[140e3238f6966a11]::rmeta::encoder::EncodeContext>::encode_crate_root
  16:     0x7a9e3c5ee24e - rustc_metadata[140e3238f6966a11]::rmeta::encoder::encode_metadata
  17:     0x7a9e3c5fc9f6 - rustc_metadata[140e3238f6966a11]::fs::encode_and_write_metadata
  18:     0x7a9e3c5fb88e - <rustc_interface[8dbe8781a5115760]::queries::Linker>::codegen_and_build_linker
  19:     0x7a9e3c5f219f - rustc_interface[8dbe8781a5115760]::passes::create_and_enter_global_ctxt::<core[58638448a60e4528]::option::Option<rustc_interface[8dbe8781a5115760]::queries::Linker>, rustc_driver_impl[721d5621d7af7046]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  20:     0x7a9e3c56cf73 - rustc_interface[8dbe8781a5115760]::interface::run_compiler::<(), rustc_driver_impl[721d5621d7af7046]::run_compiler::{closure#0}>::{closure#1}
  21:     0x7a9e3c4aa9b5 - std[3aba936f908a5414]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[8dbe8781a5115760]::util::run_in_thread_with_globals<rustc_interface[8dbe8781a5115760]::util::run_in_thread_pool_with_globals<rustc_interface[8dbe8781a5115760]::interface::run_compiler<(), rustc_driver_impl[721d5621d7af7046]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  22:     0x7a9e3c4aa699 - <<std[3aba936f908a5414]::thread::Builder>::spawn_unchecked_<rustc_interface[8dbe8781a5115760]::util::run_in_thread_with_globals<rustc_interface[8dbe8781a5115760]::util::run_in_thread_pool_with_globals<rustc_interface[8dbe8781a5115760]::interface::run_compiler<(), rustc_driver_impl[721d5621d7af7046]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[58638448a60e4528]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  23:     0x7a9e3c4a9e2f - std::sys::pal::unix::thread::Thread::new::thread_start::h87f43e958a0cb0f1
  24:     0x7a9e366a339d - <unknown>
  25:     0x7a9e3672849c - <unknown>
  26:                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.86.0-nightly (8239a37f9 2025-02-01) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib

query stack during panic:
end of query stack
error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0080`.
error: process exited unsuccessfully: exit status: 101

Metadata

Metadata

Assignees

Labels

A-metadataArea: Crate metadataC-bugCategory: This is a bug.F-generic_const_exprs`#![feature(generic_const_exprs)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-lowLow priorityS-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-incomplete-featuresThis issue requires the use of incomplete features.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions