1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//! Handle the conversion of different internal errors into a stable version.
//!
//! Currently we encode everything as [stable_mir::Error], which is represented as a string.
use crate::rustc_smir::{Stable, Tables};
use rustc_middle::mir::interpret::AllocError;
use rustc_middle::ty::layout::LayoutError;

impl<'tcx> Stable<'tcx> for LayoutError<'tcx> {
    type T = stable_mir::Error;

    fn stable(&self, _tables: &mut Tables<'_>) -> Self::T {
        stable_mir::Error::new(format!("{self:?}"))
    }
}

impl<'tcx> Stable<'tcx> for AllocError {
    type T = stable_mir::Error;

    fn stable(&self, _tables: &mut Tables<'_>) -> Self::T {
        stable_mir::Error::new(format!("{self:?}"))
    }
}