rustc_query_system/
values.rs1use rustc_span::ErrorGuaranteed;
2
3use crate::dep_graph::DepContext;
4use crate::query::CycleError;
5
6pub trait Value<Tcx: DepContext>: Sized {
7 fn from_cycle_error(tcx: Tcx, cycle_error: &CycleError, guar: ErrorGuaranteed) -> Self;
8}
9
10impl<Tcx: DepContext, T> Value<Tcx> for T {
11 default fn from_cycle_error(tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed) -> T {
12 tcx.sess().dcx().abort_if_errors();
13 {
::core::panicking::panic_fmt(format_args!("<{0} as Value>::from_cycle_error called without errors: {1:#?}",
std::any::type_name::<T>(), cycle_error.cycle));
};panic!(
16 "<{} as Value>::from_cycle_error called without errors: {:#?}",
17 std::any::type_name::<T>(),
18 cycle_error.cycle,
19 );
20 }
21}