Skip to content

Commit 870826c

Browse files
committed
refactor: implement SmirError
1 parent dfab0df commit 870826c

File tree

1 file changed

+10
-2
lines changed
  • compiler/rustc_smir/src/stable_mir

1 file changed

+10
-2
lines changed

compiler/rustc_smir/src/stable_mir/error.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
use std::fmt::{Debug, Display, Formatter};
88
use std::{fmt, io};
99

10+
use rustc_smir::SmirError;
11+
12+
use crate::rustc_smir;
13+
1014
macro_rules! error {
1115
($fmt: literal $(,)?) => { Error(format!($fmt)) };
1216
($fmt: literal, $($arg:tt)*) => { Error(format!($fmt, $($arg)*)) };
@@ -30,10 +34,14 @@ pub enum CompilerError<T> {
3034
#[derive(Clone, Debug, Eq, PartialEq)]
3135
pub struct Error(pub(crate) String);
3236

33-
impl Error {
34-
pub fn new(msg: String) -> Self {
37+
impl SmirError for Error {
38+
fn new(msg: String) -> Self {
3539
Self(msg)
3640
}
41+
42+
fn from_internal<T: Debug>(err: T) -> Self {
43+
Self(format!("{err:?}"))
44+
}
3745
}
3846

3947
impl From<&str> for Error {

0 commit comments

Comments
 (0)