Skip to content

Commit

Permalink
Auto merge of rust-lang#17348 - regexident:fix-type-or-const-param-so…
Browse files Browse the repository at this point in the history
…urce, r=Veykril

Use `.get(…)` instead of `[…]` in `TypeOrConstParam::source(…)` and `LifetimeParam::source(…)`

Resolves rust-lang#17344.
  • Loading branch information
bors committed Jun 5, 2024
2 parents 52e8065 + 78f3169 commit 48bbdd6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/hir/src/has_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,15 @@ 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()
}
}

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()
}
}

Expand Down

0 comments on commit 48bbdd6

Please sign in to comment.