@@ -9,7 +9,7 @@ extern crate alloc;
99use alloc:: string:: ToString ;
1010use alloc:: { vec, vec:: Vec } ;
1111use core:: fmt:: Debug ;
12- use facet_core:: { NumericType , PrimitiveType } ;
12+ use facet_core:: { NumericType , PointerDef , PrimitiveType , Shape } ;
1313
1414mod error;
1515use alloc:: borrow:: Cow ;
@@ -1240,7 +1240,7 @@ impl<'input> StackRunner<'input> {
12401240 trace ! ( " Starting Some(_) option for {}" , wip. shape( ) . blue( ) ) ;
12411241 wip. begin_some ( ) . map_err ( |e| self . reflect_err ( e) ) ?;
12421242 self . stack . push ( Instruction :: Pop ( PopReason :: Some ) ) ;
1243- } else if let Def :: Pointer ( inner) = wip. shape ( ) . def {
1243+ } else if let Some ( inner) = constructible_from_pointee ( wip. shape ( ) ) {
12441244 // Check if we've already begun this smart pointer
12451245 // (this can happen with slice pointees where the shape doesn't change)
12461246 if smart_pointer_begun {
@@ -1344,10 +1344,13 @@ impl<'input> StackRunner<'input> {
13441344 Some ( variant. data . fields . len ( ) ) ;
13451345 self . enum_tuple_current_field = Some ( 0 ) ;
13461346 } else {
1347- return Err ( self . err ( DeserErrorKind :: UnsupportedType {
1348- got : shape,
1349- wanted : "tuple variant for array deserialization" ,
1350- } ) ) ;
1347+ return Err ( self . err (
1348+ DeserErrorKind :: UnsupportedType {
1349+ got : shape,
1350+ wanted :
1351+ "tuple variant for array deserialization" ,
1352+ } ,
1353+ ) ) ;
13511354 }
13521355 } else {
13531356 return Err ( self . err ( DeserErrorKind :: UnsupportedType {
@@ -1845,6 +1848,13 @@ impl<'input> StackRunner<'input> {
18451848 }
18461849}
18471850
1851+ fn constructible_from_pointee ( shape : & Shape ) -> Option < PointerDef > {
1852+ match shape. def {
1853+ Def :: Pointer ( inner) if inner. constructible_from_pointee ( ) => Some ( inner) ,
1854+ _ => None ,
1855+ }
1856+ }
1857+
18481858#[ cfg( test) ]
18491859mod tests {
18501860 #[ test]
0 commit comments