1//! Direct `Rf_error`/`Rf_errorcall` usage lint.
2//!
3//! - MXL300: Warns on direct `Rf_error`/`Rf_errorcall` calls in user code.
4//! These longjmp through Rust frames, bypassing destructors unless wrapped in
5//! `R_UnwindProtect`. Prefer `panic!()` or `Err(...)` which produce structured
6//! R condition objects via the tagged-condition transport.
78use crate::crate_index::CrateIndex;
9use crate::diagnostic::Diagnostic;
10use crate::lint_code::LintCode;
1112pub fn check(index: &CrateIndex, diagnostics: &mut Vec<Diagnostic>) {
13for (path, data) in &index.file_data {
14for (fn_name, line) in &data.rf_error_calls {
15 diagnostics.push(
16 Diagnostic::new(
17 LintCode::MXL300,
18 path,
19*line,
20::alloc::__export::must_use({
::alloc::fmt::format(format_args!("Direct `{0}()` call. This longjmps through Rust frames and may skip destructors.",
fn_name))
})format!(
21"Direct `{}()` call. This longjmps through Rust frames \
22 and may skip destructors.",
23 fn_name,
24 ),
25 )
26 .with_help(
27"Use `panic!()` for unrecoverable errors or return `Err(...)` for \
28 Result types. These produce structured R condition objects via \
29 the tagged-condition transport.",
30 ),
31 );
32 }
33 }
34}