Skip to content

Commit 86071ac

Browse files
Address nits
1 parent dcdf3d6 commit 86071ac

File tree

13 files changed

+49
-48
lines changed

13 files changed

+49
-48
lines changed

src/librustc/infer/mod.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,12 @@ pub fn drain_fulfillment_cx<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
579579
Ok(infcx.tcx.erase_regions(&result))
580580
}
581581

582+
impl<'tcx, T> InferOk<'tcx, T> {
583+
fn unit(self) -> InferOk<'tcx, ()> {
584+
InferOk { value: (), obligations: self.obligations }
585+
}
586+
}
587+
582588
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
583589
pub fn projection_mode(&self) -> ProjectionMode {
584590
self.projection_mode
@@ -851,8 +857,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
851857
debug!("sub_types({:?} <: {:?})", a, b);
852858
self.commit_if_ok(|_| {
853859
let trace = TypeTrace::types(origin, a_is_expected, a, b);
854-
self.sub(a_is_expected, trace, &a, &b)
855-
.map(|InferOk { obligations, .. }| InferOk { value: (), obligations: obligations })
860+
self.sub(a_is_expected, trace, &a, &b).map(|ok| ok.unit())
856861
})
857862
}
858863

@@ -865,8 +870,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
865870
{
866871
self.commit_if_ok(|_| {
867872
let trace = TypeTrace::types(origin, a_is_expected, a, b);
868-
self.equate(a_is_expected, trace, &a, &b)
869-
.map(|InferOk { obligations, .. }| InferOk { value: (), obligations: obligations })
873+
self.equate(a_is_expected, trace, &a, &b).map(|ok| ok.unit())
870874
})
871875
}
872876

@@ -885,8 +889,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
885889
origin: origin,
886890
values: TraitRefs(expected_found(a_is_expected, a.clone(), b.clone()))
887891
};
888-
self.equate(a_is_expected, trace, &a, &b)
889-
.map(|InferOk { obligations, .. }| InferOk { value: (), obligations: obligations })
892+
self.equate(a_is_expected, trace, &a, &b).map(|ok| ok.unit())
890893
})
891894
}
892895

@@ -905,8 +908,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
905908
origin: origin,
906909
values: PolyTraitRefs(expected_found(a_is_expected, a.clone(), b.clone()))
907910
};
908-
self.sub(a_is_expected, trace, &a, &b)
909-
.map(|InferOk { obligations, .. }| InferOk { value: (), obligations: obligations })
911+
self.sub(a_is_expected, trace, &a, &b).map(|ok| ok.unit())
910912
})
911913
}
912914

@@ -955,9 +957,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
955957
let (ty::EquatePredicate(a, b), skol_map) =
956958
self.skolemize_late_bound_regions(predicate, snapshot);
957959
let origin = TypeOrigin::EquatePredicate(span);
958-
let InferOk { obligations, .. } = mk_eqty(self, false, origin, a, b)?;
959-
self.leak_check(&skol_map, snapshot)
960-
.map(|_| InferOk { value: (), obligations: obligations })
960+
let eqty_ok = mk_eqty(self, false, origin, a, b)?;
961+
self.leak_check(&skol_map, snapshot).map(|_| eqty_ok.unit())
961962
})
962963
}
963964

src/librustc/traits/fulfill.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ fn process_predicate1<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
527527
ty::Predicate::Equate(ref binder) => {
528528
match selcx.infcx().equality_predicate(obligation.cause.span, binder) {
529529
Ok(InferOk { obligations, .. }) => {
530-
// FIXME(#????) propagate obligations
530+
// FIXME(#32730) propagate obligations
531531
assert!(obligations.is_empty());
532532
Ok(Some(Vec::new()))
533533
},

src/librustc/traits/project.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ fn project_and_unify_type<'cx,'tcx>(
233233
let origin = TypeOrigin::RelateOutputImplTypes(obligation.cause.span);
234234
match infer::mk_eqty(infcx, true, origin, normalized_ty, obligation.predicate.ty) {
235235
Ok(InferOk { obligations: inferred_obligations, .. }) => {
236-
// FIXME(#????) propagate obligations
236+
// FIXME(#32730) propagate obligations
237237
assert!(inferred_obligations.is_empty());
238238
Ok(Some(obligations))
239239
},
@@ -283,7 +283,7 @@ fn consider_unification_despite_ambiguity<'cx,'tcx>(selcx: &mut SelectionContext
283283
let obligation_ty = obligation.predicate.ty;
284284
match infer::mk_eqty(infcx, true, origin, obligation_ty, ret_type) {
285285
Ok(InferOk { obligations, .. }) => {
286-
// FIXME(#????) propagate obligations
286+
// FIXME(#32730) propagate obligations
287287
assert!(obligations.is_empty());
288288
}
289289
Err(_) => { /* ignore errors */ }
@@ -837,7 +837,7 @@ fn assemble_candidates_from_predicates<'cx,'tcx,I>(
837837
origin,
838838
data_poly_trait_ref,
839839
obligation_poly_trait_ref)
840-
// FIXME(#????) propagate obligations
840+
// FIXME(#32730) propagate obligations
841841
.map(|InferOk { obligations, .. }| assert!(obligations.is_empty()))
842842
.is_ok()
843843
});
@@ -1093,7 +1093,7 @@ fn confirm_param_env_candidate<'cx,'tcx>(
10931093
obligation.predicate.trait_ref.clone(),
10941094
projection.projection_ty.trait_ref.clone()) {
10951095
Ok(InferOk { obligations, .. }) => {
1096-
// FIXME(#????) propagate obligations
1096+
// FIXME(#32730) propagate obligations
10971097
assert!(obligations.is_empty());
10981098
}
10991099
Err(e) => {

src/librustc/traits/select.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
485485
// does this code ever run?
486486
match self.infcx.equality_predicate(obligation.cause.span, p) {
487487
Ok(InferOk { obligations, .. }) => {
488-
// FIXME(#????) propagate obligations
488+
// FIXME(#32730) propagate obligations
489489
assert!(obligations.is_empty());
490490
EvaluatedToOk
491491
},
@@ -1190,7 +1190,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
11901190
trait_bound.clone(),
11911191
ty::Binder(skol_trait_ref.clone())) {
11921192
Ok(InferOk { obligations, .. }) => {
1193-
// FIXME(#????) propagate obligations
1193+
// FIXME(#32730) propagate obligations
11941194
assert!(obligations.is_empty());
11951195
}
11961196
Err(_) => { return false; }
@@ -2505,7 +2505,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
25052505
origin,
25062506
expected_trait_ref.clone(),
25072507
obligation_trait_ref.clone())
2508-
// FIXME(#????) propagate obligations
2508+
// FIXME(#32730) propagate obligations
25092509
.map(|InferOk { obligations, .. }| assert!(obligations.is_empty()))
25102510
.map_err(|e| OutputTypeParameterMismatch(expected_trait_ref, obligation_trait_ref, e))
25112511
}
@@ -2541,7 +2541,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
25412541
let InferOk { obligations, .. } =
25422542
self.infcx.sub_types(false, origin, new_trait, target)
25432543
.map_err(|_| Unimplemented)?;
2544-
// FIXME(#????) propagate obligations
2544+
// FIXME(#32730) propagate obligations
25452545
assert!(obligations.is_empty());
25462546

25472547
// Register one obligation for 'a: 'b.
@@ -2608,7 +2608,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
26082608
let InferOk { obligations, .. } =
26092609
self.infcx.sub_types(false, origin, a, b)
26102610
.map_err(|_| Unimplemented)?;
2611-
// FIXME(#????) propagate obligations
2611+
// FIXME(#32730) propagate obligations
26122612
assert!(obligations.is_empty());
26132613
}
26142614

@@ -2668,7 +2668,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
26682668
let InferOk { obligations, .. } =
26692669
self.infcx.sub_types(false, origin, new_struct, target)
26702670
.map_err(|_| Unimplemented)?;
2671-
// FIXME(#????) propagate obligations
2671+
// FIXME(#32730) propagate obligations
26722672
assert!(obligations.is_empty());
26732673

26742674
// Construct the nested Field<T>: Unsize<Field<U>> predicate.
@@ -2764,7 +2764,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
27642764
debug!("match_impl: failed eq_trait_refs due to `{}`", e);
27652765
()
27662766
})?;
2767-
// FIXME(#????) propagate obligations
2767+
// FIXME(#32730) propagate obligations
27682768
assert!(obligations.is_empty());
27692769

27702770
if let Err(e) = self.infcx.leak_check(&skol_map, snapshot) {
@@ -2832,7 +2832,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
28322832
origin,
28332833
poly_trait_ref,
28342834
obligation.predicate.to_poly_trait_ref())
2835-
// FIXME(#????) propagate obligations
2835+
// FIXME(#32730) propagate obligations
28362836
.map(|InferOk { obligations, .. }| assert!(obligations.is_empty()))
28372837
.map_err(|_| ())
28382838
}

src/librustc_driver/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
375375
pub fn check_sub(&self, t1: Ty<'tcx>, t2: Ty<'tcx>) {
376376
match self.sub(&t1, &t2) {
377377
Ok(InferOk { obligations, .. }) => {
378-
// FIXME once obligations are being propagated, assert the right thing.
378+
// FIXME(#32730) once obligations are being propagated, assert the right thing.
379379
assert!(obligations.is_empty());
380380
}
381381
Err(ref e) => {
@@ -399,7 +399,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
399399
pub fn check_lub(&self, t1: Ty<'tcx>, t2: Ty<'tcx>, t_lub: Ty<'tcx>) {
400400
match self.lub(&t1, &t2) {
401401
Ok(InferOk { obligations, value: t }) => {
402-
// FIXME once obligations are being propagated, assert the right thing.
402+
// FIXME(#32730) once obligations are being propagated, assert the right thing.
403403
assert!(obligations.is_empty());
404404

405405
self.assert_eq(t, t_lub);
@@ -418,7 +418,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
418418
panic!("unexpected error computing LUB: {:?}", e)
419419
}
420420
Ok(InferOk { obligations, value: t }) => {
421-
// FIXME once obligations are being propagated, assert the right thing.
421+
// FIXME(#32730) once obligations are being propagated, assert the right thing.
422422
assert!(obligations.is_empty());
423423

424424
self.assert_eq(t, t_glb);

src/librustc_mir/transform/type_check.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
338338
{
339339
infer::mk_subty(self.infcx, false, infer::TypeOrigin::Misc(span),
340340
sup, sub)
341-
// FIXME(#????) propagate obligations
341+
// FIXME(#32730) propagate obligations
342342
.map(|InferOk { obligations, .. }| assert!(obligations.is_empty()))
343343
}
344344

@@ -347,7 +347,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
347347
{
348348
infer::mk_eqty(self.infcx, false, infer::TypeOrigin::Misc(span),
349349
a, b)
350-
// FIXME(#????) propagate obligations
350+
// FIXME(#32730) propagate obligations
351351
.map(|InferOk { obligations, .. }| assert!(obligations.is_empty()))
352352
}
353353

src/librustc_typeck/check/_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ pub fn check_match<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
534534
let result = if is_if_let_fallback {
535535
fcx.infcx().eq_types(true, origin, arm_ty, result_ty)
536536
.map(|InferOk { obligations, .. }| {
537-
// FIXME(#????) propagate obligations
537+
// FIXME(#32730) propagate obligations
538538
assert!(obligations.is_empty());
539539
arm_ty
540540
})

src/librustc_typeck/check/coercion.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,14 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
119119
if self.use_lub {
120120
infcx.lub(false, trace, &a, &b)
121121
.map(|InferOk { value, obligations }| {
122-
// FIXME(#????) propagate obligations
122+
// FIXME(#32730) propagate obligations
123123
assert!(obligations.is_empty());
124124
value
125125
})
126126
} else {
127127
infcx.sub(false, trace, &a, &b)
128128
.map(|InferOk { value, obligations }| {
129-
// FIXME(#????) propagate obligations
129+
// FIXME(#32730) propagate obligations
130130
assert!(obligations.is_empty());
131131
value
132132
})
@@ -668,7 +668,7 @@ pub fn try_find_lub<'a, 'b, 'tcx, E, I>(fcx: &FnCtxt<'a, 'tcx>,
668668
// The signature must always match.
669669
let fty = fcx.infcx().lub(true, trace.clone(), a_fty, b_fty)
670670
.map(|InferOk { value, obligations }| {
671-
// FIXME(#????) propagate obligations
671+
// FIXME(#32730) propagate obligations
672672
assert!(obligations.is_empty());
673673
value
674674
})?;
@@ -678,7 +678,7 @@ pub fn try_find_lub<'a, 'b, 'tcx, E, I>(fcx: &FnCtxt<'a, 'tcx>,
678678
let substs = fcx.infcx().commit_if_ok(|_| {
679679
fcx.infcx().lub(true, trace.clone(), a_substs, b_substs)
680680
.map(|InferOk { value, obligations }| {
681-
// FIXME(#????) propagate obligations
681+
// FIXME(#32730) propagate obligations
682682
assert!(obligations.is_empty());
683683
value
684684
})
@@ -746,7 +746,7 @@ pub fn try_find_lub<'a, 'b, 'tcx, E, I>(fcx: &FnCtxt<'a, 'tcx>,
746746
return fcx.infcx().commit_if_ok(|_| {
747747
fcx.infcx().lub(true, trace.clone(), &prev_ty, &new_ty)
748748
.map(|InferOk { value, obligations }| {
749-
// FIXME(#????) propagate obligations
749+
// FIXME(#32730) propagate obligations
750750
assert!(obligations.is_empty());
751751
value
752752
})
@@ -763,7 +763,7 @@ pub fn try_find_lub<'a, 'b, 'tcx, E, I>(fcx: &FnCtxt<'a, 'tcx>,
763763
fcx.infcx().commit_if_ok(|_| {
764764
fcx.infcx().lub(true, trace, &prev_ty, &new_ty)
765765
.map(|InferOk { value, obligations }| {
766-
// FIXME(#????) propagate obligations
766+
// FIXME(#32730) propagate obligations
767767
assert!(obligations.is_empty());
768768
value
769769
})

src/librustc_typeck/check/compare_method.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ pub fn compare_const_impl<'tcx>(tcx: &TyCtxt<'tcx>,
476476

477477
match err {
478478
Ok(InferOk { obligations, .. }) => {
479-
// FIXME(#????) propagate obligations
479+
// FIXME(#32730) propagate obligations
480480
assert!(obligations.is_empty())
481481
}
482482
Err(terr) => {

src/librustc_typeck/check/demand.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn suptype<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, sp: Span,
2323
let origin = TypeOrigin::Misc(sp);
2424
match fcx.infcx().sub_types(false, origin, actual, expected) {
2525
Ok(InferOk { obligations, .. }) => {
26-
// FIXME(#????) propagate obligations
26+
// FIXME(#32730) propagate obligations
2727
assert!(obligations.is_empty());
2828
},
2929
Err(e) => {
@@ -37,7 +37,7 @@ pub fn eqtype<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, sp: Span,
3737
let origin = TypeOrigin::Misc(sp);
3838
match fcx.infcx().eq_types(false, origin, actual, expected) {
3939
Ok(InferOk { obligations, .. }) => {
40-
// FIXME(#????) propagate obligations
40+
// FIXME(#32730) propagate obligations
4141
assert!(obligations.is_empty());
4242
},
4343
Err(e) => {

src/librustc_typeck/check/method/probe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
11341134

11351135
fn make_sub_ty(&self, sub: Ty<'tcx>, sup: Ty<'tcx>) -> infer::UnitResult<'tcx> {
11361136
self.infcx().sub_types(false, TypeOrigin::Misc(DUMMY_SP), sub, sup)
1137-
// FIXME(#????) propagate obligations
1137+
// FIXME(#32730) propagate obligations
11381138
.map(|InferOk { obligations, .. }| assert!(obligations.is_empty()))
11391139
}
11401140

src/librustc_typeck/check/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,7 +1628,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16281628
sup: Ty<'tcx>)
16291629
-> Result<(), TypeError<'tcx>> {
16301630
infer::mk_subty(self.infcx(), a_is_expected, origin, sub, sup)
1631-
// FIXME(#????) propagate obligations
1631+
// FIXME(#32730) propagate obligations
16321632
.map(|InferOk { obligations, .. }| assert!(obligations.is_empty()))
16331633
}
16341634

@@ -1639,7 +1639,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16391639
sup: Ty<'tcx>)
16401640
-> Result<(), TypeError<'tcx>> {
16411641
infer::mk_eqty(self.infcx(), a_is_expected, origin, sub, sup)
1642-
// FIXME(#????) propagate obligations
1642+
// FIXME(#32730) propagate obligations
16431643
.map(|InferOk { obligations, .. }| assert!(obligations.is_empty()))
16441644
}
16451645

@@ -1920,7 +1920,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
19201920
TypeOrigin::Misc(default.origin_span),
19211921
ty, default.ty) {
19221922
Ok(InferOk { obligations, .. }) => {
1923-
// FIXME(#????) propagate obligations
1923+
// FIXME(#32730) propagate obligations
19241924
assert!(obligations.is_empty())
19251925
},
19261926
Err(_) => {
@@ -2015,7 +2015,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
20152015
match infer::mk_eqty(self.infcx(), false,
20162016
TypeOrigin::Misc(default.origin_span),
20172017
ty, default.ty) {
2018-
// FIXME(#????) propagate obligations
2018+
// FIXME(#32730) propagate obligations
20192019
Ok(InferOk { obligations, .. }) => assert!(obligations.is_empty()),
20202020
Err(_) => {
20212021
result = Some(default);
@@ -2784,7 +2784,7 @@ fn expected_types_for_fn_args<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
27842784
// FIXME(#15760) can't use try! here, FromError doesn't default
27852785
// to identity so the resulting type is not constrained.
27862786
match ures {
2787-
// FIXME(#????) propagate obligations
2787+
// FIXME(#32730) propagate obligations
27882788
Ok(InferOk { obligations, .. }) => assert!(obligations.is_empty()),
27892789
Err(e) => return Err(e),
27902790
}
@@ -2915,7 +2915,7 @@ fn check_expr_with_expectation_and_lvalue_pref<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
29152915
let trace = TypeTrace::types(origin, true, then_ty, else_ty);
29162916
fcx.infcx().lub(true, trace, &then_ty, &else_ty)
29172917
.map(|InferOk { value, obligations }| {
2918-
// FIXME(#????) propagate obligations
2918+
// FIXME(#32730) propagate obligations
29192919
assert!(obligations.is_empty());
29202920
value
29212921
})
@@ -2927,7 +2927,7 @@ fn check_expr_with_expectation_and_lvalue_pref<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
29272927
(origin, unit, then_ty,
29282928
fcx.infcx().eq_types(true, origin, unit, then_ty)
29292929
.map(|InferOk { obligations, .. }| {
2930-
// FIXME(#????) propagate obligations
2930+
// FIXME(#32730) propagate obligations
29312931
assert!(obligations.is_empty());
29322932
unit
29332933
}))

src/librustc_typeck/check/regionck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1847,7 +1847,7 @@ fn declared_projection_bounds_from_trait<'a,'tcx>(rcx: &Rcx<'a, 'tcx>,
18471847
// check whether this predicate applies to our current projection
18481848
match infer::mk_eqty(infcx, false, TypeOrigin::Misc(span), ty, outlives.0) {
18491849
Ok(InferOk { obligations, .. }) => {
1850-
// FIXME(#????) propagate obligations
1850+
// FIXME(#32730) propagate obligations
18511851
assert!(obligations.is_empty());
18521852
Ok(outlives.1)
18531853
}

0 commit comments

Comments
 (0)