aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r--crates/ra_hir/src/ty/infer.rs1
-rw-r--r--crates/ra_hir/src/ty/lower.rs1
-rw-r--r--crates/ra_hir/src/ty/tests.rs19
3 files changed, 21 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index ca9aefc42..a69f04ff1 100644
--- a/crates/ra_hir/src/ty/infer.rs
+++ b/crates/ra_hir/src/ty/infer.rs
@@ -559,6 +559,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
559 match resolver.resolve_path_in_type_ns_fully(self.db, &path) { 559 match resolver.resolve_path_in_type_ns_fully(self.db, &path) {
560 Some(TypeNs::Adt(Adt::Struct(it))) => it.into(), 560 Some(TypeNs::Adt(Adt::Struct(it))) => it.into(),
561 Some(TypeNs::Adt(Adt::Union(it))) => it.into(), 561 Some(TypeNs::Adt(Adt::Union(it))) => it.into(),
562 Some(TypeNs::AdtSelfType(adt)) => adt.into(),
562 Some(TypeNs::EnumVariant(it)) => it.into(), 563 Some(TypeNs::EnumVariant(it)) => it.into(),
563 Some(TypeNs::TypeAlias(it)) => it.into(), 564 Some(TypeNs::TypeAlias(it)) => it.into(),
564 565
diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs
index 4b67c82e7..a604c02e2 100644
--- a/crates/ra_hir/src/ty/lower.rs
+++ b/crates/ra_hir/src/ty/lower.rs
@@ -175,6 +175,7 @@ impl Ty {
175 Ty::Param { idx, name } 175 Ty::Param { idx, name }
176 } 176 }
177 TypeNs::SelfType(impl_block) => impl_block.target_ty(db), 177 TypeNs::SelfType(impl_block) => impl_block.target_ty(db),
178 TypeNs::AdtSelfType(adt) => adt.ty(db),
178 179
179 TypeNs::Adt(it) => Ty::from_hir_path_inner(db, resolver, resolved_segment, it.into()), 180 TypeNs::Adt(it) => Ty::from_hir_path_inner(db, resolver, resolved_segment, it.into()),
180 TypeNs::BuiltinType(it) => { 181 TypeNs::BuiltinType(it) => {
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index 263b61a59..c12326643 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -134,6 +134,25 @@ mod boxed {
134} 134}
135 135
136#[test] 136#[test]
137fn infer_adt_self() {
138 let (db, pos) = MockDatabase::with_position(
139 r#"
140//- /main.rs
141enum Nat { Succ(Self), Demo(Nat), Zero }
142
143fn test() {
144 let foo: Nat = Nat::Zero;
145 if let Nat::Succ(x) = foo {
146 x<|>
147 }
148}
149
150"#,
151 );
152 assert_eq!("Nat", type_at_pos(&db, pos));
153}
154
155#[test]
137fn infer_try() { 156fn infer_try() {
138 let (mut db, pos) = MockDatabase::with_position( 157 let (mut db, pos) = MockDatabase::with_position(
139 r#" 158 r#"