1
1
use std:: fmt:: { Debug , Formatter } ;
2
2
use std:: io;
3
3
4
- use rustc_public_bridge:: bridge:: SmirError ;
4
+ use rustc_public_bridge:: bridge;
5
5
use serde:: Serialize ;
6
6
7
7
use crate :: abi:: FnAbi ;
@@ -120,9 +120,9 @@ impl Instance {
120
120
/// Resolve an instance starting from a function definition and generic arguments.
121
121
pub fn resolve ( def : FnDef , args : & GenericArgs ) -> Result < Instance , Error > {
122
122
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
+ } )
126
126
} )
127
127
}
128
128
@@ -134,9 +134,9 @@ impl Instance {
134
134
/// Resolve an instance for a given function pointer.
135
135
pub fn resolve_for_fn_ptr ( def : FnDef , args : & GenericArgs ) -> Result < Instance , Error > {
136
136
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
+ } )
140
140
} )
141
141
}
142
142
@@ -147,9 +147,9 @@ impl Instance {
147
147
kind : ClosureKind ,
148
148
) -> Result < Instance , Error > {
149
149
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
+ } )
153
153
} )
154
154
}
155
155
@@ -201,7 +201,7 @@ impl TryFrom<CrateItem> for Instance {
201
201
if !context. requires_monomorphization ( def_id) {
202
202
Ok ( context. mono_instance ( def_id) )
203
203
} else {
204
- Err ( Error :: new ( "Item requires monomorphization" . to_string ( ) ) )
204
+ Err ( bridge :: Error :: new ( "Item requires monomorphization" . to_string ( ) ) )
205
205
}
206
206
} )
207
207
}
@@ -217,7 +217,7 @@ impl TryFrom<Instance> for CrateItem {
217
217
if value. kind == InstanceKind :: Item && context. has_body ( value. def . def_id ( ) ) {
218
218
Ok ( CrateItem ( context. instance_def_id ( value. def ) ) )
219
219
} 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) ) )
221
221
}
222
222
} )
223
223
}
@@ -263,7 +263,7 @@ impl TryFrom<CrateItem> for StaticDef {
263
263
if matches ! ( value. kind( ) , ItemKind :: Static ) {
264
264
Ok ( StaticDef ( value. 0 ) )
265
265
} 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:?}" ) ) )
267
267
}
268
268
}
269
269
}
0 commit comments