mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-14 17:07:26 +00:00
Make inherent_impls_in_block and trait_impls_in_block infallible
This commit is contained in:
parent
96407424de
commit
febd5065ad
3 changed files with 22 additions and 27 deletions
|
@ -139,7 +139,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
|
|||
}
|
||||
});
|
||||
})
|
||||
.filter_map(|block_id| self.db.trait_impls_in_block(block_id));
|
||||
.map(|block_id| self.db.trait_impls_in_block(block_id));
|
||||
|
||||
let id_to_chalk = |id: hir_def::ImplId| id.to_chalk(self.db);
|
||||
let mut result = vec![];
|
||||
|
@ -152,7 +152,8 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
|
|||
impl_maps.into_iter().chain(block_impls).for_each(&mut f);
|
||||
def_blocks
|
||||
.into_iter()
|
||||
.filter_map(|it| self.db.trait_impls_in_block(it?))
|
||||
.flatten()
|
||||
.map(|it| self.db.trait_impls_in_block(it))
|
||||
.for_each(f);
|
||||
}
|
||||
fps => {
|
||||
|
@ -165,7 +166,8 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
|
|||
impl_maps.into_iter().chain(block_impls).for_each(&mut f);
|
||||
def_blocks
|
||||
.into_iter()
|
||||
.filter_map(|it| self.db.trait_impls_in_block(it?))
|
||||
.flatten()
|
||||
.map(|it| self.db.trait_impls_in_block(it))
|
||||
.for_each(f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> {
|
|||
fn inherent_impls_in_crate(&self, krate: CrateId) -> Arc<InherentImpls>;
|
||||
|
||||
#[salsa::invoke(InherentImpls::inherent_impls_in_block_query)]
|
||||
fn inherent_impls_in_block(&self, block: BlockId) -> Option<Arc<InherentImpls>>;
|
||||
fn inherent_impls_in_block(&self, block: BlockId) -> Arc<InherentImpls>;
|
||||
|
||||
/// Collects all crates in the dependency graph that have impls for the
|
||||
/// given fingerprint. This is only used for primitive types and types
|
||||
|
@ -132,7 +132,7 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> {
|
|||
fn trait_impls_in_crate(&self, krate: CrateId) -> Arc<TraitImpls>;
|
||||
|
||||
#[salsa::invoke(TraitImpls::trait_impls_in_block_query)]
|
||||
fn trait_impls_in_block(&self, block: BlockId) -> Option<Arc<TraitImpls>>;
|
||||
fn trait_impls_in_block(&self, block: BlockId) -> Arc<TraitImpls>;
|
||||
|
||||
#[salsa::invoke(TraitImpls::trait_impls_in_deps_query)]
|
||||
fn trait_impls_in_deps(&self, krate: CrateId) -> Arc<TraitImpls>;
|
||||
|
|
|
@ -149,10 +149,7 @@ impl TraitImpls {
|
|||
Arc::new(impls)
|
||||
}
|
||||
|
||||
pub(crate) fn trait_impls_in_block_query(
|
||||
db: &dyn HirDatabase,
|
||||
block: BlockId,
|
||||
) -> Option<Arc<Self>> {
|
||||
pub(crate) fn trait_impls_in_block_query(db: &dyn HirDatabase, block: BlockId) -> Arc<Self> {
|
||||
let _p = profile::span("trait_impls_in_block_query");
|
||||
let mut impls = Self { map: FxHashMap::default() };
|
||||
|
||||
|
@ -160,7 +157,7 @@ impl TraitImpls {
|
|||
impls.collect_def_map(db, &block_def_map);
|
||||
impls.shrink_to_fit();
|
||||
|
||||
Some(Arc::new(impls))
|
||||
Arc::new(impls)
|
||||
}
|
||||
|
||||
pub(crate) fn trait_impls_in_deps_query(db: &dyn HirDatabase, krate: CrateId) -> Arc<Self> {
|
||||
|
@ -283,10 +280,7 @@ impl InherentImpls {
|
|||
Arc::new(impls)
|
||||
}
|
||||
|
||||
pub(crate) fn inherent_impls_in_block_query(
|
||||
db: &dyn HirDatabase,
|
||||
block: BlockId,
|
||||
) -> Option<Arc<Self>> {
|
||||
pub(crate) fn inherent_impls_in_block_query(db: &dyn HirDatabase, block: BlockId) -> Arc<Self> {
|
||||
let _p = profile::span("inherent_impls_in_block_query");
|
||||
let mut impls = Self { map: FxHashMap::default(), invalid_impls: Vec::default() };
|
||||
|
||||
|
@ -294,7 +288,7 @@ impl InherentImpls {
|
|||
impls.collect_def_map(db, &block_def_map);
|
||||
impls.shrink_to_fit();
|
||||
|
||||
Some(Arc::new(impls))
|
||||
Arc::new(impls)
|
||||
}
|
||||
|
||||
fn shrink_to_fit(&mut self) {
|
||||
|
@ -1178,18 +1172,17 @@ fn iterate_inherent_methods(
|
|||
};
|
||||
|
||||
while let Some(block_id) = block {
|
||||
if let Some(impls) = db.inherent_impls_in_block(block_id) {
|
||||
impls_for_self_ty(
|
||||
&impls,
|
||||
self_ty,
|
||||
table,
|
||||
name,
|
||||
receiver_ty,
|
||||
receiver_adjustments.clone(),
|
||||
module,
|
||||
callback,
|
||||
)?;
|
||||
}
|
||||
let impls = db.inherent_impls_in_block(block_id);
|
||||
impls_for_self_ty(
|
||||
&impls,
|
||||
self_ty,
|
||||
table,
|
||||
name,
|
||||
receiver_ty,
|
||||
receiver_adjustments.clone(),
|
||||
module,
|
||||
callback,
|
||||
)?;
|
||||
|
||||
block = db.block_def_map(block_id).parent().and_then(|module| module.containing_block());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue