aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db
diff options
context:
space:
mode:
authorjake <[email protected]>2021-04-11 08:31:20 +0100
committerjake <[email protected]>2021-04-11 08:42:05 +0100
commita624e2ea8d6fc97df03f663581e082541fd0348f (patch)
tree452586c51fda1939f6af09fa5b2bd71889333511 /crates/ide_db
parent5b40342d2d5bc19445e6abccef6931bdd3a03c3b (diff)
Adds impl Deref assist
Diffstat (limited to 'crates/ide_db')
-rw-r--r--crates/ide_db/src/helpers.rs4
-rw-r--r--crates/ide_db/src/helpers/famous_defs_fixture.rs8
2 files changed, 12 insertions, 0 deletions
diff --git a/crates/ide_db/src/helpers.rs b/crates/ide_db/src/helpers.rs
index 66798ea3a..83a665b37 100644
--- a/crates/ide_db/src/helpers.rs
+++ b/crates/ide_db/src/helpers.rs
@@ -113,6 +113,10 @@ impl FamousDefs<'_, '_> {
113 self.find_module("core:iter") 113 self.find_module("core:iter")
114 } 114 }
115 115
116 pub fn core_ops_Deref(&self) -> Option<Trait> {
117 self.find_trait("core:ops:Deref")
118 }
119
116 fn find_trait(&self, path: &str) -> Option<Trait> { 120 fn find_trait(&self, path: &str) -> Option<Trait> {
117 match self.find_def(path)? { 121 match self.find_def(path)? {
118 hir::ScopeDef::ModuleDef(hir::ModuleDef::Trait(it)) => Some(it), 122 hir::ScopeDef::ModuleDef(hir::ModuleDef::Trait(it)) => Some(it),
diff --git a/crates/ide_db/src/helpers/famous_defs_fixture.rs b/crates/ide_db/src/helpers/famous_defs_fixture.rs
index 4d79e064e..29ae12dcf 100644
--- a/crates/ide_db/src/helpers/famous_defs_fixture.rs
+++ b/crates/ide_db/src/helpers/famous_defs_fixture.rs
@@ -112,6 +112,12 @@ pub mod ops {
112 type Output; 112 type Output;
113 extern "rust-call" fn call_once(self, args: Args) -> Self::Output; 113 extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
114 } 114 }
115
116 #[lang = "deref"]
117 pub trait Deref {
118 type Target: ?Sized;
119 fn deref(&self) -> &Self::Target;
120 }
115} 121}
116 122
117pub mod option { 123pub mod option {
@@ -141,3 +147,5 @@ mod return_keyword {}
141 147
142/// Docs for prim_str 148/// Docs for prim_str
143mod prim_str {} 149mod prim_str {}
150
151pub use core::ops; \ No newline at end of file