From 34464ede3f57cbab4d6d1a67f36252cc22c02765 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 18 Mar 2021 21:36:52 +0100 Subject: Fix associated items not being appended to paths in import_assets --- crates/ide_assists/src/handlers/qualify_path.rs | 37 +++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'crates/ide_assists/src') diff --git a/crates/ide_assists/src/handlers/qualify_path.rs b/crates/ide_assists/src/handlers/qualify_path.rs index 30b23da6c..40571e52b 100644 --- a/crates/ide_assists/src/handlers/qualify_path.rs +++ b/crates/ide_assists/src/handlers/qualify_path.rs @@ -208,8 +208,10 @@ fn label(candidate: &ImportCandidate, import: &LocatedImport) -> String { format!("Qualify as `{}`", import.import_path) } } - ImportCandidate::TraitAssocItem(_) => format!("Qualify `{}`", import.import_path), - ImportCandidate::TraitMethod(_) => format!("Qualify with cast as `{}`", import.import_path), + ImportCandidate::TraitAssocItem(_) => { + format!("Qualify with `{}`", import.import_path) + } + ImportCandidate::TraitMethod(_) => format!("Qualify with `{}`", import.import_path), } } @@ -543,6 +545,37 @@ fn main() { ); } + #[test] + fn associated_struct_const_unqualified() { + check_assist( + qualify_path, + r" + mod test_mod { + pub struct TestStruct {} + impl TestStruct { + const TEST_CONST: u8 = 42; + } + } + + fn main() { + TEST_CONST$0 + } + ", + r" + mod test_mod { + pub struct TestStruct {} + impl TestStruct { + const TEST_CONST: u8 = 42; + } + } + + fn main() { + test_mod::TestStruct::TEST_CONST + } + ", + ); + } + #[test] fn associated_trait_function() { check_assist( -- cgit v1.2.3