Skip to content

Commit 922b034

Browse files
committed
SmirError to Error
1 parent 7831a1f commit 922b034

File tree

10 files changed

+25
-26
lines changed

10 files changed

+25
-26
lines changed

compiler/rustc_public/src/alloc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use rustc_abi::Align;
88
use rustc_middle::mir::ConstValue;
99
use rustc_middle::mir::interpret::AllocRange;
10-
use rustc_public_bridge::bridge::SmirError;
10+
use rustc_public_bridge::bridge::Error as _;
1111
use rustc_public_bridge::context::CompilerCtxt;
1212
use rustc_public_bridge::{Tables, alloc};
1313

compiler/rustc_public/src/error.rs

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

10-
use rustc_public_bridge::bridge::SmirError;
10+
use rustc_public_bridge::bridge;
1111

1212
macro_rules! error {
1313
($fmt: literal $(,)?) => { Error(format!($fmt)) };
@@ -32,7 +32,7 @@ pub enum CompilerError<T> {
3232
#[derive(Clone, Debug, Eq, PartialEq)]
3333
pub struct Error(pub(crate) String);
3434

35-
impl SmirError for Error {
35+
impl bridge::Error for Error {
3636
fn new(msg: String) -> Self {
3737
Self(msg)
3838
}

compiler/rustc_public/src/mir/mono.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::fmt::{Debug, Formatter};
22
use std::io;
33

4-
use rustc_public_bridge::bridge::SmirError;
4+
use rustc_public_bridge::bridge;
55
use serde::Serialize;
66

77
use crate::abi::FnAbi;
@@ -120,9 +120,9 @@ impl Instance {
120120
/// Resolve an instance starting from a function definition and generic arguments.
121121
pub fn resolve(def: FnDef, args: &GenericArgs) -> Result<Instance, Error> {
122122
with(|context| {
123-
context
124-
.resolve_instance(def, args)
125-
.ok_or_else(|| Error::new(format!("Failed to resolve `{def:?}` with `{args:?}`")))
123+
context.resolve_instance(def, args).ok_or_else(|| {
124+
bridge::Error::new(format!("Failed to resolve `{def:?}` with `{args:?}`"))
125+
})
126126
})
127127
}
128128

@@ -134,9 +134,9 @@ impl Instance {
134134
/// Resolve an instance for a given function pointer.
135135
pub fn resolve_for_fn_ptr(def: FnDef, args: &GenericArgs) -> Result<Instance, Error> {
136136
with(|context| {
137-
context
138-
.resolve_for_fn_ptr(def, args)
139-
.ok_or_else(|| Error::new(format!("Failed to resolve `{def:?}` with `{args:?}`")))
137+
context.resolve_for_fn_ptr(def, args).ok_or_else(|| {
138+
bridge::Error::new(format!("Failed to resolve `{def:?}` with `{args:?}`"))
139+
})
140140
})
141141
}
142142

@@ -147,9 +147,9 @@ impl Instance {
147147
kind: ClosureKind,
148148
) -> Result<Instance, Error> {
149149
with(|context| {
150-
context
151-
.resolve_closure(def, args, kind)
152-
.ok_or_else(|| Error::new(format!("Failed to resolve `{def:?}` with `{args:?}`")))
150+
context.resolve_closure(def, args, kind).ok_or_else(|| {
151+
bridge::Error::new(format!("Failed to resolve `{def:?}` with `{args:?}`"))
152+
})
153153
})
154154
}
155155

@@ -201,7 +201,7 @@ impl TryFrom<CrateItem> for Instance {
201201
if !context.requires_monomorphization(def_id) {
202202
Ok(context.mono_instance(def_id))
203203
} else {
204-
Err(Error::new("Item requires monomorphization".to_string()))
204+
Err(bridge::Error::new("Item requires monomorphization".to_string()))
205205
}
206206
})
207207
}
@@ -217,7 +217,7 @@ impl TryFrom<Instance> for CrateItem {
217217
if value.kind == InstanceKind::Item && context.has_body(value.def.def_id()) {
218218
Ok(CrateItem(context.instance_def_id(value.def)))
219219
} else {
220-
Err(Error::new(format!("Item kind `{:?}` cannot be converted", value.kind)))
220+
Err(bridge::Error::new(format!("Item kind `{:?}` cannot be converted", value.kind)))
221221
}
222222
})
223223
}
@@ -263,7 +263,7 @@ impl TryFrom<CrateItem> for StaticDef {
263263
if matches!(value.kind(), ItemKind::Static) {
264264
Ok(StaticDef(value.0))
265265
} else {
266-
Err(Error::new(format!("Expected a static item, but found: {value:?}")))
266+
Err(bridge::Error::new(format!("Expected a static item, but found: {value:?}")))
267267
}
268268
}
269269
}

compiler/rustc_public/src/unstable/convert/stable/mir.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
33
use rustc_middle::mir::mono::MonoItem;
44
use rustc_middle::{bug, mir};
5-
use rustc_public_bridge::Tables;
6-
use rustc_public_bridge::bridge::SmirError;
75
use rustc_public_bridge::context::CompilerCtxt;
6+
use rustc_public_bridge::{Tables, bridge};
87

98
use crate::compiler_interface::BridgeTys;
109
use crate::mir::alloc::GlobalAlloc;
@@ -914,7 +913,7 @@ impl<'tcx> Stable<'tcx> for mir::interpret::ErrorHandled {
914913
type T = Error;
915914

916915
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T {
917-
Error::new(format!("{self:?}"))
916+
bridge::Error::new(format!("{self:?}"))
918917
}
919918
}
920919

compiler/rustc_public/src/unstable/internal_cx/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! Implementation of InternalCx.
22
3+
pub(crate) use helpers::*;
34
use rustc_middle::ty::{List, Ty, TyCtxt};
45
use rustc_middle::{mir, ty};
5-
pub(crate) use helpers::*;
66

77
use super::InternalCx;
88

compiler/rustc_public_bridge/src/alloc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_middle::ty::{Ty, layout};
1212

1313
use super::{CompilerCtxt, Tables};
1414
use crate::bridge::Allocation as _;
15-
use crate::{Bridge, SmirError};
15+
use crate::{Bridge, Error};
1616

1717
pub fn create_ty_and_layout<'tcx, B: Bridge>(
1818
cx: &CompilerCtxt<'tcx, B>,

compiler/rustc_public_bridge/src/bridge.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::fmt::Debug;
99
use super::context::CompilerCtxt;
1010
use super::{Bridge, Tables};
1111

12-
pub trait SmirError {
12+
pub trait Error {
1313
fn new(msg: String) -> Self;
1414
fn from_internal<T: Debug>(err: T) -> Self;
1515
}

compiler/rustc_public_bridge/src/context/impls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use rustc_target::callconv::FnAbi;
2626

2727
use super::{AllocRangeHelpers, CompilerCtxt, TyHelpers, TypingEnvHelpers};
2828
use crate::builder::BodyBuilder;
29-
use crate::{Bridge, SmirError, Tables, filter_def_ids};
29+
use crate::{Bridge, Error, Tables, filter_def_ids};
3030

3131
impl<'tcx, B: Bridge> TyHelpers<'tcx> for CompilerCtxt<'tcx, B> {
3232
fn new_foreign(&self, def_id: DefId) -> ty::Ty<'tcx> {

compiler/rustc_public_bridge/src/context/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ use rustc_middle::ty;
99
use rustc_middle::ty::layout::{FnAbiOfHelpers, HasTyCtxt, HasTypingEnv, LayoutOfHelpers};
1010
use rustc_middle::ty::{Ty, TyCtxt};
1111

12-
use crate::{Bridge, SmirError};
12+
use crate::{Bridge, Error};
1313

14-
mod impls;
1514
mod helpers;
15+
mod impls;
1616

1717
pub use helpers::*;
1818

compiler/rustc_public_bridge/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ pub trait Bridge: Sized {
222222
type MirConstId: Copy + Debug + PartialEq + IndexedVal;
223223
type Layout: Copy + Debug + PartialEq + IndexedVal;
224224

225-
type Error: SmirError;
225+
type Error: Error;
226226
type CrateItem: CrateItem<Self>;
227227
type AdtDef: AdtDef<Self>;
228228
type ForeignModuleDef: ForeignModuleDef<Self>;

0 commit comments

Comments
 (0)