aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_expand/src
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2020-08-10 22:55:57 +0100
committerKirill Bulatov <[email protected]>2020-08-11 13:09:08 +0100
commitc8cad76d25f7fab856c9646b70122e0f9f7d7218 (patch)
tree67091cef7037bbde1fc0d2da599562775a954f49 /crates/ra_hir_expand/src
parent29fbc8e02180aac1f4d7819a9626206aa64028a0 (diff)
Improve the ide diagnostics trait API
Diffstat (limited to 'crates/ra_hir_expand/src')
-rw-r--r--crates/ra_hir_expand/src/diagnostics.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/crates/ra_hir_expand/src/diagnostics.rs b/crates/ra_hir_expand/src/diagnostics.rs
index 8358c488b..e58defa68 100644
--- a/crates/ra_hir_expand/src/diagnostics.rs
+++ b/crates/ra_hir_expand/src/diagnostics.rs
@@ -72,9 +72,12 @@ impl<'a> DiagnosticSinkBuilder<'a> {
72 self 72 self
73 } 73 }
74 74
75 pub fn on<D: Diagnostic, F: FnMut(&D) -> Option<()> + 'a>(mut self, mut cb: F) -> Self { 75 pub fn on<D: Diagnostic, F: FnMut(&D) + 'a>(mut self, mut cb: F) -> Self {
76 let cb = move |diag: &dyn Diagnostic| match diag.as_any().downcast_ref::<D>() { 76 let cb = move |diag: &dyn Diagnostic| match diag.as_any().downcast_ref::<D>() {
77 Some(d) => cb(d).ok_or(()), 77 Some(d) => {
78 cb(d);
79 Ok(())
80 }
78 None => Err(()), 81 None => Err(()),
79 }; 82 };
80 self.callbacks.push(Box::new(cb)); 83 self.callbacks.push(Box::new(cb));