Resolve #17344 by using .get(…) instead of […] in TypeOrConstParam::source(…)

(… and `LifetimeParam::source(…)`)
This commit is contained in:
Vincent Esche 2024-06-05 11:03:56 +02:00
parent 29e5cdfb05
commit 78f31696da

View file

@ -202,7 +202,7 @@ impl HasSource for TypeOrConstParam {
type Ast = Either<ast::TypeOrConstParam, ast::TraitOrAlias>;
fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
let child_source = self.id.parent.child_source(db.upcast());
Some(child_source.map(|it| it[self.id.local_id].clone()))
child_source.map(|it| it.get(self.id.local_id).cloned()).transpose()
}
}
@ -210,7 +210,7 @@ impl HasSource for LifetimeParam {
type Ast = ast::LifetimeParam;
fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
let child_source = self.id.parent.child_source(db.upcast());
Some(child_source.map(|it| it[self.id.local_id].clone()))
child_source.map(|it| it.get(self.id.local_id).cloned()).transpose()
}
}