Skip to content

Commit 3f8d550

Browse files
committed
std: rename Result::chain{,_err} to chain{_move,_err_move}, add chain{,_err}
cc rust-lang#7887
1 parent f3a429e commit 3f8d550

File tree

10 files changed

+127
-90
lines changed

10 files changed

+127
-90
lines changed

src/libextra/time.rs

+32-32
Original file line numberDiff line numberDiff line change
@@ -442,21 +442,21 @@ fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
442442
},
443443
'c' => {
444444
parse_type(s, pos, 'a', &mut *tm)
445-
.chain(|pos| parse_char(s, pos, ' '))
446-
.chain(|pos| parse_type(s, pos, 'b', &mut *tm))
447-
.chain(|pos| parse_char(s, pos, ' '))
448-
.chain(|pos| parse_type(s, pos, 'e', &mut *tm))
449-
.chain(|pos| parse_char(s, pos, ' '))
450-
.chain(|pos| parse_type(s, pos, 'T', &mut *tm))
451-
.chain(|pos| parse_char(s, pos, ' '))
452-
.chain(|pos| parse_type(s, pos, 'Y', &mut *tm))
445+
.chain_move(|pos| parse_char(s, pos, ' '))
446+
.chain_move(|pos| parse_type(s, pos, 'b', &mut *tm))
447+
.chain_move(|pos| parse_char(s, pos, ' '))
448+
.chain_move(|pos| parse_type(s, pos, 'e', &mut *tm))
449+
.chain_move(|pos| parse_char(s, pos, ' '))
450+
.chain_move(|pos| parse_type(s, pos, 'T', &mut *tm))
451+
.chain_move(|pos| parse_char(s, pos, ' '))
452+
.chain_move(|pos| parse_type(s, pos, 'Y', &mut *tm))
453453
}
454454
'D' | 'x' => {
455455
parse_type(s, pos, 'm', &mut *tm)
456-
.chain(|pos| parse_char(s, pos, '/'))
457-
.chain(|pos| parse_type(s, pos, 'd', &mut *tm))
458-
.chain(|pos| parse_char(s, pos, '/'))
459-
.chain(|pos| parse_type(s, pos, 'y', &mut *tm))
456+
.chain_move(|pos| parse_char(s, pos, '/'))
457+
.chain_move(|pos| parse_type(s, pos, 'd', &mut *tm))
458+
.chain_move(|pos| parse_char(s, pos, '/'))
459+
.chain_move(|pos| parse_type(s, pos, 'y', &mut *tm))
460460
}
461461
'd' => match match_digits_in_range(s, pos, 2u, false, 1_i32,
462462
31_i32) {
@@ -475,10 +475,10 @@ fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
475475
}
476476
'F' => {
477477
parse_type(s, pos, 'Y', &mut *tm)
478-
.chain(|pos| parse_char(s, pos, '-'))
479-
.chain(|pos| parse_type(s, pos, 'm', &mut *tm))
480-
.chain(|pos| parse_char(s, pos, '-'))
481-
.chain(|pos| parse_type(s, pos, 'd', &mut *tm))
478+
.chain_move(|pos| parse_char(s, pos, '-'))
479+
.chain_move(|pos| parse_type(s, pos, 'm', &mut *tm))
480+
.chain_move(|pos| parse_char(s, pos, '-'))
481+
.chain_move(|pos| parse_type(s, pos, 'd', &mut *tm))
482482
}
483483
'H' => {
484484
match match_digits_in_range(s, pos, 2u, false, 0_i32, 23_i32) {
@@ -553,17 +553,17 @@ fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
553553
},
554554
'R' => {
555555
parse_type(s, pos, 'H', &mut *tm)
556-
.chain(|pos| parse_char(s, pos, ':'))
557-
.chain(|pos| parse_type(s, pos, 'M', &mut *tm))
556+
.chain_move(|pos| parse_char(s, pos, ':'))
557+
.chain_move(|pos| parse_type(s, pos, 'M', &mut *tm))
558558
}
559559
'r' => {
560560
parse_type(s, pos, 'I', &mut *tm)
561-
.chain(|pos| parse_char(s, pos, ':'))
562-
.chain(|pos| parse_type(s, pos, 'M', &mut *tm))
563-
.chain(|pos| parse_char(s, pos, ':'))
564-
.chain(|pos| parse_type(s, pos, 'S', &mut *tm))
565-
.chain(|pos| parse_char(s, pos, ' '))
566-
.chain(|pos| parse_type(s, pos, 'p', &mut *tm))
561+
.chain_move(|pos| parse_char(s, pos, ':'))
562+
.chain_move(|pos| parse_type(s, pos, 'M', &mut *tm))
563+
.chain_move(|pos| parse_char(s, pos, ':'))
564+
.chain_move(|pos| parse_type(s, pos, 'S', &mut *tm))
565+
.chain_move(|pos| parse_char(s, pos, ' '))
566+
.chain_move(|pos| parse_type(s, pos, 'p', &mut *tm))
567567
}
568568
'S' => {
569569
match match_digits_in_range(s, pos, 2u, false, 0_i32, 60_i32) {
@@ -578,10 +578,10 @@ fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
578578
//'s' {}
579579
'T' | 'X' => {
580580
parse_type(s, pos, 'H', &mut *tm)
581-
.chain(|pos| parse_char(s, pos, ':'))
582-
.chain(|pos| parse_type(s, pos, 'M', &mut *tm))
583-
.chain(|pos| parse_char(s, pos, ':'))
584-
.chain(|pos| parse_type(s, pos, 'S', &mut *tm))
581+
.chain_move(|pos| parse_char(s, pos, ':'))
582+
.chain_move(|pos| parse_type(s, pos, 'M', &mut *tm))
583+
.chain_move(|pos| parse_char(s, pos, ':'))
584+
.chain_move(|pos| parse_type(s, pos, 'S', &mut *tm))
585585
}
586586
't' => parse_char(s, pos, '\t'),
587587
'u' => {
@@ -596,10 +596,10 @@ fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
596596
}
597597
'v' => {
598598
parse_type(s, pos, 'e', &mut *tm)
599-
.chain(|pos| parse_char(s, pos, '-'))
600-
.chain(|pos| parse_type(s, pos, 'b', &mut *tm))
601-
.chain(|pos| parse_char(s, pos, '-'))
602-
.chain(|pos| parse_type(s, pos, 'Y', &mut *tm))
599+
.chain_move(|pos| parse_char(s, pos, '-'))
600+
.chain_move(|pos| parse_type(s, pos, 'b', &mut *tm))
601+
.chain_move(|pos| parse_char(s, pos, '-'))
602+
.chain_move(|pos| parse_type(s, pos, 'Y', &mut *tm))
603603
}
604604
//'W' {}
605605
'w' => {

src/librustc/middle/typeck/infer/combine.rs

+30-31
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub trait Combine {
108108
(Some(a), Some(b)) => {
109109
// FIXME(#5781) this should be eq_tys
110110
// eq_tys(self, a, b).then(|| Ok(Some(a)) )
111-
self.contratys(a, b).chain(|t| Ok(Some(t)))
111+
self.contratys(a, b).chain_move(|t| Ok(Some(t)))
112112
}
113113
(None, Some(_)) |
114114
(Some(_), None) => {
@@ -162,13 +162,13 @@ pub trait Combine {
162162
}
163163

164164
ty::rv_covariant => {
165-
do this.regions(a_r, b_r).chain |r| {
165+
do this.regions(a_r, b_r).chain_move |r| {
166166
Ok(ty::NonerasedRegions(opt_vec::with(r)))
167167
}
168168
}
169169

170170
ty::rv_contravariant => {
171-
do this.contraregions(a_r, b_r).chain |r| {
171+
do this.contraregions(a_r, b_r).chain_move |r| {
172172
Ok(ty::NonerasedRegions(opt_vec::with(r)))
173173
}
174174
}
@@ -179,12 +179,12 @@ pub trait Combine {
179179
}
180180
}
181181

182-
do self.tps(as_.tps, bs.tps).chain |tps| {
183-
do self.self_tys(as_.self_ty, bs.self_ty).chain |self_ty| {
182+
do self.tps(as_.tps, bs.tps).chain_move |tps| {
183+
do self.self_tys(as_.self_ty, bs.self_ty).chain_move |self_ty| {
184184
do relate_region_params(self,
185185
generics,
186186
&as_.regions,
187-
&bs.regions).chain |regions| {
187+
&bs.regions).chain_move |regions| {
188188
Ok(substs {
189189
regions: regions,
190190
self_ty: self_ty,
@@ -227,8 +227,8 @@ pub trait Combine {
227227
fn flds(&self, a: ty::field, b: ty::field) -> cres<ty::field> {
228228
if a.ident == b.ident {
229229
self.mts(&a.mt, &b.mt)
230-
.chain(|mt| Ok(ty::field {ident: a.ident, mt: mt}) )
231-
.chain_err(|e| Err(ty::terr_in_field(@e, a.ident)) )
230+
.chain_move(|mt| Ok(ty::field {ident: a.ident, mt: mt}) )
231+
.chain_err_move(|e| Err(ty::terr_in_field(@e, a.ident)) )
232232
} else {
233233
Err(ty::terr_record_fields(
234234
expected_found(self,
@@ -238,7 +238,7 @@ pub trait Combine {
238238
}
239239

240240
fn args(&self, a: ty::t, b: ty::t) -> cres<ty::t> {
241-
do self.contratys(a, b).chain |t| {
241+
do self.contratys(a, b).chain_move |t| {
242242
Ok(t)
243243
}
244244
}
@@ -274,7 +274,7 @@ pub trait Combine {
274274

275275
match (a, b) {
276276
(ty::vstore_slice(a_r), ty::vstore_slice(b_r)) => {
277-
do self.contraregions(a_r, b_r).chain |r| {
277+
do self.contraregions(a_r, b_r).chain_move |r| {
278278
Ok(ty::vstore_slice(r))
279279
}
280280
}
@@ -299,7 +299,7 @@ pub trait Combine {
299299

300300
match (a, b) {
301301
(ty::RegionTraitStore(a_r), ty::RegionTraitStore(b_r)) => {
302-
do self.contraregions(a_r, b_r).chain |r| {
302+
do self.contraregions(a_r, b_r).chain_move |r| {
303303
Ok(ty::RegionTraitStore(r))
304304
}
305305
}
@@ -357,7 +357,7 @@ pub fn expected_found<C:Combine,T>(
357357
pub fn eq_tys<C:Combine>(this: &C, a: ty::t, b: ty::t) -> ures {
358358
let suber = this.sub();
359359
do this.infcx().try {
360-
do suber.tys(a, b).chain |_ok| {
360+
do suber.tys(a, b).chain_move |_ok| {
361361
suber.contratys(a, b)
362362
}.to_ures()
363363
}
@@ -371,10 +371,10 @@ pub fn eq_regions<C:Combine>(this: &C, a: ty::Region, b: ty::Region)
371371
let sub = this.sub();
372372
do indent {
373373
this.infcx().try(|| {
374-
do sub.regions(a, b).chain |_r| {
374+
do sub.regions(a, b).chain_move |_r| {
375375
sub.contraregions(a, b)
376376
}
377-
}).chain_err(|e| {
377+
}).chain_err_move(|e| {
378378
// substitute a better error, but use the regions
379379
// found in the original error
380380
match e {
@@ -426,9 +426,8 @@ pub fn super_fn_sigs<C:Combine>(
426426
}
427427
}
428428

429-
do argvecs(this, a.inputs, b.inputs)
430-
.chain |inputs| {
431-
do this.tys(a.output, b.output).chain |output| {
429+
do argvecs(this, a.inputs, b.inputs).chain_move |inputs| {
430+
do this.tys(a.output, b.output).chain_move |output| {
432431
Ok(FnSig {bound_lifetime_names: opt_vec::Empty, // FIXME(#4846)
433432
inputs: inputs.clone(),
434433
output: output})
@@ -508,7 +507,7 @@ pub fn super_tys<C:Combine>(
508507
&ty::ty_enum(b_id, ref b_substs))
509508
if a_id == b_id => {
510509
let type_def = ty::lookup_item_type(tcx, a_id);
511-
do this.substs(&type_def.generics, a_substs, b_substs).chain |substs| {
510+
do this.substs(&type_def.generics, a_substs, b_substs).chain_move |substs| {
512511
Ok(ty::mk_enum(tcx, a_id, substs))
513512
}
514513
}
@@ -517,9 +516,9 @@ pub fn super_tys<C:Combine>(
517516
&ty::ty_trait(b_id, ref b_substs, b_store, b_mutbl, b_bounds))
518517
if a_id == b_id && a_mutbl == b_mutbl => {
519518
let trait_def = ty::lookup_trait_def(tcx, a_id);
520-
do this.substs(&trait_def.generics, a_substs, b_substs).chain |substs| {
521-
do this.trait_stores(ty::terr_trait, a_store, b_store).chain |s| {
522-
do this.bounds(a_bounds, b_bounds).chain |bounds| {
519+
do this.substs(&trait_def.generics, a_substs, b_substs).chain_move |substs| {
520+
do this.trait_stores(ty::terr_trait, a_store, b_store).chain_move |s| {
521+
do this.bounds(a_bounds, b_bounds).chain_move |bounds| {
523522
Ok(ty::mk_trait(tcx,
524523
a_id,
525524
substs.clone(),
@@ -534,25 +533,25 @@ pub fn super_tys<C:Combine>(
534533
(&ty::ty_struct(a_id, ref a_substs), &ty::ty_struct(b_id, ref b_substs))
535534
if a_id == b_id => {
536535
let type_def = ty::lookup_item_type(tcx, a_id);
537-
do this.substs(&type_def.generics, a_substs, b_substs).chain |substs| {
536+
do this.substs(&type_def.generics, a_substs, b_substs).chain_move |substs| {
538537
Ok(ty::mk_struct(tcx, a_id, substs))
539538
}
540539
}
541540

542541
(&ty::ty_box(ref a_mt), &ty::ty_box(ref b_mt)) => {
543-
do this.mts(a_mt, b_mt).chain |mt| {
542+
do this.mts(a_mt, b_mt).chain_move |mt| {
544543
Ok(ty::mk_box(tcx, mt))
545544
}
546545
}
547546

548547
(&ty::ty_uniq(ref a_mt), &ty::ty_uniq(ref b_mt)) => {
549-
do this.mts(a_mt, b_mt).chain |mt| {
548+
do this.mts(a_mt, b_mt).chain_move |mt| {
550549
Ok(ty::mk_uniq(tcx, mt))
551550
}
552551
}
553552

554553
(&ty::ty_ptr(ref a_mt), &ty::ty_ptr(ref b_mt)) => {
555-
do this.mts(a_mt, b_mt).chain |mt| {
554+
do this.mts(a_mt, b_mt).chain_move |mt| {
556555
Ok(ty::mk_ptr(tcx, mt))
557556
}
558557
}
@@ -564,15 +563,15 @@ pub fn super_tys<C:Combine>(
564563
}
565564

566565
(&ty::ty_evec(ref a_mt, vs_a), &ty::ty_evec(ref b_mt, vs_b)) => {
567-
do this.mts(a_mt, b_mt).chain |mt| {
568-
do this.vstores(ty::terr_vec, vs_a, vs_b).chain |vs| {
566+
do this.mts(a_mt, b_mt).chain_move |mt| {
567+
do this.vstores(ty::terr_vec, vs_a, vs_b).chain_move |vs| {
569568
Ok(ty::mk_evec(tcx, mt, vs))
570569
}
571570
}
572571
}
573572

574573
(&ty::ty_estr(vs_a), &ty::ty_estr(vs_b)) => {
575-
do this.vstores(ty::terr_str, vs_a, vs_b).chain |vs| {
574+
do this.vstores(ty::terr_str, vs_a, vs_b).chain_move |vs| {
576575
Ok(ty::mk_estr(tcx,vs))
577576
}
578577
}
@@ -581,21 +580,21 @@ pub fn super_tys<C:Combine>(
581580
if as_.len() == bs.len() {
582581
result::collect(as_.iter().zip(bs.iter())
583582
.map(|(a, b)| this.tys(*a, *b)))
584-
.chain(|ts| Ok(ty::mk_tup(tcx, ts)) )
583+
.chain_move(|ts| Ok(ty::mk_tup(tcx, ts)) )
585584
} else {
586585
Err(ty::terr_tuple_size(
587586
expected_found(this, as_.len(), bs.len())))
588587
}
589588
}
590589

591590
(&ty::ty_bare_fn(ref a_fty), &ty::ty_bare_fn(ref b_fty)) => {
592-
do this.bare_fn_tys(a_fty, b_fty).chain |fty| {
591+
do this.bare_fn_tys(a_fty, b_fty).chain_move |fty| {
593592
Ok(ty::mk_bare_fn(tcx, fty))
594593
}
595594
}
596595

597596
(&ty::ty_closure(ref a_fty), &ty::ty_closure(ref b_fty)) => {
598-
do this.closure_tys(a_fty, b_fty).chain |fty| {
597+
do this.closure_tys(a_fty, b_fty).chain_move |fty| {
599598
Ok(ty::mk_closure(tcx, fty))
600599
}
601600
}

src/librustc/middle/typeck/infer/glb.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl Combine for Glb {
6161
// If one side or both is immutable, we can use the GLB of
6262
// both sides but mutbl must be `MutImmutable`.
6363
(MutImmutable, MutImmutable) => {
64-
self.tys(a.ty, b.ty).chain(|t| {
64+
self.tys(a.ty, b.ty).chain_move(|t| {
6565
Ok(ty::mt {ty: t, mutbl: MutImmutable})
6666
})
6767
}

src/librustc/middle/typeck/infer/lattice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ impl CombineFieldsLatticeMethods for CombineFields {
232232
(&Some(_), &None) => Ok((*a).clone()),
233233
(&None, &Some(_)) => Ok((*b).clone()),
234234
(&Some(ref v_a), &Some(ref v_b)) => {
235-
do lattice_op(self, v_a, v_b).chain |v| {
235+
do lattice_op(self, v_a, v_b).chain_move |v| {
236236
Ok(Some(v))
237237
}
238238
}

src/librustc/middle/typeck/infer/lub.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ impl Combine for Lub {
6262
let m = a.mutbl;
6363
match m {
6464
MutImmutable => {
65-
self.tys(a.ty, b.ty).chain(|t| Ok(ty::mt {ty: t, mutbl: m}) )
65+
self.tys(a.ty, b.ty).chain_move(|t| Ok(ty::mt {ty: t, mutbl: m}) )
6666
}
6767

6868
MutMutable => {
6969
self.infcx.try(|| {
7070
eq_tys(self, a.ty, b.ty).then(|| {
7171
Ok(ty::mt {ty: a.ty, mutbl: m})
7272
})
73-
}).chain_err(|e| Err(e))
73+
}).chain_err_move(|e| Err(e))
7474
}
7575
}
7676
}

src/librustc/middle/typeck/infer/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ trait then {
451451
impl then for ures {
452452
fn then<T:Clone>(&self, f: &fn() -> Result<T,ty::type_err>)
453453
-> Result<T,ty::type_err> {
454-
self.chain(|_i| f())
454+
self.chain_move(|_i| f())
455455
}
456456
}
457457

@@ -474,7 +474,7 @@ trait CresCompare<T> {
474474

475475
impl<T:Clone + Eq> CresCompare<T> for cres<T> {
476476
fn compare(&self, t: T, f: &fn() -> ty::type_err) -> cres<T> {
477-
do (*self).clone().chain |s| {
477+
do (*self).clone().chain_move |s| {
478478
if s == t {
479479
(*self).clone()
480480
} else {

src/librustc/middle/typeck/rscope.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl RegionScope for MethodRscope {
202202
if !self.region_param_names.has_ident(id) {
203203
return RegionParamNames::undeclared_name(None);
204204
}
205-
do EmptyRscope.named_region(span, id).chain_err |_e| {
205+
do EmptyRscope.named_region(span, id).chain_err_move |_e| {
206206
result::Err(RegionError {
207207
msg: ~"lifetime is not in scope",
208208
replacement: ty::re_bound(ty::br_self)
@@ -251,7 +251,7 @@ impl RegionScope for TypeRscope {
251251
}
252252
fn named_region(&self, span: Span, id: ast::Ident)
253253
-> Result<ty::Region, RegionError> {
254-
do EmptyRscope.named_region(span, id).chain_err |_e| {
254+
do EmptyRscope.named_region(span, id).chain_err_move |_e| {
255255
result::Err(RegionError {
256256
msg: ~"only 'self is allowed as part of a type declaration",
257257
replacement: self.replacement()
@@ -310,7 +310,7 @@ impl RegionScope for BindingRscope {
310310
span: Span,
311311
id: ast::Ident) -> Result<ty::Region, RegionError>
312312
{
313-
do self.base.named_region(span, id).chain_err |_e| {
313+
do self.base.named_region(span, id).chain_err_move |_e| {
314314
let result = ty::re_bound(ty::br_named(id));
315315
if self.region_param_names.has_ident(id) {
316316
result::Ok(result)

0 commit comments

Comments
 (0)