aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ids.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ids.rs')
-rw-r--r--crates/ra_hir/src/ids.rs29
1 files changed, 11 insertions, 18 deletions
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs
index 530fdf5cd..332cec9c8 100644
--- a/crates/ra_hir/src/ids.rs
+++ b/crates/ra_hir/src/ids.rs
@@ -5,7 +5,7 @@ use ra_syntax::{TreeArc, SyntaxNode, SourceFile, AstNode, ast};
5use ra_arena::{Arena, RawId, impl_arena_id}; 5use ra_arena::{Arena, RawId, impl_arena_id};
6 6
7use crate::{ 7use crate::{
8 HirDatabase, Def, Enum, EnumVariant, Crate, 8 HirDatabase, Def, EnumVariant, Crate,
9 Module, Trait, Type, Static, Const, 9 Module, Trait, Type, Static, Const,
10}; 10};
11 11
@@ -247,25 +247,22 @@ pub struct DefLoc {
247 247
248#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] 248#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
249pub(crate) enum DefKind { 249pub(crate) enum DefKind {
250 Struct,
251 Enum,
252 EnumVariant, 250 EnumVariant,
253 Const, 251 Const,
254 Static, 252 Static,
255 Trait, 253 Trait,
256 Type, 254 Type,
257 Item, 255 Item,
258 256 // /// The constructor of a struct. E.g. if we have `struct Foo(usize)`, the
259 /// The constructor of a struct. E.g. if we have `struct Foo(usize)`, the 257 // /// name `Foo` needs to resolve to different types depending on whether we
260 /// name `Foo` needs to resolve to different types depending on whether we 258 // /// are in the types or values namespace: As a type, `Foo` of course refers
261 /// are in the types or values namespace: As a type, `Foo` of course refers 259 // /// to the struct `Foo`; as a value, `Foo` is a callable type with signature
262 /// to the struct `Foo`; as a value, `Foo` is a callable type with signature 260 // /// `(usize) -> Foo`. The cleanest approach to handle this seems to be to
263 /// `(usize) -> Foo`. The cleanest approach to handle this seems to be to 261 // /// have different defs in the two namespaces.
264 /// have different defs in the two namespaces. 262 // ///
265 /// 263 // /// rustc does the same; note that it even creates a struct constructor if
266 /// rustc does the same; note that it even creates a struct constructor if 264 // /// the struct isn't a tuple struct (see `CtorKind::Fictive` in rustc).
267 /// the struct isn't a tuple struct (see `CtorKind::Fictive` in rustc). 265 // StructCtor,
268 StructCtor,
269} 266}
270 267
271impl DefId { 268impl DefId {
@@ -276,8 +273,6 @@ impl DefId {
276 pub fn resolve(self, db: &impl HirDatabase) -> Def { 273 pub fn resolve(self, db: &impl HirDatabase) -> Def {
277 let loc = self.loc(db); 274 let loc = self.loc(db);
278 match loc.kind { 275 match loc.kind {
279 DefKind::Struct => unreachable!(),
280 DefKind::Enum => Def::Enum(Enum::new(self)),
281 DefKind::EnumVariant => Def::EnumVariant(EnumVariant::new(self)), 276 DefKind::EnumVariant => Def::EnumVariant(EnumVariant::new(self)),
282 DefKind::Const => { 277 DefKind::Const => {
283 let def = Const::new(self); 278 let def = Const::new(self);
@@ -295,8 +290,6 @@ impl DefId {
295 let def = Type::new(self); 290 let def = Type::new(self);
296 Def::Type(def) 291 Def::Type(def)
297 } 292 }
298
299 DefKind::StructCtor => Def::Item,
300 DefKind::Item => Def::Item, 293 DefKind::Item => Def::Item,
301 } 294 }
302 } 295 }