about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2018-08-02 18:09:14 +0100
committervarkor <github@varkor.com>2018-08-19 20:02:34 +0100
commit6a96cf12c1583978a1e07bcd26db152cb459e03c (patch)
treeecfd13376d66722e6055c1392df3a16982f68bfb
parente79bc410bf5f8d07121cc685d611ca72c21b28d0 (diff)
Clean match statement
-rw-r--r--src/librustc_typeck/astconv.rs58
1 files changed, 27 insertions, 31 deletions
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs
index 83c18265489..6b8844a7de3 100644
--- a/src/librustc_typeck/astconv.rs
+++ b/src/librustc_typeck/astconv.rs
@@ -274,39 +274,35 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
                 // input. We try to handle both sensibly.
                 'args: for arg in &generic_args.args {
                     while let Some(param) = next_param {
-                        match param.kind {
-                            GenericParamDefKind::Lifetime => match arg {
-                                GenericArg::Lifetime(_) => {
-                                    push_kind(&mut substs, provided_kind(param, arg));
-                                    next_param = params.next();
-                                    continue 'args;
-                                }
-                                GenericArg::Type(_) => {
-                                    // We expected a lifetime argument, but got a type
-                                    // argument. That means we're inferring the lifetimes.
-                                    push_kind(&mut substs, inferred_kind(None, param, infer_types));
-                                    next_param = params.next();
-                                }
+                        match (&param.kind, arg) {
+                            (GenericParamDefKind::Lifetime, GenericArg::Lifetime(_)) => {
+                                push_kind(&mut substs, provided_kind(param, arg));
+                                next_param = params.next();
+                                continue 'args;
                             }
-                            GenericParamDefKind::Type { .. } => match arg {
-                                GenericArg::Type(_) => {
-                                    push_kind(&mut substs, provided_kind(param, arg));
-                                    next_param = params.next();
-                                    continue 'args;
-                                }
-                                GenericArg::Lifetime(_) => {
-                                    // We expected a type argument, but got a lifetime
-                                    // argument. This is an error, but we need to handle it
-                                    // gracefully so we can report sensible errors. In this
-                                    // case, we're simply going to infer the remaining
-                                    // arguments.
-                                    if err_if_invalid {
-                                        tcx.sess.delay_span_bug(span,
-                                            "found a GenericArg::Lifetime where a \
-                                            GenericArg::Type was expected");
-                                    }
-                                    break 'args;
+                            (GenericParamDefKind::Lifetime, GenericArg::Type(_)) => {
+                                // We expected a lifetime argument, but got a type
+                                // argument. That means we're inferring the lifetimes.
+                                push_kind(&mut substs, inferred_kind(None, param, infer_types));
+                                next_param = params.next();
+                            }
+                            (GenericParamDefKind::Type { .. }, GenericArg::Type(_)) => {
+                                push_kind(&mut substs, provided_kind(param, arg));
+                                next_param = params.next();
+                                continue 'args;
+                            }
+                            (GenericParamDefKind::Type { .. }, GenericArg::Lifetime(_)) => {
+                                // We expected a type argument, but got a lifetime
+                                // argument. This is an error, but we need to handle it
+                                // gracefully so we can report sensible errors. In this
+                                // case, we're simply going to infer the remaining
+                                // arguments.
+                                if err_if_invalid {
+                                    tcx.sess.delay_span_bug(span,
+                                        "found a GenericArg::Lifetime where a \
+                                        GenericArg::Type was expected");
                                 }
+                                break 'args;
                             }
                         }
                     }