Skip to content

Commit 2f0e7af

Browse files
committed
Clean up unnecessary loop
1 parent 919d71d commit 2f0e7af

File tree

1 file changed

+5
-15
lines changed
  • crates/rune/src/runtime

1 file changed

+5
-15
lines changed

crates/rune/src/runtime/vm.rs

+5-15
Original file line numberDiff line numberDiff line change
@@ -1250,8 +1250,7 @@ impl Vm {
12501250
});
12511251
}
12521252

1253-
let value = vm_try!(self.stack.pop());
1254-
vm_try!(<()>::from_value(value));
1253+
vm_try!(<()>::from_value(vm_try!(self.stack.pop())));
12551254
VmResult::Ok(())
12561255
}
12571256
}
@@ -1444,8 +1443,7 @@ impl Vm {
14441443

14451444
#[cfg_attr(feature = "bench", inline(never))]
14461445
fn op_await(&mut self) -> VmResult<Shared<Future>> {
1447-
let value = vm_try!(self.stack.pop());
1448-
value.into_future()
1446+
vm_try!(self.stack.pop()).into_future()
14491447
}
14501448

14511449
#[cfg_attr(feature = "bench", inline(never))]
@@ -1945,9 +1943,7 @@ impl Vm {
19451943
let target = vm_try!(self.stack.pop());
19461944
let value = vm_try!(self.stack.pop());
19471945

1948-
// This is a useful pattern.
1949-
#[allow(clippy::never_loop)]
1950-
loop {
1946+
'out: {
19511947
// NB: local storage for string.
19521948
let local_field;
19531949

@@ -1957,7 +1953,7 @@ impl Vm {
19571953
local_field.as_str()
19581954
}
19591955
Value::StaticString(string) => string.as_ref(),
1960-
_ => break,
1956+
_ => break 'out,
19611957
};
19621958

19631959
match &target {
@@ -1994,9 +1990,7 @@ impl Vm {
19941990
target: variant.type_info(),
19951991
});
19961992
}
1997-
_ => {
1998-
break;
1999-
}
1993+
_ => {}
20001994
}
20011995
}
20021996

@@ -2010,8 +2004,6 @@ impl Vm {
20102004
});
20112005
}
20122006

2013-
// Calling index set should not produce a value on the stack, but all
2014-
// handler functions to produce a value. So pop it here.
20152007
vm_try!(<()>::from_value(vm_try!(self.stack.pop())));
20162008
VmResult::Ok(())
20172009
}
@@ -3048,12 +3040,10 @@ impl Vm {
30483040
}
30493041
Inst::Await => {
30503042
let future = vm_try!(self.op_await());
3051-
// NB: the future itself will advance the virtual machine.
30523043
return VmResult::Ok(VmHalt::Awaited(Awaited::Future(future)));
30533044
}
30543045
Inst::Select { len } => {
30553046
if let Some(select) = vm_try!(self.op_select(len)) {
3056-
// NB: the future itself will advance the virtual machine.
30573047
return VmResult::Ok(VmHalt::Awaited(Awaited::Select(select)));
30583048
}
30593049
}

0 commit comments

Comments
 (0)