Rust 1.95 promoted collapsible_match and map_unwrap_or; CI runs -D warnings so they break the build. Collapse nested `if`s into match guards across codegen/optimizer/export, and swap map().unwrap_or(..) for map_or / is_ok_and.
This commit is contained in:
+22
-24
@@ -2012,14 +2012,12 @@ fn emit_promoted_op(f: &mut Function, op: &IrOp, sim: &mut StackSim) {
|
||||
// Outside loops, RFetch shouldn't appear in promoted code
|
||||
}
|
||||
|
||||
IrOp::LoopJ => {
|
||||
if sim.loop_index_stack.len() >= 2 {
|
||||
let (outer_index, _) = sim.loop_index_stack[sim.loop_index_stack.len() - 2];
|
||||
let result = sim.alloc();
|
||||
f.instruction(&Instruction::LocalGet(outer_index));
|
||||
f.instruction(&Instruction::LocalSet(result));
|
||||
sim.push(result);
|
||||
}
|
||||
IrOp::LoopJ if sim.loop_index_stack.len() >= 2 => {
|
||||
let (outer_index, _) = sim.loop_index_stack[sim.loop_index_stack.len() - 2];
|
||||
let result = sim.alloc();
|
||||
f.instruction(&Instruction::LocalGet(outer_index));
|
||||
f.instruction(&Instruction::LocalSet(result));
|
||||
sim.push(result);
|
||||
}
|
||||
|
||||
IrOp::Exit => {
|
||||
@@ -2147,15 +2145,15 @@ fn needs_f64_locals(ops: &[IrOp]) -> bool {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
IrOp::DoLoop { body, .. } | IrOp::BeginUntil { body } | IrOp::BeginAgain { body } => {
|
||||
if needs_f64_locals(body) {
|
||||
return true;
|
||||
}
|
||||
IrOp::DoLoop { body, .. } | IrOp::BeginUntil { body } | IrOp::BeginAgain { body }
|
||||
if needs_f64_locals(body) =>
|
||||
{
|
||||
return true;
|
||||
}
|
||||
IrOp::BeginWhileRepeat { test, body } => {
|
||||
if needs_f64_locals(test) || needs_f64_locals(body) {
|
||||
return true;
|
||||
}
|
||||
IrOp::BeginWhileRepeat { test, body }
|
||||
if needs_f64_locals(test) || needs_f64_locals(body) =>
|
||||
{
|
||||
return true;
|
||||
}
|
||||
IrOp::BeginDoubleWhileRepeat {
|
||||
outer_test,
|
||||
@@ -2209,15 +2207,15 @@ fn body_needs_return_stack(ops: &[IrOp]) -> bool {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
IrOp::DoLoop { body, .. } | IrOp::BeginUntil { body } | IrOp::BeginAgain { body } => {
|
||||
if body_needs_return_stack(body) {
|
||||
return true;
|
||||
}
|
||||
IrOp::DoLoop { body, .. } | IrOp::BeginUntil { body } | IrOp::BeginAgain { body }
|
||||
if body_needs_return_stack(body) =>
|
||||
{
|
||||
return true;
|
||||
}
|
||||
IrOp::BeginWhileRepeat { test, body } => {
|
||||
if body_needs_return_stack(test) || body_needs_return_stack(body) {
|
||||
return true;
|
||||
}
|
||||
IrOp::BeginWhileRepeat { test, body }
|
||||
if body_needs_return_stack(test) || body_needs_return_stack(body) =>
|
||||
{
|
||||
return true;
|
||||
}
|
||||
IrOp::BeginDoubleWhileRepeat {
|
||||
outer_test,
|
||||
|
||||
@@ -131,10 +131,8 @@ pub fn export_module(
|
||||
fn collect_external_calls(ops: &[IrOp], ir_ids: &HashSet<WordId>, host_ids: &mut HashSet<WordId>) {
|
||||
for op in ops {
|
||||
match op {
|
||||
IrOp::Call(id) | IrOp::TailCall(id) => {
|
||||
if !ir_ids.contains(id) {
|
||||
host_ids.insert(*id);
|
||||
}
|
||||
IrOp::Call(id) | IrOp::TailCall(id) if !ir_ids.contains(id) => {
|
||||
host_ids.insert(*id);
|
||||
}
|
||||
IrOp::If {
|
||||
then_body,
|
||||
|
||||
@@ -591,15 +591,15 @@ fn contains_call_to(ops: &[IrOp], target: WordId) -> bool {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
IrOp::DoLoop { body, .. } | IrOp::BeginUntil { body } | IrOp::BeginAgain { body } => {
|
||||
if contains_call_to(body, target) {
|
||||
return true;
|
||||
}
|
||||
IrOp::DoLoop { body, .. } | IrOp::BeginUntil { body } | IrOp::BeginAgain { body }
|
||||
if contains_call_to(body, target) =>
|
||||
{
|
||||
return true;
|
||||
}
|
||||
IrOp::BeginWhileRepeat { test, body } => {
|
||||
if contains_call_to(test, target) || contains_call_to(body, target) {
|
||||
return true;
|
||||
}
|
||||
IrOp::BeginWhileRepeat { test, body }
|
||||
if contains_call_to(test, target) || contains_call_to(body, target) =>
|
||||
{
|
||||
return true;
|
||||
}
|
||||
IrOp::BeginDoubleWhileRepeat {
|
||||
outer_test,
|
||||
@@ -651,15 +651,13 @@ fn contains_exit(ops: &[IrOp]) -> bool {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
IrOp::DoLoop { body, .. } | IrOp::BeginUntil { body } | IrOp::BeginAgain { body } => {
|
||||
if contains_exit(body) {
|
||||
return true;
|
||||
}
|
||||
IrOp::DoLoop { body, .. } | IrOp::BeginUntil { body } | IrOp::BeginAgain { body }
|
||||
if contains_exit(body) =>
|
||||
{
|
||||
return true;
|
||||
}
|
||||
IrOp::BeginWhileRepeat { test, body } => {
|
||||
if contains_exit(test) || contains_exit(body) {
|
||||
return true;
|
||||
}
|
||||
IrOp::BeginWhileRepeat { test, body } if contains_exit(test) || contains_exit(body) => {
|
||||
return true;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
@@ -397,8 +397,7 @@ impl<R: Runtime> ForthVM<R> {
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
let seed = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.map(|d| d.as_nanos() as u64)
|
||||
.unwrap_or(0xDEAD_BEEF_CAFE_BABE);
|
||||
.map_or(0xDEAD_BEEF_CAFE_BABE, |d| d.as_nanos() as u64);
|
||||
Arc::new(Mutex::new(if seed == 0 {
|
||||
0xDEAD_BEEF_CAFE_BABE
|
||||
} else {
|
||||
|
||||
@@ -26,8 +26,7 @@ fn probe_gforth(candidate: &str) -> bool {
|
||||
.arg("-e")
|
||||
.arg("bye")
|
||||
.output()
|
||||
.map(|o| o.status.success())
|
||||
.unwrap_or(false)
|
||||
.is_ok_and(|o| o.status.success())
|
||||
}
|
||||
|
||||
fn find_gforth() -> Option<&'static str> {
|
||||
|
||||
Reference in New Issue
Block a user