about summary refs log tree commit diff
diff options
context:
space:
mode:
authorljedrz <ljedrz@gmail.com>2018-12-19 16:39:01 +0100
committerljedrz <ljedrz@gmail.com>2018-12-19 16:39:01 +0100
commit818ed6935dc10f450f5c230b19465b1a323b07ea (patch)
treecd17facc75a2b7a61fe7ccbf6150428b9d971ed8
parente7b4bc35e99ee3c5b2b42a1b8b3f9cd6eca1f0b2 (diff)
downloadrust-818ed6935dc10f450f5c230b19465b1a323b07ea.tar.gz
rust-818ed6935dc10f450f5c230b19465b1a323b07ea.zip
dropck: simplify common patterns
-rw-r--r--src/librustc/traits/query/dropck_outlives.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/librustc/traits/query/dropck_outlives.rs b/src/librustc/traits/query/dropck_outlives.rs
index b8bf0fcc153..b993dd6080b 100644
--- a/src/librustc/traits/query/dropck_outlives.rs
+++ b/src/librustc/traits/query/dropck_outlives.rs
@@ -55,8 +55,8 @@ impl<'cx, 'gcx, 'tcx> At<'cx, 'gcx, 'tcx> {
         let c_ty = self.infcx.canonicalize_query(&self.param_env.and(ty), &mut orig_values);
         let span = self.cause.span;
         debug!("c_ty = {:?}", c_ty);
-        match &gcx.dropck_outlives(c_ty) {
-            Ok(result) if result.is_proven() => {
+        if let Ok(result) = &gcx.dropck_outlives(c_ty) {
+            if result.is_proven() {
                 if let Ok(InferOk { value, obligations }) =
                     self.infcx.instantiate_query_response_and_region_obligations(
                     self.cause,
@@ -72,8 +72,6 @@ impl<'cx, 'gcx, 'tcx> At<'cx, 'gcx, 'tcx> {
                     };
                 }
             }
-
-            _ => { /* fallthrough to error-handling code below */ }
         }
 
         // Errors and ambiuity in dropck occur in two cases:
@@ -82,10 +80,11 @@ impl<'cx, 'gcx, 'tcx> At<'cx, 'gcx, 'tcx> {
         // Either of these should have created an error before.
         tcx.sess
             .delay_span_bug(span, "dtorck encountered internal error");
-        return InferOk {
+
+        InferOk {
             value: vec![],
             obligations: vec![],
-        };
+        }
     }
 }
 
@@ -102,7 +101,7 @@ impl<'tcx> DropckOutlivesResult<'tcx> {
         span: Span,
         ty: Ty<'tcx>,
     ) {
-        for overflow_ty in self.overflows.iter().take(1) {
+        if let Some(overflow_ty) = self.overflows.iter().next() {
             let mut err = struct_span_err!(
                 tcx.sess,
                 span,