Skip to content

Commit fd8e284

Browse files
committed
Rename param_counts to own_counts
1 parent 365c8c3 commit fd8e284

File tree

11 files changed

+35
-35
lines changed

11 files changed

+35
-35
lines changed

src/librustc/hir/lowering.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,7 @@ impl<'a> LoweringContext<'a> {
14611461
assert!(!def_id.is_local());
14621462
let item_generics =
14631463
self.cstore.item_generics_cloned_untracked(def_id, self.sess);
1464-
let n = item_generics.param_counts().lifetimes;
1464+
let n = item_generics.own_counts().lifetimes;
14651465
self.type_def_lifetime_params.insert(def_id, n);
14661466
n
14671467
});

src/librustc/traits/object_safety.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
284284
}
285285

286286
// We can't monomorphize things like `fn foo<A>(...)`.
287-
if self.generics_of(method.def_id).param_counts().types != 0 {
287+
if self.generics_of(method.def_id).own_counts().types != 0 {
288288
return Some(MethodViolationCode::Generic);
289289
}
290290

src/librustc/ty/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -794,23 +794,23 @@ impl<'a, 'gcx, 'tcx> Generics {
794794
self.parent_count + self.params.len()
795795
}
796796

797-
pub fn param_counts(&self) -> GenericParamCount {
797+
pub fn own_counts(&self) -> GenericParamCount {
798798
// We could cache this as a property of `GenericParamCount`, but
799799
// the aim is to refactor this away entirely eventually and the
800800
// presence of this method will be a constant reminder.
801-
let mut param_counts = GenericParamCount {
801+
let mut own_counts = GenericParamCount {
802802
lifetimes: 0,
803803
types: 0,
804804
};
805805

806806
for param in self.params.iter() {
807807
match param.kind {
808-
GenericParamDefKind::Lifetime => param_counts.lifetimes += 1,
809-
GenericParamDefKind::Type(_) => param_counts.types += 1,
808+
GenericParamDefKind::Lifetime => own_counts.lifetimes += 1,
809+
GenericParamDefKind::Type(_) => own_counts.types += 1,
810810
};
811811
}
812812

813-
param_counts
813+
own_counts
814814
}
815815

816816
pub fn requires_monomorphization(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> bool {

src/librustc/util/ppaux.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ impl PrintContext {
257257
let verbose = self.is_verbose;
258258
let mut num_supplied_defaults = 0;
259259
let mut has_self = false;
260-
let mut param_counts = GenericParamCount {
260+
let mut own_counts = GenericParamCount {
261261
lifetimes: 0,
262262
types: 0,
263263
};
@@ -306,17 +306,17 @@ impl PrintContext {
306306
}
307307
}
308308
let mut generics = tcx.generics_of(item_def_id);
309-
let child_param_counts = generics.param_counts();
309+
let child_own_counts = generics.own_counts();
310310
let mut path_def_id = did;
311311
has_self = generics.has_self;
312312

313313
let mut child_types = 0;
314314
if let Some(def_id) = generics.parent {
315315
// Methods.
316316
assert!(is_value_path);
317-
child_types = child_param_counts.types;
317+
child_types = child_own_counts.types;
318318
generics = tcx.generics_of(def_id);
319-
param_counts = generics.param_counts();
319+
own_counts = generics.own_counts();
320320

321321
if has_self {
322322
print!(f, self, write("<"), print_display(substs.type_at(0)), write(" as "))?;
@@ -331,7 +331,7 @@ impl PrintContext {
331331
assert_eq!(has_self, false);
332332
} else {
333333
// Types and traits.
334-
param_counts = child_param_counts;
334+
own_counts = child_own_counts;
335335
}
336336
}
337337

@@ -415,10 +415,10 @@ impl PrintContext {
415415
Ok(())
416416
};
417417

418-
print_regions(f, "<", 0, param_counts.lifetimes)?;
418+
print_regions(f, "<", 0, own_counts.lifetimes)?;
419419

420420
let tps = substs.types()
421-
.take(param_counts.types - num_supplied_defaults)
421+
.take(own_counts.types - num_supplied_defaults)
422422
.skip(has_self as usize);
423423

424424
for ty in tps {
@@ -450,10 +450,10 @@ impl PrintContext {
450450
write!(f, "::{}", item_name)?;
451451
}
452452

453-
print_regions(f, "::<", param_counts.lifetimes, usize::MAX)?;
453+
print_regions(f, "::<", own_counts.lifetimes, usize::MAX)?;
454454

455455
// FIXME: consider being smart with defaults here too
456-
for ty in substs.types().skip(param_counts.types) {
456+
for ty in substs.types().skip(own_counts.types) {
457457
start_or_continue(f, "::<", ", ")?;
458458
ty.print_display(f, self)?;
459459
}

src/librustc_mir/monomorphize/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ fn create_mono_items_for_default_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
11081108
continue;
11091109
}
11101110

1111-
if tcx.generics_of(method.def_id).param_counts().types != 0 {
1111+
if tcx.generics_of(method.def_id).own_counts().types != 0 {
11121112
continue;
11131113
}
11141114

src/librustc_mir/transform/check_unsafety.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ fn unsafe_derive_on_repr_packed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: D
357357

358358
// FIXME: when we make this a hard error, this should have its
359359
// own error code.
360-
let message = if tcx.generics_of(def_id).param_counts().types != 0 {
360+
let message = if tcx.generics_of(def_id).own_counts().types != 0 {
361361
format!("#[derive] can't be used on a #[repr(packed)] struct with \
362362
type parameters (error E0133)")
363363
} else {

src/librustc_typeck/astconv.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,9 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
208208
// region with the current anon region binding (in other words,
209209
// whatever & would get replaced with).
210210
let decl_generics = tcx.generics_of(def_id);
211-
let param_counts = decl_generics.param_counts();
211+
let own_counts = decl_generics.own_counts();
212212
let num_types_provided = parameters.types.len();
213-
let expected_num_region_params = param_counts.lifetimes;
213+
let expected_num_region_params = own_counts.lifetimes;
214214
let supplied_num_region_params = parameters.lifetimes.len();
215215
if expected_num_region_params != supplied_num_region_params {
216216
report_lifetime_number_error(tcx, span,
@@ -223,7 +223,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
223223

224224
// Check the number of type parameters supplied by the user.
225225
let own_self = self_ty.is_some() as usize;
226-
let ty_param_defs = param_counts.types - own_self;
226+
let ty_param_defs = own_counts.types - own_self;
227227
if !infer_types || num_types_provided > ty_param_defs {
228228
let type_params_without_defaults = {
229229
let mut count = 0;
@@ -279,7 +279,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
279279
_ => unreachable!()
280280
};
281281

282-
let i = i - (param_counts.lifetimes + own_self);
282+
let i = i - (own_counts.lifetimes + own_self);
283283
if i < num_types_provided {
284284
// A provided type parameter.
285285
self.ast_ty_to_ty(&parameters.types[i])

src/librustc_typeck/check/compare_method.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ fn check_region_bounds_on_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
357357
trait_to_skol_substs: &Substs<'tcx>)
358358
-> Result<(), ErrorReported> {
359359
let span = tcx.sess.codemap().def_span(span);
360-
let trait_params = trait_generics.param_counts().lifetimes;
361-
let impl_params = impl_generics.param_counts().lifetimes;
360+
let trait_params = trait_generics.own_counts().lifetimes;
361+
let impl_params = impl_generics.own_counts().lifetimes;
362362

363363
debug!("check_region_bounds_on_impl_method: \
364364
trait_generics={:?} \
@@ -574,8 +574,8 @@ fn compare_number_of_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
574574
-> Result<(), ErrorReported> {
575575
let impl_m_generics = tcx.generics_of(impl_m.def_id);
576576
let trait_m_generics = tcx.generics_of(trait_m.def_id);
577-
let num_impl_m_type_params = impl_m_generics.param_counts().types;
578-
let num_trait_m_type_params = trait_m_generics.param_counts().types;
577+
let num_impl_m_type_params = impl_m_generics.own_counts().types;
578+
let num_trait_m_type_params = trait_m_generics.own_counts().types;
579579
if num_impl_m_type_params != num_trait_m_type_params {
580580
let impl_m_node_id = tcx.hir.as_local_node_id(impl_m.def_id).unwrap();
581581
let impl_m_item = tcx.hir.expect_impl_item(impl_m_node_id);

src/librustc_typeck/check/intrinsic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn equate_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
4545
}
4646
}
4747

48-
let i_n_tps = tcx.generics_of(def_id).param_counts().types;
48+
let i_n_tps = tcx.generics_of(def_id).own_counts().types;
4949
if i_n_tps != n_tps {
5050
let span = match it.node {
5151
hir::ForeignItemFn(_, _, ref generics) => generics.span,
@@ -346,7 +346,7 @@ pub fn check_platform_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
346346
};
347347

348348
let def_id = tcx.hir.local_def_id(it.id);
349-
let i_n_tps = tcx.generics_of(def_id).param_counts().types;
349+
let i_n_tps = tcx.generics_of(def_id).own_counts().types;
350350
let name = it.name.as_str();
351351

352352
let (n_tps, inputs, output) = match &*name {

src/librustc_typeck/check/method/confirm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
316316
// parameters from the type and those from the method.
317317
assert_eq!(method_generics.parent_count, parent_substs.len());
318318
let provided = &segment.parameters;
319-
let param_counts = method_generics.param_counts();
319+
let own_counts = method_generics.own_counts();
320320
Substs::for_item(self.tcx, pick.item.def_id, |def, _| {
321321
let i = def.index as usize;
322322
if i < parent_substs.len() {
@@ -334,7 +334,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
334334
} else if let Some(ast_ty)
335335
= provided.as_ref().and_then(|p| {
336336
let idx =
337-
i - parent_substs.len() - param_counts.lifetimes;
337+
i - parent_substs.len() - own_counts.lifetimes;
338338
p.types.get(idx)
339339
})
340340
{

0 commit comments

Comments
 (0)