11use std:: fmt:: { Debug , Formatter } ;
22use std:: io;
33
4- use rustc_public_bridge:: bridge:: SmirError ;
4+ use rustc_public_bridge:: bridge;
55use serde:: Serialize ;
66
77use 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}
0 commit comments