Skip to content

Commit 15f93e2

Browse files
jtbraunmeta-codesync[bot]
authored andcommitted
Remove the FrozenDef alias
Summary: `FrozenDef` is a leftover `'static` spelling from the heap-brand migration: the freeze machinery already carries defs as branded `ValueTyped<'fv, Def<'fv>>`, and the alias survives only as a name for two call sites. Spell those directly instead and delete it: the frozen-def registration check compares `TypeId`s through `AnyLifetime::static_type_id`, which never names a `'static` instantiation; the bytecode golden test downcasts through `Def` and lets the owned carrier fix the brand. Reviewed By: JakobDegen Differential Revision: D119373674 fbshipit-source-id: 249979d353eda27d47a644c1bc1406428f72b67d
1 parent c36ea2f commit 15f93e2

3 files changed

Lines changed: 6 additions & 9 deletions

File tree

starlark/src/eval/compiler/def.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,8 +721,6 @@ impl Display for Def<'_> {
721721
}
722722
}
723723

724-
pub(crate) type FrozenDef = Def<'static>;
725-
726724
impl<'v> AllocValue<'v> for Def<'v> {
727725
fn alloc_value(self, heap: Heap<'v>) -> Value<'v> {
728726
heap.alloc_complex_branded(self)

starlark/src/tests/bc/golden.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use std::mem;
2121
use starlark_syntax::golden_test_template::golden_test_template;
2222

2323
use crate::assert::Assert;
24-
use crate::eval::compiler::def::FrozenDef;
24+
use crate::eval::compiler::def::Def;
2525
use crate::syntax::Dialect;
2626

2727
fn test_function_bytecode(program: &str) -> String {
@@ -33,7 +33,7 @@ fn test_function_bytecode(program: &str) -> String {
3333
.module("instrs.star", program)
3434
.get_owned("test")
3535
.unwrap()
36-
.downcast_starlark::<FrozenDef>()
36+
.downcast_starlark::<Def>()
3737
.unwrap();
3838

3939
let mut golden = String::new();

starlark/src/values/layout/avalues/complex_branded.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
* limitations under the License.
1616
*/
1717

18-
use std::any::TypeId;
1918
use std::marker::PhantomData;
2019
use std::mem;
2120

2221
use super::simple::AValueSimple;
23-
use crate::eval::compiler::def::FrozenDef;
22+
use crate::any::AnyLifetime;
23+
use crate::eval::compiler::def::Def;
2424
use crate::private::Private;
2525
use crate::values::FreezeBranded;
2626
use crate::values::FreezeResult;
@@ -73,9 +73,8 @@ where
7373
AValueHeader::overwrite_with_forward::<Self::StarlarkValue>(me, r.forward_ptr());
7474
let res = x.freeze(freezer)?;
7575
let fv = r.fill(res);
76-
if TypeId::of::<T::Frozen<'static>>() == TypeId::of::<FrozenDef>() {
77-
let frozen_def =
78-
ValueTyped::new(fv).expect("`fv` was just filled with a `FrozenDef`");
76+
if T::Frozen::<'fv>::static_type_id() == Def::static_type_id() {
77+
let frozen_def = ValueTyped::new(fv).expect("`fv` was just filled with a `Def`");
7978
freezer.frozen_defs.borrow_mut().push(frozen_def);
8079
}
8180
Ok(fv)

0 commit comments

Comments
 (0)