aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_hir/src/code_model.rs2
-rw-r--r--crates/ra_hir/src/resolve.rs2
-rw-r--r--crates/ra_hir/src/ty/infer.rs4
-rw-r--r--crates/ra_ide_api/src/completion/complete_scope.rs29
4 files changed, 32 insertions, 5 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index cd501d1f6..58db6832d 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -465,7 +465,7 @@ impl Enum {
465 // ...and add generic params, if present 465 // ...and add generic params, if present
466 let p = self.generic_params(db); 466 let p = self.generic_params(db);
467 let r = if !p.params.is_empty() { r.push_generic_params_scope(p) } else { r }; 467 let r = if !p.params.is_empty() { r.push_generic_params_scope(p) } else { r };
468 r.push_scope(Scope::AdtScope(From::from(self))) 468 r.push_scope(Scope::AdtScope(self.into()))
469 } 469 }
470} 470}
471 471
diff --git a/crates/ra_hir/src/resolve.rs b/crates/ra_hir/src/resolve.rs
index c46f7e157..3c797c0c3 100644
--- a/crates/ra_hir/src/resolve.rs
+++ b/crates/ra_hir/src/resolve.rs
@@ -45,7 +45,7 @@ pub(crate) enum Scope {
45 GenericParams(Arc<GenericParams>), 45 GenericParams(Arc<GenericParams>),
46 /// Brings `Self` in `impl` block into scope 46 /// Brings `Self` in `impl` block into scope
47 ImplBlockScope(ImplBlock), 47 ImplBlockScope(ImplBlock),
48 /// Brings `Self` in enum definition into scope 48 /// Brings `Self` in enum, struct and union definitions into scope
49 AdtScope(Adt), 49 AdtScope(Adt),
50 /// Local bindings 50 /// Local bindings
51 ExprScope(ExprScope), 51 ExprScope(ExprScope),
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index 9e5d42509..a69f04ff1 100644
--- a/crates/ra_hir/src/ty/infer.rs
+++ b/crates/ra_hir/src/ty/infer.rs
@@ -559,9 +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::Struct(it))) => it.into(), 562 Some(TypeNs::AdtSelfType(adt)) => adt.into(),
563 Some(TypeNs::AdtSelfType(Adt::Union(it))) => it.into(),
564 Some(TypeNs::AdtSelfType(Adt::Enum(it))) => it.into(),
565 Some(TypeNs::EnumVariant(it)) => it.into(), 563 Some(TypeNs::EnumVariant(it)) => it.into(),
566 Some(TypeNs::TypeAlias(it)) => it.into(), 564 Some(TypeNs::TypeAlias(it)) => it.into(),
567 565
diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs
index 515a6285c..38a6c3d37 100644
--- a/crates/ra_ide_api/src/completion/complete_scope.rs
+++ b/crates/ra_ide_api/src/completion/complete_scope.rs
@@ -310,6 +310,35 @@ mod tests {
310 } 310 }
311 311
312 #[test] 312 #[test]
313 fn completes_self_in_enum() {
314 assert_debug_snapshot!(
315 do_reference_completion(
316 r"
317 enum X {
318 Y(<|>)
319 }
320 "
321 ),
322 @r###"[
323 CompletionItem {
324 label: "Self",
325 source_range: [48; 48),
326 delete: [48; 48),
327 insert: "Self",
328 kind: TypeParam,
329 },
330 CompletionItem {
331 label: "X",
332 source_range: [48; 48),
333 delete: [48; 48),
334 insert: "X",
335 kind: Enum,
336 },
337]"###
338 );
339 }
340
341 #[test]
313 fn completes_module_items() { 342 fn completes_module_items() {
314 assert_debug_snapshot!( 343 assert_debug_snapshot!(
315 do_reference_completion( 344 do_reference_completion(