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};
9
10impl<'tcx> Stable<'tcx> for LayoutError<'tcx> {
11 type T = stable_mir::Error;
12
13 fn stable(&self, _tables: &mut Tables<'_>) -> Self::T {
14 stable_mir::Error::new(format!("{self:?}"))
15 }
16}
17
18impl<'tcx> Stable<'tcx> for AllocError {
19 type T = stable_mir::Error;
20
21 fn stable(&self, _tables: &mut Tables<'_>) -> Self::T {
22 stable_mir::Error::new(format!("{self:?}"))
23 }
24}