about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2018-06-16 11:30:31 +0100
committervarkor <github@varkor.com>2018-06-20 12:23:46 +0100
commit95ce05c586b8d8c97238ca4bedc5b06909bb7090 (patch)
tree037b1cd9b2ba11233c7f54ed16b573399a55173d
parent7a829273bf67999838cb14e6ff9ce6fd3a14a5e7 (diff)
downloadrust-95ce05c586b8d8c97238ca4bedc5b06909bb7090.tar.gz
rust-95ce05c586b8d8c97238ca4bedc5b06909bb7090.zip
Simplify some counting
-rw-r--r--src/librustc_typeck/astconv.rs29
-rw-r--r--src/librustc_typeck/check/mod.rs3
2 files changed, 13 insertions, 19 deletions
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs
index d0cd1cf61ff..f3912c3042d 100644
--- a/src/librustc_typeck/astconv.rs
+++ b/src/librustc_typeck/astconv.rs
@@ -213,14 +213,18 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
         // If the type is parameterized by this region, then replace this
         // region with the current anon region binding (in other words,
         // whatever & would get replaced with).
-        let mut lt_provided = 0;
-        let mut ty_provided = 0;
-        for arg in &generic_args.args {
-            match arg {
-                GenericArg::Lifetime(_) => lt_provided += 1,
-                GenericArg::Type(_) => ty_provided += 1,
-            }
-        }
+
+        // FIXME(varkor): Separating out the parameters is messy.
+        let lifetimes: Vec<_> = generic_args.args.iter().filter_map(|arg| match arg {
+            GenericArg::Lifetime(lt) => Some(lt),
+            _ => None,
+        }).collect();
+        let types: Vec<_> = generic_args.args.iter().filter_map(|arg| match arg {
+            GenericArg::Type(ty) => Some(ty),
+            _ => None,
+        }).collect();
+        let lt_provided = lifetimes.len();
+        let ty_provided = types.len();
 
         let decl_generics = tcx.generics_of(def_id);
         let mut lt_accepted = 0;
@@ -271,15 +275,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
         };
 
         let own_self = self_ty.is_some() as usize;
-        // FIXME(varkor): Separating out the parameters is messy.
-        let lifetimes: Vec<_> = generic_args.args.iter().filter_map(|arg| match arg {
-            GenericArg::Lifetime(lt) => Some(lt),
-            _ => None,
-        }).collect();
-        let types: Vec<_> = generic_args.args.iter().filter_map(|arg| match arg {
-            GenericArg::Type(ty) => Some(ty),
-            _ => None,
-        }).collect();
         let substs = Substs::for_item(tcx, def_id, |param, substs| {
             match param.kind {
                 GenericParamDefKind::Lifetime => {
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index 0a16cbeccd1..366420cfcab 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -4742,8 +4742,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
             Def::Fn(def_id) |
             Def::Const(def_id) |
             Def::Static(def_id, _) => {
-                fn_segment = Some((segments.last().unwrap(),
-                                   self.tcx.generics_of(def_id)));
+                fn_segment = Some((segments.last().unwrap(), self.tcx.generics_of(def_id)));
             }
 
             // Case 3. Reference to a method or associated const.