diff options
| author | hi-rustin <rustin.liu@gmail.com> | 2022-03-16 20:54:01 +0800 |
|---|---|---|
| committer | hi-rustin <rustin.liu@gmail.com> | 2022-03-17 20:39:04 +0800 |
| commit | c6ef4e830ecfeb5bd592d2604d46cc67b77dcdc5 (patch) | |
| tree | 6792d176bc2d3f940e3f37c9ca453f7c396cd755 | |
| parent | a9aae250ed8034ab78a9c1b42df62ef9fc0df0e8 (diff) | |
| download | rust-c6ef4e830ecfeb5bd592d2604d46cc67b77dcdc5.tar.gz rust-c6ef4e830ecfeb5bd592d2604d46cc67b77dcdc5.zip | |
Fix the wrong path resolution
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
| -rw-r--r-- | crates/ide_completion/src/completions/pattern.rs | 7 | ||||
| -rw-r--r-- | crates/ide_completion/src/tests/pattern.rs | 4 |
2 files changed, 9 insertions, 2 deletions
diff --git a/crates/ide_completion/src/completions/pattern.rs b/crates/ide_completion/src/completions/pattern.rs index 7926db8acf4..4b5849dab52 100644 --- a/crates/ide_completion/src/completions/pattern.rs +++ b/crates/ide_completion/src/completions/pattern.rs @@ -143,10 +143,15 @@ fn pattern_path_completion( .into_iter() .for_each(|variant| acc.add_enum_variant(ctx, variant, None)); } - res @ (hir::PathResolution::TypeParam(_) | hir::PathResolution::SelfType(_)) => { + res @ (hir::PathResolution::TypeParam(_) + | hir::PathResolution::SelfType(_) + | hir::PathResolution::Def(hir::ModuleDef::Adt(hir::Adt::Struct(_)))) => { let ty = match res { hir::PathResolution::TypeParam(param) => param.ty(ctx.db), hir::PathResolution::SelfType(impl_def) => impl_def.self_ty(ctx.db), + hir::PathResolution::Def(hir::ModuleDef::Adt(hir::Adt::Struct(s))) => { + s.ty(ctx.db) + } _ => return, }; diff --git a/crates/ide_completion/src/tests/pattern.rs b/crates/ide_completion/src/tests/pattern.rs index c1c73aaf618..1dcb0a5531b 100644 --- a/crates/ide_completion/src/tests/pattern.rs +++ b/crates/ide_completion/src/tests/pattern.rs @@ -463,6 +463,8 @@ fn f(t: Ty) { } } "#, - expect![[""]], + expect![[r#" + ct ABC const ABC: Self + "#]], ) } |
