Skip to content

Commit a88f105

Browse files
committed
Auto merge of rust-lang#84767 - scottmcm:try_trait_actual, r=lcnr
Implement the new desugaring from `try_trait_v2` ~~Currently blocked on rust-lang#84782, which has a PR in rust-lang#84811 Rebased atop that fix. `try_trait_v2` tracking issue: rust-lang#84277 Unfortunately this is already touching a ton of things, so if you have suggestions for good ways to split it up, I'd be happy to hear them. (The combination between the use in the library, the compiler changes, the corresponding diagnostic differences, even MIR tests mean that I don't really have a great plan for it other than trying to have decently-readable commits. r? `@ghost` ~~(This probably shouldn't go in during the last week before the fork anyway.)~~ Fork happened.
2 parents 9d42d79 + 142ac73 commit a88f105

38 files changed

+295
-139
lines changed

alloc/src/collections/vec_deque/iter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl<'a, T> Iterator for Iter<'a, T> {
6666
where
6767
Self: Sized,
6868
F: FnMut(B, Self::Item) -> R,
69-
R: Try<Ok = B>,
69+
R: Try<Output = B>,
7070
{
7171
let (mut iter, final_res);
7272
if self.tail <= self.head {
@@ -140,7 +140,7 @@ impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
140140
where
141141
Self: Sized,
142142
F: FnMut(B, Self::Item) -> R,
143-
R: Try<Ok = B>,
143+
R: Try<Output = B>,
144144
{
145145
let (mut iter, final_res);
146146
if self.tail <= self.head {

alloc/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@
140140
#![feature(maybe_uninit_extra, maybe_uninit_slice, maybe_uninit_uninit_array)]
141141
#![feature(alloc_layout_extra)]
142142
#![feature(trusted_random_access)]
143-
#![feature(try_trait)]
143+
#![cfg_attr(bootstrap, feature(try_trait))]
144+
#![cfg_attr(not(bootstrap), feature(try_trait_v2))]
144145
#![feature(min_type_alias_impl_trait)]
145146
#![feature(associated_type_bounds)]
146147
#![feature(slice_group_by)]

core/src/iter/adapters/chain.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ where
9898
where
9999
Self: Sized,
100100
F: FnMut(Acc, Self::Item) -> R,
101-
R: Try<Ok = Acc>,
101+
R: Try<Output = Acc>,
102102
{
103103
if let Some(ref mut a) = self.a {
104104
acc = a.try_fold(acc, &mut f)?;
@@ -281,7 +281,7 @@ where
281281
where
282282
Self: Sized,
283283
F: FnMut(Acc, Self::Item) -> R,
284-
R: Try<Ok = Acc>,
284+
R: Try<Output = Acc>,
285285
{
286286
if let Some(ref mut b) = self.b {
287287
acc = b.try_rfold(acc, &mut f)?;

core/src/iter/adapters/cloned.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ where
4646
where
4747
Self: Sized,
4848
F: FnMut(B, Self::Item) -> R,
49-
R: Try<Ok = B>,
49+
R: Try<Output = B>,
5050
{
5151
self.it.try_fold(init, clone_try_fold(f))
5252
}
@@ -82,7 +82,7 @@ where
8282
where
8383
Self: Sized,
8484
F: FnMut(B, Self::Item) -> R,
85-
R: Try<Ok = B>,
85+
R: Try<Output = B>,
8686
{
8787
self.it.try_rfold(init, clone_try_fold(f))
8888
}

core/src/iter/adapters/copied.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ where
5050
where
5151
Self: Sized,
5252
F: FnMut(B, Self::Item) -> R,
53-
R: Try<Ok = B>,
53+
R: Try<Output = B>,
5454
{
5555
self.it.try_fold(init, copy_try_fold(f))
5656
}
@@ -98,7 +98,7 @@ where
9898
where
9999
Self: Sized,
100100
F: FnMut(B, Self::Item) -> R,
101-
R: Try<Ok = B>,
101+
R: Try<Output = B>,
102102
{
103103
self.it.try_rfold(init, copy_try_fold(f))
104104
}

core/src/iter/adapters/cycle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ where
5353
fn try_fold<Acc, F, R>(&mut self, mut acc: Acc, mut f: F) -> R
5454
where
5555
F: FnMut(Acc, Self::Item) -> R,
56-
R: Try<Ok = Acc>,
56+
R: Try<Output = Acc>,
5757
{
5858
// fully iterate the current iterator. this is necessary because
5959
// `self.iter` may be empty even when `self.orig` isn't

core/src/iter/adapters/enumerate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ where
7171
where
7272
Self: Sized,
7373
Fold: FnMut(Acc, Self::Item) -> R,
74-
R: Try<Ok = Acc>,
74+
R: Try<Output = Acc>,
7575
{
7676
#[inline]
7777
fn enumerate<'a, T, Acc, R>(
@@ -150,7 +150,7 @@ where
150150
where
151151
Self: Sized,
152152
Fold: FnMut(Acc, Self::Item) -> R,
153-
R: Try<Ok = Acc>,
153+
R: Try<Output = Acc>,
154154
{
155155
// Can safely add and subtract the count, as `ExactSizeIterator` promises
156156
// that the number of elements fits into a `usize`.

core/src/iter/adapters/filter.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn filter_fold<T, Acc>(
3737
move |acc, item| if predicate(&item) { fold(acc, item) } else { acc }
3838
}
3939

40-
fn filter_try_fold<'a, T, Acc, R: Try<Ok = Acc>>(
40+
fn filter_try_fold<'a, T, Acc, R: Try<Output = Acc>>(
4141
predicate: &'a mut impl FnMut(&T) -> bool,
4242
mut fold: impl FnMut(Acc, T) -> R + 'a,
4343
) -> impl FnMut(Acc, T) -> R + 'a {
@@ -88,7 +88,7 @@ where
8888
where
8989
Self: Sized,
9090
Fold: FnMut(Acc, Self::Item) -> R,
91-
R: Try<Ok = Acc>,
91+
R: Try<Output = Acc>,
9292
{
9393
self.iter.try_fold(init, filter_try_fold(&mut self.predicate, fold))
9494
}
@@ -117,7 +117,7 @@ where
117117
where
118118
Self: Sized,
119119
Fold: FnMut(Acc, Self::Item) -> R,
120-
R: Try<Ok = Acc>,
120+
R: Try<Output = Acc>,
121121
{
122122
self.iter.try_rfold(init, filter_try_fold(&mut self.predicate, fold))
123123
}

core/src/iter/adapters/filter_map.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn filter_map_fold<T, B, Acc>(
3939
}
4040
}
4141

42-
fn filter_map_try_fold<'a, T, B, Acc, R: Try<Ok = Acc>>(
42+
fn filter_map_try_fold<'a, T, B, Acc, R: Try<Output = Acc>>(
4343
f: &'a mut impl FnMut(T) -> Option<B>,
4444
mut fold: impl FnMut(Acc, B) -> R + 'a,
4545
) -> impl FnMut(Acc, T) -> R + 'a {
@@ -72,7 +72,7 @@ where
7272
where
7373
Self: Sized,
7474
Fold: FnMut(Acc, Self::Item) -> R,
75-
R: Try<Ok = Acc>,
75+
R: Try<Output = Acc>,
7676
{
7777
self.iter.try_fold(init, filter_map_try_fold(&mut self.f, fold))
7878
}
@@ -111,7 +111,7 @@ where
111111
where
112112
Self: Sized,
113113
Fold: FnMut(Acc, Self::Item) -> R,
114-
R: Try<Ok = Acc>,
114+
R: Try<Output = Acc>,
115115
{
116116
self.iter.try_rfold(init, filter_map_try_fold(&mut self.f, fold))
117117
}

core/src/iter/adapters/flatten.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ where
6161
where
6262
Self: Sized,
6363
Fold: FnMut(Acc, Self::Item) -> R,
64-
R: Try<Ok = Acc>,
64+
R: Try<Output = Acc>,
6565
{
6666
self.inner.try_fold(init, fold)
6767
}
@@ -91,7 +91,7 @@ where
9191
where
9292
Self: Sized,
9393
Fold: FnMut(Acc, Self::Item) -> R,
94-
R: Try<Ok = Acc>,
94+
R: Try<Output = Acc>,
9595
{
9696
self.inner.try_rfold(init, fold)
9797
}
@@ -178,7 +178,7 @@ where
178178
where
179179
Self: Sized,
180180
Fold: FnMut(Acc, Self::Item) -> R,
181-
R: Try<Ok = Acc>,
181+
R: Try<Output = Acc>,
182182
{
183183
self.inner.try_fold(init, fold)
184184
}
@@ -208,7 +208,7 @@ where
208208
where
209209
Self: Sized,
210210
Fold: FnMut(Acc, Self::Item) -> R,
211-
R: Try<Ok = Acc>,
211+
R: Try<Output = Acc>,
212212
{
213213
self.inner.try_rfold(init, fold)
214214
}
@@ -293,10 +293,10 @@ where
293293
where
294294
Self: Sized,
295295
Fold: FnMut(Acc, Self::Item) -> R,
296-
R: Try<Ok = Acc>,
296+
R: Try<Output = Acc>,
297297
{
298298
#[inline]
299-
fn flatten<'a, T: IntoIterator, Acc, R: Try<Ok = Acc>>(
299+
fn flatten<'a, T: IntoIterator, Acc, R: Try<Output = Acc>>(
300300
frontiter: &'a mut Option<T::IntoIter>,
301301
fold: &'a mut impl FnMut(Acc, T::Item) -> R,
302302
) -> impl FnMut(Acc, T) -> R + 'a {
@@ -382,10 +382,10 @@ where
382382
where
383383
Self: Sized,
384384
Fold: FnMut(Acc, Self::Item) -> R,
385-
R: Try<Ok = Acc>,
385+
R: Try<Output = Acc>,
386386
{
387387
#[inline]
388-
fn flatten<'a, T: IntoIterator, Acc, R: Try<Ok = Acc>>(
388+
fn flatten<'a, T: IntoIterator, Acc, R: Try<Output = Acc>>(
389389
backiter: &'a mut Option<T::IntoIter>,
390390
fold: &'a mut impl FnMut(Acc, T::Item) -> R,
391391
) -> impl FnMut(Acc, T) -> R + 'a

0 commit comments

Comments
 (0)