aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/name.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/name.rs')
-rw-r--r--crates/ra_hir/src/name.rs30
1 files changed, 29 insertions, 1 deletions
diff --git a/crates/ra_hir/src/name.rs b/crates/ra_hir/src/name.rs
index e3a82cf03..e9003e00b 100644
--- a/crates/ra_hir/src/name.rs
+++ b/crates/ra_hir/src/name.rs
@@ -123,7 +123,7 @@ impl AsName for ra_db::Dependency {
123// const ISIZE: Name = Name::new("isize") 123// const ISIZE: Name = Name::new("isize")
124// ``` 124// ```
125// but const-fn is not that powerful yet. 125// but const-fn is not that powerful yet.
126#[derive(Debug, PartialEq, Eq)] 126#[derive(Debug, Clone, Copy, PartialEq, Eq)]
127pub(crate) enum KnownName { 127pub(crate) enum KnownName {
128 Isize, 128 Isize,
129 I8, 129 I8,
@@ -151,3 +151,31 @@ pub(crate) enum KnownName {
151 151
152 MacroRules, 152 MacroRules,
153} 153}
154
155impl AsName for KnownName {
156 fn as_name(&self) -> Name {
157 let s = match self {
158 KnownName::Isize => "isize",
159 KnownName::I8 => "i8",
160 KnownName::I16 => "i16",
161 KnownName::I32 => "i32",
162 KnownName::I64 => "i64",
163 KnownName::I128 => "i128",
164 KnownName::Usize => "usize",
165 KnownName::U8 => "u8",
166 KnownName::U16 => "u16",
167 KnownName::U32 => "u32",
168 KnownName::U64 => "u64",
169 KnownName::U128 => "u128",
170 KnownName::F32 => "f32",
171 KnownName::F64 => "f64",
172 KnownName::Bool => "bool",
173 KnownName::Char => "char",
174 KnownName::Str => "str",
175 KnownName::SelfType => "Self",
176 KnownName::SelfParam => "self",
177 KnownName::MacroRules => "macro_rules",
178 };
179 Name::new(s.into())
180 }
181}