]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/middle/typeck/variance.rs
rollup merge of #18407 : thestinger/arena
[rust.git] / src / librustc / middle / typeck / variance.rs
index 1b64d90427bd08be618b90ac6bbb9e63bd3f9dd9..b8c47cff48c6b1fe9f92dcbd667d0ae1114169d4 100644 (file)
@@ -572,7 +572,7 @@ fn find_binding_for_lifetime(&self, param_id: ast::NodeId) -> ast::NodeId {
         match tcx.named_region_map.find(&param_id) {
             Some(&rl::DefEarlyBoundRegion(_, _, lifetime_decl_id))
                 => lifetime_decl_id,
-            Some(_) => fail!("should not encounter non early-bound cases"),
+            Some(_) => panic!("should not encounter non early-bound cases"),
 
             // The lookup should only fail when `param_id` is
             // itself a lifetime binding: use it as the decl_id.
@@ -597,11 +597,11 @@ fn is_to_be_inferred(&self, param_id: ast::NodeId) -> bool {
             assert!(is_lifetime(&tcx.map, param_id));
             let parent_id = tcx.map.get_parent(decl_id);
             let parent = tcx.map.find(parent_id).unwrap_or_else(
-                || fail!("tcx.map missing entry for id: {}", parent_id));
+                || panic!("tcx.map missing entry for id: {}", parent_id));
 
             let is_inferred;
             macro_rules! cannot_happen { () => { {
-                fail!("invalid parent: {:s} for {:s}",
+                panic!("invalid parent: {:s} for {:s}",
                       tcx.map.node_to_string(parent_id),
                       tcx.map.node_to_string(param_id));
             } } }
@@ -728,15 +728,14 @@ fn add_constraints_from_ty(&mut self,
         debug!("add_constraints_from_ty(ty={})", ty.repr(self.tcx()));
 
         match ty::get(ty).sty {
-            ty::ty_nil | ty::ty_bot | ty::ty_bool |
+            ty::ty_nil | ty::ty_bool |
             ty::ty_char | ty::ty_int(_) | ty::ty_uint(_) |
             ty::ty_float(_) | ty::ty_str => {
                 /* leaf type -- noop */
             }
 
-            ty::ty_unboxed_closure(_, region) => {
-                let contra = self.contravariant(variance);
-                self.add_constraints_from_region(region, contra);
+            ty::ty_unboxed_closure(..) => {
+                self.tcx().sess.bug("Unexpected unboxed closure type in variance computation");
             }
 
             ty::ty_rptr(region, ref mt) => {
@@ -883,7 +882,9 @@ fn add_constraints_from_sig(&mut self,
         for &input in sig.inputs.iter() {
             self.add_constraints_from_ty(input, contra);
         }
-        self.add_constraints_from_ty(sig.output, variance);
+        if let ty::FnConverging(result_type) = sig.output {
+            self.add_constraints_from_ty(result_type, variance);
+        }
     }
 
     /// Adds constraints appropriate for a region appearing in a