diff --git a/tamer/src/asg/graph.rs b/tamer/src/asg/graph.rs index c24520c2..8a3ae72b 100644 --- a/tamer/src/asg/graph.rs +++ b/tamer/src/asg/graph.rs @@ -430,12 +430,13 @@ pub trait AsgObjectMut: ObjectKind { /// and the commit cannot fail. /// If [`Err`] is provided to `commit`, /// then [`Asg::add_edge`] will fail with that error. - fn pre_add_edge< - OA: ObjectIndexRelTo, - OB: ObjectKind + ObjectRelatable, - >( + /// + /// Unlike the type of [`Asg::add_edge`], + /// the source [`ObjectIndex`] has been narrowed to the appropriate + /// type for you. + fn pre_add_edge( asg: &mut Asg, - _from_oi: &OA, + _from_oi: ObjectIndex, _to_oi: ObjectIndex, _ctx_span: Option, commit: impl FnOnce(&mut Asg), diff --git a/tamer/src/asg/graph/object/rel.rs b/tamer/src/asg/graph/object/rel.rs index fa0855e0..3404cfd9 100644 --- a/tamer/src/asg/graph/object/rel.rs +++ b/tamer/src/asg/graph/object/rel.rs @@ -938,7 +938,13 @@ where ctx_span: Option, commit: impl FnOnce(&mut Asg), ) -> Result<(), AsgError> { - O::pre_add_edge(asg, self, to_oi, ctx_span, commit) + O::pre_add_edge( + asg, + self.widen().must_narrow_into::(), + to_oi, + ctx_span, + commit, + ) } } @@ -962,7 +968,13 @@ impl ObjectIndexRelTo for ObjectIndexTo { ) -> Result<(), AsgError> { macro_rules! pre_add_edge { ($ty:ident) => { - $ty::pre_add_edge(asg, self, to_oi, ctx_span, commit) + $ty::pre_add_edge( + asg, + self.widen().must_narrow_into::<$ty>(), + to_oi, + ctx_span, + commit, + ) }; }