aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_db/src')
-rw-r--r--crates/ide_db/src/call_info/tests.rs6
-rw-r--r--crates/ide_db/src/helpers/import_assets.rs19
-rw-r--r--crates/ide_db/src/traits/tests.rs6
3 files changed, 10 insertions, 21 deletions
diff --git a/crates/ide_db/src/call_info/tests.rs b/crates/ide_db/src/call_info/tests.rs
index 1aeda08e5..b585085f3 100644
--- a/crates/ide_db/src/call_info/tests.rs
+++ b/crates/ide_db/src/call_info/tests.rs
@@ -1,6 +1,5 @@
1use base_db::{fixture::ChangeFixture, FilePosition}; 1use base_db::{fixture::ChangeFixture, FilePosition};
2use expect_test::{expect, Expect}; 2use expect_test::{expect, Expect};
3use test_utils::RangeOrOffset;
4 3
5use crate::RootDatabase; 4use crate::RootDatabase;
6 5
@@ -10,10 +9,7 @@ pub(crate) fn position(ra_fixture: &str) -> (RootDatabase, FilePosition) {
10 let mut database = RootDatabase::default(); 9 let mut database = RootDatabase::default();
11 database.apply_change(change_fixture.change); 10 database.apply_change(change_fixture.change);
12 let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker ($0)"); 11 let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker ($0)");
13 let offset = match range_or_offset { 12 let offset = range_or_offset.expect_offset();
14 RangeOrOffset::Range(_) => panic!(),
15 RangeOrOffset::Offset(it) => it,
16 };
17 (database, FilePosition { file_id, offset }) 13 (database, FilePosition { file_id, offset })
18} 14}
19 15
diff --git a/crates/ide_db/src/helpers/import_assets.rs b/crates/ide_db/src/helpers/import_assets.rs
index 91d6a4665..ae52dd8bb 100644
--- a/crates/ide_db/src/helpers/import_assets.rs
+++ b/crates/ide_db/src/helpers/import_assets.rs
@@ -420,6 +420,8 @@ fn trait_applicable_items(
420 420
421 let db = sema.db; 421 let db = sema.db;
422 422
423 let related_dyn_traits =
424 trait_candidate.receiver_ty.applicable_inherent_traits(db).collect::<FxHashSet<_>>();
423 let mut required_assoc_items = FxHashSet::default(); 425 let mut required_assoc_items = FxHashSet::default();
424 let trait_candidates = items_locator::items_with_name( 426 let trait_candidates = items_locator::items_with_name(
425 sema, 427 sema,
@@ -431,13 +433,15 @@ fn trait_applicable_items(
431 .filter_map(|input| item_as_assoc(db, input)) 433 .filter_map(|input| item_as_assoc(db, input))
432 .filter_map(|assoc| { 434 .filter_map(|assoc| {
433 let assoc_item_trait = assoc.containing_trait(db)?; 435 let assoc_item_trait = assoc.containing_trait(db)?;
434 required_assoc_items.insert(assoc); 436 if related_dyn_traits.contains(&assoc_item_trait) {
435 Some(assoc_item_trait.into()) 437 None
438 } else {
439 required_assoc_items.insert(assoc);
440 Some(assoc_item_trait.into())
441 }
436 }) 442 })
437 .collect(); 443 .collect();
438 444
439 let related_dyn_traits =
440 trait_candidate.receiver_ty.applicable_inherent_traits(db).collect::<FxHashSet<_>>();
441 let mut located_imports = FxHashSet::default(); 445 let mut located_imports = FxHashSet::default();
442 446
443 if trait_assoc_item { 447 if trait_assoc_item {
@@ -454,10 +458,6 @@ fn trait_applicable_items(
454 } 458 }
455 } 459 }
456 let located_trait = assoc.containing_trait(db)?; 460 let located_trait = assoc.containing_trait(db)?;
457 if related_dyn_traits.contains(&located_trait) {
458 return None;
459 }
460
461 let trait_item = ItemInNs::from(ModuleDef::from(located_trait)); 461 let trait_item = ItemInNs::from(ModuleDef::from(located_trait));
462 let original_item = assoc_to_item(assoc); 462 let original_item = assoc_to_item(assoc);
463 located_imports.insert(LocatedImport::new( 463 located_imports.insert(LocatedImport::new(
@@ -480,9 +480,6 @@ fn trait_applicable_items(
480 let assoc = function.as_assoc_item(db)?; 480 let assoc = function.as_assoc_item(db)?;
481 if required_assoc_items.contains(&assoc) { 481 if required_assoc_items.contains(&assoc) {
482 let located_trait = assoc.containing_trait(db)?; 482 let located_trait = assoc.containing_trait(db)?;
483 if related_dyn_traits.contains(&located_trait) {
484 return None;
485 }
486 let trait_item = ItemInNs::from(ModuleDef::from(located_trait)); 483 let trait_item = ItemInNs::from(ModuleDef::from(located_trait));
487 let original_item = assoc_to_item(assoc); 484 let original_item = assoc_to_item(assoc);
488 located_imports.insert(LocatedImport::new( 485 located_imports.insert(LocatedImport::new(
diff --git a/crates/ide_db/src/traits/tests.rs b/crates/ide_db/src/traits/tests.rs
index 2a5482024..de994407c 100644
--- a/crates/ide_db/src/traits/tests.rs
+++ b/crates/ide_db/src/traits/tests.rs
@@ -2,7 +2,6 @@ use base_db::{fixture::ChangeFixture, FilePosition};
2use expect_test::{expect, Expect}; 2use expect_test::{expect, Expect};
3use hir::Semantics; 3use hir::Semantics;
4use syntax::ast::{self, AstNode}; 4use syntax::ast::{self, AstNode};
5use test_utils::RangeOrOffset;
6 5
7use crate::RootDatabase; 6use crate::RootDatabase;
8 7
@@ -12,10 +11,7 @@ pub(crate) fn position(ra_fixture: &str) -> (RootDatabase, FilePosition) {
12 let mut database = RootDatabase::default(); 11 let mut database = RootDatabase::default();
13 database.apply_change(change_fixture.change); 12 database.apply_change(change_fixture.change);
14 let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker ($0)"); 13 let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker ($0)");
15 let offset = match range_or_offset { 14 let offset = range_or_offset.expect_offset();
16 RangeOrOffset::Range(_) => panic!(),
17 RangeOrOffset::Offset(it) => it,
18 };
19 (database, FilePosition { file_id, offset }) 15 (database, FilePosition { file_id, offset })
20} 16}
21 17