]> git.lizzy.rs Git - rust.git/blob - src/librustc_typeck/namespace.rs
Use Arena inside hir::ImplItem.
[rust.git] / src / librustc_typeck / namespace.rs
1 use rustc::hir;
2 use rustc::ty;
3
4 // Whether an item exists in the type or value namespace.
5 #[derive(Copy, Clone, PartialEq, Eq, Debug)]
6 pub enum Namespace {
7     Type,
8     Value,
9 }
10
11 impl From<ty::AssocKind> for Namespace {
12     fn from(a_kind: ty::AssocKind) -> Self {
13         match a_kind {
14             ty::AssocKind::OpaqueTy |
15             ty::AssocKind::Type => Namespace::Type,
16             ty::AssocKind::Const |
17             ty::AssocKind::Method => Namespace::Value,
18         }
19     }
20 }
21
22 impl<'a> From <&'a hir::ImplItemKind<'_>> for Namespace {
23     fn from(impl_kind: &'a hir::ImplItemKind<'_>) -> Self {
24         match *impl_kind {
25             hir::ImplItemKind::OpaqueTy(..) |
26             hir::ImplItemKind::TyAlias(..) => Namespace::Type,
27             hir::ImplItemKind::Const(..) |
28             hir::ImplItemKind::Method(..) => Namespace::Value,
29         }
30     }
31 }