mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-13 00:17:15 +00:00
Make GenericParams::lifetimes private
This commit is contained in:
parent
be1ea4028b
commit
966798b7ba
8 changed files with 12 additions and 14 deletions
|
@ -215,7 +215,7 @@ impl ChildBySource for GenericDefId {
|
|||
|
||||
let generic_params = db.generic_params(*self);
|
||||
let mut toc_idx_iter = generic_params.iter_type_or_consts().map(|(idx, _)| idx);
|
||||
let lts_idx_iter = generic_params.lifetimes.iter().map(|(idx, _)| idx);
|
||||
let lts_idx_iter = generic_params.iter_lt().map(|(idx, _)| idx);
|
||||
|
||||
// For traits the first type index is `Self`, skip it.
|
||||
if let GenericDefId::TraitId(_) = *self {
|
||||
|
|
|
@ -160,7 +160,7 @@ pub enum GenericParamDataRef<'a> {
|
|||
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
|
||||
pub struct GenericParams {
|
||||
type_or_consts: Arena<TypeOrConstParamData>,
|
||||
pub lifetimes: Arena<LifetimeParamData>,
|
||||
lifetimes: Arena<LifetimeParamData>,
|
||||
where_predicates: Box<[WherePredicate]>,
|
||||
}
|
||||
|
||||
|
|
|
@ -532,7 +532,7 @@ impl Printer<'_> {
|
|||
|
||||
w!(self, "<");
|
||||
let mut first = true;
|
||||
for (idx, lt) in params.lifetimes.iter() {
|
||||
for (idx, lt) in params.iter_lt() {
|
||||
if !first {
|
||||
w!(self, ", ");
|
||||
}
|
||||
|
|
|
@ -775,7 +775,7 @@ impl Scope {
|
|||
);
|
||||
}
|
||||
}
|
||||
for (local_id, param) in params.lifetimes.iter() {
|
||||
for (local_id, param) in params.iter_lt() {
|
||||
let id = LifetimeParamId { parent, local_id };
|
||||
acc.add(¶m.name, ScopeDef::GenericParam(id.into()))
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ impl HasChildSource<LocalLifetimeParamId> for GenericDefId {
|
|||
db: &dyn DefDatabase,
|
||||
) -> InFile<ArenaMap<LocalLifetimeParamId, Self::Value>> {
|
||||
let generic_params = db.generic_params(*self);
|
||||
let idx_iter = generic_params.lifetimes.iter().map(|(idx, _)| idx);
|
||||
let idx_iter = generic_params.iter_lt().map(|(idx, _)| idx);
|
||||
|
||||
let (file_id, generic_params_list) = self.file_id_and_params_of(db);
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ impl Generics {
|
|||
fn find_lifetime(&self, lifetime: LifetimeParamId) -> Option<usize> {
|
||||
if lifetime.parent == self.def {
|
||||
let idx = lifetime.local_id.into_raw().into_u32() as usize;
|
||||
debug_assert!(idx <= self.params.lifetimes.len());
|
||||
debug_assert!(idx <= self.params.len_lifetimes());
|
||||
Some(self.params.len_type_or_consts() + idx)
|
||||
} else {
|
||||
debug_assert_eq!(self.parent_generics().map(|it| it.def), Some(lifetime.parent));
|
||||
|
|
|
@ -539,7 +539,7 @@ fn write_generic_params(
|
|||
f: &mut HirFormatter<'_>,
|
||||
) -> Result<(), HirDisplayError> {
|
||||
let params = f.db.generic_params(def);
|
||||
if params.lifetimes.is_empty()
|
||||
if params.iter_lt().next().is_none()
|
||||
&& params.iter_type_or_consts().all(|it| it.1.const_param().is_none())
|
||||
&& params
|
||||
.iter_type_or_consts()
|
||||
|
@ -559,7 +559,7 @@ fn write_generic_params(
|
|||
f.write_str(", ")
|
||||
}
|
||||
};
|
||||
for (_, lifetime) in params.lifetimes.iter() {
|
||||
for (_, lifetime) in params.iter_lt() {
|
||||
delim(f)?;
|
||||
write!(f, "{}", lifetime.name.display(f.db.upcast()))?;
|
||||
}
|
||||
|
|
|
@ -665,7 +665,7 @@ impl Module {
|
|||
}
|
||||
let parent = impl_def.id.into();
|
||||
let generic_params = db.generic_params(parent);
|
||||
let lifetime_params = generic_params.lifetimes.iter().map(|(local_id, _)| {
|
||||
let lifetime_params = generic_params.iter_lt().map(|(local_id, _)| {
|
||||
GenericParamId::LifetimeParamId(LifetimeParamId { parent, local_id })
|
||||
});
|
||||
let type_params = generic_params
|
||||
|
@ -1540,8 +1540,7 @@ impl Adt {
|
|||
resolver
|
||||
.generic_params()
|
||||
.and_then(|gp| {
|
||||
gp.lifetimes
|
||||
.iter()
|
||||
gp.iter_lt()
|
||||
// there should only be a single lifetime
|
||||
// but `Arena` requires to use an iterator
|
||||
.nth(0)
|
||||
|
@ -3141,8 +3140,7 @@ impl GenericDef {
|
|||
pub fn lifetime_params(self, db: &dyn HirDatabase) -> Vec<LifetimeParam> {
|
||||
let generics = db.generic_params(self.into());
|
||||
generics
|
||||
.lifetimes
|
||||
.iter()
|
||||
.iter_lt()
|
||||
.map(|(local_id, _)| LifetimeParam {
|
||||
id: LifetimeParamId { parent: self.into(), local_id },
|
||||
})
|
||||
|
@ -3548,7 +3546,7 @@ pub struct LifetimeParam {
|
|||
impl LifetimeParam {
|
||||
pub fn name(self, db: &dyn HirDatabase) -> Name {
|
||||
let params = db.generic_params(self.id.parent);
|
||||
params.lifetimes[self.id.local_id].name.clone()
|
||||
params[self.id.local_id].name.clone()
|
||||
}
|
||||
|
||||
pub fn module(self, db: &dyn HirDatabase) -> Module {
|
||||
|
|
Loading…
Reference in a new issue