clippy: fix assigning_clones lint

https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#assigning_clones
This commit is contained in:
xtqqczze
2026-04-30 22:59:01 +02:00
committed by Sylvestre Ledru
parent b7072cb4a5
commit 60243b4fa7
2 changed files with 14 additions and 14 deletions
+7 -7
View File
@@ -120,7 +120,7 @@ fn patch_block_endings(head: Option<Rc<RefCell<Command>>>) {
}
// 3) splice the tails `.next` to splice_target
tail.borrow_mut().next = splice_target.clone();
tail.borrow_mut().next.clone_from(&splice_target);
}
// drop the borrow before moving on
@@ -140,7 +140,7 @@ fn populate_label_map(
mut cur: Option<Rc<RefCell<Command>>>,
context: &mut ProcessingContext,
) -> UResult<()> {
while let Some(rc_cmd) = cur {
while let Some(rc_cmd) = cur.take() {
// Borrow mutably just long enough to inspect/rewire this node
let cmd = rc_cmd.borrow_mut();
@@ -163,14 +163,14 @@ fn populate_label_map(
context.label_to_command_map.insert(label, rc_cmd.clone());
}
cur = cmd.next.clone();
cur.clone_from(&cmd.next);
}
Ok(())
}
/// Populate the context's address range command list with references to associated commands.
fn populate_range_commands(mut cur: Option<Rc<RefCell<Command>>>, context: &mut ProcessingContext) {
while let Some(rc_cmd) = cur {
while let Some(rc_cmd) = cur.take() {
// Borrow mutably just long enough to inspect/rewire this node
let cmd = rc_cmd.borrow_mut();
@@ -184,7 +184,7 @@ fn populate_range_commands(mut cur: Option<Rc<RefCell<Command>>>, context: &mut
context.range_commands.push(Rc::clone(&rc_cmd));
}
cur = cmd.next.clone();
cur.clone_from(&cmd.next);
}
}
@@ -194,7 +194,7 @@ fn resolve_branch_targets(
mut cur: Option<Rc<RefCell<Command>>>,
context: &mut ProcessingContext,
) -> UResult<()> {
while let Some(rc_cmd) = cur {
while let Some(rc_cmd) = cur.take() {
// Borrow mutably just long enough to inspect/rewire this node
let mut cmd = rc_cmd.borrow_mut();
@@ -233,7 +233,7 @@ fn resolve_branch_targets(
}
// Advance to the next sibling
cur = cmd.next.clone();
cur.clone_from(&cmd.next);
}
Ok(())
}
+7 -7
View File
@@ -444,12 +444,12 @@ fn process_file(
};
// Loop over script commands.
while let Some(command_rc) = current {
while let Some(command_rc) = current.take() {
let mut command = command_rc.borrow_mut();
if !applies(&mut command, reader, &mut pattern, context)? {
// Advance to next command
current = command.next.clone();
current.clone_from(&command.next);
continue;
}
@@ -457,7 +457,7 @@ fn process_file(
'{' => {
// Block begin; start processing the enclosed ones.
let body = extract_variant!(command, BranchTarget);
current = body.clone();
current.clone_from(body);
continue;
}
'}' => {
@@ -475,7 +475,7 @@ fn process_file(
let target = extract_variant!(command, BranchTarget);
if target.is_some() {
// New command to execute
current = target.clone();
current.clone_from(target);
continue;
} else {
// Branch to the end of the script.
@@ -502,7 +502,7 @@ fn process_file(
if let Some(pos) = pattern.as_str()?.find('\n') {
let (s, _) = pattern.fields_mut()?;
s.drain(..=pos);
current = commands.clone();
current.clone_from(&commands);
continue;
} else {
// Same as d
@@ -598,7 +598,7 @@ fn process_file(
context.substitution_made = false;
if target.is_some() {
// New command to execute
current = target.clone();
current.clone_from(target);
continue;
} else {
// Branch to the end of the script.
@@ -635,7 +635,7 @@ fn process_file(
_ => panic!("invalid command code"),
} // match
// Advance to next command.
current = command.next.clone();
current.clone_from(&command.next);
}
if !context.quiet {