aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/nameres.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-03-25 21:00:16 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-03-25 21:00:16 +0000
commitdc94f3612583c5e960b334761ad0c18d328840ea (patch)
treec79204bca4912574614eafff8f9e18775d5aa963 /crates/ra_hir/src/nameres.rs
parentbb77bc5c2f6c6b9681d9b3d0a068791db7eec0e2 (diff)
parent99711c1863fc712dc14ca61809055b283415acbe (diff)
Merge #1040
1040: Trait beginnings r=matklad a=flodiebold This adds some very simple trait method resolution, going through traits in scope, looking for methods of the given name, and checking very naively whether there's an impl for the given type and trait. Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/nameres.rs')
-rw-r--r--crates/ra_hir/src/nameres.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs
index 56ed872d5..c34aa4b50 100644
--- a/crates/ra_hir/src/nameres.rs
+++ b/crates/ra_hir/src/nameres.rs
@@ -62,7 +62,7 @@ use test_utils::tested_by;
62 62
63use crate::{ 63use crate::{
64 ModuleDef, Name, Crate, Module, 64 ModuleDef, Name, Crate, Module,
65 DefDatabase, Path, PathKind, HirFileId, 65 DefDatabase, Path, PathKind, HirFileId, Trait,
66 ids::{SourceItemId, SourceFileItemId, MacroCallId}, 66 ids::{SourceItemId, SourceFileItemId, MacroCallId},
67 diagnostics::DiagnosticSink, 67 diagnostics::DiagnosticSink,
68 nameres::diagnostics::DefDiagnostic, 68 nameres::diagnostics::DefDiagnostic,
@@ -139,6 +139,12 @@ impl ModuleScope {
139 pub fn get(&self, name: &Name) -> Option<&Resolution> { 139 pub fn get(&self, name: &Name) -> Option<&Resolution> {
140 self.items.get(name) 140 self.items.get(name)
141 } 141 }
142 pub fn traits<'a>(&'a self) -> impl Iterator<Item = Trait> + 'a {
143 self.items.values().filter_map(|r| match r.def.take_types() {
144 Some(ModuleDef::Trait(t)) => Some(t),
145 _ => None,
146 })
147 }
142} 148}
143 149
144#[derive(Debug, Clone, PartialEq, Eq, Default)] 150#[derive(Debug, Clone, PartialEq, Eq, Default)]