Add new LintBuffer::dyn_buffer_lint method

This commit is contained in:
Guillaume Gomez
2026-03-22 18:34:43 +01:00
parent e52f547ed4
commit faddfb5001
@@ -81,4 +81,21 @@ pub fn buffer_lint(
diagnostic: decorate.into(),
});
}
pub fn dyn_buffer_lint<
F: for<'a> FnOnce(DiagCtxtHandle<'a>, Level) -> Diag<'a, ()> + DynSend + 'static,
>(
&mut self,
lint: &'static Lint,
node_id: NodeId,
span: impl Into<MultiSpan>,
callback: F,
) {
self.add_early_lint(BufferedEarlyLint {
lint_id: LintId::of(lint),
node_id,
span: Some(span.into()),
diagnostic: DecorateDiagCompat::Dynamic(Box::new(callback)),
});
}
}