Skip to main content

raise_rust_condition_via_stop

Function raise_rust_condition_via_stop 

Source
pub(crate) unsafe fn raise_rust_condition_via_stop(
    message: &str,
    class: Option<&str>,
    call: Option<SEXP>,
) -> !
Expand description

Raise an R condition with rust_* class layering by evaluating stop(structure(list(message = msg, call = call), class = c(...))).

This is Approach 3 from the issue-345 plan: the Rf_eval(stop(...)) pattern that works in any context where there is no outer R wrapper to inspect a tagged SEXP. It is the only viable option for ALTREP callbacks, which are invoked directly by R’s runtime (no .Call frame, no R wrapper).

The stop() call longjmps, so this function never returns — declared -> !.

§Class layering

  • If class is Some("my_class"), the resulting R condition has class: c("my_class", "rust_error", "simpleError", "error", "condition").
  • Without a custom class: c("rust_error", "simpleError", "error", "condition").

§MXL300 compliance

This function raises an R error via Rf_eval(stop(...)), not via direct Rf_error/Rf_errorcall. MXL300 does not flag Rf_eval.

§Safety

Must be called from R’s main thread inside an R_UnwindProtect cleanup or equivalent context where R longjmps are safe. In practice, always called from with_r_unwind_protect_sourced on the ALTREP guard path.