make TryToNav take Semantics instead of RootDatabase
diff --git a/crates/ide/src/call_hierarchy.rs b/crates/ide/src/call_hierarchy.rs
index 7a04059..f42cead 100644
--- a/crates/ide/src/call_hierarchy.rs
+++ b/crates/ide/src/call_hierarchy.rs
@@ -67,7 +67,7 @@
                 let def = ast::Fn::cast(node).and_then(|fn_| sema.to_def(&fn_))?;
                 // We should return def before check if it is a test, so that we
                 // will not continue to search for outer fn in nested fns
-                def.try_to_nav(sema.db).map(|nav| (def, nav))
+                def.try_to_nav(sema).map(|nav| (def, nav))
             });
 
             if let Some((def, nav)) = def_nav {
@@ -122,10 +122,10 @@
                             if exclude_tests && it.is_test(db) {
                                 return None;
                             }
-                            it.try_to_nav(db)
+                            it.try_to_nav(&sema)
                         }
-                        hir::CallableKind::TupleEnumVariant(it) => it.try_to_nav(db),
-                        hir::CallableKind::TupleStruct(it) => it.try_to_nav(db),
+                        hir::CallableKind::TupleEnumVariant(it) => it.try_to_nav(&sema),
+                        hir::CallableKind::TupleStruct(it) => it.try_to_nav(&sema),
                         _ => None,
                     }
                     .zip(Some(sema.original_range(expr.syntax())))
@@ -136,7 +136,7 @@
                         return None;
                     }
                     function
-                        .try_to_nav(db)
+                        .try_to_nav(&sema)
                         .zip(Some(sema.original_range(expr.name_ref()?.syntax())))
                 }
             }?;
diff --git a/crates/ide/src/doc_links/tests.rs b/crates/ide/src/doc_links/tests.rs
index b004c07..11518d1 100644
--- a/crates/ide/src/doc_links/tests.rs
+++ b/crates/ide/src/doc_links/tests.rs
@@ -68,7 +68,7 @@
                 resolve_doc_path_for_def(sema.db, cursor_def, &link, ns, is_inner_attr)
                     .unwrap_or_else(|| panic!("Failed to resolve {link}"))
             });
-            def.try_to_nav(sema.db).unwrap().into_iter().zip(iter::repeat(link))
+            def.try_to_nav(sema).unwrap().into_iter().zip(iter::repeat(link))
         })
         .map(|(nav_target, link)| {
             let range =
diff --git a/crates/ide/src/goto_declaration.rs b/crates/ide/src/goto_declaration.rs
index 267e8ff..686dbe2 100644
--- a/crates/ide/src/goto_declaration.rs
+++ b/crates/ide/src/goto_declaration.rs
@@ -38,14 +38,14 @@
                     ast::NameRef(name_ref) => match NameRefClass::classify(&sema, &name_ref)? {
                         NameRefClass::Definition(it, _) => Some(it),
                         NameRefClass::FieldShorthand { field_ref, .. } =>
-                            return field_ref.try_to_nav(db),
+                            return field_ref.try_to_nav(&sema),
                         NameRefClass::ExternCrateShorthand { decl, .. } =>
-                            return decl.try_to_nav(db),
+                            return decl.try_to_nav(&sema),
                     },
                     ast::Name(name) => match NameClass::classify(&sema, &name)? {
                         NameClass::Definition(it) | NameClass::ConstReference(it) => Some(it),
                         NameClass::PatFieldShorthand { field_ref, .. } =>
-                            return field_ref.try_to_nav(db),
+                            return field_ref.try_to_nav(&sema),
                     },
                     _ => None
                 }
@@ -57,14 +57,14 @@
                 Definition::Const(c) => c.as_assoc_item(db),
                 Definition::TypeAlias(ta) => ta.as_assoc_item(db),
                 Definition::Function(f) => f.as_assoc_item(db),
-                Definition::ExternCrateDecl(it) => return it.try_to_nav(db),
+                Definition::ExternCrateDecl(it) => return it.try_to_nav(&sema),
                 _ => None,
             }?;
 
             let trait_ = assoc.implemented_trait(db)?;
             let name = Some(assoc.name(db)?);
             let item = trait_.items(db).into_iter().find(|it| it.name(db) == name)?;
-            item.try_to_nav(db)
+            item.try_to_nav(&sema)
         })
         .flatten()
         .collect();
diff --git a/crates/ide/src/goto_definition.rs b/crates/ide/src/goto_definition.rs
index d50d7f6..2dcb13d 100644
--- a/crates/ide/src/goto_definition.rs
+++ b/crates/ide/src/goto_definition.rs
@@ -62,7 +62,7 @@
     })?;
     if let Some(doc_comment) = token_as_doc_comment(&original_token) {
         return doc_comment.get_definition_with_descend_at(sema, offset, |def, _, link_range| {
-            let nav = def.try_to_nav(db)?;
+            let nav = def.try_to_nav(sema)?;
             Some(RangeInfo::new(link_range, nav.collect()))
         });
     }
@@ -73,7 +73,7 @@
         return Some(RangeInfo::new(
             range,
             match resolution {
-                Some(res) => def_to_nav(db, Definition::from(res)),
+                Some(res) => def_to_nav(sema, Definition::from(res)),
                 None => vec![],
             },
         ));
@@ -121,7 +121,7 @@
                                 .collect();
                         }
                         try_filter_trait_item_definition(sema, &def)
-                            .unwrap_or_else(|| def_to_nav(sema.db, def))
+                            .unwrap_or_else(|| def_to_nav(sema, def))
                     })
                     .collect(),
             )
@@ -160,7 +160,7 @@
                     t_f,
                     [return_type.type_arguments().next()?],
                 )
-                .map(|f| def_to_nav(sema.db, f.into()));
+                .map(|f| def_to_nav(sema, f.into()));
         }
         hir::AssocItemContainer::Impl(_) => return None,
     };
@@ -201,7 +201,7 @@
     // succeed
     let _t = f.as_assoc_item(sema.db)?.implemented_trait(sema.db)?;
     let def = Definition::from(f);
-    Some(def_to_nav(sema.db, def))
+    Some(def_to_nav(sema, def))
 }
 
 fn try_lookup_include_path(
@@ -246,7 +246,7 @@
     for mod_def in krate.root_module().declarations(sema.db) {
         if let ModuleDef::Macro(mac) = mod_def
             && mac.name(sema.db).as_str() == token.text()
-            && let Some(nav) = mac.try_to_nav(sema.db)
+            && let Some(nav) = mac.try_to_nav(sema)
         {
             return Some(nav.call_site);
         }
@@ -278,7 +278,7 @@
                 .items(db)
                 .iter()
                 .filter(|itm| discriminant(*itm) == discriminant_value)
-                .find_map(|itm| (itm.name(db)? == name).then(|| itm.try_to_nav(db)).flatten())
+                .find_map(|itm| (itm.name(db)? == name).then(|| itm.try_to_nav(sema)).flatten())
                 .map(|it| it.collect())
         }
     }
@@ -347,7 +347,7 @@
             match_ast! {
                 match node {
                     ast::Fn(fn_) => {
-                        let mut nav = sema.to_def(&fn_)?.try_to_nav(db)?;
+                        let mut nav = sema.to_def(&fn_)?.try_to_nav(sema)?;
                         // For async token, we navigate to itself, which triggers
                         // VSCode to find the references
                         let focus_token = if matches!(token_kind, T![async]) {
@@ -564,8 +564,8 @@
     Some(navs)
 }
 
-fn def_to_nav(db: &RootDatabase, def: Definition) -> Vec<NavigationTarget> {
-    def.try_to_nav(db).map(|it| it.collect()).unwrap_or_default()
+fn def_to_nav(sema: &Semantics<'_, RootDatabase>, def: Definition) -> Vec<NavigationTarget> {
+    def.try_to_nav(sema).map(|it| it.collect()).unwrap_or_default()
 }
 
 fn expr_to_nav(
diff --git a/crates/ide/src/goto_implementation.rs b/crates/ide/src/goto_implementation.rs
index 4f17262..875403c 100644
--- a/crates/ide/src/goto_implementation.rs
+++ b/crates/ide/src/goto_implementation.rs
@@ -86,7 +86,7 @@
 fn impls_for_ty(sema: &Semantics<'_, RootDatabase>, ty: hir::Type<'_>) -> Vec<NavigationTarget> {
     Impl::all_for_type(sema.db, ty)
         .into_iter()
-        .filter_map(|imp| imp.try_to_nav(sema.db))
+        .filter_map(|imp| imp.try_to_nav(sema))
         .flatten()
         .collect()
 }
@@ -97,7 +97,7 @@
 ) -> Vec<NavigationTarget> {
     Impl::all_for_trait(sema.db, trait_)
         .into_iter()
-        .filter_map(|imp| imp.try_to_nav(sema.db))
+        .filter_map(|imp| imp.try_to_nav(sema))
         .flatten()
         .collect()
 }
@@ -114,7 +114,7 @@
                 let itm_name = itm.name(sema.db)?;
                 (itm_name == fun_name).then_some(*itm)
             })?;
-            item.try_to_nav(sema.db)
+            item.try_to_nav(sema)
         })
         .flatten()
         .collect()
diff --git a/crates/ide/src/goto_type_definition.rs b/crates/ide/src/goto_type_definition.rs
index b80e81d..ffd144a 100644
--- a/crates/ide/src/goto_type_definition.rs
+++ b/crates/ide/src/goto_type_definition.rs
@@ -30,7 +30,7 @@
 
     let mut res = Vec::new();
     let mut push = |def: Definition| {
-        if let Some(navs) = def.try_to_nav(db) {
+        if let Some(navs) = def.try_to_nav(&sema) {
             for nav in navs {
                 if !res.contains(&nav) {
                     res.push(nav);
diff --git a/crates/ide/src/highlight_related.rs b/crates/ide/src/highlight_related.rs
index af1557f..04ce5a7 100644
--- a/crates/ide/src/highlight_related.rs
+++ b/crates/ide/src/highlight_related.rs
@@ -277,7 +277,7 @@
                     Definition::Module(module) => {
                         NavigationTarget::from_module_to_decl(sema.db, module)
                     }
-                    def => match def.try_to_nav(sema.db) {
+                    def => match def.try_to_nav(sema) {
                         Some(it) => it,
                         None => continue,
                     },
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs
index 44c98a4..3f52303 100644
--- a/crates/ide/src/hover.rs
+++ b/crates/ide/src/hover.rs
@@ -85,10 +85,11 @@
 
 impl HoverAction {
     fn goto_type_from_targets(
-        db: &RootDatabase,
+        sema: &Semantics<'_, RootDatabase>,
         targets: Vec<hir::ModuleDef>,
         edition: Edition,
     ) -> Option<Self> {
+        let db = sema.db;
         let targets = targets
             .into_iter()
             .filter_map(|it| {
@@ -99,7 +100,7 @@
                         it.name(db).map(|name| name.display(db, edition).to_string()),
                         edition,
                     ),
-                    nav: it.try_to_nav(db)?.call_site(),
+                    nav: it.try_to_nav(sema)?.call_site(),
                 })
             })
             .collect::<Vec<_>>();
@@ -467,10 +468,10 @@
     HoverResult {
         markup: render::process_markup(sema.db, def, &markup, range_map, config),
         actions: [
-            show_fn_references_action(sema.db, def),
-            show_implementations_action(sema.db, def),
+            show_fn_references_action(sema, def),
+            show_implementations_action(sema, def),
             runnable_action(sema, def, file_id),
-            goto_type_action_for_def(sema.db, def, &notable_traits, subst_types, edition),
+            goto_type_action_for_def(sema, def, &notable_traits, subst_types, edition),
         ]
         .into_iter()
         .flatten()
@@ -505,7 +506,10 @@
         .collect::<Vec<_>>()
 }
 
-fn show_implementations_action(db: &RootDatabase, def: Definition) -> Option<HoverAction> {
+fn show_implementations_action(
+    sema: &Semantics<'_, RootDatabase>,
+    def: Definition,
+) -> Option<HoverAction> {
     fn to_action(nav_target: NavigationTarget) -> HoverAction {
         HoverAction::Implementation(FilePosition {
             file_id: nav_target.file_id,
@@ -515,19 +519,22 @@
 
     let adt = match def {
         Definition::Trait(it) => {
-            return it.try_to_nav(db).map(UpmappingResult::call_site).map(to_action);
+            return it.try_to_nav(sema).map(UpmappingResult::call_site).map(to_action);
         }
         Definition::Adt(it) => Some(it),
-        Definition::SelfType(it) => it.self_ty(db).as_adt(),
+        Definition::SelfType(it) => it.self_ty(sema.db).as_adt(),
         _ => None,
     }?;
-    adt.try_to_nav(db).map(UpmappingResult::call_site).map(to_action)
+    adt.try_to_nav(sema).map(UpmappingResult::call_site).map(to_action)
 }
 
-fn show_fn_references_action(db: &RootDatabase, def: Definition) -> Option<HoverAction> {
+fn show_fn_references_action(
+    sema: &Semantics<'_, RootDatabase>,
+    def: Definition,
+) -> Option<HoverAction> {
     match def {
         Definition::Function(it) => {
-            it.try_to_nav(db).map(UpmappingResult::call_site).map(|nav_target| {
+            it.try_to_nav(sema).map(UpmappingResult::call_site).map(|nav_target| {
                 HoverAction::Reference(FilePosition {
                     file_id: nav_target.file_id,
                     offset: nav_target.focus_or_full_range().start(),
@@ -560,12 +567,13 @@
 }
 
 fn goto_type_action_for_def(
-    db: &RootDatabase,
+    sema: &Semantics<'_, RootDatabase>,
     def: Definition,
     notable_traits: &[(hir::Trait, Vec<(Option<hir::Type<'_>>, hir::Name)>)],
     subst_types: Option<Vec<(hir::Symbol, hir::Type<'_>)>>,
     edition: Edition,
 ) -> Option<HoverAction> {
+    let db = sema.db;
     let mut targets: Vec<hir::ModuleDef> = Vec::new();
     let mut push_new_def = |item: hir::ModuleDef| {
         if !targets.contains(&item) {
@@ -612,7 +620,7 @@
         }
     }
 
-    HoverAction::goto_type_from_targets(db, targets, edition)
+    HoverAction::goto_type_from_targets(sema, targets, edition)
 }
 
 fn walk_and_push_ty(
diff --git a/crates/ide/src/hover/render.rs b/crates/ide/src/hover/render.rs
index 2adafbb..4512606 100644
--- a/crates/ide/src/hover/render.rs
+++ b/crates/ide/src/hover/render.rs
@@ -128,7 +128,7 @@
     };
     walk_and_push_ty(sema.db, &inner_ty, &mut push_new_def);
     walk_and_push_ty(sema.db, &body_ty, &mut push_new_def);
-    if let Some(actions) = HoverAction::goto_type_from_targets(sema.db, targets, edition) {
+    if let Some(actions) = HoverAction::goto_type_from_targets(sema, targets, edition) {
         res.actions.push(actions);
     }
 
@@ -210,7 +210,7 @@
         )
         .into()
     };
-    if let Some(actions) = HoverAction::goto_type_from_targets(sema.db, targets, edition) {
+    if let Some(actions) = HoverAction::goto_type_from_targets(sema, targets, edition) {
         res.actions.push(actions);
     }
 
@@ -323,7 +323,7 @@
 
         Markup::fenced_block(&s)
     };
-    if let Some(actions) = HoverAction::goto_type_from_targets(sema.db, targets, edition) {
+    if let Some(actions) = HoverAction::goto_type_from_targets(sema, targets, edition) {
         res.actions.push(actions);
     }
     res
@@ -1030,7 +1030,7 @@
         };
         desc.into()
     };
-    if let Some(actions) = HoverAction::goto_type_from_targets(db, targets, edition) {
+    if let Some(actions) = HoverAction::goto_type_from_targets(sema, targets, edition) {
         res.actions.push(actions);
     }
     Some(res)
@@ -1098,7 +1098,7 @@
     format_to!(markup, "{adjusted}\n\n## Captures\n{}", captures_rendered,);
 
     let mut res = HoverResult::default();
-    if let Some(actions) = HoverAction::goto_type_from_targets(sema.db, targets, edition) {
+    if let Some(actions) = HoverAction::goto_type_from_targets(sema, targets, edition) {
         res.actions.push(actions);
     }
     res.markup = markup.into();
@@ -1302,7 +1302,7 @@
                     KeywordHint {
                         description,
                         keyword_mod,
-                        actions: HoverAction::goto_type_from_targets(sema.db, targets, edition)
+                        actions: HoverAction::goto_type_from_targets(sema, targets, edition)
                             .into_iter()
                             .collect(),
                     }
diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs
index cc44ae8..507af41 100644
--- a/crates/ide/src/inlay_hints.rs
+++ b/crates/ide/src/inlay_hints.rs
@@ -672,7 +672,7 @@
 
 #[derive(Debug)]
 struct InlayHintLabelBuilder<'a> {
-    db: &'a RootDatabase,
+    sema: &'a Semantics<'a, RootDatabase>,
     result: InlayHintLabel,
     last_part: String,
     resolve: bool,
@@ -694,7 +694,7 @@
             LazyProperty::Lazy
         } else {
             LazyProperty::Computed({
-                let Some(location) = ModuleDef::from(def).try_to_nav(self.db) else { return };
+                let Some(location) = ModuleDef::from(def).try_to_nav(self.sema) else { return };
                 let location = location.call_site();
                 FileRange { file_id: location.file_id, range: location.focus_or_full_range() }
             })
@@ -782,7 +782,7 @@
     }
 
     let mut label_builder = InlayHintLabelBuilder {
-        db: sema.db,
+        sema,
         last_part: String::new(),
         location: None,
         result: InlayHintLabel::default(),
diff --git a/crates/ide/src/inlay_hints/bounds.rs b/crates/ide/src/inlay_hints/bounds.rs
index f0003da..4abd67b 100644
--- a/crates/ide/src/inlay_hints/bounds.rs
+++ b/crates/ide/src/inlay_hints/bounds.rs
@@ -44,7 +44,7 @@
                             text: "Sized".to_owned(),
                             linked_location: sized_trait.and_then(|it| {
                                 config.lazy_location_opt(|| {
-                                    it.try_to_nav(sema.db).map(|it| {
+                                    it.try_to_nav(sema).map(|it| {
                                         let n = it.call_site();
                                         FileRange {
                                             file_id: n.file_id,
diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs
index cddf5f0..3a6b324 100644
--- a/crates/ide/src/lib.rs
+++ b/crates/ide/src/lib.rs
@@ -483,7 +483,7 @@
             salsa::attach(&self.db, || {
                 symbols
                     .into_iter()
-                    .filter_map(|s| s.try_to_nav(&self.db))
+                    .filter_map(|s| s.try_to_nav(&Semantics::new(&self.db)))
                     .take(limit)
                     .map(UpmappingResult::call_site)
                     .collect::<Vec<_>>()
diff --git a/crates/ide/src/navigation_target.rs b/crates/ide/src/navigation_target.rs
index 641bde5..46ff16f 100644
--- a/crates/ide/src/navigation_target.rs
+++ b/crates/ide/src/navigation_target.rs
@@ -83,14 +83,20 @@
 }
 
 pub trait TryToNav {
-    fn try_to_nav(&self, db: &RootDatabase) -> Option<UpmappingResult<NavigationTarget>>;
+    fn try_to_nav(
+        &self,
+        sema: &Semantics<'_, RootDatabase>,
+    ) -> Option<UpmappingResult<NavigationTarget>>;
 }
 
 impl<T: TryToNav, U: TryToNav> TryToNav for Either<T, U> {
-    fn try_to_nav(&self, db: &RootDatabase) -> Option<UpmappingResult<NavigationTarget>> {
+    fn try_to_nav(
+        &self,
+        sema: &Semantics<'_, RootDatabase>,
+    ) -> Option<UpmappingResult<NavigationTarget>> {
         match self {
-            Either::Left(it) => it.try_to_nav(db),
-            Either::Right(it) => it.try_to_nav(db),
+            Either::Left(it) => it.try_to_nav(sema),
+            Either::Right(it) => it.try_to_nav(sema),
         }
     }
 }
@@ -185,7 +191,11 @@
 }
 
 impl TryToNav for FileSymbol {
-    fn try_to_nav(&self, db: &RootDatabase) -> Option<UpmappingResult<NavigationTarget>> {
+    fn try_to_nav(
+        &self,
+        sema: &Semantics<'_, RootDatabase>,
+    ) -> Option<UpmappingResult<NavigationTarget>> {
+        let db = sema.db;
         let edition =
             self.def.module(db).map(|it| it.krate().edition(db)).unwrap_or(Edition::CURRENT);
         let display_target = self.def.krate(db).to_display_target(db);
@@ -244,49 +254,55 @@
 }
 
 impl TryToNav for Definition {
-    fn try_to_nav(&self, db: &RootDatabase) -> Option<UpmappingResult<NavigationTarget>> {
+    fn try_to_nav(
+        &self,
+        sema: &Semantics<'_, RootDatabase>,
+    ) -> Option<UpmappingResult<NavigationTarget>> {
         match self {
-            Definition::Local(it) => Some(it.to_nav(db)),
-            Definition::Label(it) => it.try_to_nav(db),
-            Definition::Module(it) => Some(it.to_nav(db)),
-            Definition::Crate(it) => Some(it.to_nav(db)),
-            Definition::Macro(it) => it.try_to_nav(db),
-            Definition::Field(it) => it.try_to_nav(db),
-            Definition::SelfType(it) => it.try_to_nav(db),
-            Definition::GenericParam(it) => it.try_to_nav(db),
-            Definition::Function(it) => it.try_to_nav(db),
-            Definition::Adt(it) => it.try_to_nav(db),
-            Definition::Variant(it) => it.try_to_nav(db),
-            Definition::Const(it) => it.try_to_nav(db),
-            Definition::Static(it) => it.try_to_nav(db),
-            Definition::Trait(it) => it.try_to_nav(db),
-            Definition::TypeAlias(it) => it.try_to_nav(db),
-            Definition::ExternCrateDecl(it) => it.try_to_nav(db),
-            Definition::InlineAsmOperand(it) => it.try_to_nav(db),
-            Definition::BuiltinType(it) => it.try_to_nav(db),
+            Definition::Local(it) => Some(it.to_nav(sema.db)),
+            Definition::Label(it) => it.try_to_nav(sema),
+            Definition::Module(it) => Some(it.to_nav(sema.db)),
+            Definition::Crate(it) => Some(it.to_nav(sema.db)),
+            Definition::Macro(it) => it.try_to_nav(sema),
+            Definition::Field(it) => it.try_to_nav(sema),
+            Definition::SelfType(it) => it.try_to_nav(sema),
+            Definition::GenericParam(it) => it.try_to_nav(sema),
+            Definition::Function(it) => it.try_to_nav(sema),
+            Definition::Adt(it) => it.try_to_nav(sema),
+            Definition::Variant(it) => it.try_to_nav(sema),
+            Definition::Const(it) => it.try_to_nav(sema),
+            Definition::Static(it) => it.try_to_nav(sema),
+            Definition::Trait(it) => it.try_to_nav(sema),
+            Definition::TypeAlias(it) => it.try_to_nav(sema),
+            Definition::ExternCrateDecl(it) => it.try_to_nav(sema),
+            Definition::InlineAsmOperand(it) => it.try_to_nav(sema),
+            Definition::BuiltinType(it) => it.try_to_nav(sema),
             Definition::BuiltinLifetime(_)
             | Definition::TupleField(_)
             | Definition::ToolModule(_)
             | Definition::InlineAsmRegOrRegClass(_)
             | Definition::BuiltinAttr(_) => None,
             // FIXME: The focus range should be set to the helper declaration
-            Definition::DeriveHelper(it) => it.derive().try_to_nav(db),
+            Definition::DeriveHelper(it) => it.derive().try_to_nav(sema),
         }
     }
 }
 
 impl TryToNav for hir::ModuleDef {
-    fn try_to_nav(&self, db: &RootDatabase) -> Option<UpmappingResult<NavigationTarget>> {
+    fn try_to_nav(
+        &self,
+        sema: &Semantics<'_, RootDatabase>,
+    ) -> Option<UpmappingResult<NavigationTarget>> {
         match self {
-            hir::ModuleDef::Module(it) => Some(it.to_nav(db)),
-            hir::ModuleDef::Function(it) => it.try_to_nav(db),
-            hir::ModuleDef::Adt(it) => it.try_to_nav(db),
-            hir::ModuleDef::Variant(it) => it.try_to_nav(db),
-            hir::ModuleDef::Const(it) => it.try_to_nav(db),
-            hir::ModuleDef::Static(it) => it.try_to_nav(db),
-            hir::ModuleDef::Trait(it) => it.try_to_nav(db),
-            hir::ModuleDef::TypeAlias(it) => it.try_to_nav(db),
-            hir::ModuleDef::Macro(it) => it.try_to_nav(db),
+            hir::ModuleDef::Module(it) => Some(it.to_nav(sema.db)),
+            hir::ModuleDef::Function(it) => it.try_to_nav(sema),
+            hir::ModuleDef::Adt(it) => it.try_to_nav(sema),
+            hir::ModuleDef::Variant(it) => it.try_to_nav(sema),
+            hir::ModuleDef::Const(it) => it.try_to_nav(sema),
+            hir::ModuleDef::Static(it) => it.try_to_nav(sema),
+            hir::ModuleDef::Trait(it) => it.try_to_nav(sema),
+            hir::ModuleDef::TypeAlias(it) => it.try_to_nav(sema),
+            hir::ModuleDef::Macro(it) => it.try_to_nav(sema),
             hir::ModuleDef::BuiltinType(_) => None,
         }
     }
@@ -369,7 +385,11 @@
     D: HasSource + ToNavFromAst + Copy + HasDocs + HirDisplay + HasCrate,
     D::Ast: ast::HasName,
 {
-    fn try_to_nav(&self, db: &RootDatabase) -> Option<UpmappingResult<NavigationTarget>> {
+    fn try_to_nav(
+        &self,
+        sema: &Semantics<'_, RootDatabase>,
+    ) -> Option<UpmappingResult<NavigationTarget>> {
+        let db = sema.db;
         let src = self.source(db)?;
         Some(
             NavigationTarget::from_named(
@@ -423,7 +443,11 @@
 }
 
 impl TryToNav for hir::Impl {
-    fn try_to_nav(&self, db: &RootDatabase) -> Option<UpmappingResult<NavigationTarget>> {
+    fn try_to_nav(
+        &self,
+        sema: &Semantics<'_, RootDatabase>,
+    ) -> Option<UpmappingResult<NavigationTarget>> {
+        let db = sema.db;
         let InFile { file_id, value } = self.source(db)?;
         let derive_path = self.as_builtin_derive_path(db);
 
@@ -447,7 +471,11 @@
 }
 
 impl TryToNav for hir::ExternCrateDecl {
-    fn try_to_nav(&self, db: &RootDatabase) -> Option<UpmappingResult<NavigationTarget>> {
+    fn try_to_nav(
+        &self,
+        sema: &Semantics<'_, RootDatabase>,
+    ) -> Option<UpmappingResult<NavigationTarget>> {
+        let db = sema.db;
         let src = self.source(db)?;
         let InFile { file_id, value } = src;
         let focus = value
@@ -479,7 +507,11 @@
 }
 
 impl TryToNav for hir::Field {
-    fn try_to_nav(&self, db: &RootDatabase) -> Option<UpmappingResult<NavigationTarget>> {
+    fn try_to_nav(
+        &self,
+        sema: &Semantics<'_, RootDatabase>,
+    ) -> Option<UpmappingResult<NavigationTarget>> {
+        let db = sema.db;
         let src = self.source(db)?;
         let krate = self.parent_def(db).module(db).krate();
 
@@ -512,7 +544,11 @@
 }
 
 impl TryToNav for hir::Macro {
-    fn try_to_nav(&self, db: &RootDatabase) -> Option<UpmappingResult<NavigationTarget>> {
+    fn try_to_nav(
+        &self,
+        sema: &Semantics<'_, RootDatabase>,
+    ) -> Option<UpmappingResult<NavigationTarget>> {
+        let db = sema.db;
         let src = self.source(db)?;
         let name_owner: &dyn ast::HasName = match &src.value {
             Either::Left(it) => it,
@@ -533,31 +569,40 @@
 }
 
 impl TryToNav for hir::Adt {
-    fn try_to_nav(&self, db: &RootDatabase) -> Option<UpmappingResult<NavigationTarget>> {
+    fn try_to_nav(
+        &self,
+        sema: &Semantics<'_, RootDatabase>,
+    ) -> Option<UpmappingResult<NavigationTarget>> {
         match self {
-            hir::Adt::Struct(it) => it.try_to_nav(db),
-            hir::Adt::Union(it) => it.try_to_nav(db),
-            hir::Adt::Enum(it) => it.try_to_nav(db),
+            hir::Adt::Struct(it) => it.try_to_nav(sema),
+            hir::Adt::Union(it) => it.try_to_nav(sema),
+            hir::Adt::Enum(it) => it.try_to_nav(sema),
         }
     }
 }
 
 impl TryToNav for hir::AssocItem {
-    fn try_to_nav(&self, db: &RootDatabase) -> Option<UpmappingResult<NavigationTarget>> {
+    fn try_to_nav(
+        &self,
+        sema: &Semantics<'_, RootDatabase>,
+    ) -> Option<UpmappingResult<NavigationTarget>> {
         match self {
-            AssocItem::Function(it) => it.try_to_nav(db),
-            AssocItem::Const(it) => it.try_to_nav(db),
-            AssocItem::TypeAlias(it) => it.try_to_nav(db),
+            AssocItem::Function(it) => it.try_to_nav(sema),
+            AssocItem::Const(it) => it.try_to_nav(sema),
+            AssocItem::TypeAlias(it) => it.try_to_nav(sema),
         }
     }
 }
 
 impl TryToNav for hir::GenericParam {
-    fn try_to_nav(&self, db: &RootDatabase) -> Option<UpmappingResult<NavigationTarget>> {
+    fn try_to_nav(
+        &self,
+        sema: &Semantics<'_, RootDatabase>,
+    ) -> Option<UpmappingResult<NavigationTarget>> {
         match self {
-            hir::GenericParam::TypeParam(it) => it.try_to_nav(db),
-            hir::GenericParam::ConstParam(it) => it.try_to_nav(db),
-            hir::GenericParam::LifetimeParam(it) => it.try_to_nav(db),
+            hir::GenericParam::TypeParam(it) => it.try_to_nav(sema),
+            hir::GenericParam::ConstParam(it) => it.try_to_nav(sema),
+            hir::GenericParam::LifetimeParam(it) => it.try_to_nav(sema),
         }
     }
 }
@@ -606,7 +651,11 @@
 }
 
 impl TryToNav for hir::Label {
-    fn try_to_nav(&self, db: &RootDatabase) -> Option<UpmappingResult<NavigationTarget>> {
+    fn try_to_nav(
+        &self,
+        sema: &Semantics<'_, RootDatabase>,
+    ) -> Option<UpmappingResult<NavigationTarget>> {
+        let db = sema.db;
         let InFile { file_id, value } = self.source(db)?;
         // Labels can't be keywords, so no escaping needed.
         let name = self.name(db).display_no_db(Edition::Edition2015).to_smolstr();
@@ -628,7 +677,11 @@
 }
 
 impl TryToNav for hir::TypeParam {
-    fn try_to_nav(&self, db: &RootDatabase) -> Option<UpmappingResult<NavigationTarget>> {
+    fn try_to_nav(
+        &self,
+        sema: &Semantics<'_, RootDatabase>,
+    ) -> Option<UpmappingResult<NavigationTarget>> {
+        let db = sema.db;
         let InFile { file_id, value } = self.merge().source(db)?;
         let edition = self.module(db).krate().edition(db);
         let name = self.name(db).display_no_db(edition).to_smolstr();
@@ -665,13 +718,20 @@
 }
 
 impl TryToNav for hir::TypeOrConstParam {
-    fn try_to_nav(&self, db: &RootDatabase) -> Option<UpmappingResult<NavigationTarget>> {
-        self.split(db).try_to_nav(db)
+    fn try_to_nav(
+        &self,
+        sema: &Semantics<'_, RootDatabase>,
+    ) -> Option<UpmappingResult<NavigationTarget>> {
+        self.split(sema.db).try_to_nav(sema)
     }
 }
 
 impl TryToNav for hir::LifetimeParam {
-    fn try_to_nav(&self, db: &RootDatabase) -> Option<UpmappingResult<NavigationTarget>> {
+    fn try_to_nav(
+        &self,
+        sema: &Semantics<'_, RootDatabase>,
+    ) -> Option<UpmappingResult<NavigationTarget>> {
+        let db = sema.db;
         let InFile { file_id, value } = self.source(db)?;
         // Lifetimes cannot be keywords, so not escaping needed.
         let name = self.name(db).display_no_db(Edition::Edition2015).to_smolstr();
@@ -693,7 +753,11 @@
 }
 
 impl TryToNav for hir::ConstParam {
-    fn try_to_nav(&self, db: &RootDatabase) -> Option<UpmappingResult<NavigationTarget>> {
+    fn try_to_nav(
+        &self,
+        sema: &Semantics<'_, RootDatabase>,
+    ) -> Option<UpmappingResult<NavigationTarget>> {
+        let db = sema.db;
         let InFile { file_id, value } = self.merge().source(db)?;
         let edition = self.module(db).krate().edition(db);
         let name = self.name(db).display_no_db(edition).to_smolstr();
@@ -723,7 +787,11 @@
 }
 
 impl TryToNav for hir::InlineAsmOperand {
-    fn try_to_nav(&self, db: &RootDatabase) -> Option<UpmappingResult<NavigationTarget>> {
+    fn try_to_nav(
+        &self,
+        sema: &Semantics<'_, RootDatabase>,
+    ) -> Option<UpmappingResult<NavigationTarget>> {
+        let db = sema.db;
         let InFile { file_id, value } = &self.source(db)?;
         let file_id = *file_id;
         Some(orig_range_with_focus(db, file_id, value.syntax(), value.name()).map(
@@ -748,9 +816,11 @@
 }
 
 impl TryToNav for hir::BuiltinType {
-    fn try_to_nav(&self, db: &RootDatabase) -> Option<UpmappingResult<NavigationTarget>> {
-        let sema = Semantics::new(db);
-
+    fn try_to_nav(
+        &self,
+        sema: &Semantics<'_, RootDatabase>,
+    ) -> Option<UpmappingResult<NavigationTarget>> {
+        let db = sema.db;
         let krate = db
             .all_crates()
             .iter()
@@ -759,7 +829,7 @@
             .map(Crate::from)?;
         let edition = krate.edition(db);
 
-        let fd = FamousDefs(&sema, krate);
+        let fd = FamousDefs(sema, krate);
         let primitive_mod = format!("prim_{}", self.name().display(fd.0.db, edition));
         let doc_owner = find_std_module(&fd, &primitive_mod, edition)?;
 
diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs
index dc509b3..0189939 100644
--- a/crates/ide/src/references.rs
+++ b/crates/ide/src/references.rs
@@ -138,7 +138,7 @@
                 Definition::Module(module) => {
                     Some(NavigationTarget::from_module_to_decl(sema.db, module))
                 }
-                def => def.try_to_nav(sema.db),
+                def => def.try_to_nav(sema),
             }
             .map(|nav| {
                 let (nav, extra_ref) = match nav.def_site {
diff --git a/crates/ide/src/runnables.rs b/crates/ide/src/runnables.rs
index 6d33ddc..6ad9c78 100644
--- a/crates/ide/src/runnables.rs
+++ b/crates/ide/src/runnables.rs
@@ -158,15 +158,15 @@
             Definition::SelfType(impl_) => runnable_impl(&sema, &impl_),
             _ => None,
         };
-        add_opt(runnable.or_else(|| module_def_doctest(sema.db, def)), Some(def));
+        add_opt(runnable.or_else(|| module_def_doctest(&sema, def)), Some(def));
         if let Definition::SelfType(impl_) = def {
             impl_.items(db).into_iter().for_each(|assoc| {
                 let runnable = match assoc {
                     hir::AssocItem::Function(it) => {
-                        runnable_fn(&sema, it).or_else(|| module_def_doctest(sema.db, it.into()))
+                        runnable_fn(&sema, it).or_else(|| module_def_doctest(&sema, it.into()))
                     }
-                    hir::AssocItem::Const(it) => module_def_doctest(sema.db, it.into()),
-                    hir::AssocItem::TypeAlias(it) => module_def_doctest(sema.db, it.into()),
+                    hir::AssocItem::Const(it) => module_def_doctest(&sema, it.into()),
+                    hir::AssocItem::TypeAlias(it) => module_def_doctest(&sema, it.into()),
                 };
                 add_opt(runnable, Some(assoc.into()))
             });
@@ -410,7 +410,7 @@
         return None;
     }
     let cfg = attrs.cfg();
-    let nav = def.try_to_nav(sema.db)?.call_site();
+    let nav = def.try_to_nav(sema)?.call_site();
     let ty = def.self_ty(sema.db);
     let adt_name = ty.as_adt()?.name(sema.db);
     let mut ty_args = ty.generic_parameters(sema.db, display_target).peekable();
@@ -486,7 +486,8 @@
     })
 }
 
-fn module_def_doctest(db: &RootDatabase, def: Definition) -> Option<Runnable> {
+fn module_def_doctest(sema: &Semantics<'_, RootDatabase>, def: Definition) -> Option<Runnable> {
+    let db = sema.db;
     let attrs = match def {
         Definition::Module(it) => it.attrs(db),
         Definition::Function(it) => it.attrs(db),
@@ -540,7 +541,7 @@
 
     let mut nav = match def {
         Definition::Module(def) => NavigationTarget::from_module_to_decl(db, def),
-        def => def.try_to_nav(db)?,
+        def => def.try_to_nav(sema)?,
     }
     .call_site();
     nav.focus_range = None;
diff --git a/crates/ide/src/static_index.rs b/crates/ide/src/static_index.rs
index 8c3275d..8214b4d 100644
--- a/crates/ide/src/static_index.rs
+++ b/crates/ide/src/static_index.rs
@@ -243,7 +243,7 @@
                             edition,
                             display_target,
                         )),
-                        definition: def.try_to_nav(self.db).map(UpmappingResult::call_site).map(
+                        definition: def.try_to_nav(&sema).map(UpmappingResult::call_site).map(
                             |it| FileRange { file_id: it.file_id, range: it.focus_or_full_range() },
                         ),
                         references: vec![],
@@ -261,7 +261,7 @@
             let token = self.tokens.get_mut(id).unwrap();
             token.references.push(ReferenceData {
                 range: FileRange { range, file_id },
-                is_definition: match def.try_to_nav(self.db).map(UpmappingResult::call_site) {
+                is_definition: match def.try_to_nav(&sema).map(UpmappingResult::call_site) {
                     Some(it) => it.file_id == file_id && it.focus_or_full_range() == range,
                     None => false,
                 },
diff --git a/crates/ide/src/test_explorer.rs b/crates/ide/src/test_explorer.rs
index 06cbd50..bd60ffe 100644
--- a/crates/ide/src/test_explorer.rs
+++ b/crates/ide/src/test_explorer.rs
@@ -94,7 +94,7 @@
         if !f.is_test(db) {
             continue;
         }
-        let nav = f.try_to_nav(db).map(|r| r.call_site);
+        let nav = f.try_to_nav(&sema).map(|r| r.call_site);
         let fn_name = f.name(db).as_str().to_owned();
         r.push(TestItem {
             id: format!("{prefix_id}::{fn_name}"),