Rename Generics::params to Generics::own_params
This commit is contained in:
parent
8c7c151a7a
commit
1c19b6ad60
54 changed files with 177 additions and 169 deletions
|
@ -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(_))
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -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`
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue