Unnamed repository; edit this file 'description' to name the repository.
Auto merge of #17348 - regexident:fix-type-or-const-param-source, r=Veykril
Use `.get(…)` instead of `[…]` in `TypeOrConstParam::source(…)` and `LifetimeParam::source(…)` Resolves #17344.
bors 2024-06-05
parent 52e8065 · parent 78f3169 · commit 48bbdd6
-rw-r--r--crates/hir/src/has_source.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/crates/hir/src/has_source.rs b/crates/hir/src/has_source.rs
index 7cdcdd76d1..308e8a31ca 100644
--- a/crates/hir/src/has_source.rs
+++ b/crates/hir/src/has_source.rs
@@ -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()
}
}