Skip to content

Commit 64b1121

Browse files
stepanchegfacebook-github-bot
authored andcommitted
Merge copy-paste in StarlarkValue impl for def
Summary: Implementations are identical except ignored parameter to `eval.ann`. {F663006871} There's an explanation in comment: ``` // We define two different StarlarkValue instances because // the invoker uses different types for both of them. ``` which makes no sense to me. Probably some legacy. Reviewed By: ndmitchell Differential Revision: D30887690 fbshipit-source-id: b80826f763d1a2ebd8592b56c884e4705d6b8111
1 parent 324152f commit 64b1121

File tree

1 file changed

+5
-36
lines changed
  • starlark/src/eval/fragment

1 file changed

+5
-36
lines changed

starlark/src/eval/fragment/def.rs

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use crate::{
4646
},
4747
};
4848
use derivative::Derivative;
49-
use gazebo::prelude::*;
49+
use gazebo::{any::AnyLifetime, prelude::*};
5050
use std::{collections::HashMap, mem, sync::Arc};
5151

5252
struct ParameterName {
@@ -433,41 +433,10 @@ impl<'v> ComplexValue<'v> for Def<'v> {
433433
}
434434
}
435435

436-
// We define two different StarlarkValue instances because
437-
// the invoker uses different types for both of them.
438-
impl<'v> StarlarkValue<'v> for FrozenDef {
439-
starlark_type!(FUNCTION_TYPE);
440-
441-
fn collect_repr(&self, collector: &mut String) {
442-
collector.push_str(&self.parameters.signature());
443-
}
444-
445-
fn invoke(
446-
&self,
447-
me: Value<'v>,
448-
location: Option<Span>,
449-
args: Arguments<'v, '_>,
450-
eval: &mut Evaluator<'v, '_>,
451-
) -> anyhow::Result<Value<'v>> {
452-
eval.ann("invoke_frozen_def", |eval| {
453-
let local_slots = self.stmt.scope_names.used;
454-
let slot_base = eval.local_variables.reserve(local_slots);
455-
let slots = eval.local_variables.get_slots_at(slot_base);
456-
self.parameters.collect_inline(args, slots, eval.heap())?;
457-
eval.with_call_stack(me, location, |eval| {
458-
eval.ann("invoke_frozen_def_raw", |eval| {
459-
self.invoke_raw(slot_base, eval)
460-
})
461-
})
462-
})
463-
}
464-
465-
fn documentation(&self) -> Option<DocItem> {
466-
self.docs()
467-
}
468-
}
469-
470-
impl<'v> StarlarkValue<'v> for Def<'v> {
436+
impl<'v, V: ValueLike<'v>> StarlarkValue<'v> for DefGen<V>
437+
where
438+
Self: AnyLifetime<'v>,
439+
{
471440
starlark_type!(FUNCTION_TYPE);
472441

473442
fn collect_repr(&self, collector: &mut String) {

0 commit comments

Comments
 (0)