mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
Merge #8095
8095: Fix associated items not being appended to paths in import_assets r=SomeoneToIgnore a=Veykril Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
commit
86878443b1
@ -208,8 +208,10 @@ fn label(candidate: &ImportCandidate, import: &LocatedImport) -> String {
|
|||||||
format!("Qualify as `{}`", import.import_path)
|
format!("Qualify as `{}`", import.import_path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImportCandidate::TraitAssocItem(_) => format!("Qualify `{}`", import.import_path),
|
ImportCandidate::TraitAssocItem(_) => {
|
||||||
ImportCandidate::TraitMethod(_) => format!("Qualify with cast as `{}`", import.import_path),
|
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]
|
#[test]
|
||||||
fn associated_trait_function() {
|
fn associated_trait_function() {
|
||||||
check_assist(
|
check_assist(
|
||||||
|
@ -304,7 +304,11 @@ fn path_applicable_imports(
|
|||||||
return items_with_candidate_name
|
return items_with_candidate_name
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|item| {
|
.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();
|
.collect();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user