Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/navigation_target.rs')
-rw-r--r--crates/ide/src/navigation_target.rs38
1 files changed, 17 insertions, 21 deletions
diff --git a/crates/ide/src/navigation_target.rs b/crates/ide/src/navigation_target.rs
index 8e73ddf8bf..b222ff3eec 100644
--- a/crates/ide/src/navigation_target.rs
+++ b/crates/ide/src/navigation_target.rs
@@ -54,8 +54,7 @@ pub struct NavigationTarget {
// FIXME: Symbol
pub container_name: Option<SmolStr>,
pub description: Option<String>,
- // FIXME: Use the database lifetime here.
- pub docs: Option<Documentation<'static>>,
+ pub docs: Option<Documentation>,
/// In addition to a `name` field, a `NavigationTarget` may also be aliased
/// In such cases we want a `NavigationTarget` to be accessible by its alias
// FIXME: Symbol
@@ -164,7 +163,7 @@ impl NavigationTarget {
full_range,
SymbolKind::Module,
);
- res.docs = module.docs(db).map(Documentation::into_owned);
+ res.docs = module.docs(db);
res.description = Some(
module.display(db, module.krate().to_display_target(db)).to_string(),
);
@@ -438,7 +437,7 @@ where
D::KIND,
)
.map(|mut res| {
- res.docs = self.docs(db).map(Documentation::into_owned);
+ res.docs = self.docs(db);
res.description = hir::attach_db(db, || {
Some(self.display(db, self.krate(db).to_display_target(db)).to_string())
});
@@ -537,7 +536,7 @@ impl TryToNav for hir::ExternCrateDecl {
SymbolKind::Module,
);
- res.docs = self.docs(db).map(Documentation::into_owned);
+ res.docs = self.docs(db);
res.description = Some(self.display(db, krate.to_display_target(db)).to_string());
res.container_name = container_name(db, *self, edition);
res
@@ -559,9 +558,10 @@ impl TryToNav for hir::Field {
FieldSource::Named(it) => {
NavigationTarget::from_named(db, src.with_value(it), SymbolKind::Field).map(
|mut res| {
- res.docs = self.docs(db).map(Documentation::into_owned);
- res.description =
- Some(self.display(db, krate.to_display_target(db)).to_string());
+ res.docs = self.docs(db);
+ res.description = hir::attach_db(db, || {
+ Some(self.display(db, krate.to_display_target(db)).to_string())
+ });
res
},
)
@@ -600,7 +600,7 @@ impl TryToNav for hir::Macro {
self.kind(db).into(),
)
.map(|mut res| {
- res.docs = self.docs(db).map(Documentation::into_owned);
+ res.docs = self.docs(db);
res
}),
)
@@ -939,7 +939,7 @@ pub(crate) fn orig_range_with_focus_r(
) -> UpmappingResult<(FileRange, Option<TextRange>)> {
let Some(name) = focus_range else { return orig_range_r(db, hir_file, value) };
- let call = || db.lookup_intern_macro_call(hir_file.macro_file().unwrap());
+ let call_kind = || db.lookup_intern_macro_call(hir_file.macro_file().unwrap()).kind;
let def_range =
|| db.lookup_intern_macro_call(hir_file.macro_file().unwrap()).def.definition_range(db);
@@ -965,8 +965,7 @@ pub(crate) fn orig_range_with_focus_r(
// name lies outside the node, so instead point to the macro call which
// *should* contain the name
_ => {
- let call = call();
- let kind = call.kind;
+ let kind = call_kind();
let range = kind.clone().original_call_range_with_input(db);
//If the focus range is in the attribute/derive body, we
// need to point the call site to the entire body, if not, fall back
@@ -978,7 +977,7 @@ pub(crate) fn orig_range_with_focus_r(
{
range
} else {
- kind.original_call_range(db, call.krate)
+ kind.original_call_range(db)
}
}
},
@@ -1007,14 +1006,11 @@ pub(crate) fn orig_range_with_focus_r(
},
),
// node is in macro def, just show the focus
- _ => {
- let call = call();
- (
- // show the macro call
- (call.kind.original_call_range(db, call.krate), None),
- Some((focus_range, Some(focus_range))),
- )
- }
+ _ => (
+ // show the macro call
+ (call_kind().original_call_range(db), None),
+ Some((focus_range, Some(focus_range))),
+ ),
}
}
// lost name? can't happen for single tokens