2022-12-23 13:09:49 +00:00
|
|
|
use crate::dep_graph::{DepContext, DepKind};
|
2022-08-15 19:11:11 +00:00
|
|
|
use crate::query::QueryInfo;
|
2022-09-02 01:43:12 +00:00
|
|
|
|
2022-12-23 13:09:49 +00:00
|
|
|
pub trait Value<Tcx: DepContext, D: DepKind>: Sized {
|
|
|
|
fn from_cycle_error(tcx: Tcx, cycle: &[QueryInfo<D>]) -> Self;
|
2022-09-02 01:43:12 +00:00
|
|
|
}
|
|
|
|
|
2022-12-23 13:09:49 +00:00
|
|
|
impl<Tcx: DepContext, T, D: DepKind> Value<Tcx, D> for T {
|
|
|
|
default fn from_cycle_error(tcx: Tcx, _: &[QueryInfo<D>]) -> T {
|
2022-09-02 01:43:12 +00:00
|
|
|
tcx.sess().abort_if_errors();
|
|
|
|
// Ideally we would use `bug!` here. But bug! is only defined in rustc_middle, and it's
|
|
|
|
// non-trivial to define it earlier.
|
|
|
|
panic!("Value::from_cycle_error called without errors");
|
|
|
|
}
|
|
|
|
}
|