aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/hover.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide/src/hover.rs')
-rw-r--r--crates/ide/src/hover.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs
index ed4f18e1f..c08516805 100644
--- a/crates/ide/src/hover.rs
+++ b/crates/ide/src/hover.rs
@@ -131,7 +131,7 @@ pub(crate) fn hover(
131 let (docs, doc_mapping) = attributes.docs_with_rangemap(db)?; 131 let (docs, doc_mapping) = attributes.docs_with_rangemap(db)?;
132 let (idl_range, link, ns) = 132 let (idl_range, link, ns) =
133 extract_definitions_from_markdown(docs.as_str()).into_iter().find_map(|(range, link, ns)| { 133 extract_definitions_from_markdown(docs.as_str()).into_iter().find_map(|(range, link, ns)| {
134 let InFile { file_id, value: range } = doc_mapping.map(range.clone())?; 134 let InFile { file_id, value: range } = doc_mapping.map(range)?;
135 if file_id == position.file_id.into() && range.contains(position.offset) { 135 if file_id == position.file_id.into() && range.contains(position.offset) {
136 Some((range, link, ns)) 136 Some((range, link, ns))
137 } else { 137 } else {
@@ -208,7 +208,7 @@ pub(crate) fn hover(
208} 208}
209 209
210fn try_hover_for_attribute(token: &SyntaxToken) -> Option<RangeInfo<HoverResult>> { 210fn try_hover_for_attribute(token: &SyntaxToken) -> Option<RangeInfo<HoverResult>> {
211 let attr = token.ancestors().nth(1).and_then(ast::Attr::cast)?; 211 let attr = token.ancestors().find_map(ast::Attr::cast)?;
212 let (path, tt) = attr.as_simple_call()?; 212 let (path, tt) = attr.as_simple_call()?;
213 if !tt.syntax().text_range().contains(token.text_range().start()) { 213 if !tt.syntax().text_range().contains(token.text_range().start()) {
214 return None; 214 return None;
@@ -288,7 +288,7 @@ fn runnable_action(
288) -> Option<HoverAction> { 288) -> Option<HoverAction> {
289 match def { 289 match def {
290 Definition::ModuleDef(it) => match it { 290 Definition::ModuleDef(it) => match it {
291 ModuleDef::Module(it) => runnable_mod(&sema, it).map(|it| HoverAction::Runnable(it)), 291 ModuleDef::Module(it) => runnable_mod(sema, it).map(HoverAction::Runnable),
292 ModuleDef::Function(func) => { 292 ModuleDef::Function(func) => {
293 let src = func.source(sema.db)?; 293 let src = func.source(sema.db)?;
294 if src.file_id != file_id.into() { 294 if src.file_id != file_id.into() {
@@ -297,7 +297,7 @@ fn runnable_action(
297 return None; 297 return None;
298 } 298 }
299 299
300 runnable_fn(&sema, func).map(HoverAction::Runnable) 300 runnable_fn(sema, func).map(HoverAction::Runnable)
301 } 301 }
302 _ => None, 302 _ => None,
303 }, 303 },
@@ -432,7 +432,7 @@ fn hover_for_definition(
432 return match def { 432 return match def {
433 Definition::Macro(it) => match &it.source(db)?.value { 433 Definition::Macro(it) => match &it.source(db)?.value {
434 Either::Left(mac) => { 434 Either::Left(mac) => {
435 let label = macro_label(&mac); 435 let label = macro_label(mac);
436 from_def_source_labeled(db, it, Some(label), mod_path) 436 from_def_source_labeled(db, it, Some(label), mod_path)
437 } 437 }
438 Either::Right(_) => { 438 Either::Right(_) => {
@@ -516,7 +516,7 @@ fn hover_for_keyword(
516 if !token.kind().is_keyword() { 516 if !token.kind().is_keyword() {
517 return None; 517 return None;
518 } 518 }
519 let famous_defs = FamousDefs(&sema, sema.scope(&token.parent()?).krate()); 519 let famous_defs = FamousDefs(sema, sema.scope(&token.parent()?).krate());
520 // std exposes {}_keyword modules with docstrings on the root to document keywords 520 // std exposes {}_keyword modules with docstrings on the root to document keywords
521 let keyword_mod = format!("{}_keyword", token.text()); 521 let keyword_mod = format!("{}_keyword", token.text());
522 let doc_owner = find_std_module(&famous_defs, &keyword_mod)?; 522 let doc_owner = find_std_module(&famous_defs, &keyword_mod)?;