Fix #2123 : check that the source and destination are different for manual memcpy
This commit is contained in:
parent
4d9ed8beef
commit
dfa4cb7ade
@ -749,7 +749,14 @@ fn get_indexed_assignments<'a, 'tcx>(
|
||||
) -> Option<(FixedOffsetVar, FixedOffsetVar)> {
|
||||
if let Expr_::ExprAssign(ref lhs, ref rhs) = e.node {
|
||||
match (get_fixed_offset_var(cx, lhs, var), fetch_cloned_fixed_offset_var(cx, rhs, var)) {
|
||||
(Some(offset_left), Some(offset_right)) => Some((offset_left, offset_right)),
|
||||
(Some(offset_left), Some(offset_right)) => {
|
||||
// Source and destination must be different
|
||||
if offset_left.var_name != offset_right.var_name {
|
||||
Some((offset_left, offset_right))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
} else {
|
||||
|
@ -548,3 +548,11 @@ pub fn manual_clone(src: &[String], dst: &mut [String]) {
|
||||
dst[i] = src[i].clone();
|
||||
}
|
||||
}
|
||||
|
||||
#[warn(needless_range_loop)]
|
||||
pub fn manual_copy_same_destination(dst: &mut [i32], d: usize, s: usize) {
|
||||
// Same source and destination - don't trigger lint
|
||||
for i in 0..dst.len() {
|
||||
dst[d + i] = dst[s + i];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user