Function clippy_utils::find_binding_init

source ยท
pub fn find_binding_init<'tcx>(
    cx: &LateContext<'tcx>,
    hir_id: HirId,
) -> Option<&'tcx Expr<'tcx>>
Expand description

Finds the initializer expression for a local binding. Returns None if the binding is mutable.

By only considering immutable bindings, we guarantee that the returned expression represents the value of the binding wherever it is referenced.

Example: For let x = 1, if the HirId of x is provided, the Expr 1 is returned. Note: If you have an expression that references a binding x, use path_to_local to get the canonical binding HirId.