fn generate_method_shim(
trait_name: &Ident,
method: &MethodInfo,
extra_bounds: &ExtraBounds,
trait_param_idents: &[&Ident],
trait_type_params: &[&GenericParam],
trait_where_clause: &Option<WhereClause>,
) -> TokenStreamExpand description
Generate a method shim function for a trait method.
The shim is an extern "C" function that, inside with_r_unwind_protect_shim:
- Checks argument arity
- Refuses aliased native borrows among the arguments
- Converts SEXP arguments to Rust types
- Calls the actual method on the concrete type
- Converts the result back to SEXP
A panic in any step comes back as a tagged condition SEXP, which the View
re-panics with. generate_concrete_vtable_shims emits the same steps for
a generic trait’s impls.
For generic traits, the shim carries the trait’s type parameters plus __ImplT.