Fix manual_map: don't lint when partially moved values are used.

Fix `manual_map`: don't lint when `return`, `break`, and `continue` are used.
This commit is contained in:
Jason Newcomb
2021-02-26 11:50:12 -05:00
parent 6343446b89
commit ef87e58993
5 changed files with 168 additions and 22 deletions

View File

@@ -456,6 +456,18 @@ pub fn has_drop<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
}
}
/// Checks whether a type can be partially moved.
pub fn can_partially_move_ty(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
if has_drop(cx, ty) || is_copy(cx, ty) {
return false;
}
match ty.kind() {
ty::Param(_) => false,
ty::Adt(def, subs) => def.all_fields().any(|f| !is_copy(cx, f.ty(cx.tcx, subs))),
_ => true,
}
}
/// Returns the method names and argument list of nested method call expressions that make up
/// `expr`. method/span lists are sorted with the most recent call first.
pub fn method_calls<'tcx>(