]> git.lizzy.rs Git - rust.git/commitdiff
outlives: convert outlives to use an exhaustive match, for better
authorNiko Matsakis <niko@alum.mit.edu>
Tue, 11 Aug 2015 15:17:15 +0000 (11:17 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Wed, 12 Aug 2015 21:58:57 +0000 (17:58 -0400)
reliability.

src/librustc/middle/outlives.rs

index ec7dc5520ae3a395da3d6004decb5f41050789a1..b7fcc5469231145af5a1820fc8e4b03525ff4b27 100644 (file)
@@ -161,9 +161,28 @@ fn compute_components<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
                     compute_components(infcx, ty, out);
                 }
             }
-            _ => {
-                // for all other types, just constrain the regions and
-                // keep walking to find any other types.
+
+            // Most types do not introduce any region binders, nor
+            // involve any other subtle cases, and so the WF relation
+            // simply constraints any regions referenced directly by
+            // the type and then visits the types that are lexically
+            // contained within. (The comments refer to relevant rules
+            // from RFC1214.)
+            ty::TyBool(..) |        // OutlivesScalar
+            ty::TyChar(..) |        // OutlivesScalar
+            ty::TyInt(..) |         // OutlivesScalar
+            ty::TyUint(..) |        // OutlivesScalar
+            ty::TyFloat(..) |       // OutlivesScalar
+            ty::TyEnum(..) |        // OutlivesNominalType
+            ty::TyStruct(..) |      // OutlivesNominalType
+            ty::TyBox(..) |         // OutlivesNominalType (ish)
+            ty::TyStr(..) |         // OutlivesScalar (ish)
+            ty::TyArray(..) |       // ...
+            ty::TySlice(..) |       // ...
+            ty::TyRawPtr(..) |      // ...
+            ty::TyRef(..) |         // OutlivesReference
+            ty::TyTuple(..) |       // ...
+            ty::TyError(..) => {
                 push_region_constraints(out, ty.regions());
             }
         }
@@ -188,4 +207,3 @@ fn push_region_constraints<'tcx>(out: &mut Vec<Component<'tcx>>, regions: Vec<ty
         }
     }
 }
-