rustc_smir/rustc_smir/convert/
error.rs

1//! Handle the conversion of different internal errors into a stable version.
2//!
3//! Currently we encode everything as [stable_mir::Error], which is represented as a string.
4
5use rustc_middle::mir::interpret::AllocError;
6use rustc_middle::ty::layout::LayoutError;
7
8use crate::rustc_smir::{Stable, Tables};
9use crate::stable_mir;
10
11impl<'tcx> Stable<'tcx> for LayoutError<'tcx> {
12    type T = stable_mir::Error;
13
14    fn stable(&self, _tables: &mut Tables<'_>) -> Self::T {
15        stable_mir::Error::new(format!("{self:?}"))
16    }
17}
18
19impl<'tcx> Stable<'tcx> for AllocError {
20    type T = stable_mir::Error;
21
22    fn stable(&self, _tables: &mut Tables<'_>) -> Self::T {
23        stable_mir::Error::new(format!("{self:?}"))
24    }
25}