From 693ac892f2db5db1ce7cf86db7bf6207b3515c42 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 13 Jul 2020 16:16:53 +0200 Subject: Don't copy-paste `impl_froms` into every crate --- crates/ra_hir_ty/src/lower.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'crates/ra_hir_ty/src/lower.rs') diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs index 3af8d55a1..101b8aebe 100644 --- a/crates/ra_hir_ty/src/lower.rs +++ b/crates/ra_hir_ty/src/lower.rs @@ -5,10 +5,7 @@ //! - Building the type for an item: This happens through the `type_for_def` query. //! //! This usually involves resolving names, collecting generic arguments etc. -use std::iter; -use std::sync::Arc; - -use smallvec::SmallVec; +use std::{iter, sync::Arc}; use hir_def::{ adt::StructKind, @@ -24,6 +21,8 @@ use hir_def::{ use hir_expand::name::Name; use ra_arena::map::ArenaMap; use ra_db::CrateId; +use smallvec::SmallVec; +use stdx::impl_from; use test_utils::mark; use crate::{ @@ -1110,7 +1109,7 @@ pub enum CallableDef { StructId(StructId), EnumVariantId(EnumVariantId), } -impl_froms!(CallableDef: FunctionId, StructId, EnumVariantId); +impl_from!(FunctionId, StructId, EnumVariantId for CallableDef); impl CallableDef { pub fn krate(self, db: &dyn HirDatabase) -> CrateId { @@ -1140,7 +1139,7 @@ pub enum TyDefId { AdtId(AdtId), TypeAliasId(TypeAliasId), } -impl_froms!(TyDefId: BuiltinType, AdtId(StructId, EnumId, UnionId), TypeAliasId); +impl_from!(BuiltinType, AdtId(StructId, EnumId, UnionId), TypeAliasId for TyDefId); #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum ValueTyDefId { @@ -1150,7 +1149,7 @@ pub enum ValueTyDefId { ConstId(ConstId), StaticId(StaticId), } -impl_froms!(ValueTyDefId: FunctionId, StructId, EnumVariantId, ConstId, StaticId); +impl_from!(FunctionId, StructId, EnumVariantId, ConstId, StaticId for ValueTyDefId); /// Build the declared type of an item. This depends on the namespace; e.g. for /// `struct Foo(usize)`, we have two types: The type of the struct itself, and -- cgit v1.2.3