]> git.lizzy.rs Git - rust.git/blob - src/librustc_typeck/namespace.rs
Add some type-alias-impl-trait regression tests
[rust.git] / src / librustc_typeck / namespace.rs
1 use rustc::ty;
2 use rustc_hir as hir;
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 | ty::AssocKind::Type => Namespace::Type,
15             ty::AssocKind::Const | ty::AssocKind::Method => Namespace::Value,
16         }
17     }
18 }
19
20 impl<'a> From<&'a hir::ImplItemKind<'_>> for Namespace {
21     fn from(impl_kind: &'a hir::ImplItemKind<'_>) -> Self {
22         match *impl_kind {
23             hir::ImplItemKind::OpaqueTy(..) | hir::ImplItemKind::TyAlias(..) => Namespace::Type,
24             hir::ImplItemKind::Const(..) | hir::ImplItemKind::Method(..) => Namespace::Value,
25         }
26     }
27 }