mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Merge #9017
9017: internal: Reduce the number of traits passed through chalk during applicable trait lookup r=SomeoneToIgnore a=SomeoneToIgnore Inherent traits can be omitted before trait solving, presumably slightly helping https://github.com/rust-analyzer/rust-analyzer/issues/7542 and slightly simplifying the code. Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
This commit is contained in:
commit
d6ed315806
1 changed files with 8 additions and 11 deletions
|
@ -420,6 +420,8 @@ fn trait_applicable_items(
|
||||||
|
|
||||||
let db = sema.db;
|
let db = sema.db;
|
||||||
|
|
||||||
|
let related_dyn_traits =
|
||||||
|
trait_candidate.receiver_ty.applicable_inherent_traits(db).collect::<FxHashSet<_>>();
|
||||||
let mut required_assoc_items = FxHashSet::default();
|
let mut required_assoc_items = FxHashSet::default();
|
||||||
let trait_candidates = items_locator::items_with_name(
|
let trait_candidates = items_locator::items_with_name(
|
||||||
sema,
|
sema,
|
||||||
|
@ -431,13 +433,15 @@ fn trait_applicable_items(
|
||||||
.filter_map(|input| item_as_assoc(db, input))
|
.filter_map(|input| item_as_assoc(db, input))
|
||||||
.filter_map(|assoc| {
|
.filter_map(|assoc| {
|
||||||
let assoc_item_trait = assoc.containing_trait(db)?;
|
let assoc_item_trait = assoc.containing_trait(db)?;
|
||||||
required_assoc_items.insert(assoc);
|
if related_dyn_traits.contains(&assoc_item_trait) {
|
||||||
Some(assoc_item_trait.into())
|
None
|
||||||
|
} else {
|
||||||
|
required_assoc_items.insert(assoc);
|
||||||
|
Some(assoc_item_trait.into())
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let related_dyn_traits =
|
|
||||||
trait_candidate.receiver_ty.applicable_inherent_traits(db).collect::<FxHashSet<_>>();
|
|
||||||
let mut located_imports = FxHashSet::default();
|
let mut located_imports = FxHashSet::default();
|
||||||
|
|
||||||
if trait_assoc_item {
|
if trait_assoc_item {
|
||||||
|
@ -454,10 +458,6 @@ fn trait_applicable_items(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let located_trait = assoc.containing_trait(db)?;
|
let located_trait = assoc.containing_trait(db)?;
|
||||||
if related_dyn_traits.contains(&located_trait) {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
let trait_item = ItemInNs::from(ModuleDef::from(located_trait));
|
let trait_item = ItemInNs::from(ModuleDef::from(located_trait));
|
||||||
let original_item = assoc_to_item(assoc);
|
let original_item = assoc_to_item(assoc);
|
||||||
located_imports.insert(LocatedImport::new(
|
located_imports.insert(LocatedImport::new(
|
||||||
|
@ -480,9 +480,6 @@ fn trait_applicable_items(
|
||||||
let assoc = function.as_assoc_item(db)?;
|
let assoc = function.as_assoc_item(db)?;
|
||||||
if required_assoc_items.contains(&assoc) {
|
if required_assoc_items.contains(&assoc) {
|
||||||
let located_trait = assoc.containing_trait(db)?;
|
let located_trait = assoc.containing_trait(db)?;
|
||||||
if related_dyn_traits.contains(&located_trait) {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
let trait_item = ItemInNs::from(ModuleDef::from(located_trait));
|
let trait_item = ItemInNs::from(ModuleDef::from(located_trait));
|
||||||
let original_item = assoc_to_item(assoc);
|
let original_item = assoc_to_item(assoc);
|
||||||
located_imports.insert(LocatedImport::new(
|
located_imports.insert(LocatedImport::new(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue