aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/hir_ty/src/autoderef.rs1
-rw-r--r--crates/ide_completion/src/completions/flyimport.rs32
-rw-r--r--crates/ide_db/src/helpers/import_assets.rs8
3 files changed, 38 insertions, 3 deletions
diff --git a/crates/hir_ty/src/autoderef.rs b/crates/hir_ty/src/autoderef.rs
index 23ab042c1..0b8ac455b 100644
--- a/crates/hir_ty/src/autoderef.rs
+++ b/crates/hir_ty/src/autoderef.rs
@@ -27,6 +27,7 @@ pub fn autoderef<'a>(
27 krate: Option<CrateId>, 27 krate: Option<CrateId>,
28 ty: InEnvironment<Canonical<Ty>>, 28 ty: InEnvironment<Canonical<Ty>>,
29) -> impl Iterator<Item = Canonical<Ty>> + 'a { 29) -> impl Iterator<Item = Canonical<Ty>> + 'a {
30 // from_chalk
30 let InEnvironment { value: ty, environment } = ty; 31 let InEnvironment { value: ty, environment } = ty;
31 successors(Some(ty), move |ty| { 32 successors(Some(ty), move |ty| {
32 deref(db, krate?, InEnvironment { value: ty, environment: environment.clone() }) 33 deref(db, krate?, InEnvironment { value: ty, environment: environment.clone() })
diff --git a/crates/ide_completion/src/completions/flyimport.rs b/crates/ide_completion/src/completions/flyimport.rs
index 08df2df3f..f6c7d507f 100644
--- a/crates/ide_completion/src/completions/flyimport.rs
+++ b/crates/ide_completion/src/completions/flyimport.rs
@@ -947,4 +947,36 @@ fn main() {
947 expect![[]], 947 expect![[]],
948 ) 948 )
949 } 949 }
950
951 #[test]
952 fn local_assoc_items_are_omitted() {
953 check(
954 r#"
955mod something {
956 pub trait BaseTrait {
957 fn test_function() -> i32;
958 }
959
960 pub struct Item1;
961 pub struct Item2;
962
963 impl BaseTrait for Item1 {
964 fn test_function() -> i32 {
965 1
966 }
967 }
968
969 impl BaseTrait for Item2 {
970 fn test_function() -> i32 {
971 2
972 }
973 }
974}
975
976fn main() {
977 test_f$0
978}"#,
979 expect![[]],
980 )
981 }
950} 982}
diff --git a/crates/ide_db/src/helpers/import_assets.rs b/crates/ide_db/src/helpers/import_assets.rs
index 7c8844e95..dbc980ba9 100644
--- a/crates/ide_db/src/helpers/import_assets.rs
+++ b/crates/ide_db/src/helpers/import_assets.rs
@@ -304,10 +304,12 @@ fn path_applicable_imports(
304 return items_with_candidate_name 304 return items_with_candidate_name
305 .into_iter() 305 .into_iter()
306 .filter_map(|item| { 306 .filter_map(|item| {
307 let mut mod_path = mod_path(item)?; 307 if item_as_assoc(db, item).is_some() {
308 if let Some(assoc_item) = item_as_assoc(db, item) { 308 // unqualified assoc items are not valid syntax
309 mod_path.push_segment(assoc_item.name(db)?); 309 return None;
310 } 310 }
311
312 let mod_path = mod_path(item)?;
311 Some(LocatedImport::new(mod_path.clone(), item, item, Some(mod_path))) 313 Some(LocatedImport::new(mod_path.clone(), item, item, Some(mod_path)))
312 }) 314 })
313 .collect(); 315 .collect();