remove unnecessary lifetimes that can be elided

This commit is contained in:
Daniel Eades 2022-12-30 09:00:42 +00:00
parent 8615bba105
commit 4f8ffd0ba4
11 changed files with 49 additions and 63 deletions

View file

@ -142,8 +142,8 @@ pub enum WherePredicateTypeTarget {
impl GenericParams { impl GenericParams {
/// Iterator of type_or_consts field /// Iterator of type_or_consts field
pub fn iter<'a>( pub fn iter(
&'a self, &self,
) -> impl DoubleEndedIterator<Item = (Idx<TypeOrConstParamData>, &TypeOrConstParamData)> { ) -> impl DoubleEndedIterator<Item = (Idx<TypeOrConstParamData>, &TypeOrConstParamData)> {
self.type_or_consts.iter() self.type_or_consts.iter()
} }

View file

@ -393,8 +393,8 @@ impl Query {
/// Searches dependencies of `krate` for an importable path matching `query`. /// Searches dependencies of `krate` for an importable path matching `query`.
/// ///
/// This returns a list of items that could be imported from dependencies of `krate`. /// This returns a list of items that could be imported from dependencies of `krate`.
pub fn search_dependencies<'a>( pub fn search_dependencies(
db: &'a dyn DefDatabase, db: &dyn DefDatabase,
krate: CrateId, krate: CrateId,
query: Query, query: Query,
) -> FxHashSet<ItemInNs> { ) -> FxHashSet<ItemInNs> {

View file

@ -96,7 +96,7 @@ pub(crate) enum BuiltinShadowMode {
/// Legacy macros can only be accessed through special methods like `get_legacy_macros`. /// Legacy macros can only be accessed through special methods like `get_legacy_macros`.
/// Other methods will only resolve values, types and module scoped macros only. /// Other methods will only resolve values, types and module scoped macros only.
impl ItemScope { impl ItemScope {
pub fn entries<'a>(&'a self) -> impl Iterator<Item = (&'a Name, PerNs)> + 'a { pub fn entries(&self) -> impl Iterator<Item = (&Name, PerNs)> + '_ {
// FIXME: shadowing // FIXME: shadowing
self.types self.types
.keys() .keys()
@ -169,7 +169,7 @@ impl ItemScope {
iter.find_map(|(name, &(other_def, vis))| (other_def == def).then_some((name, vis))) iter.find_map(|(name, &(other_def, vis))| (other_def == def).then_some((name, vis)))
} }
pub(crate) fn traits<'a>(&'a self) -> impl Iterator<Item = TraitId> + 'a { pub(crate) fn traits(&self) -> impl Iterator<Item = TraitId> + '_ {
self.types self.types
.values() .values()
.filter_map(|&(def, _)| match def { .filter_map(|&(def, _)| match def {
@ -326,7 +326,7 @@ impl ItemScope {
changed changed
} }
pub(crate) fn resolutions<'a>(&'a self) -> impl Iterator<Item = (Option<Name>, PerNs)> + 'a { pub(crate) fn resolutions(&self) -> impl Iterator<Item = (Option<Name>, PerNs)> + '_ {
self.entries().map(|(name, res)| (Some(name.clone()), res)).chain( self.entries().map(|(name, res)| (Some(name.clone()), res)).chain(
self.unnamed_trait_imports self.unnamed_trait_imports
.iter() .iter()

View file

@ -82,11 +82,11 @@ pub(crate) fn autoderef_step(
} }
// FIXME: replace uses of this with Autoderef above // FIXME: replace uses of this with Autoderef above
pub fn autoderef<'a>( pub fn autoderef(
db: &'a dyn HirDatabase, db: &dyn HirDatabase,
env: Arc<TraitEnvironment>, env: Arc<TraitEnvironment>,
ty: Canonical<Ty>, ty: Canonical<Ty>,
) -> impl Iterator<Item = Canonical<Ty>> + 'a { ) -> impl Iterator<Item = Canonical<Ty>> + '_ {
let mut table = InferenceTable::new(db, env); let mut table = InferenceTable::new(db, env);
let ty = table.instantiate_canonical(ty); let ty = table.instantiate_canonical(ty);
let mut autoderef = Autoderef::new(&mut table, ty); let mut autoderef = Autoderef::new(&mut table, ty);

View file

@ -511,10 +511,10 @@ pub(crate) fn const_eval_query_variant(
) )
} }
pub(crate) fn eval_to_const<'a>( pub(crate) fn eval_to_const(
expr: Idx<Expr>, expr: Idx<Expr>,
mode: ParamLoweringMode, mode: ParamLoweringMode,
ctx: &mut InferenceContext<'a>, ctx: &mut InferenceContext<'_>,
args: impl FnOnce() -> Generics, args: impl FnOnce() -> Generics,
debruijn: DebruijnIndex, debruijn: DebruijnIndex,
) -> Const { ) -> Const {

View file

@ -228,7 +228,7 @@ impl chalk_ir::interner::Interner for Interner {
Interned::new(InternedWrapper(chalk_ir::TyData { kind, flags })) Interned::new(InternedWrapper(chalk_ir::TyData { kind, flags }))
} }
fn ty_data<'a>(self, ty: &'a Self::InternedType) -> &'a chalk_ir::TyData<Self> { fn ty_data(self, ty: &Self::InternedType) -> &chalk_ir::TyData<Self> {
&ty.0 &ty.0
} }
@ -236,10 +236,7 @@ impl chalk_ir::interner::Interner for Interner {
Interned::new(InternedWrapper(lifetime)) Interned::new(InternedWrapper(lifetime))
} }
fn lifetime_data<'a>( fn lifetime_data(self, lifetime: &Self::InternedLifetime) -> &chalk_ir::LifetimeData<Self> {
self,
lifetime: &'a Self::InternedLifetime,
) -> &'a chalk_ir::LifetimeData<Self> {
&lifetime.0 &lifetime.0
} }
@ -247,7 +244,7 @@ impl chalk_ir::interner::Interner for Interner {
Interned::new(InternedWrapper(constant)) Interned::new(InternedWrapper(constant))
} }
fn const_data<'a>(self, constant: &'a Self::InternedConst) -> &'a chalk_ir::ConstData<Self> { fn const_data(self, constant: &Self::InternedConst) -> &chalk_ir::ConstData<Self> {
&constant.0 &constant.0
} }
@ -267,10 +264,10 @@ impl chalk_ir::interner::Interner for Interner {
parameter parameter
} }
fn generic_arg_data<'a>( fn generic_arg_data(
self, self,
parameter: &'a Self::InternedGenericArg, parameter: &Self::InternedGenericArg,
) -> &'a chalk_ir::GenericArgData<Self> { ) -> &chalk_ir::GenericArgData<Self> {
parameter parameter
} }
@ -285,11 +282,11 @@ impl chalk_ir::interner::Interner for Interner {
data.into_iter().collect() data.into_iter().collect()
} }
fn goal_data<'a>(self, goal: &'a Self::InternedGoal) -> &'a GoalData<Self> { fn goal_data(self, goal: &Self::InternedGoal) -> &GoalData<Self> {
goal goal
} }
fn goals_data<'a>(self, goals: &'a Self::InternedGoals) -> &'a [Goal<Interner>] { fn goals_data(self, goals: &Self::InternedGoals) -> &[Goal<Interner>] {
goals goals
} }
@ -300,10 +297,7 @@ impl chalk_ir::interner::Interner for Interner {
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?))) Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
} }
fn substitution_data<'a>( fn substitution_data(self, substitution: &Self::InternedSubstitution) -> &[GenericArg] {
self,
substitution: &'a Self::InternedSubstitution,
) -> &'a [GenericArg] {
&substitution.as_ref().0 &substitution.as_ref().0
} }
@ -314,10 +308,10 @@ impl chalk_ir::interner::Interner for Interner {
data data
} }
fn program_clause_data<'a>( fn program_clause_data(
self, self,
clause: &'a Self::InternedProgramClause, clause: &Self::InternedProgramClause,
) -> &'a chalk_ir::ProgramClauseData<Self> { ) -> &chalk_ir::ProgramClauseData<Self> {
clause clause
} }
@ -328,10 +322,10 @@ impl chalk_ir::interner::Interner for Interner {
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?))) Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
} }
fn program_clauses_data<'a>( fn program_clauses_data(
self, self,
clauses: &'a Self::InternedProgramClauses, clauses: &Self::InternedProgramClauses,
) -> &'a [chalk_ir::ProgramClause<Self>] { ) -> &[chalk_ir::ProgramClause<Self>] {
clauses clauses
} }
@ -342,10 +336,10 @@ impl chalk_ir::interner::Interner for Interner {
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?))) Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
} }
fn quantified_where_clauses_data<'a>( fn quantified_where_clauses_data(
self, self,
clauses: &'a Self::InternedQuantifiedWhereClauses, clauses: &Self::InternedQuantifiedWhereClauses,
) -> &'a [chalk_ir::QuantifiedWhereClause<Self>] { ) -> &[chalk_ir::QuantifiedWhereClause<Self>] {
clauses clauses
} }
@ -356,10 +350,10 @@ impl chalk_ir::interner::Interner for Interner {
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?))) Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
} }
fn variable_kinds_data<'a>( fn variable_kinds_data(
self, self,
parameter_kinds: &'a Self::InternedVariableKinds, parameter_kinds: &Self::InternedVariableKinds,
) -> &'a [chalk_ir::VariableKind<Self>] { ) -> &[chalk_ir::VariableKind<Self>] {
&parameter_kinds.as_ref().0 &parameter_kinds.as_ref().0
} }
@ -370,10 +364,10 @@ impl chalk_ir::interner::Interner for Interner {
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?))) Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
} }
fn canonical_var_kinds_data<'a>( fn canonical_var_kinds_data(
self, self,
canonical_var_kinds: &'a Self::InternedCanonicalVarKinds, canonical_var_kinds: &Self::InternedCanonicalVarKinds,
) -> &'a [chalk_ir::CanonicalVarKind<Self>] { ) -> &[chalk_ir::CanonicalVarKind<Self>] {
canonical_var_kinds canonical_var_kinds
} }
@ -384,10 +378,10 @@ impl chalk_ir::interner::Interner for Interner {
data.into_iter().collect() data.into_iter().collect()
} }
fn constraints_data<'a>( fn constraints_data(
self, self,
constraints: &'a Self::InternedConstraints, constraints: &Self::InternedConstraints,
) -> &'a [chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>] { ) -> &[chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>] {
constraints constraints
} }
fn debug_closure_id( fn debug_closure_id(
@ -410,10 +404,7 @@ impl chalk_ir::interner::Interner for Interner {
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?))) Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
} }
fn variances_data<'a>( fn variances_data(self, variances: &Self::InternedVariances) -> &[chalk_ir::Variance] {
self,
variances: &'a Self::InternedVariances,
) -> &'a [chalk_ir::Variance] {
variances variances
} }
} }

View file

@ -55,10 +55,7 @@ impl TraitEnvironment {
} }
} }
pub fn traits_in_scope_from_clauses<'a>( pub fn traits_in_scope_from_clauses(&self, ty: Ty) -> impl Iterator<Item = TraitId> + '_ {
&'a self,
ty: Ty,
) -> impl Iterator<Item = TraitId> + 'a {
self.traits_from_clauses self.traits_from_clauses
.iter() .iter()
.filter_map(move |(self_ty, trait_id)| (*self_ty == ty).then_some(*trait_id)) .filter_map(move |(self_ty, trait_id)| (*self_ty == ty).then_some(*trait_id))

View file

@ -184,9 +184,7 @@ pub(crate) struct Generics {
} }
impl Generics { impl Generics {
pub(crate) fn iter_id<'a>( pub(crate) fn iter_id(&self) -> impl Iterator<Item = Either<TypeParamId, ConstParamId>> + '_ {
&'a self,
) -> impl Iterator<Item = Either<TypeParamId, ConstParamId>> + 'a {
self.iter().map(|(id, data)| match data { self.iter().map(|(id, data)| match data {
TypeOrConstParamData::TypeParamData(_) => Either::Left(TypeParamId::from_unchecked(id)), TypeOrConstParamData::TypeParamData(_) => Either::Left(TypeParamId::from_unchecked(id)),
TypeOrConstParamData::ConstParamData(_) => { TypeOrConstParamData::ConstParamData(_) => {
@ -216,9 +214,9 @@ impl Generics {
} }
/// Iterator over types and const params of parent. /// Iterator over types and const params of parent.
pub(crate) fn iter_parent<'a>( pub(crate) fn iter_parent(
&'a self, &self,
) -> impl DoubleEndedIterator<Item = (TypeOrConstParamId, &'a TypeOrConstParamData)> + 'a { ) -> impl DoubleEndedIterator<Item = (TypeOrConstParamId, &TypeOrConstParamData)> {
self.parent_generics().into_iter().flat_map(|it| { self.parent_generics().into_iter().flat_map(|it| {
let to_toc_id = let to_toc_id =
move |(local_id, p)| (TypeOrConstParamId { parent: it.def, local_id }, p); move |(local_id, p)| (TypeOrConstParamId { parent: it.def, local_id }, p);

View file

@ -285,7 +285,7 @@ impl DocCommentToken {
} }
} }
fn broken_link_clone_cb<'a>(link: BrokenLink<'a>) -> Option<(CowStr<'a>, CowStr<'a>)> { fn broken_link_clone_cb(link: BrokenLink<'_>) -> Option<(CowStr<'_>, CowStr<'_>)> {
Some((/*url*/ link.reference.clone(), /*title*/ link.reference)) Some((/*url*/ link.reference.clone(), /*title*/ link.reference))
} }

View file

@ -116,9 +116,9 @@ enum Mode {
Template, Template,
} }
fn next_op<'a>( fn next_op(
first_peeked: &tt::TokenTree, first_peeked: &tt::TokenTree,
src: &mut TtIter<'a>, src: &mut TtIter<'_>,
mode: Mode, mode: Mode,
) -> Result<Op, ParseError> { ) -> Result<Op, ParseError> {
let res = match first_peeked { let res = match first_peeked {

View file

@ -411,7 +411,7 @@ impl CargoWorkspace {
CargoWorkspace { packages, targets, workspace_root } CargoWorkspace { packages, targets, workspace_root }
} }
pub fn packages<'a>(&'a self) -> impl Iterator<Item = Package> + ExactSizeIterator + 'a { pub fn packages(&self) -> impl Iterator<Item = Package> + ExactSizeIterator + '_ {
self.packages.iter().map(|(id, _pkg)| id) self.packages.iter().map(|(id, _pkg)| id)
} }