@@ -106,13 +106,10 @@ impl TypeMapper {
106106 let inner = self . map_type ( & a. element ) ?;
107107 match & a. size {
108108 Some ( Expr :: Lit ( lit) ) if lit. kind == LitKind :: Integer => {
109- let n: usize = lit. span . src ( ) . parse ( ) . map_err ( |_| {
110- TranspileError :: UnsupportedType {
111- message : format ! ( "invalid array size literal `{}`" , lit. span. src( ) ) ,
112- src : lit. span . full_source ( ) . to_owned ( ) ,
113- err_span : lit. span . into ( ) ,
114- }
115- } ) ?;
109+ let n: usize =
110+ lit. span . src ( ) . parse ( ) . map_err ( |_| {
111+ unsupported_from_type ( "invalid array size literal" , ty)
112+ } ) ?;
116113 let lit_n =
117114 syn:: LitInt :: new ( & n. to_string ( ) , proc_macro2:: Span :: call_site ( ) ) ;
118115 Ok ( syn:: parse_quote!( [ #inner; #lit_n] ) )
@@ -159,11 +156,10 @@ impl TypeMapper {
159156 }
160157 Ok ( result)
161158 }
162- Type :: Auto ( a) => Err ( TranspileError :: UnsupportedType {
163- message : "auto type cannot be mapped to Rust" . to_owned ( ) ,
164- src : a. span . full_source ( ) . to_owned ( ) ,
165- err_span : a. span . into ( ) ,
166- } ) ,
159+ Type :: Auto ( _) => Err ( unsupported_from_type (
160+ "auto type cannot be mapped to Rust" ,
161+ ty,
162+ ) ) ,
167163 Type :: Decltype ( _) => Err ( unsupported_from_type (
168164 "decltype cannot be mapped to Rust" ,
169165 ty,
@@ -271,11 +267,13 @@ fn unsupported_from_type(message: &str, ty: &Type<'_>) -> TranspileError {
271267 match type_span ( ty) {
272268 Some ( span) => TranspileError :: UnsupportedType {
273269 message : message. to_owned ( ) ,
270+ ty : format ! ( "{ty:?}" ) ,
274271 src : span. full_source ( ) . to_owned ( ) ,
275272 err_span : span. into ( ) ,
276273 } ,
277274 None => TranspileError :: UnsupportedType {
278275 message : message. to_owned ( ) ,
276+ ty : format ! ( "{ty:?}" ) ,
279277 src : String :: new ( ) ,
280278 err_span : miette:: SourceSpan :: new ( 0 . into ( ) , 0 ) ,
281279 } ,
@@ -355,6 +353,7 @@ impl<'de> Transpile for ItemStatic<'de> {
355353 . as_ref ( )
356354 . ok_or_else ( || TranspileError :: UnsupportedExpr {
357355 message : "Rust statics require an initializer" . to_owned ( ) ,
356+ expr : "missing initializer" . to_owned ( ) ,
358357 src : name. span . full_source ( ) . to_owned ( ) ,
359358 err_span : name. span . into ( ) ,
360359 } ) ?;
0 commit comments