Fix associated items not being appended to paths in import_assets
This commit is contained in:
parent
816bc73895
commit
34464ede3f
2 changed files with 40 additions and 3 deletions
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -304,7 +304,11 @@ fn path_applicable_imports(
|
|||
return items_with_candidate_name
|
||||
.into_iter()
|
||||
.filter_map(|item| {
|
||||
Some(LocatedImport::new(mod_path(item)?, item, item, mod_path(item)))
|
||||
let mut mod_path = mod_path(item)?;
|
||||
if let Some(assoc_item) = item_as_assoc(db, item) {
|
||||
mod_path.push_segment(assoc_item.name(db)?);
|
||||
}
|
||||
Some(LocatedImport::new(mod_path.clone(), item, item, Some(mod_path)))
|
||||
})
|
||||
.collect();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue