diff options
| author | bors <bors@rust-lang.org> | 2024-06-05 10:34:31 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-06-05 10:34:31 +0000 |
| commit | 6e7eecc4236d1dbb7a7798edbd5e278bc86f7b91 (patch) | |
| tree | 382dd133bb38e675bdfaf09d76d7161af822f949 /src | |
| parent | 02c178b780d1dbfd496c9bf828d139a1671ce79b (diff) | |
| parent | bd5f27605abb6ba987aaba432467b78e4468436a (diff) | |
| download | rust-6e7eecc4236d1dbb7a7798edbd5e278bc86f7b91.tar.gz rust-6e7eecc4236d1dbb7a7798edbd5e278bc86f7b91.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/rust-analyzer/crates/hir/src/has_source.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/tools/rust-analyzer/crates/hir/src/has_source.rs b/src/tools/rust-analyzer/crates/hir/src/has_source.rs index 7cdcdd76d18..308e8a31ca5 100644 --- a/src/tools/rust-analyzer/crates/hir/src/has_source.rs +++ b/src/tools/rust-analyzer/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() } } |
