annotate_mut_binding_to_immutable_binding

Function annotate_mut_binding_to_immutable_binding 

Source
fn annotate_mut_binding_to_immutable_binding<'tcx>(
    tcx: TyCtxt<'tcx>,
    place: PlaceRef<'tcx>,
    body_def_id: LocalDefId,
    assignment_span: Span,
    body: &Body<'tcx>,
) -> Option<UnusedAssignSuggestion>
Expand description

Detect the following case

fn change_object(mut a: &Ty) {
    let a = Ty::new();
    b = &a;
}

where the user likely meant to modify the value behind there reference, use a as an out parameter, instead of mutating the local binding. When encountering this we suggest:

fn change_object(a: &'_ mut Ty) {
    let a = Ty::new();
    *b = a;
}