aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r--crates/ra_hir_def/src/lang_item.rs44
-rw-r--r--crates/ra_hir_def/src/path.rs4
2 files changed, 44 insertions, 4 deletions
diff --git a/crates/ra_hir_def/src/lang_item.rs b/crates/ra_hir_def/src/lang_item.rs
index cef061837..37c861a87 100644
--- a/crates/ra_hir_def/src/lang_item.rs
+++ b/crates/ra_hir_def/src/lang_item.rs
@@ -22,6 +22,50 @@ pub enum LangItemTarget {
22 TraitId(TraitId), 22 TraitId(TraitId),
23} 23}
24 24
25impl LangItemTarget {
26 pub fn as_enum(self) -> Option<EnumId> {
27 match self {
28 LangItemTarget::EnumId(id) => Some(id),
29 _ => None,
30 }
31 }
32
33 pub fn as_function(self) -> Option<FunctionId> {
34 match self {
35 LangItemTarget::FunctionId(id) => Some(id),
36 _ => None,
37 }
38 }
39
40 pub fn as_impl_block(self) -> Option<ImplId> {
41 match self {
42 LangItemTarget::ImplBlockId(id) => Some(id),
43 _ => None,
44 }
45 }
46
47 pub fn as_static(self) -> Option<StaticId> {
48 match self {
49 LangItemTarget::StaticId(id) => Some(id),
50 _ => None,
51 }
52 }
53
54 pub fn as_struct(self) -> Option<StructId> {
55 match self {
56 LangItemTarget::StructId(id) => Some(id),
57 _ => None,
58 }
59 }
60
61 pub fn as_trait(self) -> Option<TraitId> {
62 match self {
63 LangItemTarget::TraitId(id) => Some(id),
64 _ => None,
65 }
66 }
67}
68
25#[derive(Default, Debug, Clone, PartialEq, Eq)] 69#[derive(Default, Debug, Clone, PartialEq, Eq)]
26pub struct LangItems { 70pub struct LangItems {
27 items: FxHashMap<SmolStr, LangItemTarget>, 71 items: FxHashMap<SmolStr, LangItemTarget>,
diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs
index 107d2d799..82cfa67a9 100644
--- a/crates/ra_hir_def/src/path.rs
+++ b/crates/ra_hir_def/src/path.rs
@@ -260,12 +260,8 @@ macro_rules! __known_path {
260 (std::ops::RangeTo) => {}; 260 (std::ops::RangeTo) => {};
261 (std::ops::RangeToInclusive) => {}; 261 (std::ops::RangeToInclusive) => {};
262 (std::ops::RangeInclusive) => {}; 262 (std::ops::RangeInclusive) => {};
263 (std::boxed::Box) => {};
264 (std::future::Future) => {}; 263 (std::future::Future) => {};
265 (std::ops::Try) => {}; 264 (std::ops::Try) => {};
266 (std::ops::Neg) => {};
267 (std::ops::Not) => {};
268 (std::ops::Index) => {};
269 ($path:path) => { 265 ($path:path) => {
270 compile_error!("Please register your known path in the path module") 266 compile_error!("Please register your known path in the path module")
271 }; 267 };