From a624e2ea8d6fc97df03f663581e082541fd0348f Mon Sep 17 00:00:00 2001 From: jake Date: Sun, 11 Apr 2021 00:31:20 -0700 Subject: Adds impl Deref assist --- crates/ide_db/src/helpers.rs | 4 ++++ crates/ide_db/src/helpers/famous_defs_fixture.rs | 8 ++++++++ 2 files changed, 12 insertions(+) (limited to 'crates/ide_db/src') 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<'_, '_> { self.find_module("core:iter") } + pub fn core_ops_Deref(&self) -> Option { + self.find_trait("core:ops:Deref") + } + fn find_trait(&self, path: &str) -> Option { match self.find_def(path)? { 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 { type Output; extern "rust-call" fn call_once(self, args: Args) -> Self::Output; } + + #[lang = "deref"] + pub trait Deref { + type Target: ?Sized; + fn deref(&self) -> &Self::Target; + } } pub mod option { @@ -141,3 +147,5 @@ mod return_keyword {} /// Docs for prim_str mod prim_str {} + +pub use core::ops; \ No newline at end of file -- cgit v1.2.3