From 7e70fc22a79ad2eb4deeb6465799f03e7580fee1 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 14 Jan 2020 17:11:47 +0100 Subject: Flip generics --- crates/ra_hir/src/source_binder.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'crates/ra_hir') diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 8f002d2ee..ca003576a 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs @@ -52,16 +52,16 @@ impl SourceBinder<'_, DB> { SourceAnalyzer::new_for_resolver(resolver, src) } - pub fn to_def(&mut self, src: InFile) -> Option + pub fn to_def(&mut self, src: InFile) -> Option where - D: From, - ID: ToId, + D: From, + T: ToId, { - let id: ID = self.to_id(src)?; + let id: T::ID = self.to_id(src)?; Some(id.into()) } - fn to_id(&mut self, src: InFile) -> Option { + fn to_id(&mut self, src: InFile) -> Option { let container = self.find_container(src.as_ref().map(|it| it.syntax()))?; let db = self.db; let dyn_map = @@ -73,7 +73,7 @@ impl SourceBinder<'_, DB> { ChildContainer::EnumId(it) => it.child_by_source(db), ChildContainer::VariantId(it) => it.child_by_source(db), }); - dyn_map[D::KEY].get(&src).copied() + dyn_map[T::KEY].get(&src).copied() } fn find_container(&mut self, src: InFile<&SyntaxNode>) -> Option { @@ -144,16 +144,16 @@ impl_froms! { VariantId, } -pub trait ToId: Sized + Copy + 'static { - type Ast: AstNode + 'static; - const KEY: Key; +pub trait ToId: Sized + AstNode + 'static { + type ID: Sized + Copy + 'static; + const KEY: Key; } macro_rules! to_id_impls { ($(($id:ident, $ast:path, $key:path)),* ,) => {$( - impl ToId for $id { - type Ast = $ast; - const KEY: Key = $key; + impl ToId for $ast { + type ID = $id; + const KEY: Key = $key; } )*} } -- cgit v1.2.3