diff options
| author | bors <bors@rust-lang.org> | 2024-05-10 04:43:57 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-05-10 04:43:57 +0000 |
| commit | 98dabb622ad758f681ebbee1f4f797cd17de30c4 (patch) | |
| tree | badca58e1ef4a368374b795f95eee92ff67967fa /compiler/rustc_middle/src | |
| parent | a6e87c546dd806b2f8eb7bb314defc56dc190e4d (diff) | |
| parent | 1c19b6ad60d4993fb25c44ee8b6e625791084662 (diff) | |
Auto merge of #124953 - compiler-errors:own-params, r=lcnr
Rename `Generics::params` to `Generics::own_params` I hope this makes it slightly more obvious that `generics.own_params` is insufficient when considering nested items. I didn't actually audit any of the usages, for the record. r? lcnr
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/ty/context.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/generic_args.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/generics.rs | 24 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/predicate.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/print/mod.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/values.rs | 2 |
6 files changed, 20 insertions, 20 deletions
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 94b13269bfd..188a9f1c64c 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -2060,7 +2060,7 @@ impl<'tcx> TyCtxt<'tcx> { && let DefKind::AssocTy = self.def_kind(def_id) && let DefKind::Impl { of_trait: false } = self.def_kind(self.parent(def_id)) { - if generics.params.len() + 1 != args.len() { + if generics.own_params.len() + 1 != args.len() { return false; } @@ -2085,7 +2085,7 @@ impl<'tcx> TyCtxt<'tcx> { own_args }; - for (param, arg) in std::iter::zip(&generics.params, own_args) { + for (param, arg) in std::iter::zip(&generics.own_params, own_args) { match (¶m.kind, arg.unpack()) { (ty::GenericParamDefKind::Type { .. }, ty::GenericArgKind::Type(_)) | (ty::GenericParamDefKind::Lifetime, ty::GenericArgKind::Lifetime(_)) diff --git a/compiler/rustc_middle/src/ty/generic_args.rs b/compiler/rustc_middle/src/ty/generic_args.rs index de2c01c3046..4a613083ef7 100644 --- a/compiler/rustc_middle/src/ty/generic_args.rs +++ b/compiler/rustc_middle/src/ty/generic_args.rs @@ -359,8 +359,8 @@ impl<'tcx> GenericArgs<'tcx> { ) where F: FnMut(&ty::GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>, { - args.reserve(defs.params.len()); - for param in &defs.params { + args.reserve(defs.own_params.len()); + for param in &defs.own_params { let kind = mk_kind(param, args); assert_eq!(param.index as usize, args.len(), "{args:#?}, {defs:#?}"); args.push(kind); diff --git a/compiler/rustc_middle/src/ty/generics.rs b/compiler/rustc_middle/src/ty/generics.rs index 6bf2051d67c..f380aeaae0e 100644 --- a/compiler/rustc_middle/src/ty/generics.rs +++ b/compiler/rustc_middle/src/ty/generics.rs @@ -132,7 +132,7 @@ pub struct GenericParamCount { pub struct Generics { pub parent: Option<DefId>, pub parent_count: usize, - pub params: Vec<GenericParamDef>, + pub own_params: Vec<GenericParamDef>, /// Reverse map to the `index` field of each `GenericParamDef`. #[stable_hasher(ignore)] @@ -163,7 +163,7 @@ impl<'tcx> Generics { #[inline] pub fn count(&self) -> usize { - self.parent_count + self.params.len() + self.parent_count + self.own_params.len() } pub fn own_counts(&self) -> GenericParamCount { @@ -172,7 +172,7 @@ impl<'tcx> Generics { // presence of this method will be a constant reminder. let mut own_counts = GenericParamCount::default(); - for param in &self.params { + for param in &self.own_params { match param.kind { GenericParamDefKind::Lifetime => own_counts.lifetimes += 1, GenericParamDefKind::Type { .. } => own_counts.types += 1, @@ -186,7 +186,7 @@ impl<'tcx> Generics { pub fn own_defaults(&self) -> GenericParamCount { let mut own_defaults = GenericParamCount::default(); - for param in &self.params { + for param in &self.own_params { match param.kind { GenericParamDefKind::Lifetime => (), GenericParamDefKind::Type { has_default, .. } => { @@ -215,7 +215,7 @@ impl<'tcx> Generics { } pub fn own_requires_monomorphization(&self) -> bool { - for param in &self.params { + for param in &self.own_params { match param.kind { GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { is_host_effect: false, .. } => { @@ -231,7 +231,7 @@ impl<'tcx> Generics { /// Returns the `GenericParamDef` with the given index. pub fn param_at(&'tcx self, param_index: usize, tcx: TyCtxt<'tcx>) -> &'tcx GenericParamDef { if let Some(index) = param_index.checked_sub(self.parent_count) { - &self.params[index] + &self.own_params[index] } else { tcx.generics_of(self.parent.expect("parent_count > 0 but no parent?")) .param_at(param_index, tcx) @@ -245,7 +245,7 @@ impl<'tcx> Generics { tcx: TyCtxt<'tcx>, ) -> Option<&'tcx GenericParamDef> { if let Some(index) = param_index.checked_sub(self.parent_count) { - self.params.get(index) + self.own_params.get(index) } else { tcx.generics_of(self.parent.expect("parent_count > 0 but no parent?")) .opt_param_at(param_index, tcx) @@ -254,7 +254,7 @@ impl<'tcx> Generics { pub fn params_to(&'tcx self, param_index: usize, tcx: TyCtxt<'tcx>) -> &'tcx [GenericParamDef] { if let Some(index) = param_index.checked_sub(self.parent_count) { - &self.params[..index] + &self.own_params[..index] } else { tcx.generics_of(self.parent.expect("parent_count > 0 but no parent?")) .params_to(param_index, tcx) @@ -308,7 +308,7 @@ impl<'tcx> Generics { /// Returns `true` if `params` has `impl Trait`. pub fn has_impl_trait(&'tcx self) -> bool { - self.params.iter().any(|param| { + self.own_params.iter().any(|param| { matches!(param.kind, ty::GenericParamDefKind::Type { synthetic: true, .. }) }) } @@ -336,7 +336,7 @@ impl<'tcx> Generics { // good enough for now as this should only be used // for diagnostics anyways. own_params.end -= self - .params + .own_params .iter() .rev() .take_while(|param| { @@ -358,7 +358,7 @@ impl<'tcx> Generics { &'tcx self, args: &'tcx [ty::GenericArg<'tcx>], ) -> &'tcx [ty::GenericArg<'tcx>] { - let own = &args[self.parent_count..][..self.params.len()]; + let own = &args[self.parent_count..][..self.own_params.len()]; if self.has_self && self.parent.is_none() { &own[1..] } else { own } } @@ -372,7 +372,7 @@ impl<'tcx> Generics { args: &'tcx [ty::GenericArg<'tcx>], ) -> bool { let mut default_param_seen = false; - for param in self.params.iter() { + for param in self.own_params.iter() { if let Some(inst) = param.default_value(tcx).map(|default| default.instantiate(tcx, args)) { diff --git a/compiler/rustc_middle/src/ty/predicate.rs b/compiler/rustc_middle/src/ty/predicate.rs index 56dd52567fd..48d900ef0c9 100644 --- a/compiler/rustc_middle/src/ty/predicate.rs +++ b/compiler/rustc_middle/src/ty/predicate.rs @@ -250,7 +250,7 @@ impl<'tcx> PolyExistentialPredicate<'tcx> { } ExistentialPredicate::AutoTrait(did) => { let generics = tcx.generics_of(did); - let trait_ref = if generics.params.len() == 1 { + let trait_ref = if generics.own_params.len() == 1 { ty::TraitRef::new(tcx, did, [self_ty]) } else { // If this is an ill-formed auto trait, then synthesize @@ -373,7 +373,7 @@ impl<'tcx> TraitRef<'tcx> { args: GenericArgsRef<'tcx>, ) -> ty::TraitRef<'tcx> { let defs = tcx.generics_of(trait_id); - ty::TraitRef::new(tcx, trait_id, tcx.mk_args(&args[..defs.params.len()])) + ty::TraitRef::new(tcx, trait_id, tcx.mk_args(&args[..defs.own_params.len()])) } /// Returns a `TraitRef` of the form `P0: Foo<P1..Pn>` where `Pi` diff --git a/compiler/rustc_middle/src/ty/print/mod.rs b/compiler/rustc_middle/src/ty/print/mod.rs index 9d0e1123e43..eecd7dc6422 100644 --- a/compiler/rustc_middle/src/ty/print/mod.rs +++ b/compiler/rustc_middle/src/ty/print/mod.rs @@ -157,7 +157,7 @@ pub trait Printer<'tcx>: Sized { // If we have any generic arguments to print, we do that // on top of the same path, but without its own generics. _ => { - if !generics.params.is_empty() && args.len() >= generics.count() { + if !generics.own_params.is_empty() && args.len() >= generics.count() { let args = generics.own_args_no_defaults(self.tcx(), args); return self.path_generic_args( |cx| cx.print_def_path(def_id, parent_args), diff --git a/compiler/rustc_middle/src/values.rs b/compiler/rustc_middle/src/values.rs index 5c17c0b3088..e3866b27cee 100644 --- a/compiler/rustc_middle/src/values.rs +++ b/compiler/rustc_middle/src/values.rs @@ -141,7 +141,7 @@ impl<'tcx> Value<TyCtxt<'tcx>> for &[ty::Variance] { && frame.query.dep_kind == dep_kinds::variances_of && let Some(def_id) = frame.query.def_id { - let n = tcx.generics_of(def_id).params.len(); + let n = tcx.generics_of(def_id).own_params.len(); vec![ty::Variance::Bivariant; n].leak() } else { span_bug!( |
