]> git.lizzy.rs Git - rust.git/commitdiff
Rename param_counts to own_counts
authorvarkor <github@varkor.com>
Thu, 10 May 2018 23:30:34 +0000 (00:30 +0100)
committervarkor <github@varkor.com>
Tue, 15 May 2018 13:21:32 +0000 (14:21 +0100)
src/librustc/hir/lowering.rs
src/librustc/traits/object_safety.rs
src/librustc/ty/mod.rs
src/librustc/util/ppaux.rs
src/librustc_mir/monomorphize/collector.rs
src/librustc_mir/transform/check_unsafety.rs
src/librustc_typeck/astconv.rs
src/librustc_typeck/check/compare_method.rs
src/librustc_typeck/check/intrinsic.rs
src/librustc_typeck/check/method/confirm.rs
src/librustc_typeck/check/mod.rs

index 628b871ed513515a83b3e2eab304a1062cf6386b..be9c5d2d334ae442d6bb78f8913316ef63f924bb 100644 (file)
@@ -1461,7 +1461,7 @@ fn lower_qpath(
                         assert!(!def_id.is_local());
                         let item_generics =
                             self.cstore.item_generics_cloned_untracked(def_id, self.sess);
-                        let n = item_generics.param_counts().lifetimes;
+                        let n = item_generics.own_counts().lifetimes;
                         self.type_def_lifetime_params.insert(def_id, n);
                         n
                     });
index 7c68d5522fcc39cb6e1cc6124ea0f2cde2c25d6f..6c67c10dc69cf490dd3120bb064e5cc90ea5def4 100644 (file)
@@ -284,7 +284,7 @@ fn virtual_call_violation_for_method(self,
         }
 
         // We can't monomorphize things like `fn foo<A>(...)`.
-        if self.generics_of(method.def_id).param_counts().types != 0 {
+        if self.generics_of(method.def_id).own_counts().types != 0 {
             return Some(MethodViolationCode::Generic);
         }
 
index aef8e7f5eea752e61e06f1c8441a057acecae70a..fc085cbd4f84455151ce75063cfbc926257d190a 100644 (file)
@@ -794,23 +794,23 @@ pub fn count(&self) -> usize {
         self.parent_count + self.params.len()
     }
 
-    pub fn param_counts(&self) -> GenericParamCount {
+    pub fn own_counts(&self) -> GenericParamCount {
         // We could cache this as a property of `GenericParamCount`, but
         // the aim is to refactor this away entirely eventually and the
         // presence of this method will be a constant reminder.
-        let mut param_counts = GenericParamCount {
+        let mut own_counts = GenericParamCount {
             lifetimes: 0,
             types: 0,
         };
 
         for param in self.params.iter() {
             match param.kind {
-                GenericParamDefKind::Lifetime => param_counts.lifetimes += 1,
-                GenericParamDefKind::Type(_) => param_counts.types += 1,
+                GenericParamDefKind::Lifetime => own_counts.lifetimes += 1,
+                GenericParamDefKind::Type(_) => own_counts.types += 1,
             };
         }
 
-        param_counts
+        own_counts
     }
 
     pub fn requires_monomorphization(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> bool {
index b3e840ae025ddc3d3dc13f4db15eac6988e7bf86..7044404e655b9a887678d02600d794f0f2de3709 100644 (file)
@@ -257,7 +257,7 @@ fn parameterized<F: fmt::Write>(&mut self,
         let verbose = self.is_verbose;
         let mut num_supplied_defaults = 0;
         let mut has_self = false;
-        let mut param_counts = GenericParamCount {
+        let mut own_counts = GenericParamCount {
             lifetimes: 0,
             types: 0,
         };
@@ -306,7 +306,7 @@ fn parameterized<F: fmt::Write>(&mut self,
                 }
             }
             let mut generics = tcx.generics_of(item_def_id);
-            let child_param_counts = generics.param_counts();
+            let child_own_counts = generics.own_counts();
             let mut path_def_id = did;
             has_self = generics.has_self;
 
@@ -314,9 +314,9 @@ fn parameterized<F: fmt::Write>(&mut self,
             if let Some(def_id) = generics.parent {
                 // Methods.
                 assert!(is_value_path);
-                child_types = child_param_counts.types;
+                child_types = child_own_counts.types;
                 generics = tcx.generics_of(def_id);
-                param_counts = generics.param_counts();
+                own_counts = generics.own_counts();
 
                 if has_self {
                     print!(f, self, write("<"), print_display(substs.type_at(0)), write(" as "))?;
@@ -331,7 +331,7 @@ fn parameterized<F: fmt::Write>(&mut self,
                     assert_eq!(has_self, false);
                 } else {
                     // Types and traits.
-                    param_counts = child_param_counts;
+                    own_counts = child_own_counts;
                 }
             }
 
@@ -415,10 +415,10 @@ fn parameterized<F: fmt::Write>(&mut self,
             Ok(())
         };
 
-        print_regions(f, "<", 0, param_counts.lifetimes)?;
+        print_regions(f, "<", 0, own_counts.lifetimes)?;
 
         let tps = substs.types()
-                        .take(param_counts.types - num_supplied_defaults)
+                        .take(own_counts.types - num_supplied_defaults)
                         .skip(has_self as usize);
 
         for ty in tps {
@@ -450,10 +450,10 @@ fn parameterized<F: fmt::Write>(&mut self,
                 write!(f, "::{}", item_name)?;
             }
 
-            print_regions(f, "::<", param_counts.lifetimes, usize::MAX)?;
+            print_regions(f, "::<", own_counts.lifetimes, usize::MAX)?;
 
             // FIXME: consider being smart with defaults here too
-            for ty in substs.types().skip(param_counts.types) {
+            for ty in substs.types().skip(own_counts.types) {
                 start_or_continue(f, "::<", ", ")?;
                 ty.print_display(f, self)?;
             }
index 92b4babe8a3b2e23632bfdb8ad0c5518892491a8..f8f6bec33a2ab26865e24e81062e38632edf0068 100644 (file)
@@ -1108,7 +1108,7 @@ fn create_mono_items_for_default_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                         continue;
                     }
 
-                    if tcx.generics_of(method.def_id).param_counts().types != 0 {
+                    if tcx.generics_of(method.def_id).own_counts().types != 0 {
                         continue;
                     }
 
index b65353e449f68aca4f112279b249e62834f56812..fc3764e4f49a5bbb8391ab4604b655c93340f9a5 100644 (file)
@@ -357,7 +357,7 @@ fn unsafe_derive_on_repr_packed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: D
 
     // FIXME: when we make this a hard error, this should have its
     // own error code.
-    let message = if tcx.generics_of(def_id).param_counts().types != 0 {
+    let message = if tcx.generics_of(def_id).own_counts().types != 0 {
         format!("#[derive] can't be used on a #[repr(packed)] struct with \
                  type parameters (error E0133)")
     } else {
index 6c64d1ae0213643a2579fa265d32727e572b6177..50d76d817905711b64ead6c592ff876a73578ba4 100644 (file)
@@ -208,9 +208,9 @@ fn create_substs_for_ast_path(&self,
         // region with the current anon region binding (in other words,
         // whatever & would get replaced with).
         let decl_generics = tcx.generics_of(def_id);
-        let param_counts = decl_generics.param_counts();
+        let own_counts = decl_generics.own_counts();
         let num_types_provided = parameters.types.len();
-        let expected_num_region_params = param_counts.lifetimes;
+        let expected_num_region_params = own_counts.lifetimes;
         let supplied_num_region_params = parameters.lifetimes.len();
         if expected_num_region_params != supplied_num_region_params {
             report_lifetime_number_error(tcx, span,
@@ -223,7 +223,7 @@ fn create_substs_for_ast_path(&self,
 
         // Check the number of type parameters supplied by the user.
         let own_self = self_ty.is_some() as usize;
-        let ty_param_defs = param_counts.types - own_self;
+        let ty_param_defs = own_counts.types - own_self;
         if !infer_types || num_types_provided > ty_param_defs {
             let type_params_without_defaults = {
                 let mut count = 0;
@@ -279,7 +279,7 @@ fn create_substs_for_ast_path(&self,
                 _ => unreachable!()
             };
 
-            let i = i - (param_counts.lifetimes + own_self);
+            let i = i - (own_counts.lifetimes + own_self);
             if i < num_types_provided {
                 // A provided type parameter.
                 self.ast_ty_to_ty(&parameters.types[i])
index 355440769cdf08d00cc21eaf54b6e8ed9fbf7d98..ba950f90d0a02db5fa5bef9c87761ed0a139c673 100644 (file)
@@ -357,8 +357,8 @@ fn check_region_bounds_on_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                                 trait_to_skol_substs: &Substs<'tcx>)
                                                 -> Result<(), ErrorReported> {
     let span = tcx.sess.codemap().def_span(span);
-    let trait_params = trait_generics.param_counts().lifetimes;
-    let impl_params = impl_generics.param_counts().lifetimes;
+    let trait_params = trait_generics.own_counts().lifetimes;
+    let impl_params = impl_generics.own_counts().lifetimes;
 
     debug!("check_region_bounds_on_impl_method: \
             trait_generics={:?} \
@@ -574,8 +574,8 @@ fn compare_number_of_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                         -> Result<(), ErrorReported> {
     let impl_m_generics = tcx.generics_of(impl_m.def_id);
     let trait_m_generics = tcx.generics_of(trait_m.def_id);
-    let num_impl_m_type_params = impl_m_generics.param_counts().types;
-    let num_trait_m_type_params = trait_m_generics.param_counts().types;
+    let num_impl_m_type_params = impl_m_generics.own_counts().types;
+    let num_trait_m_type_params = trait_m_generics.own_counts().types;
     if num_impl_m_type_params != num_trait_m_type_params {
         let impl_m_node_id = tcx.hir.as_local_node_id(impl_m.def_id).unwrap();
         let impl_m_item = tcx.hir.expect_impl_item(impl_m_node_id);
index d852a865174fbc0f62d57ce78dd30af4305c4596..97e4a35ea4762a449220ad77c9fbd8521d53031b 100644 (file)
@@ -45,7 +45,7 @@ fn equate_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
         }
     }
 
-    let i_n_tps = tcx.generics_of(def_id).param_counts().types;
+    let i_n_tps = tcx.generics_of(def_id).own_counts().types;
     if i_n_tps != n_tps {
         let span = match it.node {
             hir::ForeignItemFn(_, _, ref generics) => generics.span,
@@ -346,7 +346,7 @@ pub fn check_platform_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     };
 
     let def_id = tcx.hir.local_def_id(it.id);
-    let i_n_tps = tcx.generics_of(def_id).param_counts().types;
+    let i_n_tps = tcx.generics_of(def_id).own_counts().types;
     let name = it.name.as_str();
 
     let (n_tps, inputs, output) = match &*name {
index cfb844123170684f7e2f217a1dd801042ad33089..9928ef549ff70a686b92d311fcb3db5b6c618741 100644 (file)
@@ -316,7 +316,7 @@ fn instantiate_method_substs(&mut self,
         // parameters from the type and those from the method.
         assert_eq!(method_generics.parent_count, parent_substs.len());
         let provided = &segment.parameters;
-        let param_counts = method_generics.param_counts();
+        let own_counts = method_generics.own_counts();
         Substs::for_item(self.tcx, pick.item.def_id, |def, _| {
             let i = def.index as usize;
             if i < parent_substs.len() {
@@ -334,7 +334,7 @@ fn instantiate_method_substs(&mut self,
             } else if let Some(ast_ty)
                 = provided.as_ref().and_then(|p| {
                     let idx =
-                        i - parent_substs.len() - param_counts.lifetimes;
+                        i - parent_substs.len() - own_counts.lifetimes;
                     p.types.get(idx)
                 })
             {
index a6b072f3213d90663a18e678a7a0ebb2b6eb13a0..2ff760726d253ac990d3873d4e38f1baa69f23e1 100644 (file)
@@ -1239,7 +1239,7 @@ pub fn check_item_type<'a,'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Item
         } else {
             for item in &m.items {
                 let generics = tcx.generics_of(tcx.hir.local_def_id(item.id));
-                if generics.params.len() - generics.param_counts().lifetimes != 0 {
+                if generics.params.len() - generics.own_counts().lifetimes != 0 {
                     let mut err = struct_span_err!(tcx.sess, item.span, E0044,
                         "foreign items may not have type parameters");
                     err.span_label(item.span, "can't have type parameters");
@@ -4799,7 +4799,7 @@ pub fn instantiate_value_path(&self,
 
             // Skip over the lifetimes in the same segment.
             if let Some((_, generics)) = segment {
-                i -= generics.param_counts().lifetimes;
+                i -= generics.own_counts().lifetimes;
             }
 
             let has_default = match def.kind {
@@ -4925,10 +4925,10 @@ fn check_path_parameter_count(&self,
         // Check provided parameters.
         let (ty_req_len, accepted, lt_req_len) =
             segment.map_or((0, 0, 0), |(_, generics)| {
-                let param_counts = generics.param_counts();
+                let own_counts = generics.own_counts();
 
                 let own_self = (generics.parent.is_none() && generics.has_self) as usize;
-                let type_params = param_counts.types - own_self;
+                let type_params = own_counts.types - own_self;
                 let type_params_without_defaults = {
                     let mut count = 0;
                     for param in generics.params.iter() {
@@ -4943,7 +4943,7 @@ fn check_path_parameter_count(&self,
                 let type_params_barring_defaults =
                     type_params_without_defaults - own_self;
 
-                (type_params_barring_defaults, type_params, param_counts.lifetimes)
+                (type_params_barring_defaults, type_params, own_counts.lifetimes)
             });
 
         if types.len() > accepted {