Skip to main content

expr_skip_clone

Function expr_skip_clone 

Source
pub fn expr_skip_clone(expr: &Expr, ectx: &EmitCtx) -> bool
Expand description

Should .clone() be skipped for this expression? True for: Copy types, last-use locals, globals/namespaces. False for: rc_wrapped, borrowed_params (need special clone paths).

For Expr::Ident: in Rust codegen, Ident is used for both globals AND locals (resolver doesn’t run). Check ectx to distinguish:

  • If name is in local_types → it’s a local/param, apply rc_wrapped/borrowed checks
  • If name is NOT in local_types → it’s a global/namespace, skip clone