Skip to content

Commit 95ce05c

Browse files
committed
Simplify some counting
1 parent 7a82927 commit 95ce05c

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

src/librustc_typeck/astconv.rs

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,18 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
213213
// If the type is parameterized by this region, then replace this
214214
// region with the current anon region binding (in other words,
215215
// whatever & would get replaced with).
216-
let mut lt_provided = 0;
217-
let mut ty_provided = 0;
218-
for arg in &generic_args.args {
219-
match arg {
220-
GenericArg::Lifetime(_) => lt_provided += 1,
221-
GenericArg::Type(_) => ty_provided += 1,
222-
}
223-
}
216+
217+
// FIXME(varkor): Separating out the parameters is messy.
218+
let lifetimes: Vec<_> = generic_args.args.iter().filter_map(|arg| match arg {
219+
GenericArg::Lifetime(lt) => Some(lt),
220+
_ => None,
221+
}).collect();
222+
let types: Vec<_> = generic_args.args.iter().filter_map(|arg| match arg {
223+
GenericArg::Type(ty) => Some(ty),
224+
_ => None,
225+
}).collect();
226+
let lt_provided = lifetimes.len();
227+
let ty_provided = types.len();
224228

225229
let decl_generics = tcx.generics_of(def_id);
226230
let mut lt_accepted = 0;
@@ -271,15 +275,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
271275
};
272276

273277
let own_self = self_ty.is_some() as usize;
274-
// FIXME(varkor): Separating out the parameters is messy.
275-
let lifetimes: Vec<_> = generic_args.args.iter().filter_map(|arg| match arg {
276-
GenericArg::Lifetime(lt) => Some(lt),
277-
_ => None,
278-
}).collect();
279-
let types: Vec<_> = generic_args.args.iter().filter_map(|arg| match arg {
280-
GenericArg::Type(ty) => Some(ty),
281-
_ => None,
282-
}).collect();
283278
let substs = Substs::for_item(tcx, def_id, |param, substs| {
284279
match param.kind {
285280
GenericParamDefKind::Lifetime => {

src/librustc_typeck/check/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4742,8 +4742,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
47424742
Def::Fn(def_id) |
47434743
Def::Const(def_id) |
47444744
Def::Static(def_id, _) => {
4745-
fn_segment = Some((segments.last().unwrap(),
4746-
self.tcx.generics_of(def_id)));
4745+
fn_segment = Some((segments.last().unwrap(), self.tcx.generics_of(def_id)));
47474746
}
47484747

47494748
// Case 3. Reference to a method or associated const.

0 commit comments

Comments
 (0)