]> git.lizzy.rs Git - rust.git/commitdiff
Address nits
authorMasood Malekghassemi <atash@google.com>
Mon, 4 Apr 2016 19:41:05 +0000 (12:41 -0700)
committerMasood Malekghassemi <atash@google.com>
Mon, 4 Apr 2016 19:41:05 +0000 (12:41 -0700)
13 files changed:
src/librustc/infer/mod.rs
src/librustc/traits/fulfill.rs
src/librustc/traits/project.rs
src/librustc/traits/select.rs
src/librustc_driver/test.rs
src/librustc_mir/transform/type_check.rs
src/librustc_typeck/check/_match.rs
src/librustc_typeck/check/coercion.rs
src/librustc_typeck/check/compare_method.rs
src/librustc_typeck/check/demand.rs
src/librustc_typeck/check/method/probe.rs
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/regionck.rs

index 6e97cdef3d7ca4a5bdc81cbab62ce0495f51dc97..3bf618202e9b42b1336ab844a068f94689990e86 100644 (file)
@@ -579,6 +579,12 @@ pub fn drain_fulfillment_cx<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
     Ok(infcx.tcx.erase_regions(&result))
 }
 
+impl<'tcx, T> InferOk<'tcx, T> {
+    fn unit(self) -> InferOk<'tcx, ()> {
+        InferOk { value: (), obligations: self.obligations }
+    }
+}
+
 impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
     pub fn projection_mode(&self) -> ProjectionMode {
         self.projection_mode
@@ -851,8 +857,7 @@ pub fn sub_types(&self,
         debug!("sub_types({:?} <: {:?})", a, b);
         self.commit_if_ok(|_| {
             let trace = TypeTrace::types(origin, a_is_expected, a, b);
-            self.sub(a_is_expected, trace, &a, &b)
-                .map(|InferOk { obligations, .. }| InferOk { value: (), obligations: obligations })
+            self.sub(a_is_expected, trace, &a, &b).map(|ok| ok.unit())
         })
     }
 
@@ -865,8 +870,7 @@ pub fn eq_types(&self,
     {
         self.commit_if_ok(|_| {
             let trace = TypeTrace::types(origin, a_is_expected, a, b);
-            self.equate(a_is_expected, trace, &a, &b)
-                .map(|InferOk { obligations, .. }| InferOk { value: (), obligations: obligations })
+            self.equate(a_is_expected, trace, &a, &b).map(|ok| ok.unit())
         })
     }
 
@@ -885,8 +889,7 @@ pub fn eq_trait_refs(&self,
                 origin: origin,
                 values: TraitRefs(expected_found(a_is_expected, a.clone(), b.clone()))
             };
-            self.equate(a_is_expected, trace, &a, &b)
-                .map(|InferOk { obligations, .. }| InferOk { value: (), obligations: obligations })
+            self.equate(a_is_expected, trace, &a, &b).map(|ok| ok.unit())
         })
     }
 
@@ -905,8 +908,7 @@ pub fn sub_poly_trait_refs(&self,
                 origin: origin,
                 values: PolyTraitRefs(expected_found(a_is_expected, a.clone(), b.clone()))
             };
-            self.sub(a_is_expected, trace, &a, &b)
-                .map(|InferOk { obligations, .. }| InferOk { value: (), obligations: obligations })
+            self.sub(a_is_expected, trace, &a, &b).map(|ok| ok.unit())
         })
     }
 
@@ -955,9 +957,8 @@ pub fn equality_predicate(&self,
             let (ty::EquatePredicate(a, b), skol_map) =
                 self.skolemize_late_bound_regions(predicate, snapshot);
             let origin = TypeOrigin::EquatePredicate(span);
-            let InferOk { obligations, .. } = mk_eqty(self, false, origin, a, b)?;
-            self.leak_check(&skol_map, snapshot)
-                .map(|_| InferOk { value: (), obligations: obligations })
+            let eqty_ok = mk_eqty(self, false, origin, a, b)?;
+            self.leak_check(&skol_map, snapshot).map(|_| eqty_ok.unit())
         })
     }
 
index 68173bc9ea513cc81601333effde3b234a8041a4..46323cdf77ee4249ba27dd99c34a1089acd852a7 100644 (file)
@@ -527,7 +527,7 @@ fn process_predicate1<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
         ty::Predicate::Equate(ref binder) => {
             match selcx.infcx().equality_predicate(obligation.cause.span, binder) {
                 Ok(InferOk { obligations, .. }) => {
-                    // FIXME(#????) propagate obligations
+                    // FIXME(#32730) propagate obligations
                     assert!(obligations.is_empty());
                     Ok(Some(Vec::new()))
                 },
index 85fe457c75e8cfd7a16fd39428ff44d9b82ea5b1..71eb0a227b4ed64e32d126c48ccab833f1929402 100644 (file)
@@ -233,7 +233,7 @@ fn project_and_unify_type<'cx,'tcx>(
     let origin = TypeOrigin::RelateOutputImplTypes(obligation.cause.span);
     match infer::mk_eqty(infcx, true, origin, normalized_ty, obligation.predicate.ty) {
         Ok(InferOk { obligations: inferred_obligations, .. }) => {
-            // FIXME(#????) propagate obligations
+            // FIXME(#32730) propagate obligations
             assert!(inferred_obligations.is_empty());
             Ok(Some(obligations))
         },
@@ -283,7 +283,7 @@ fn consider_unification_despite_ambiguity<'cx,'tcx>(selcx: &mut SelectionContext
             let obligation_ty = obligation.predicate.ty;
             match infer::mk_eqty(infcx, true, origin, obligation_ty, ret_type) {
                 Ok(InferOk { obligations, .. }) => {
-                    // FIXME(#????) propagate obligations
+                    // FIXME(#32730) propagate obligations
                     assert!(obligations.is_empty());
                 }
                 Err(_) => { /* ignore errors */ }
@@ -837,7 +837,7 @@ fn assemble_candidates_from_predicates<'cx,'tcx,I>(
                                               origin,
                                               data_poly_trait_ref,
                                               obligation_poly_trait_ref)
-                        // FIXME(#????) propagate obligations
+                        // FIXME(#32730) propagate obligations
                         .map(|InferOk { obligations, .. }| assert!(obligations.is_empty()))
                         .is_ok()
                 });
@@ -1093,7 +1093,7 @@ fn confirm_param_env_candidate<'cx,'tcx>(
                               obligation.predicate.trait_ref.clone(),
                               projection.projection_ty.trait_ref.clone()) {
         Ok(InferOk { obligations, .. }) => {
-            // FIXME(#????) propagate obligations
+            // FIXME(#32730) propagate obligations
             assert!(obligations.is_empty());
         }
         Err(e) => {
index 013c75bf8d2bbc3eefcd46abe79a804193ff80ad..d18f8e9dc53d03766625e6b4d84cb1897966d49a 100644 (file)
@@ -485,7 +485,7 @@ fn evaluate_predicate_recursively<'o>(&mut self,
                 // does this code ever run?
                 match self.infcx.equality_predicate(obligation.cause.span, p) {
                     Ok(InferOk { obligations, .. }) => {
-                        // FIXME(#????) propagate obligations
+                        // FIXME(#32730) propagate obligations
                         assert!(obligations.is_empty());
                         EvaluatedToOk
                     },
@@ -1190,7 +1190,7 @@ fn match_projection(&mut self,
                                              trait_bound.clone(),
                                              ty::Binder(skol_trait_ref.clone())) {
             Ok(InferOk { obligations, .. }) => {
-                // FIXME(#????) propagate obligations
+                // FIXME(#32730) propagate obligations
                 assert!(obligations.is_empty());
             }
             Err(_) => { return false; }
@@ -2505,7 +2505,7 @@ fn confirm_poly_trait_refs(&mut self,
                                        origin,
                                        expected_trait_ref.clone(),
                                        obligation_trait_ref.clone())
-            // FIXME(#????) propagate obligations
+            // FIXME(#32730) propagate obligations
             .map(|InferOk { obligations, .. }| assert!(obligations.is_empty()))
             .map_err(|e| OutputTypeParameterMismatch(expected_trait_ref, obligation_trait_ref, e))
     }
@@ -2541,7 +2541,7 @@ fn confirm_builtin_unsize_candidate(&mut self,
                 let InferOk { obligations, .. } =
                     self.infcx.sub_types(false, origin, new_trait, target)
                     .map_err(|_| Unimplemented)?;
-                // FIXME(#????) propagate obligations
+                // FIXME(#32730) propagate obligations
                 assert!(obligations.is_empty());
 
                 // Register one obligation for 'a: 'b.
@@ -2608,7 +2608,7 @@ fn confirm_builtin_unsize_candidate(&mut self,
                 let InferOk { obligations, .. } =
                     self.infcx.sub_types(false, origin, a, b)
                     .map_err(|_| Unimplemented)?;
-                // FIXME(#????) propagate obligations
+                // FIXME(#32730) propagate obligations
                 assert!(obligations.is_empty());
             }
 
@@ -2668,7 +2668,7 @@ fn confirm_builtin_unsize_candidate(&mut self,
                 let InferOk { obligations, .. } =
                     self.infcx.sub_types(false, origin, new_struct, target)
                     .map_err(|_| Unimplemented)?;
-                // FIXME(#????) propagate obligations
+                // FIXME(#32730) propagate obligations
                 assert!(obligations.is_empty());
 
                 // Construct the nested Field<T>: Unsize<Field<U>> predicate.
@@ -2764,7 +2764,7 @@ fn match_impl(&mut self,
                 debug!("match_impl: failed eq_trait_refs due to `{}`", e);
                 ()
             })?;
-        // FIXME(#????) propagate obligations
+        // FIXME(#32730) propagate obligations
         assert!(obligations.is_empty());
 
         if let Err(e) = self.infcx.leak_check(&skol_map, snapshot) {
@@ -2832,7 +2832,7 @@ fn match_poly_trait_ref(&self,
                                        origin,
                                        poly_trait_ref,
                                        obligation.predicate.to_poly_trait_ref())
-            // FIXME(#????) propagate obligations
+            // FIXME(#32730) propagate obligations
             .map(|InferOk { obligations, .. }| assert!(obligations.is_empty()))
             .map_err(|_| ())
     }
index 00569d50cbb9c4dff75e497d4d65829530c68b21..ce0d42203b987baf56ebe03fe2d0e3e64adb98df 100644 (file)
@@ -375,7 +375,7 @@ pub fn glb(&self, t1: &Ty<'tcx>, t2: &Ty<'tcx>) -> InferResult<'tcx, Ty<'tcx>> {
     pub fn check_sub(&self, t1: Ty<'tcx>, t2: Ty<'tcx>) {
         match self.sub(&t1, &t2) {
             Ok(InferOk { obligations, .. }) => {
-                // FIXME once obligations are being propagated, assert the right thing.
+                // FIXME(#32730) once obligations are being propagated, assert the right thing.
                 assert!(obligations.is_empty());
             }
             Err(ref e) => {
@@ -399,7 +399,7 @@ pub fn check_not_sub(&self, t1: Ty<'tcx>, t2: Ty<'tcx>) {
     pub fn check_lub(&self, t1: Ty<'tcx>, t2: Ty<'tcx>, t_lub: Ty<'tcx>) {
         match self.lub(&t1, &t2) {
             Ok(InferOk { obligations, value: t }) => {
-                // FIXME once obligations are being propagated, assert the right thing.
+                // FIXME(#32730) once obligations are being propagated, assert the right thing.
                 assert!(obligations.is_empty());
 
                 self.assert_eq(t, t_lub);
@@ -418,7 +418,7 @@ pub fn check_glb(&self, t1: Ty<'tcx>, t2: Ty<'tcx>, t_glb: Ty<'tcx>) {
                 panic!("unexpected error computing LUB: {:?}", e)
             }
             Ok(InferOk { obligations, value: t }) => {
-                // FIXME once obligations are being propagated, assert the right thing.
+                // FIXME(#32730) once obligations are being propagated, assert the right thing.
                 assert!(obligations.is_empty());
 
                 self.assert_eq(t, t_glb);
index 3f85a3e1d461827ff1334afe8662bc117e458872..ce8ede7f4b9592be12d82a5caf829bc507c81e67 100644 (file)
@@ -338,7 +338,7 @@ fn mk_subty(&self, span: Span, sup: Ty<'tcx>, sub: Ty<'tcx>)
     {
         infer::mk_subty(self.infcx, false, infer::TypeOrigin::Misc(span),
                         sup, sub)
-            // FIXME(#????) propagate obligations
+            // FIXME(#32730) propagate obligations
             .map(|InferOk { obligations, .. }| assert!(obligations.is_empty()))
     }
 
@@ -347,7 +347,7 @@ fn mk_eqty(&self, span: Span, a: Ty<'tcx>, b: Ty<'tcx>)
     {
         infer::mk_eqty(self.infcx, false, infer::TypeOrigin::Misc(span),
                        a, b)
-            // FIXME(#????) propagate obligations
+            // FIXME(#32730) propagate obligations
             .map(|InferOk { obligations, .. }| assert!(obligations.is_empty()))
     }
 
index dcbfa2bb79b6c04ac4652533bdbd8b74cb6d40eb..e359329ebcf7f168afc6691b02ff17ab354168e1 100644 (file)
@@ -534,7 +534,7 @@ pub fn check_match<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
         let result = if is_if_let_fallback {
             fcx.infcx().eq_types(true, origin, arm_ty, result_ty)
                 .map(|InferOk { obligations, .. }| {
-                    // FIXME(#????) propagate obligations
+                    // FIXME(#32730) propagate obligations
                     assert!(obligations.is_empty());
                     arm_ty
                 })
index a4d8e2ae049381eab60a75422b2081a8191fd2c5..a9849e93578c8c5f9380f083ec6e1ee464d3b1d7 100644 (file)
@@ -119,14 +119,14 @@ fn unify(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
             if self.use_lub {
                 infcx.lub(false, trace, &a, &b)
                     .map(|InferOk { value, obligations }| {
-                        // FIXME(#????) propagate obligations
+                        // FIXME(#32730) propagate obligations
                         assert!(obligations.is_empty());
                         value
                     })
             } else {
                 infcx.sub(false, trace, &a, &b)
                     .map(|InferOk { value, obligations }| {
-                        // FIXME(#????) propagate obligations
+                        // FIXME(#32730) propagate obligations
                         assert!(obligations.is_empty());
                         value
                     })
@@ -668,7 +668,7 @@ pub fn try_find_lub<'a, 'b, 'tcx, E, I>(fcx: &FnCtxt<'a, 'tcx>,
             // The signature must always match.
             let fty = fcx.infcx().lub(true, trace.clone(), a_fty, b_fty)
                 .map(|InferOk { value, obligations }| {
-                    // FIXME(#????) propagate obligations
+                    // FIXME(#32730) propagate obligations
                     assert!(obligations.is_empty());
                     value
                 })?;
@@ -678,7 +678,7 @@ pub fn try_find_lub<'a, 'b, 'tcx, E, I>(fcx: &FnCtxt<'a, 'tcx>,
                 let substs = fcx.infcx().commit_if_ok(|_| {
                     fcx.infcx().lub(true, trace.clone(), a_substs, b_substs)
                         .map(|InferOk { value, obligations }| {
-                            // FIXME(#????) propagate obligations
+                            // FIXME(#32730) propagate obligations
                             assert!(obligations.is_empty());
                             value
                         })
@@ -746,7 +746,7 @@ pub fn try_find_lub<'a, 'b, 'tcx, E, I>(fcx: &FnCtxt<'a, 'tcx>,
             return fcx.infcx().commit_if_ok(|_| {
                 fcx.infcx().lub(true, trace.clone(), &prev_ty, &new_ty)
                     .map(|InferOk { value, obligations }| {
-                        // FIXME(#????) propagate obligations
+                        // FIXME(#32730) propagate obligations
                         assert!(obligations.is_empty());
                         value
                     })
@@ -763,7 +763,7 @@ pub fn try_find_lub<'a, 'b, 'tcx, E, I>(fcx: &FnCtxt<'a, 'tcx>,
                 fcx.infcx().commit_if_ok(|_| {
                     fcx.infcx().lub(true, trace, &prev_ty, &new_ty)
                         .map(|InferOk { value, obligations }| {
-                            // FIXME(#????) propagate obligations
+                            // FIXME(#32730) propagate obligations
                             assert!(obligations.is_empty());
                             value
                         })
index 5f49b0335d929cde9c21fdf7ca280a0d8ce453ab..3c12ab8d59840ea61ade8994d21005ed7ca109f8 100644 (file)
@@ -476,7 +476,7 @@ pub fn compare_const_impl<'tcx>(tcx: &TyCtxt<'tcx>,
 
     match err {
         Ok(InferOk { obligations, .. }) => {
-            // FIXME(#????) propagate obligations
+            // FIXME(#32730) propagate obligations
             assert!(obligations.is_empty())
         }
         Err(terr) => {
index 75f6b11a229314d95bd0a59561e1bcc76d0b0ca4..bc2ef9aafee59d4b669000991d0f8b7606ba0d18 100644 (file)
@@ -23,7 +23,7 @@ pub fn suptype<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, sp: Span,
     let origin = TypeOrigin::Misc(sp);
     match fcx.infcx().sub_types(false, origin, actual, expected) {
         Ok(InferOk { obligations, .. }) => {
-            // FIXME(#????) propagate obligations
+            // FIXME(#32730) propagate obligations
             assert!(obligations.is_empty());
         },
         Err(e) => {
@@ -37,7 +37,7 @@ pub fn eqtype<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, sp: Span,
     let origin = TypeOrigin::Misc(sp);
     match fcx.infcx().eq_types(false, origin, actual, expected) {
         Ok(InferOk { obligations, .. }) => {
-            // FIXME(#????) propagate obligations
+            // FIXME(#32730) propagate obligations
             assert!(obligations.is_empty());
         },
         Err(e) => {
index 44dbcd051e201275fccf20ca00ceffa27a0edd34..7e487c1f717f79b38c92df04733faa5644099d36 100644 (file)
@@ -1134,7 +1134,7 @@ fn collapse_candidates_to_trait_pick(&self,
 
     fn make_sub_ty(&self, sub: Ty<'tcx>, sup: Ty<'tcx>) -> infer::UnitResult<'tcx> {
         self.infcx().sub_types(false, TypeOrigin::Misc(DUMMY_SP), sub, sup)
-            // FIXME(#????) propagate obligations
+            // FIXME(#32730) propagate obligations
             .map(|InferOk { obligations, .. }| assert!(obligations.is_empty()))
     }
 
index 625e59c6e3c631c6d9a87028db6a6bf9d933b9af..da93180c600ddcf3a3dc0e67c6e566624661aff6 100644 (file)
@@ -1628,7 +1628,7 @@ pub fn mk_subty(&self,
                     sup: Ty<'tcx>)
                     -> Result<(), TypeError<'tcx>> {
         infer::mk_subty(self.infcx(), a_is_expected, origin, sub, sup)
-            // FIXME(#????) propagate obligations
+            // FIXME(#32730) propagate obligations
             .map(|InferOk { obligations, .. }| assert!(obligations.is_empty()))
     }
 
@@ -1639,7 +1639,7 @@ pub fn mk_eqty(&self,
                    sup: Ty<'tcx>)
                    -> Result<(), TypeError<'tcx>> {
         infer::mk_eqty(self.infcx(), a_is_expected, origin, sub, sup)
-            // FIXME(#????) propagate obligations
+            // FIXME(#32730) propagate obligations
             .map(|InferOk { obligations, .. }| assert!(obligations.is_empty()))
     }
 
@@ -1920,7 +1920,7 @@ fn new_select_all_obligations_and_apply_defaults(&self) {
                                                          TypeOrigin::Misc(default.origin_span),
                                                          ty, default.ty) {
                                         Ok(InferOk { obligations, .. }) => {
-                                            // FIXME(#????) propagate obligations
+                                            // FIXME(#32730) propagate obligations
                                             assert!(obligations.is_empty())
                                         },
                                         Err(_) => {
@@ -2015,7 +2015,7 @@ fn find_conflicting_default(&self,
                             match infer::mk_eqty(self.infcx(), false,
                                                  TypeOrigin::Misc(default.origin_span),
                                                  ty, default.ty) {
-                                // FIXME(#????) propagate obligations
+                                // FIXME(#32730) propagate obligations
                                 Ok(InferOk { obligations, .. }) => assert!(obligations.is_empty()),
                                 Err(_) => {
                                     result = Some(default);
@@ -2784,7 +2784,7 @@ fn expected_types_for_fn_args<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
                 // FIXME(#15760) can't use try! here, FromError doesn't default
                 // to identity so the resulting type is not constrained.
                 match ures {
-                    // FIXME(#????) propagate obligations
+                    // FIXME(#32730) propagate obligations
                     Ok(InferOk { obligations, .. }) => assert!(obligations.is_empty()),
                     Err(e) => return Err(e),
                 }
@@ -2915,7 +2915,7 @@ fn check_then_else<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
                     let trace = TypeTrace::types(origin, true, then_ty, else_ty);
                     fcx.infcx().lub(true, trace, &then_ty, &else_ty)
                         .map(|InferOk { value, obligations }| {
-                            // FIXME(#????) propagate obligations
+                            // FIXME(#32730) propagate obligations
                             assert!(obligations.is_empty());
                             value
                         })
@@ -2927,7 +2927,7 @@ fn check_then_else<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
             (origin, unit, then_ty,
              fcx.infcx().eq_types(true, origin, unit, then_ty)
                  .map(|InferOk { obligations, .. }| {
-                     // FIXME(#????) propagate obligations
+                     // FIXME(#32730) propagate obligations
                      assert!(obligations.is_empty());
                      unit
                  }))
index 515a898699e0c4e67392fa8ba136a040fefa526e..dae14c33296899a5b6822bedee99de2ed1520a27 100644 (file)
@@ -1847,7 +1847,7 @@ fn declared_projection_bounds_from_trait<'a,'tcx>(rcx: &Rcx<'a, 'tcx>,
                 // check whether this predicate applies to our current projection
                 match infer::mk_eqty(infcx, false, TypeOrigin::Misc(span), ty, outlives.0) {
                     Ok(InferOk { obligations, .. }) => {
-                        // FIXME(#????) propagate obligations
+                        // FIXME(#32730) propagate obligations
                         assert!(obligations.is_empty());
                         Ok(outlives.1)
                     }