Skip to content

Commit 6e7eecc

Browse files
committed
Auto merge of rust-lang#17348 - regexident:fix-type-or-const-param-source, r=Veykril
Use `.get(…)` instead of `[…]` in `TypeOrConstParam::source(…)` and `LifetimeParam::source(…)` Resolves rust-lang#17344.
2 parents 02c178b + bd5f276 commit 6e7eecc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/tools/rust-analyzer/crates/hir/src/has_source.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,15 @@ impl HasSource for TypeOrConstParam {
202202
type Ast = Either<ast::TypeOrConstParam, ast::TraitOrAlias>;
203203
fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
204204
let child_source = self.id.parent.child_source(db.upcast());
205-
Some(child_source.map(|it| it[self.id.local_id].clone()))
205+
child_source.map(|it| it.get(self.id.local_id).cloned()).transpose()
206206
}
207207
}
208208

209209
impl HasSource for LifetimeParam {
210210
type Ast = ast::LifetimeParam;
211211
fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
212212
let child_source = self.id.parent.child_source(db.upcast());
213-
Some(child_source.map(|it| it[self.id.local_id].clone()))
213+
child_source.map(|it| it.get(self.id.local_id).cloned()).transpose()
214214
}
215215
}
216216

0 commit comments

Comments
 (0)