Skip to content

Commit cdfe5a8

Browse files
committed
fix: no more Registering progress handler for token rustAnalyzer/Indexing failed.
1 parent ad13104 commit cdfe5a8

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

crates/ide/src/prime_caches.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pub(crate) fn prime_caches(db: &RootDatabase, cb: &(dyn Fn(PrimeCachesProgress)
2727
let topo = &graph.crates_in_topological_order();
2828

2929
cb(PrimeCachesProgress::Started);
30+
let _d = stdx::defer(|| cb(PrimeCachesProgress::Finished));
3031

3132
// FIXME: This would be easy to parallelize, since it's in the ideal ordering for that.
3233
// Unfortunately rayon prevents panics from propagation out of a `scope`, which breaks
@@ -41,6 +42,4 @@ pub(crate) fn prime_caches(db: &RootDatabase, cb: &(dyn Fn(PrimeCachesProgress)
4142
});
4243
db.crate_def_map(*krate);
4344
}
44-
45-
cb(PrimeCachesProgress::Finished);
4645
}

crates/stdx/src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,18 @@ where
179179
start..start + len
180180
}
181181

182+
pub fn defer<F: FnOnce()>(f: F) -> impl Drop {
183+
struct D<F: FnOnce()>(Option<F>);
184+
impl<F: FnOnce()> Drop for D<F> {
185+
fn drop(&mut self) {
186+
if let Some(f) = self.0.take() {
187+
f()
188+
}
189+
}
190+
}
191+
D(Some(f))
192+
}
193+
182194
#[repr(transparent)]
183195
pub struct JodChild(pub std::process::Child);
184196

0 commit comments

Comments
 (0)