Skip to content

Commit b995469

Browse files
stepanchegfacebook-github-bot
authored andcommitted
Require StarlarkTypeRepr for AllocFrozenValue
Summary: Used in the following diff D47173723. Reviewed By: ndmitchell Differential Revision: D47173718 fbshipit-source-id: ec3c80efd762ae4d432cb87facc0db8fceebb10a
1 parent 9ffee3a commit b995469

File tree

6 files changed

+20
-8
lines changed

6 files changed

+20
-8
lines changed

starlark/src/values/alloc_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl<A: AllocFrozenValue, B: AllocFrozenValue> AllocFrozenValue for Either<A, B>
9292
}
9393

9494
/// Trait for things that can be allocated on a [`FrozenHeap`] producing a [`FrozenValue`].
95-
pub trait AllocFrozenValue {
95+
pub trait AllocFrozenValue: StarlarkTypeRepr {
9696
/// Allocate a value in the frozen heap and return a reference to the allocated value.
9797
fn alloc_frozen_value(self, heap: &FrozenHeap) -> FrozenValue;
9898
}

starlark/src/values/owned.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ use dupe::Clone_;
2424
use dupe::Dupe;
2525
use dupe::Dupe_;
2626

27+
use crate::typing::Ty;
2728
use crate::values::none::NoneType;
29+
use crate::values::type_repr::StarlarkTypeRepr;
2830
use crate::values::AllocFrozenValue;
2931
use crate::values::FrozenHeap;
3032
use crate::values::FrozenHeapRef;
@@ -60,6 +62,12 @@ impl Display for OwnedFrozenValue {
6062
}
6163
}
6264

65+
impl StarlarkTypeRepr for OwnedFrozenValue {
66+
fn starlark_type_repr() -> Ty {
67+
FrozenValue::starlark_type_repr()
68+
}
69+
}
70+
6371
impl AllocFrozenValue for OwnedFrozenValue {
6472
fn alloc_frozen_value(self, heap: &FrozenHeap) -> FrozenValue {
6573
// Safe because this is the standard expectation for alloc_frozen_value

starlark/src/values/types/dict/value.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ impl<'v> AllocValue<'v> for Dict<'v> {
123123
}
124124
}
125125

126+
impl StarlarkTypeRepr for FrozenDictData {
127+
fn starlark_type_repr() -> Ty {
128+
Ty::dict(Ty::Any, Ty::Any)
129+
}
130+
}
131+
126132
impl AllocFrozenValue for FrozenDictData {
127133
fn alloc_frozen_value(self, heap: &FrozenHeap) -> FrozenValue {
128134
if self.content.is_empty() {

starlark/src/values/types/list/value.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ impl<V: AllocFrozenValue> AllocFrozenValue for Vec<V> {
239239
}
240240
}
241241

242-
impl<'a, 'v, V: 'a> StarlarkTypeRepr for &'a [V]
242+
impl<'a, V: 'a> StarlarkTypeRepr for &'a [V]
243243
where
244-
&'a V: AllocValue<'v> + StarlarkTypeRepr,
244+
&'a V: StarlarkTypeRepr,
245245
{
246246
fn starlark_type_repr() -> Ty {
247247
Vec::<&'a V>::starlark_type_repr()

starlark/src/values/types/structs/alloc.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,10 @@ impl AllocStruct<iter::Empty<(String, String)>> {
5757
pub const EMPTY: AllocStruct<iter::Empty<(String, String)>> = AllocStruct(iter::empty());
5858
}
5959

60-
impl<'v, K, V, S> StarlarkTypeRepr for AllocStruct<S>
60+
impl<K, V, S> StarlarkTypeRepr for AllocStruct<S>
6161
where
6262
S: IntoIterator<Item = (K, V)>,
63-
K: AllocStringValue<'v>,
64-
V: AllocValue<'v>,
63+
V: StarlarkTypeRepr,
6564
{
6665
fn starlark_type_repr() -> Ty {
6766
Struct::starlark_type_repr()

starlark/src/values/types/tuple/alloc.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,9 @@ impl AllocTuple<iter::Empty<FrozenValue>> {
4848
pub const EMPTY: AllocTuple<iter::Empty<FrozenValue>> = AllocTuple(iter::empty());
4949
}
5050

51-
impl<'v, T> StarlarkTypeRepr for AllocTuple<T>
51+
impl<T> StarlarkTypeRepr for AllocTuple<T>
5252
where
5353
T: IntoIterator,
54-
T::Item: AllocValue<'v>,
5554
{
5655
fn starlark_type_repr() -> Ty {
5756
Ty::name(TupleRef::TYPE)

0 commit comments

Comments
 (0)