Skip to content

Commit a9874d3

Browse files
Modernize many where constraints (#610)
* Modernize many where constraints * set MSV to 1.79 * Work around MSVC regression
1 parent d352100 commit a9874d3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+371
-469
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
os:
1313
- ubuntu
1414
- macos
15-
- windows
15+
# - windows
1616
toolchain:
1717
- stable
18-
- 1.78
18+
- 1.79
1919
name: cargo test on ${{ matrix.os }}, rust ${{ matrix.toolchain }}
2020
runs-on: ${{ matrix.os }}-latest
2121
steps:

advent_of_code_2017/src/bin/day_09.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ fn main() {
9797
/// Accumulate data in `collection` into all powers-of-two intervals containing them.
9898
fn pp_aggregate<G, D, F>(collection: Collection<G, (usize, D)>, combine: F) -> Collection<G, ((usize, usize), D)>
9999
where
100-
G: Scope,
101-
G::Timestamp: Lattice,
100+
G: Scope<Timestamp: Lattice>,
102101
D: Data,
103102
F: Fn(D, &D) -> D + 'static,
104103
{
@@ -132,8 +131,7 @@ fn pp_broadcast<G, D, B, F>(
132131
zero: D,
133132
combine: F) -> Collection<G, (usize, B)>
134133
where
135-
G: Scope,
136-
G::Timestamp: Lattice+Ord+::std::fmt::Debug,
134+
G: Scope<Timestamp: Lattice+Ord+::std::fmt::Debug>,
137135
D: Data,
138136
B: Data+::std::hash::Hash,
139137
F: Fn(&B, &D) -> B + 'static,

differential-dataflow/examples/bfs.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@ fn main() {
9191
}
9292

9393
// returns pairs (n, s) indicating node n can be reached from a root in s steps.
94-
fn bfs<G: Scope>(edges: &Collection<G, Edge>, roots: &Collection<G, Node>) -> Collection<G, (Node, u32)>
95-
where G::Timestamp: Lattice+Ord {
96-
94+
fn bfs<G>(edges: &Collection<G, Edge>, roots: &Collection<G, Node>) -> Collection<G, (Node, u32)>
95+
where
96+
G: Scope<Timestamp: Lattice+Ord>,
97+
{
9798
// initialize roots as reaching themselves at distance 0
9899
let nodes = roots.map(|x| (x, 0));
99100

differential-dataflow/examples/columnar.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ mod container {
139139
fn default() -> Self { Self::Typed(Default::default()) }
140140
}
141141

142-
impl<C: Columnar> Clone for Column<C> where C::Container: Clone {
142+
impl<C: Columnar<Container: Clone>> Clone for Column<C> {
143143
fn clone(&self) -> Self {
144144
match self {
145145
Column::Typed(t) => Column::Typed(t.clone()),
@@ -213,7 +213,7 @@ mod container {
213213
}
214214

215215
use timely::container::PushInto;
216-
impl<C: Columnar, T> PushInto<T> for Column<C> where C::Container: columnar::Push<T> {
216+
impl<T, C: Columnar<Container: columnar::Push<T>>> PushInto<T> for Column<C> {
217217
#[inline]
218218
fn push_into(&mut self, item: T) {
219219
use columnar::Push;
@@ -286,7 +286,7 @@ mod builder {
286286
}
287287

288288
use timely::container::PushInto;
289-
impl<C: Columnar, T> PushInto<T> for ColumnBuilder<C> where C::Container: columnar::Push<T> {
289+
impl<T, C: Columnar<Container: columnar::Push<T>>> PushInto<T> for ColumnBuilder<C> {
290290
#[inline]
291291
fn push_into(&mut self, item: T) {
292292
self.current.push(item);
@@ -314,7 +314,7 @@ mod builder {
314314
}
315315

316316
use timely::container::{ContainerBuilder, LengthPreservingContainerBuilder};
317-
impl<C: Columnar> ContainerBuilder for ColumnBuilder<C> where C::Container: Clone {
317+
impl<C: Columnar<Container: Clone>> ContainerBuilder for ColumnBuilder<C> {
318318
type Container = Column<C>;
319319

320320
#[inline]
@@ -342,7 +342,7 @@ mod builder {
342342
}
343343
}
344344

345-
impl<C: Columnar> LengthPreservingContainerBuilder for ColumnBuilder<C> where C::Container: Clone { }
345+
impl<C: Columnar<Container: Clone>> LengthPreservingContainerBuilder for ColumnBuilder<C> { }
346346
}
347347

348348

@@ -396,12 +396,9 @@ pub mod batcher {
396396

397397
impl<'a, D, T, R, C2> PushInto<&'a mut Column<(D, T, R)>> for Chunker<C2>
398398
where
399-
D: Columnar,
400-
for<'b> D::Ref<'b>: Ord + Copy,
401-
T: Columnar,
402-
for<'b> T::Ref<'b>: Ord + Copy,
403-
R: Columnar + Semigroup + for<'b> Semigroup<R::Ref<'b>>,
404-
for<'b> R::Ref<'b>: Ord,
399+
D: for<'b> Columnar<Ref<'b>: Ord>,
400+
T: for<'b> Columnar<Ref<'b>: Ord>,
401+
R: for<'b> Columnar<Ref<'b>: Ord> + for<'b> Semigroup<R::Ref<'b>>,
405402
C2: Container + for<'b> PushInto<&'b (D, T, R)>,
406403
{
407404
fn push_into(&mut self, container: &'a mut Column<(D, T, R)>) {

differential-dataflow/examples/dynamic.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@ fn main() {
9191
}
9292

9393
// returns pairs (n, s) indicating node n can be reached from a root in s steps.
94-
fn bfs<G: Scope>(edges: &Collection<G, Edge>, roots: &Collection<G, Node>) -> Collection<G, (Node, u32)>
95-
where G::Timestamp: Lattice+Ord {
96-
94+
fn bfs<G>(edges: &Collection<G, Edge>, roots: &Collection<G, Node>) -> Collection<G, (Node, u32)>
95+
where
96+
G: Scope<Timestamp: Lattice+Ord>,
97+
{
9798
use timely::order::Product;
9899
use iterate::Variable;
99100
use differential_dataflow::dynamic::{feedback_summary, pointstamp::PointStamp};

differential-dataflow/examples/graspan.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ type Arrange<G,K,V,R> = Arranged<G, TraceValHandle<K, V, <G as ScopeParent>::Tim
8282
///
8383
/// An edge variable provides arranged representations of its contents, even before they are
8484
/// completely defined, in support of recursively defined productions.
85-
pub struct EdgeVariable<G: Scope> where G::Timestamp : Lattice {
85+
pub struct EdgeVariable<G: Scope<Timestamp: Lattice>> {
8686
variable: Variable<G, Edge, Diff>,
8787
current: Collection<G, Edge, Diff>,
8888
forward: Option<Arrange<G, Node, Node, Diff>>,
8989
reverse: Option<Arrange<G, Node, Node, Diff>>,
9090
}
9191

92-
impl<G: Scope> EdgeVariable<G> where G::Timestamp : Lattice {
92+
impl<G: Scope<Timestamp: Lattice>> EdgeVariable<G> {
9393
/// Creates a new variable initialized with `source`.
9494
pub fn from(source: &Collection<G, Edge>, step: <G::Timestamp as Timestamp>::Summary) -> Self {
9595
let variable = Variable::new(&mut source.scope(), step);
@@ -152,9 +152,10 @@ impl Query {
152152
}
153153

154154
/// Creates a dataflow implementing the query, and returns input and trace handles.
155-
pub fn render_in<G: Scope>(&self, scope: &mut G) -> IndexMap<String, RelationHandles<G::Timestamp>>
156-
where G::Timestamp: Lattice+::timely::order::TotalOrder {
157-
155+
pub fn render_in<G>(&self, scope: &mut G) -> IndexMap<String, RelationHandles<G::Timestamp>>
156+
where
157+
G: Scope<Timestamp: Lattice+::timely::order::TotalOrder>,
158+
{
158159
// Create new input (handle, stream) pairs
159160
let mut input_map = IndexMap::new();
160161
for production in self.productions.iter() {

differential-dataflow/examples/interpreted.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ fn main() {
4141
}).unwrap();
4242
}
4343

44-
fn interpret<G: Scope>(edges: &Collection<G, Edge>, relations: &[(usize, usize)]) -> Collection<G, Vec<Node>>
45-
where G::Timestamp: Lattice+Hash+Ord {
44+
fn interpret<G>(edges: &Collection<G, Edge>, relations: &[(usize, usize)]) -> Collection<G, Vec<Node>>
45+
where
46+
G: Scope<Timestamp: Lattice+Hash+Ord>,
47+
{
4648

4749
// arrange the edge relation three ways.
4850
let as_self = edges.arrange_by_self();

differential-dataflow/examples/itembased_cf.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl CRP {
144144
CRP { alpha, discount, weight: 0.0, weights: Vec::new() }
145145
}
146146

147-
fn sample<R>(&mut self, rng: &mut R) -> u32 where R: Rng {
147+
fn sample<R: Rng>(&mut self, rng: &mut R) -> u32 {
148148
let mut u = rng.gen::<f64>() * (self.alpha + self.weight);
149149
for j in 0 .. self.weights.len() {
150150
if u < self.weights[j] - self.discount {
@@ -164,7 +164,7 @@ impl CRP {
164164
}
165165

166166
// Generate synthetic interactions with a skewed distribution
167-
fn generate_interactions<R>(how_many: usize, rng: &mut R) -> Vec<(u32,u32)> where R: Rng {
167+
fn generate_interactions<R: Rng>(how_many: usize, rng: &mut R) -> Vec<(u32,u32)> {
168168
let mut interactions = Vec::with_capacity(how_many);
169169

170170
let mut user_sampler = CRP::new(6000.0, 0.35);

differential-dataflow/examples/monoid-bfs.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,10 @@ fn main() {
123123
}
124124

125125
// returns pairs (n, s) indicating node n can be reached from a root in s steps.
126-
fn bfs<G: Scope>(edges: &Collection<G, Edge, MinSum>, roots: &Collection<G, Node, MinSum>) -> Collection<G, Node, MinSum>
127-
where G::Timestamp: Lattice+Ord {
128-
126+
fn bfs<G>(edges: &Collection<G, Edge, MinSum>, roots: &Collection<G, Node, MinSum>) -> Collection<G, Node, MinSum>
127+
where
128+
G: Scope<Timestamp: Lattice+Ord>,
129+
{
129130
// repeatedly update minimal distances each node can be reached from each root
130131
roots.scope().iterative::<u32,_,_>(|scope| {
131132

differential-dataflow/examples/pagerank.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ fn main() {
7979
// to its PageRank in the input graph `edges`.
8080
fn pagerank<G>(iters: Iter, edges: &Collection<G, Edge, Diff>) -> Collection<G, Node, Diff>
8181
where
82-
G: Scope,
83-
G::Timestamp: Lattice,
82+
G: Scope<Timestamp: Lattice>,
8483
{
8584
// initialize many surfers at each node.
8685
let nodes =

0 commit comments

Comments
 (0)