diff options
Diffstat (limited to 'crates/hir_expand/src/name.rs')
-rw-r--r-- | crates/hir_expand/src/name.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/crates/hir_expand/src/name.rs b/crates/hir_expand/src/name.rs index 0aeea48d5..a0f8766b0 100644 --- a/crates/hir_expand/src/name.rs +++ b/crates/hir_expand/src/name.rs | |||
@@ -55,6 +55,15 @@ impl Name { | |||
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
58 | /// A fake name for things missing in the source code. | ||
59 | /// | ||
60 | /// For example, `impl Foo for {}` should be treated as a trait impl for a | ||
61 | /// type with a missing name. Similarly, `struct S { : u32 }` should have a | ||
62 | /// single field with a missing name. | ||
63 | /// | ||
64 | /// Ideally, we want a `gensym` semantics for missing names -- each missing | ||
65 | /// name is equal only to itself. It's not clear how to implement this in | ||
66 | /// salsa though, so we punt on that bit for a moment. | ||
58 | pub fn missing() -> Name { | 67 | pub fn missing() -> Name { |
59 | Name::new_text("[missing name]".into()) | 68 | Name::new_text("[missing name]".into()) |
60 | } | 69 | } |
@@ -75,14 +84,14 @@ impl AsName for ast::NameRef { | |||
75 | fn as_name(&self) -> Name { | 84 | fn as_name(&self) -> Name { |
76 | match self.as_tuple_field() { | 85 | match self.as_tuple_field() { |
77 | Some(idx) => Name::new_tuple_field(idx), | 86 | Some(idx) => Name::new_tuple_field(idx), |
78 | None => Name::resolve(self.text()), | 87 | None => Name::resolve(&self.text()), |
79 | } | 88 | } |
80 | } | 89 | } |
81 | } | 90 | } |
82 | 91 | ||
83 | impl AsName for ast::Name { | 92 | impl AsName for ast::Name { |
84 | fn as_name(&self) -> Name { | 93 | fn as_name(&self) -> Name { |
85 | Name::resolve(self.text()) | 94 | Name::resolve(&self.text()) |
86 | } | 95 | } |
87 | } | 96 | } |
88 | 97 | ||
@@ -199,6 +208,8 @@ pub mod known { | |||
199 | line, | 208 | line, |
200 | module_path, | 209 | module_path, |
201 | assert, | 210 | assert, |
211 | core_panic, | ||
212 | std_panic, | ||
202 | stringify, | 213 | stringify, |
203 | concat, | 214 | concat, |
204 | include, | 215 | include, |