aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorNick Spain <[email protected]>2021-01-02 11:11:25 +0000
committerNick Spain <[email protected]>2021-01-02 11:11:25 +0000
commit40cd6cdf67dcfad89a80ff3a662bec2dfd983d67 (patch)
tree9101b9ae60806cfa9612d4617f6acef514c3f111 /crates
parent887028fcf52bf7f3af55114f112123c902989bed (diff)
Fix ConstParam HasSource impl and implement TryToNav not Nav
Diffstat (limited to 'crates')
-rw-r--r--crates/hir/src/has_source.rs4
-rw-r--r--crates/ide/src/display/navigation_target.rs12
2 files changed, 8 insertions, 8 deletions
diff --git a/crates/hir/src/has_source.rs b/crates/hir/src/has_source.rs
index 57baeb3cf..7c57d8378 100644
--- a/crates/hir/src/has_source.rs
+++ b/crates/hir/src/has_source.rs
@@ -142,8 +142,8 @@ impl HasSource for LifetimeParam {
142 142
143impl HasSource for ConstParam { 143impl HasSource for ConstParam {
144 type Ast = ast::ConstParam; 144 type Ast = ast::ConstParam;
145 fn source(self, db: &dyn HirDatabase) -> InFile<Self::Ast> { 145 fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
146 let child_source = self.id.parent.child_source(db.upcast()); 146 let child_source = self.id.parent.child_source(db.upcast());
147 child_source.map(|it| it[self.id.local_id].clone()) 147 Some(child_source.map(|it| it[self.id.local_id].clone()))
148 } 148 }
149} 149}
diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs
index 1fb26c226..e24c78301 100644
--- a/crates/ide/src/display/navigation_target.rs
+++ b/crates/ide/src/display/navigation_target.rs
@@ -218,7 +218,7 @@ impl TryToNav for Definition {
218 Definition::TypeParam(it) => it.try_to_nav(db), 218 Definition::TypeParam(it) => it.try_to_nav(db),
219 Definition::LifetimeParam(it) => it.try_to_nav(db), 219 Definition::LifetimeParam(it) => it.try_to_nav(db),
220 Definition::Label(it) => Some(it.to_nav(db)), 220 Definition::Label(it) => Some(it.to_nav(db)),
221 Definition::ConstParam(it) => Some(it.to_nav(db)), 221 Definition::ConstParam(it) => it.try_to_nav(db),
222 } 222 }
223 } 223 }
224} 224}
@@ -479,11 +479,11 @@ impl TryToNav for hir::LifetimeParam {
479 } 479 }
480} 480}
481 481
482impl ToNav for hir::ConstParam { 482impl TryToNav for hir::ConstParam {
483 fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { 483 fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
484 let src = self.source(db); 484 let src = self.source(db)?;
485 let full_range = src.value.syntax().text_range(); 485 let full_range = src.value.syntax().text_range();
486 NavigationTarget { 486 Some(NavigationTarget {
487 file_id: src.file_id.original_file(db), 487 file_id: src.file_id.original_file(db),
488 name: self.name(db).to_string().into(), 488 name: self.name(db).to_string().into(),
489 kind: Some(SymbolKind::ConstParam), 489 kind: Some(SymbolKind::ConstParam),
@@ -492,7 +492,7 @@ impl ToNav for hir::ConstParam {
492 container_name: None, 492 container_name: None,
493 description: None, 493 description: None,
494 docs: None, 494 docs: None,
495 } 495 })
496 } 496 }
497} 497}
498 498