diff --git a/lattices/src/collections.rs b/lattices/src/collections.rs index 13494e6fe915..42bc8ec24cf8 100644 --- a/lattices/src/collections.rs +++ b/lattices/src/collections.rs @@ -84,7 +84,8 @@ impl Len for VecSet { } } impl CollectionRef for VecSet { - type ItemRef<'a> = &'a Self::Item + type ItemRef<'a> + = &'a Self::Item where Self: 'a; @@ -103,7 +104,8 @@ where } } impl CollectionMut for VecSet { - type ItemMut<'a> = &'a mut Self::Item + type ItemMut<'a> + = &'a mut Self::Item where Self: 'a; @@ -119,7 +121,8 @@ where } } impl Iter for VecSet { - type Iter<'a> = std::slice::Iter<'a, T> + type Iter<'a> + = std::slice::Iter<'a, T> where Self: 'a; @@ -128,7 +131,8 @@ impl Iter for VecSet { } } impl IterMut for VecSet { - type IterMut<'a> = std::slice::IterMut<'a, T> + type IterMut<'a> + = std::slice::IterMut<'a, T> where Self: 'a; @@ -176,7 +180,8 @@ impl Len for VecMap { } } impl CollectionRef for VecMap { - type ItemRef<'a> = &'a Self::Item + type ItemRef<'a> + = &'a Self::Item where Self: 'a; @@ -198,7 +203,8 @@ where } } impl CollectionMut for VecMap { - type ItemMut<'a> = &'a mut Self::Item + type ItemMut<'a> + = &'a mut Self::Item where Self: 'a; @@ -220,7 +226,8 @@ impl Keyed for VecMap { type Key = K; } impl KeyedRef for VecMap { - type KeyRef<'a> = &'a Self::Key + type KeyRef<'a> + = &'a Self::Key where Self: 'a; @@ -254,18 +261,20 @@ impl SimpleKeyedRef for VecMap { simple_keyed_ref!(); } impl MapIter for VecMap { - type Iter<'a> = std::iter::Zip, std::slice::Iter<'a, V>> - where - Self: 'a; + type Iter<'a> + = std::iter::Zip, std::slice::Iter<'a, V>> + where + Self: 'a; fn iter(&self) -> Self::Iter<'_> { self.keys.iter().zip(self.vals.iter()) } } impl MapIterMut for VecMap { - type IterMut<'a> = std::iter::Zip, std::slice::IterMut<'a, V>> - where - Self: 'a; + type IterMut<'a> + = std::iter::Zip, std::slice::IterMut<'a, V>> + where + Self: 'a; fn iter_mut(&mut self) -> Self::IterMut<'_> { self.keys.iter().zip(self.vals.iter_mut()) @@ -307,7 +316,10 @@ impl Collection for EmptySet { } impl CollectionRef for EmptySet { - type ItemRef<'a> = &'a Self::Item where Self::Item: 'a; + type ItemRef<'a> + = &'a Self::Item + where + Self::Item: 'a; covariant_item_ref!(); } @@ -328,7 +340,10 @@ impl Len for EmptySet { } impl Iter for EmptySet { - type Iter<'a> = std::iter::Empty<&'a T> where T: 'a; + type Iter<'a> + = std::iter::Empty<&'a T> + where + T: 'a; fn iter(&self) -> Self::Iter<'_> { std::iter::empty() @@ -371,7 +386,8 @@ impl Len for SingletonSet { } } impl CollectionRef for SingletonSet { - type ItemRef<'a> = &'a Self::Item + type ItemRef<'a> + = &'a Self::Item where Self: 'a; @@ -390,7 +406,8 @@ where } } impl CollectionMut for SingletonSet { - type ItemMut<'a> = &'a mut T + type ItemMut<'a> + = &'a mut T where Self: 'a; @@ -406,16 +423,18 @@ where } } impl Iter for SingletonSet { - type Iter<'a> = std::iter::Once<&'a T> - where - Self: 'a; + type Iter<'a> + = std::iter::Once<&'a T> + where + Self: 'a; fn iter(&self) -> Self::Iter<'_> { std::iter::once(&self.0) } } impl IterMut for SingletonSet { - type IterMut<'a> = std::iter::Once<&'a mut T> + type IterMut<'a> + = std::iter::Once<&'a mut T> where Self: 'a; @@ -457,7 +476,8 @@ impl Len for EmptyMap { } } impl CollectionRef for EmptyMap { - type ItemRef<'a> = &'a Self::Item + type ItemRef<'a> + = &'a Self::Item where Self: 'a; @@ -476,7 +496,8 @@ where } } impl CollectionMut for EmptyMap { - type ItemMut<'a> = &'a mut Self::Item + type ItemMut<'a> + = &'a mut Self::Item where Self: 'a; @@ -495,9 +516,10 @@ impl Keyed for EmptyMap { type Key = K; } impl KeyedRef for EmptyMap { - type KeyRef<'a> = &'a Self::Key - where - Self: 'a; + type KeyRef<'a> + = &'a Self::Key + where + Self: 'a; covariant_key_ref!(); } @@ -520,9 +542,10 @@ where } } impl Iter for EmptyMap { - type Iter<'a> = std::iter::Empty<&'a V> - where - Self: 'a; + type Iter<'a> + = std::iter::Empty<&'a V> + where + Self: 'a; fn iter(&self) -> Self::Iter<'_> { std::iter::empty() @@ -532,18 +555,20 @@ impl SimpleKeyedRef for EmptyMap { simple_keyed_ref!(); } impl MapIter for EmptyMap { - type Iter<'a> = std::iter::Empty<(&'a K, &'a V)> - where - Self: 'a; + type Iter<'a> + = std::iter::Empty<(&'a K, &'a V)> + where + Self: 'a; fn iter(&self) -> Self::Iter<'_> { std::iter::empty() } } impl MapIterMut for EmptyMap { - type IterMut<'a> = std::iter::Empty<(&'a K, &'a mut V)> - where - Self: 'a; + type IterMut<'a> + = std::iter::Empty<(&'a K, &'a mut V)> + where + Self: 'a; fn iter_mut(&mut self) -> Self::IterMut<'_> { std::iter::empty() @@ -576,7 +601,8 @@ impl Len for SingletonMap { } } impl CollectionRef for SingletonMap { - type ItemRef<'a> = &'a Self::Item + type ItemRef<'a> + = &'a Self::Item where Self: 'a; @@ -595,7 +621,8 @@ where } } impl CollectionMut for SingletonMap { - type ItemMut<'a> = &'a mut Self::Item + type ItemMut<'a> + = &'a mut Self::Item where Self: 'a; @@ -614,9 +641,10 @@ impl Keyed for SingletonMap { type Key = K; } impl KeyedRef for SingletonMap { - type KeyRef<'a> = &'a Self::Key - where - Self: 'a; + type KeyRef<'a> + = &'a Self::Key + where + Self: 'a; covariant_key_ref!(); } @@ -639,9 +667,10 @@ where } } impl Iter for SingletonMap { - type Iter<'a> = std::iter::Once<&'a V> - where - Self: 'a; + type Iter<'a> + = std::iter::Once<&'a V> + where + Self: 'a; fn iter(&self) -> Self::Iter<'_> { std::iter::once(&self.1) @@ -651,18 +680,20 @@ impl SimpleKeyedRef for SingletonMap { simple_keyed_ref!(); } impl MapIter for SingletonMap { - type Iter<'a> = std::iter::Once<(&'a K, &'a V)> - where - Self: 'a; + type Iter<'a> + = std::iter::Once<(&'a K, &'a V)> + where + Self: 'a; fn iter(&self) -> Self::Iter<'_> { std::iter::once((&self.0, &self.1)) } } impl MapIterMut for SingletonMap { - type IterMut<'a> = std::iter::Once<(&'a K, &'a mut V)> - where - Self: 'a; + type IterMut<'a> + = std::iter::Once<(&'a K, &'a mut V)> + where + Self: 'a; fn iter_mut(&mut self) -> Self::IterMut<'_> { std::iter::once((&self.0, &mut self.1)) @@ -716,7 +747,8 @@ impl Len for OptionSet { } } impl CollectionRef for OptionSet { - type ItemRef<'a> = &'a Self::Item + type ItemRef<'a> + = &'a Self::Item where Self: 'a; @@ -735,7 +767,8 @@ where } } impl CollectionMut for OptionSet { - type ItemMut<'a> = &'a mut T + type ItemMut<'a> + = &'a mut T where Self: 'a; @@ -751,16 +784,18 @@ where } } impl Iter for OptionSet { - type Iter<'a> = std::option::Iter<'a, T> - where - Self: 'a; + type Iter<'a> + = std::option::Iter<'a, T> + where + Self: 'a; fn iter(&self) -> Self::Iter<'_> { self.0.iter() } } impl IterMut for OptionSet { - type IterMut<'a> = std::option::IterMut<'a, T> + type IterMut<'a> + = std::option::IterMut<'a, T> where Self: 'a; @@ -803,7 +838,8 @@ impl Len for OptionMap { } } impl CollectionRef for OptionMap { - type ItemRef<'a> = &'a Self::Item + type ItemRef<'a> + = &'a Self::Item where Self: 'a; @@ -825,7 +861,8 @@ where } } impl CollectionMut for OptionMap { - type ItemMut<'a> = &'a mut Self::Item + type ItemMut<'a> + = &'a mut Self::Item where Self: 'a; @@ -847,9 +884,10 @@ impl Keyed for OptionMap { type Key = K; } impl KeyedRef for OptionMap { - type KeyRef<'a> = &'a Self::Key - where - Self: 'a; + type KeyRef<'a> + = &'a Self::Key + where + Self: 'a; covariant_key_ref!(); } @@ -878,9 +916,10 @@ where } } impl Iter for OptionMap { - type Iter<'a> = std::option::IntoIter<&'a V> - where - Self: 'a; + type Iter<'a> + = std::option::IntoIter<&'a V> + where + Self: 'a; fn iter(&self) -> Self::Iter<'_> { self.0.as_ref().map(|(_k, v)| v).into_iter() @@ -890,18 +929,20 @@ impl SimpleKeyedRef for OptionMap { simple_keyed_ref!(); } impl MapIter for OptionMap { - type Iter<'a> = std::option::IntoIter<(&'a K, &'a V)> - where - Self: 'a; + type Iter<'a> + = std::option::IntoIter<(&'a K, &'a V)> + where + Self: 'a; fn iter(&self) -> Self::Iter<'_> { self.0.as_ref().map(|(k, v)| (k, v)).into_iter() } } impl MapIterMut for OptionMap { - type IterMut<'a> = std::option::IntoIter<(&'a K, &'a mut V)> - where - Self: 'a; + type IterMut<'a> + = std::option::IntoIter<(&'a K, &'a mut V)> + where + Self: 'a; fn iter_mut(&mut self) -> Self::IterMut<'_> { self.0.as_mut().map(|(k, v)| (&*k, v)).into_iter() @@ -945,7 +986,8 @@ impl Len for ArraySet { } } impl CollectionRef for ArraySet { - type ItemRef<'a> = &'a T + type ItemRef<'a> + = &'a T where Self: 'a; @@ -967,7 +1009,8 @@ where } } impl CollectionMut for ArraySet { - type ItemMut<'a> = &'a mut T + type ItemMut<'a> + = &'a mut T where Self: 'a; @@ -986,9 +1029,10 @@ where } } impl Iter for ArraySet { - type Iter<'a> = std::slice::Iter<'a, T> - where - Self: 'a; + type Iter<'a> + = std::slice::Iter<'a, T> + where + Self: 'a; fn iter(&self) -> Self::Iter<'_> { self.0.iter() @@ -1035,7 +1079,8 @@ impl Len for ArrayMap { } } impl CollectionRef for ArrayMap { - type ItemRef<'a> = &'a Self::Item + type ItemRef<'a> + = &'a Self::Item where Self: 'a; @@ -1057,7 +1102,8 @@ where } } impl CollectionMut for ArrayMap { - type ItemMut<'a> = &'a mut Self::Item + type ItemMut<'a> + = &'a mut Self::Item where Self: 'a; @@ -1079,9 +1125,10 @@ impl Keyed for ArrayMap { type Key = K; } impl KeyedRef for ArrayMap { - type KeyRef<'a> = &'a Self::Key - where - Self: 'a; + type KeyRef<'a> + = &'a Self::Key + where + Self: 'a; covariant_key_ref!(); } @@ -1110,9 +1157,10 @@ where } } impl Iter for ArrayMap { - type Iter<'a> = std::slice::Iter<'a, V> - where - Self: 'a; + type Iter<'a> + = std::slice::Iter<'a, V> + where + Self: 'a; fn iter(&self) -> Self::Iter<'_> { self.vals.iter() @@ -1122,18 +1170,20 @@ impl SimpleKeyedRef for ArrayMap { simple_keyed_ref!(); } impl MapIter for ArrayMap { - type Iter<'a> = std::iter::Zip, std::slice::Iter<'a, V>> - where - Self: 'a; + type Iter<'a> + = std::iter::Zip, std::slice::Iter<'a, V>> + where + Self: 'a; fn iter(&self) -> Self::Iter<'_> { self.keys.iter().zip(self.vals.iter()) } } impl MapIterMut for ArrayMap { - type IterMut<'a> = std::iter::Zip, std::slice::IterMut<'a, V>> - where - Self: 'a; + type IterMut<'a> + = std::iter::Zip, std::slice::IterMut<'a, V>> + where + Self: 'a; fn iter_mut(&mut self) -> Self::IterMut<'_> { self.keys.iter().zip(self.vals.iter_mut()) diff --git a/lattices/src/ght_lattice.rs b/lattices/src/ght_lattice.rs index 93e80b8f3360..4469677df9a0 100644 --- a/lattices/src/ght_lattice.rs +++ b/lattices/src/ght_lattice.rs @@ -1,3 +1,5 @@ +//! Lattice traits for GHT + use core::cmp::Ordering::{Equal, Greater, Less}; use std::cmp::Ordering; use std::collections::HashMap; @@ -9,10 +11,6 @@ use variadics::{var_expr, var_type, CloneVariadic, PartialEqVariadic, SplitBySuf use crate::ght::{GeneralizedHashTrieNode, GhtGet, GhtInner, GhtLeaf}; use crate::{IsBot, IsTop, LatticeBimorphism, LatticeOrd, Merge}; -////////////////////////// -/// Lattice traits for GHT -////////////////////////// - impl Merge> for GhtInner where Node: GeneralizedHashTrieNode + Merge, diff --git a/variadics/src/lib.rs b/variadics/src/lib.rs index bd0de27a1a3f..ad08b9fe0a9b 100644 --- a/variadics/src/lib.rs +++ b/variadics/src/lib.rs @@ -209,7 +209,10 @@ where { const LEN: usize = 1 + Rest::LEN; - type Extend = (Item, Rest::Extend) where Suffix: VariadicExt; + type Extend + = (Item, Rest::Extend) + where + Suffix: VariadicExt; fn extend(self, suffix: Suffix) -> Self::Extend where Suffix: VariadicExt, @@ -232,7 +235,8 @@ where out2 } - type AsRefVar<'a> = (&'a Item, Rest::AsRefVar<'a>) + type AsRefVar<'a> + = (&'a Item, Rest::AsRefVar<'a>) where Self: 'a; fn as_ref_var(&self) -> Self::AsRefVar<'_> { @@ -240,7 +244,8 @@ where (item, rest.as_ref_var()) } - type AsMutVar<'a> = (&'a mut Item, Rest::AsMutVar<'a>) + type AsMutVar<'a> + = (&'a mut Item, Rest::AsMutVar<'a>) where Self: 'a; fn as_mut_var(&mut self) -> Self::AsMutVar<'_> { @@ -248,7 +253,8 @@ where (item, rest.as_mut_var()) } - type IterAnyRef<'a> = std::iter::Chain, Rest::IterAnyRef<'a>> + type IterAnyRef<'a> + = std::iter::Chain, Rest::IterAnyRef<'a>> where Self: 'static; fn iter_any_ref(&self) -> Self::IterAnyRef<'_> @@ -260,7 +266,8 @@ where std::iter::once(item).chain(rest.iter_any_ref()) } - type IterAnyMut<'a> = std::iter::Chain, Rest::IterAnyMut<'a>> + type IterAnyMut<'a> + = std::iter::Chain, Rest::IterAnyMut<'a>> where Self: 'static; fn iter_any_mut(&mut self) -> Self::IterAnyMut<'_> @@ -289,7 +296,10 @@ where impl VariadicExt for () { const LEN: usize = 0; - type Extend = Suffix where Suffix: VariadicExt; + type Extend + = Suffix + where + Suffix: VariadicExt; fn extend(self, suffix: Suffix) -> Self::Extend where Suffix: VariadicExt, @@ -307,7 +317,8 @@ impl VariadicExt for () { type AsMutVar<'a> = (); fn as_mut_var(&mut self) -> Self::AsMutVar<'_> {} - type IterAnyRef<'a> = std::iter::Empty<&'a dyn Any> + type IterAnyRef<'a> + = std::iter::Empty<&'a dyn Any> where Self: 'static; fn iter_any_ref(&self) -> Self::IterAnyRef<'_> @@ -317,7 +328,8 @@ impl VariadicExt for () { std::iter::empty() } - type IterAnyMut<'a> = std::iter::Empty<&'a mut dyn Any> + type IterAnyMut<'a> + = std::iter::Empty<&'a mut dyn Any> where Self: 'static; fn iter_any_mut(&mut self) -> Self::IterAnyMut<'_> @@ -820,7 +832,10 @@ where std::iter::zip(this, rest.into_zip()) } - type Drain<'a> = std::iter::Zip, Rest::Drain<'a>> where Self: 'a; + type Drain<'a> + = std::iter::Zip, Rest::Drain<'a>> + where + Self: 'a; fn drain(&mut self, range: R) -> Self::Drain<'_> where R: std::ops::RangeBounds + Clone, @@ -849,7 +864,10 @@ impl VecVariadic for var_type!() { std::iter::repeat(var_expr!()) } - type Drain<'a> = std::iter::Repeat where Self: 'a; + type Drain<'a> + = std::iter::Repeat + where + Self: 'a; fn drain(&mut self, _range: R) -> Self::Drain<'_> where R: std::ops::RangeBounds, diff --git a/variadics/tests/boxed_refed.rs b/variadics/tests/boxed_refed.rs index 17366b177dc5..8d7e44fc9f5c 100644 --- a/variadics/tests/boxed_refed.rs +++ b/variadics/tests/boxed_refed.rs @@ -29,7 +29,8 @@ impl Refed for (Item, Rest) where Rest: Refed, { - type Refed<'a> = (&'a Item, Rest::Refed<'a>) + type Refed<'a> + = (&'a Item, Rest::Refed<'a>) where Self: 'a; fn refed(&self) -> Self::Refed<'_> {