aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide/src')
-rw-r--r--crates/ide/src/diagnostics/fixes.rs2
-rw-r--r--crates/ide/src/doc_links.rs4
-rw-r--r--crates/ide/src/goto_definition.rs2
-rw-r--r--crates/ide/src/hover.rs18
-rw-r--r--crates/ide/src/syntax_highlighting/inject.rs2
5 files changed, 9 insertions, 19 deletions
diff --git a/crates/ide/src/diagnostics/fixes.rs b/crates/ide/src/diagnostics/fixes.rs
index cbfc66ab3..2f840909c 100644
--- a/crates/ide/src/diagnostics/fixes.rs
+++ b/crates/ide/src/diagnostics/fixes.rs
@@ -180,7 +180,7 @@ fn missing_record_expr_field_fix(
180 let def_id = sema.resolve_variant(record_lit)?; 180 let def_id = sema.resolve_variant(record_lit)?;
181 let module; 181 let module;
182 let def_file_id; 182 let def_file_id;
183 let record_fields = match VariantDef::from(def_id) { 183 let record_fields = match def_id {
184 VariantDef::Struct(s) => { 184 VariantDef::Struct(s) => {
185 module = s.module(sema.db); 185 module = s.module(sema.db);
186 let source = s.source(sema.db)?; 186 let source = s.source(sema.db)?;
diff --git a/crates/ide/src/doc_links.rs b/crates/ide/src/doc_links.rs
index 461e11060..5ea9fc4fb 100644
--- a/crates/ide/src/doc_links.rs
+++ b/crates/ide/src/doc_links.rs
@@ -93,7 +93,7 @@ pub(crate) fn remove_links(markdown: &str) -> String {
93 93
94 let mut cb = |_: BrokenLink| { 94 let mut cb = |_: BrokenLink| {
95 let empty = InlineStr::try_from("").unwrap(); 95 let empty = InlineStr::try_from("").unwrap();
96 Some((CowStr::Inlined(empty.clone()), CowStr::Inlined(empty))) 96 Some((CowStr::Inlined(empty), CowStr::Inlined(empty)))
97 }; 97 };
98 let doc = Parser::new_with_broken_link_callback(markdown, opts, Some(&mut cb)); 98 let doc = Parser::new_with_broken_link_callback(markdown, opts, Some(&mut cb));
99 let doc = doc.filter_map(move |evt| match evt { 99 let doc = doc.filter_map(move |evt| match evt {
@@ -147,7 +147,7 @@ fn get_doc_link(db: &RootDatabase, definition: Definition) -> Option<String> {
147 _ => return None, 147 _ => return None,
148 }; 148 };
149 149
150 let ns = ItemInNs::from(target_def.clone()); 150 let ns = ItemInNs::from(target_def);
151 151
152 let module = definition.module(db)?; 152 let module = definition.module(db)?;
153 let krate = module.krate(); 153 let krate = module.krate();
diff --git a/crates/ide/src/goto_definition.rs b/crates/ide/src/goto_definition.rs
index 6986477a5..b71f4917c 100644
--- a/crates/ide/src/goto_definition.rs
+++ b/crates/ide/src/goto_definition.rs
@@ -102,7 +102,7 @@ fn extract_positioned_link_from_comment(
102 None => comment_range.end(), 102 None => comment_range.end(),
103 } 103 }
104 })?; 104 })?;
105 Some((def_link.to_string(), ns.clone())) 105 Some((def_link.to_string(), *ns))
106} 106}
107 107
108fn pick_best(tokens: TokenAtOffset<SyntaxToken>) -> Option<SyntaxToken> { 108fn pick_best(tokens: TokenAtOffset<SyntaxToken>) -> Option<SyntaxToken> {
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs
index 8d45b4875..325014622 100644
--- a/crates/ide/src/hover.rs
+++ b/crates/ide/src/hover.rs
@@ -1,6 +1,6 @@
1use either::Either; 1use either::Either;
2use hir::{ 2use hir::{
3 Adt, AsAssocItem, AssocItemContainer, GenericParam, HasAttrs, HasSource, HirDisplay, Module, 3 AsAssocItem, AssocItemContainer, GenericParam, HasAttrs, HasSource, HirDisplay, Module,
4 ModuleDef, Semantics, 4 ModuleDef, Semantics,
5}; 5};
6use ide_db::{ 6use ide_db::{
@@ -339,9 +339,7 @@ fn hover_for_definition(
339 Definition::ModuleDef(it) => match it { 339 Definition::ModuleDef(it) => match it {
340 ModuleDef::Module(it) => from_hir_fmt(db, it, mod_path), 340 ModuleDef::Module(it) => from_hir_fmt(db, it, mod_path),
341 ModuleDef::Function(it) => from_hir_fmt(db, it, mod_path), 341 ModuleDef::Function(it) => from_hir_fmt(db, it, mod_path),
342 ModuleDef::Adt(Adt::Struct(it)) => from_hir_fmt(db, it, mod_path), 342 ModuleDef::Adt(it) => from_hir_fmt(db, it, mod_path),
343 ModuleDef::Adt(Adt::Union(it)) => from_hir_fmt(db, it, mod_path),
344 ModuleDef::Adt(Adt::Enum(it)) => from_hir_fmt(db, it, mod_path),
345 ModuleDef::Variant(it) => from_hir_fmt(db, it, mod_path), 343 ModuleDef::Variant(it) => from_hir_fmt(db, it, mod_path),
346 ModuleDef::Const(it) => from_hir_fmt(db, it, mod_path), 344 ModuleDef::Const(it) => from_hir_fmt(db, it, mod_path),
347 ModuleDef::Static(it) => from_hir_fmt(db, it, mod_path), 345 ModuleDef::Static(it) => from_hir_fmt(db, it, mod_path),
@@ -353,18 +351,10 @@ fn hover_for_definition(
353 }, 351 },
354 Definition::Local(it) => hover_for_local(it, db), 352 Definition::Local(it) => hover_for_local(it, db),
355 Definition::SelfType(impl_def) => { 353 Definition::SelfType(impl_def) => {
356 impl_def.target_ty(db).as_adt().and_then(|adt| match adt { 354 impl_def.target_ty(db).as_adt().and_then(|adt| from_hir_fmt(db, adt, mod_path))
357 Adt::Struct(it) => from_hir_fmt(db, it, mod_path),
358 Adt::Union(it) => from_hir_fmt(db, it, mod_path),
359 Adt::Enum(it) => from_hir_fmt(db, it, mod_path),
360 })
361 } 355 }
356 Definition::GenericParam(it) => from_hir_fmt(db, it, None),
362 Definition::Label(it) => Some(Markup::fenced_block(&it.name(db))), 357 Definition::Label(it) => Some(Markup::fenced_block(&it.name(db))),
363 Definition::GenericParam(it) => match it {
364 GenericParam::TypeParam(it) => Some(Markup::fenced_block(&it.display(db))),
365 GenericParam::LifetimeParam(it) => Some(Markup::fenced_block(&it.name(db))),
366 GenericParam::ConstParam(it) => Some(Markup::fenced_block(&it.display(db))),
367 },
368 }; 358 };
369 359
370 fn from_hir_fmt<D>(db: &RootDatabase, def: D, mod_path: Option<String>) -> Option<Markup> 360 fn from_hir_fmt<D>(db: &RootDatabase, def: D, mod_path: Option<String>) -> Option<Markup>
diff --git a/crates/ide/src/syntax_highlighting/inject.rs b/crates/ide/src/syntax_highlighting/inject.rs
index d4c367f66..d57ce4027 100644
--- a/crates/ide/src/syntax_highlighting/inject.rs
+++ b/crates/ide/src/syntax_highlighting/inject.rs
@@ -60,7 +60,7 @@ pub(super) fn ra_fixture(
60 for range in inj.map_range_up(hl_range.range) { 60 for range in inj.map_range_up(hl_range.range) {
61 if let Some(range) = literal.map_range_up(range) { 61 if let Some(range) = literal.map_range_up(range) {
62 hl_range.range = range; 62 hl_range.range = range;
63 hl.add(hl_range.clone()); 63 hl.add(hl_range);
64 } 64 }
65 } 65 }
66 } 66 }