Skip to content

Commit 3172bf8

Browse files
Merge pull request #8 from sarah-quinones/main
fix reference deserialization?
2 parents 61d2f59 + 9403e02 commit 3172bf8

File tree

3 files changed

+48
-38
lines changed

3 files changed

+48
-38
lines changed

Cargo.lock

Lines changed: 30 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ default = ["std", "rich-diagnostics"]
2424

2525
[dependencies]
2626
ariadne = { version = "0.5.1", optional = true }
27-
facet-core = { version = "0.31", default-features = false }
28-
facet-reflect = { version = "0.31", default-features = false }
27+
facet-core = { version = "0.31.3", default-features = false }
28+
facet-reflect = { version = "0.31.3", default-features = false }
2929
log = "0.4.27"
3030
owo-colors = "4.2.2"
3131

src/lib.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ extern crate alloc;
99
use alloc::string::ToString;
1010
use alloc::{vec, vec::Vec};
1111
use core::fmt::Debug;
12-
use facet_core::{NumericType, PrimitiveType};
12+
use facet_core::{NumericType, PointerDef, PrimitiveType, Shape};
1313

1414
mod error;
1515
use 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)]
18491859
mod tests {
18501860
#[test]

0 commit comments

Comments
 (0)