aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/generics.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-11-21 13:32:40 +0000
committerGitHub <[email protected]>2019-11-21 13:32:40 +0000
commit0630bbabfc19126be5fa47933c5ea03d48030582 (patch)
treed7e8fc2fc2234c4bd28c2274bdc761f74a78940a /crates/ra_hir/src/generics.rs
parent1f61915bde4c5d8d4fe2e9b8dfa9445008730b79 (diff)
parent952405cb4180993af0f5c939d5276dbdf2a19152 (diff)
Merge #2338
2338: Remove old hir::generics module r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/generics.rs')
-rw-r--r--crates/ra_hir/src/generics.rs54
1 files changed, 0 insertions, 54 deletions
diff --git a/crates/ra_hir/src/generics.rs b/crates/ra_hir/src/generics.rs
deleted file mode 100644
index f1bf2ee9d..000000000
--- a/crates/ra_hir/src/generics.rs
+++ /dev/null
@@ -1,54 +0,0 @@
1//! Temp module to wrap hir_def::generics
2use std::sync::Arc;
3
4use crate::{
5 db::DefDatabase, Adt, Const, Container, Enum, EnumVariant, Function, ImplBlock, Struct, Trait,
6 TypeAlias, Union,
7};
8
9pub use hir_def::generics::{GenericParam, GenericParams, WherePredicate};
10
11#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
12pub enum GenericDef {
13 Function(Function),
14 Adt(Adt),
15 Trait(Trait),
16 TypeAlias(TypeAlias),
17 ImplBlock(ImplBlock),
18 // enum variants cannot have generics themselves, but their parent enums
19 // can, and this makes some code easier to write
20 EnumVariant(EnumVariant),
21 // consts can have type parameters from their parents (i.e. associated consts of traits)
22 Const(Const),
23}
24impl_froms!(
25 GenericDef: Function,
26 Adt(Struct, Enum, Union),
27 Trait,
28 TypeAlias,
29 ImplBlock,
30 EnumVariant,
31 Const
32);
33
34impl From<Container> for GenericDef {
35 fn from(c: Container) -> Self {
36 match c {
37 Container::Trait(trait_) => trait_.into(),
38 Container::ImplBlock(impl_block) => impl_block.into(),
39 }
40 }
41}
42
43pub trait HasGenericParams: Copy {
44 fn generic_params(self, db: &impl DefDatabase) -> Arc<GenericParams>;
45}
46
47impl<T> HasGenericParams for T
48where
49 T: Into<GenericDef> + Copy,
50{
51 fn generic_params(self, db: &impl DefDatabase) -> Arc<GenericParams> {
52 db.generic_params(self.into().into())
53 }
54}