@@ -2,12 +2,13 @@ use std::fmt::{Debug, Formatter};
2
2
use std:: io;
3
3
4
4
use serde:: Serialize ;
5
+ use stable_mir:: abi:: FnAbi ;
6
+ use stable_mir:: crate_def:: CrateDef ;
7
+ use stable_mir:: mir:: Body ;
8
+ use stable_mir:: ty:: { Allocation , ClosureDef , ClosureKind , FnDef , GenericArgs , IndexedVal , Ty } ;
9
+ use stable_mir:: { CrateItem , DefId , Error , ItemKind , Opaque , Symbol , with} ;
5
10
6
- use crate :: abi:: FnAbi ;
7
- use crate :: crate_def:: CrateDef ;
8
- use crate :: mir:: Body ;
9
- use crate :: ty:: { Allocation , ClosureDef , ClosureKind , FnDef , GenericArgs , IndexedVal , Ty } ;
10
- use crate :: { CrateItem , DefId , Error , ItemKind , Opaque , Symbol , with} ;
11
+ use crate :: stable_mir;
11
12
12
13
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize ) ]
13
14
pub enum MonoItem {
@@ -117,11 +118,11 @@ impl Instance {
117
118
}
118
119
119
120
/// Resolve an instance starting from a function definition and generic arguments.
120
- pub fn resolve ( def : FnDef , args : & GenericArgs ) -> Result < Instance , crate :: Error > {
121
+ pub fn resolve ( def : FnDef , args : & GenericArgs ) -> Result < Instance , Error > {
121
122
with ( |context| {
122
- context. resolve_instance ( def , args ) . ok_or_else ( || {
123
- crate :: Error :: new ( format ! ( "Failed to resolve `{ def:?}` with `{ args:?}`" ) )
124
- } )
123
+ context
124
+ . resolve_instance ( def, args)
125
+ . ok_or_else ( || Error :: new ( format ! ( "Failed to resolve `{def:?}` with `{args:?}`" ) ) )
125
126
} )
126
127
}
127
128
@@ -131,11 +132,11 @@ impl Instance {
131
132
}
132
133
133
134
/// Resolve an instance for a given function pointer.
134
- pub fn resolve_for_fn_ptr ( def : FnDef , args : & GenericArgs ) -> Result < Instance , crate :: Error > {
135
+ pub fn resolve_for_fn_ptr ( def : FnDef , args : & GenericArgs ) -> Result < Instance , Error > {
135
136
with ( |context| {
136
- context. resolve_for_fn_ptr ( def , args ) . ok_or_else ( || {
137
- crate :: Error :: new ( format ! ( "Failed to resolve `{ def:?}` with `{ args:?}`" ) )
138
- } )
137
+ context
138
+ . resolve_for_fn_ptr ( def, args)
139
+ . ok_or_else ( || Error :: new ( format ! ( "Failed to resolve `{def:?}` with `{args:?}`" ) ) )
139
140
} )
140
141
}
141
142
@@ -144,11 +145,11 @@ impl Instance {
144
145
def : ClosureDef ,
145
146
args : & GenericArgs ,
146
147
kind : ClosureKind ,
147
- ) -> Result < Instance , crate :: Error > {
148
+ ) -> Result < Instance , Error > {
148
149
with ( |context| {
149
- context. resolve_closure ( def , args , kind ) . ok_or_else ( || {
150
- crate :: Error :: new ( format ! ( "Failed to resolve `{ def:?}` with `{ args:?}`" ) )
151
- } )
150
+ context
151
+ . resolve_closure ( def, args, kind )
152
+ . ok_or_else ( || Error :: new ( format ! ( "Failed to resolve `{def:?}` with `{args:?}`" ) ) )
152
153
} )
153
154
}
154
155
@@ -195,7 +196,7 @@ impl Debug for Instance {
195
196
/// Try to convert a crate item into an instance.
196
197
/// The item cannot be generic in order to be converted into an instance.
197
198
impl TryFrom < CrateItem > for Instance {
198
- type Error = crate :: Error ;
199
+ type Error = stable_mir :: Error ;
199
200
200
201
fn try_from ( item : CrateItem ) -> Result < Self , Self :: Error > {
201
202
with ( |context| {
@@ -212,7 +213,7 @@ impl TryFrom<CrateItem> for Instance {
212
213
/// Try to convert an instance into a crate item.
213
214
/// Only user defined instances can be converted.
214
215
impl TryFrom < Instance > for CrateItem {
215
- type Error = crate :: Error ;
216
+ type Error = stable_mir :: Error ;
216
217
217
218
fn try_from ( value : Instance ) -> Result < Self , Self :: Error > {
218
219
with ( |context| {
@@ -259,7 +260,7 @@ crate_def! {
259
260
}
260
261
261
262
impl TryFrom < CrateItem > for StaticDef {
262
- type Error = crate :: Error ;
263
+ type Error = stable_mir :: Error ;
263
264
264
265
fn try_from ( value : CrateItem ) -> Result < Self , Self :: Error > {
265
266
if matches ! ( value. kind( ) , ItemKind :: Static ) {
@@ -271,7 +272,7 @@ impl TryFrom<CrateItem> for StaticDef {
271
272
}
272
273
273
274
impl TryFrom < Instance > for StaticDef {
274
- type Error = crate :: Error ;
275
+ type Error = stable_mir :: Error ;
275
276
276
277
fn try_from ( value : Instance ) -> Result < Self , Self :: Error > {
277
278
StaticDef :: try_from ( CrateItem :: try_from ( value) ?)
0 commit comments