From 89a035bcdb13ea1a31b6618f89a89493906c91d8 Mon Sep 17 00:00:00 2001
From: timofey <tim@ongoteam.yaconnect.com>
Date: Sat, 29 Jul 2023 21:34:58 +0000
Subject: [PATCH] delete `ExternalPoints`

---
 src/rcore.rs                     |  9 ++++--
 src/rstd.rs                      |  1 -
 src/rstd/collections/stack.rs    | 55 ++++++--------------------------
 src/rstd/external_points.rs      | 21 ------------
 src/rstd/inlining/static_pair.rs |  4 +--
 5 files changed, 18 insertions(+), 72 deletions(-)
 delete mode 100644 src/rstd/external_points.rs

diff --git a/src/rcore.rs b/src/rcore.rs
index 16294fd..0cb9822 100644
--- a/src/rcore.rs
+++ b/src/rcore.rs
@@ -62,13 +62,18 @@ pub trait MentionableTop<'a, Ctx: Context<'a>>: 'a {
     /// See implementation for the definition.
     /// Hash of all the references' points concatenated, ordered, non-unique.
     /// Used for walking over object trees to ensure two objects with different references don't collide.
-    fn topology(&self) -> Hash {
+    fn topology(&self) -> Hash
+    where
+        Self: Mentionable<'a, Ctx>,
+    {
         let mut vec = Vec::new();
         self.points_typed(&mut vec);
         Ctx::hash(&vec)
     }
     /// References ([Point]s) to other objects. Typed.
-    fn points_typed(&self, points: &mut impl PointsVisitor<'a, Ctx>);
+    fn points_typed(&self, points: &mut impl PointsVisitor<'a, Ctx>)
+    where
+        Self: Mentionable<'a, Ctx>;
 }
 
 pub trait Mentionable<'a, Ctx: Context<'a>>:
diff --git a/src/rstd.rs b/src/rstd.rs
index f6f04c6..1d706d4 100644
--- a/src/rstd.rs
+++ b/src/rstd.rs
@@ -3,7 +3,6 @@
 pub mod atomic;
 pub mod cast;
 pub mod collections;
-mod external_points;
 pub mod inject;
 pub mod inlining;
 mod local_origin;
diff --git a/src/rstd/collections/stack.rs b/src/rstd/collections/stack.rs
index c3d33f2..8077776 100644
--- a/src/rstd/collections/stack.rs
+++ b/src/rstd/collections/stack.rs
@@ -2,7 +2,6 @@
 
 use crate::func::{context::*, controlflow::ControlFlow};
 use crate::rcore::*;
-use crate::rstd::external_points::*;
 use crate::rstd::{inlining::*, nullable::*, point::*, *};
 
 /// Node containing a (nullable) reference to the next node and an element.
@@ -36,19 +35,6 @@ impl<'a, Ctx: Context<'a>, A: MentionableBase<'a, Ctx>> Serializable for StackNo
     }
 }
 
-pub trait StackCompatible<'a, Ctx: Context<'a>>:
-    Mentionable<'a, Ctx> + ExternalPoints<'a, Ctx, Stack<'a, Ctx, Self>>
-{
-}
-
-impl<
-        'a,
-        Ctx: Context<'a>,
-        A: Mentionable<'a, Ctx> + ExternalPoints<'a, Ctx, Stack<'a, Ctx, A>>,
-    > StackCompatible<'a, Ctx> for A
-{
-}
-
 impl<'a, Ctx: Context<'a>, A: MentionableBase<'a, Ctx>> MentionableBase<'a, Ctx>
     for StackNode<'a, Ctx, A>
 {
@@ -59,11 +45,14 @@ impl<'a, Ctx: Context<'a>, A: MentionableBase<'a, Ctx>> MentionableBase<'a, Ctx>
     }
 }
 
-impl<'a, Ctx: Context<'a>, A: StackCompatible<'a, Ctx>> MentionableTop<'a, Ctx>
+impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> MentionableTop<'a, Ctx>
     for StackNode<'a, Ctx, A>
 {
-    fn points_typed(&self, points: &mut impl PointsVisitor<'a, Ctx>) {
-        <A as ExternalPoints<'a, Ctx, _>>::ex_points_typed(&self.rest, points);
+    fn points_typed(&self, points: &mut impl PointsVisitor<'a, Ctx>)
+    where
+        Self: Mentionable<'a, Ctx>,
+    {
+        self.rest.points_typed(points);
         self.element.points_typed(points);
     }
 }
@@ -117,19 +106,6 @@ impl<F: ParseMode> ImplMode for StackNodeFactory<F> {
     type Mode = F::Mode;
 }
 
-impl<'a, Ctx: Context<'a>, F: ImplMode + RegularFactory<'a, Ctx>>
-    ExternalPointsProxy<'a, Ctx, Stack<'a, Ctx, Mtbl<'a, Ctx, F>>> for WithMode<F, RegularMode>
-where
-    F::Mtbl: MentionableTop<'a, Ctx>,
-{
-    fn exp_points_typed(
-        mentionable: &Stack<'a, Ctx, Mtbl<'a, Ctx, Self::F>>,
-        points: &mut impl PointsVisitor<'a, Ctx>,
-    ) {
-        mentionable.points_typed(points)
-    }
-}
-
 impl<'a, Ctx: Context<'a>, F: ImplMode + RegularFactory<'a, Ctx>> RegularFactory<'a, Ctx>
     for StackNodeFactory<F>
 where
@@ -177,14 +153,14 @@ pub trait ExtStack<'a, Ctx: Context<'a>, A: MentionableBase<'a, Ctx>>:
 }
 
 /// Extention trait with helper methods for [Stack]s.
-pub trait ExtStackClone<'a, Ctx: Context<'a>, A: StackCompatible<'a, Ctx> + Clone>:
+pub trait ExtStackClone<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx> + Clone>:
     MentionableBase<'a, Ctx>
 {
     /// Collect all the elements into a [`Vec`].
     fn vec(self) -> StackVecWrapped<'a, Ctx, A>;
 }
 
-impl<'a, Ctx: Context<'a>, A: StackCompatible<'a, Ctx> + Mentionable<'a, Ctx>> ExtStack<'a, Ctx, A>
+impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx> + Mentionable<'a, Ctx>> ExtStack<'a, Ctx, A>
     for Stack<'a, Ctx, A>
 where
     StackNode<'a, Ctx, A>: Mentionable<'a, Ctx, _Fctr = StackNodeFactory<A::Fctr>>,
@@ -206,7 +182,7 @@ where
     }
 }
 
-impl<'a, Ctx: Context<'a>, A: StackCompatible<'a, Ctx> + Mentionable<'a, Ctx> + Clone>
+impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx> + Mentionable<'a, Ctx> + Clone>
     ExtStackClone<'a, Ctx, A> for Stack<'a, Ctx, A>
 where
     StackNode<'a, Ctx, A>: Mentionable<'a, Ctx, _Fctr = StackNodeFactory<A::Fctr>>,
@@ -229,19 +205,6 @@ where
     }
 }
 
-impl<'a, Ctx: Context<'a>, F: ImplMode + InliningFactory<'a, Ctx>>
-    ExternalPointsProxy<'a, Ctx, Stack<'a, Ctx, Mtbl<'a, Ctx, F>>> for WithMode<F, InliningMode>
-where
-    F::Mtbl: MentionableTop<'a, Ctx>,
-{
-    fn exp_points_typed(
-        mentionable: &Stack<'a, Ctx, Mtbl<'a, Ctx, Self::F>>,
-        points: &mut impl PointsVisitor<'a, Ctx>,
-    ) {
-        mentionable.points_typed(points)
-    }
-}
-
 impl<'a, Ctx: Context<'a>, F: ImplMode + InliningFactory<'a, Ctx>> InliningFactory<'a, Ctx>
     for StackNodeFactory<F>
 where
diff --git a/src/rstd/external_points.rs b/src/rstd/external_points.rs
deleted file mode 100644
index 664d924..0000000
--- a/src/rstd/external_points.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-use crate::rcore::*;
-
-pub trait ExternalPoints<'a, Ctx: Context<'a>, T> {
-    fn ex_points_typed(mentionable: &T, points: &mut impl PointsVisitor<'a, Ctx>);
-}
-
-pub trait ExternalPointsProxy<'a, Ctx: Context<'a>, T>: FactoryModeProxy<'a, Ctx> {
-    fn exp_points_typed(mentionable: &T, points: &mut impl PointsVisitor<'a, Ctx>);
-}
-
-impl<'a, Ctx: Context<'a>, A: MentionableBase<'a, Ctx>, T> ExternalPoints<'a, Ctx, T> for A
-where
-    Fctr<'a, Ctx, A>: WithParseMode,
-    <Fctr<'a, Ctx, A> as WithParseMode>::WithMode:
-        ExternalPointsProxy<'a, Ctx, T, F = Fctr<'a, Ctx, A>>,
-{
-    fn ex_points_typed(mentionable: &T, points: &mut impl PointsVisitor<'a, Ctx>) {
-        type Wm<'a, Ctx, A> = <Fctr<'a, Ctx, A> as WithParseMode>::WithMode;
-        <Wm<'a, Ctx, A> as ExternalPointsProxy<'a, Ctx, _>>::exp_points_typed(mentionable, points)
-    }
-}
diff --git a/src/rstd/inlining/static_pair.rs b/src/rstd/inlining/static_pair.rs
index 626f0c5..cd52efb 100644
--- a/src/rstd/inlining/static_pair.rs
+++ b/src/rstd/inlining/static_pair.rs
@@ -114,8 +114,8 @@ impl<'a, Ctx: Context<'a>, SP: StaticPair<'a, Ctx>> MentionableBase<'a, Ctx>
 
 impl<'a, Ctx: Context<'a>, SP: StaticPair<'a, Ctx>> MentionableTop<'a, Ctx> for StaticPairObject<SP>
 where
-    SP::A: MentionableTop<'a, Ctx>,
-    SP::B: MentionableTop<'a, Ctx>,
+    SP::A: Mentionable<'a, Ctx>,
+    SP::B: Mentionable<'a, Ctx>,
 {
     fn points_typed(&self, points: &mut impl PointsVisitor<'a, Ctx>) {
         let (a, b) = self.pair.elements();