From b6d72dbc69983545108b36856c92566414acd11f Mon Sep 17 00:00:00 2001
From: Jakub Doka <jakub.doka2@gmail.com>
Date: Wed, 19 Feb 2025 11:40:26 +0100
Subject: [PATCH] fixing nightly breaking changes

Signed-off-by: Jakub Doka <jakub.doka2@gmail.com>
---
 cranelift-backend/src/lib.rs      | 10 +++++-----
 cranelift-backend/src/x86_64.rs   |  2 +-
 depell/wasm-rt/src/lib.rs         |  2 +-
 lang/src/backend/hbvm.rs          |  2 +-
 lang/src/backend/hbvm/regalloc.rs |  4 ++--
 lang/src/lib.rs                   |  2 +-
 lang/src/ty.rs                    |  2 +-
 lang/src/utils.rs                 |  2 +-
 8 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/cranelift-backend/src/lib.rs b/cranelift-backend/src/lib.rs
index 418175be..203145f2 100644
--- a/cranelift-backend/src/lib.rs
+++ b/cranelift-backend/src/lib.rs
@@ -340,7 +340,7 @@ impl FuncBuilder<'_, '_> {
         let mut arg_vals = &self.bl.block_params(entry).to_vec()[..];
 
         if self.stack_ret {
-            let ret_ptr = *arg_vals.take_first().unwrap();
+            let ret_ptr = *arg_vals.split_off_first().unwrap();
             self.values[hbnodes::MEM as usize] = Some(Ok(ret_ptr));
         }
 
@@ -359,7 +359,7 @@ impl FuncBuilder<'_, '_> {
                     size: self.tys.size_of(ty),
                     align_shift: self.tys.align_of(ty).ilog2() as _,
                 });
-                let loc = arg_vals.take(..abi_meta.arg_count).unwrap();
+                let loc = arg_vals.split_off(..abi_meta.arg_count).unwrap();
                 assert!(loc.len() <= 2, "NEED handling");
                 let align =
                     loc.iter().map(|&p| self.bl.func.dfg.value_type(p).bytes()).max().unwrap();
@@ -371,7 +371,7 @@ impl FuncBuilder<'_, '_> {
                 self.values[arg as usize] =
                     Some(Ok(self.bl.ins().stack_addr(cir::types::I64, slot, 0)))
             } else {
-                let loc = arg_vals.take(..abi_meta.arg_count).unwrap();
+                let loc = arg_vals.split_off(..abi_meta.arg_count).unwrap();
                 debug_assert_eq!(loc.len(), 1);
                 self.values[arg as usize] = Some(Ok(loc[0]));
             }
@@ -608,7 +608,7 @@ impl FuncBuilder<'_, '_> {
                         }
                         let &arg = args.next().unwrap();
                         if !abi_meta.trough_mem && ty.is_aggregate(self.tys) {
-                            let loc = params.take(..abi_meta.arg_count).unwrap();
+                            let loc = params.split_off(..abi_meta.arg_count).unwrap();
                             assert!(loc.len() <= 2, "NEED handling");
                             let align = loc.iter().map(|&p| p.value_type.bytes()).max().unwrap();
                             let mut offset = 0i32;
@@ -624,7 +624,7 @@ impl FuncBuilder<'_, '_> {
                                 offset += align as i32;
                             }
                         } else {
-                            let loc = params.take(..abi_meta.arg_count).unwrap();
+                            let loc = params.split_off(..abi_meta.arg_count).unwrap();
                             debug_assert_eq!(loc.len(), 1);
                             ir_args.push(self.value_of(arg));
                         }
diff --git a/cranelift-backend/src/x86_64.rs b/cranelift-backend/src/x86_64.rs
index 9fcb4167..b232819a 100644
--- a/cranelift-backend/src/x86_64.rs
+++ b/cranelift-backend/src/x86_64.rs
@@ -138,7 +138,7 @@ fn classify_arg(
     }
 
     let size = cx.size_of(arg);
-    let n = ((size + 7) / 8) as usize;
+    let n = size.div_ceil(8) as usize;
     if n > MAX_EIGHTBYTES {
         return Err(Memory);
     }
diff --git a/depell/wasm-rt/src/lib.rs b/depell/wasm-rt/src/lib.rs
index f4bafd50..55c94d1e 100644
--- a/depell/wasm-rt/src/lib.rs
+++ b/depell/wasm-rt/src/lib.rs
@@ -152,7 +152,7 @@ pub struct Write<'a>(pub &'a mut [u8]);
 
 impl core::fmt::Write for Write<'_> {
     fn write_str(&mut self, s: &str) -> core::fmt::Result {
-        if let Some(m) = self.0.take_mut(..s.len()) {
+        if let Some(m) = self.0.split_off_mut(..s.len()) {
             m.copy_from_slice(s.as_bytes());
             Ok(())
         } else {
diff --git a/lang/src/backend/hbvm.rs b/lang/src/backend/hbvm.rs
index 1be31f01..7842fefc 100644
--- a/lang/src/backend/hbvm.rs
+++ b/lang/src/backend/hbvm.rs
@@ -447,7 +447,7 @@ impl Nodes {
                     || (matches!(self[n].kind, Kind::BinOp { op: TokenKind::Add })
                         && self.is_never_used(n, tys))
             }),
-            Kind::Load { .. } => node.ty.loc(tys) == Loc::Stack,
+            Kind::Load => node.ty.loc(tys) == Loc::Stack,
             _ => false,
         }
     }
diff --git a/lang/src/backend/hbvm/regalloc.rs b/lang/src/backend/hbvm/regalloc.rs
index 6140100b..89aaf2d1 100644
--- a/lang/src/backend/hbvm/regalloc.rs
+++ b/lang/src/backend/hbvm/regalloc.rs
@@ -27,7 +27,7 @@ impl HbvmBackend {
         let tail = FunctionBuilder::build(nodes, tys, &mut self.ralloc, sig);
 
         let strip_load = |value| match nodes[value].kind {
-            Kind::Load { .. } if nodes[value].ty.loc(tys) == Loc::Stack => nodes[value].inputs[1],
+            Kind::Load if nodes[value].ty.loc(tys) == Loc::Stack => nodes[value].inputs[1],
             _ => value,
         };
 
@@ -701,7 +701,7 @@ impl<'a> FunctionBuilder<'a> {
             | Kind::BinOp { .. }
             | Kind::UnOp { .. }
             | Kind::Global { .. }
-            | Kind::Load { .. }
+            | Kind::Load
             | Kind::Stre
             | Kind::RetVal
             | Kind::Stck => self.add_instr(nid),
diff --git a/lang/src/lib.rs b/lang/src/lib.rs
index ecdb1a2c..cdf27057 100644
--- a/lang/src/lib.rs
+++ b/lang/src/lib.rs
@@ -424,7 +424,7 @@ fn endoce_string(
 }
 
 pub fn quad_sort<T>(mut slice: &mut [T], mut cmp: impl FnMut(&T, &T) -> core::cmp::Ordering) {
-    while let Some(it) = slice.take_first_mut() {
+    while let Some(it) = slice.split_off_first_mut() {
         for ot in &mut *slice {
             if cmp(it, ot) == core::cmp::Ordering::Greater {
                 core::mem::swap(it, ot);
diff --git a/lang/src/ty.rs b/lang/src/ty.rs
index 22f19798..61c6ed49 100644
--- a/lang/src/ty.rs
+++ b/lang/src/ty.rs
@@ -1070,7 +1070,7 @@ impl Types {
                 self.ins.unions[union].size.set(size);
                 size
             }
-            Kind::Enum(enm) => (self.enum_field_range(enm).len().ilog2() + 7) / 8,
+            Kind::Enum(enm) => self.enum_field_range(enm).len().ilog2().div_ceil(8),
             Kind::Opt(opt) => {
                 let base = self.ins.opts[opt].base;
                 if self.nieche_of(base).is_some() {
diff --git a/lang/src/utils.rs b/lang/src/utils.rs
index 6c45399c..c08eaa60 100644
--- a/lang/src/utils.rs
+++ b/lang/src/utils.rs
@@ -277,7 +277,7 @@ impl Iterator for BitSetIter<'_> {
 
     fn next(&mut self) -> Option<Self::Item> {
         while self.current == 0 {
-            self.current = *self.remining.take_first()?;
+            self.current = *self.remining.split_off_first()?;
             self.index += 1;
         }