Skip to content

Commit 3a67ccd

Browse files
committed
fix: resolve massive syntax errors across wrt-sync and wrt-platform
- Fixed missing closing parentheses in wrt-sync unified_sync.rs and verify.rs - Fixed syntax errors in wrt-sync test files (kani_proofs.rs, no_std_test_reference.rs) - Fixed wrt-platform lib.rs panic handler and test function syntax - Fixed wrt-platform comprehensive_limits.rs constructor and assertion syntax - Partially fixed memory.rs syntax errors This resolves the cargo-wrt build blocking syntax errors introduced by previous global sed operations. Progress toward full compilation.
1 parent 3528e02 commit 3a67ccd

File tree

18 files changed

+692
-691
lines changed

18 files changed

+692
-691
lines changed

cargo-wrt/src/main.rs

Lines changed: 186 additions & 186 deletions
Large diffs are not rendered by default.

wrt-foundation/src/atomic_memory.rs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ impl<P: Provider + Clone> Clone for AtomicMemoryOps<P> {
4949
impl<P: Provider + PartialEq> PartialEq for AtomicMemoryOps<P> {
5050
fn eq(&self, other: &Self) -> bool {
5151
// Compare the underlying handlers (requires locking both)
52-
let self_handler = self.handler.lock);
53-
let other_handler = other.handler.lock);
52+
let self_handler = self.handler.lock();
53+
let other_handler = other.handler.lock();
5454
*self_handler == *other_handler && self.verification_level == other.verification_level
5555
}
5656
}
@@ -62,7 +62,7 @@ impl<P: Provider> AtomicMemoryOps<P> {
6262
///
6363
/// This wraps the handler in a mutex to ensure atomic operations.
6464
pub fn new(handler: SafeMemoryHandler<P>) -> Self {
65-
let verification_level = handler.verification_level);
65+
let verification_level = handler.verification_level();
6666
Self { handler: WrtMutex::new(handler), verification_level }
6767
}
6868

@@ -74,8 +74,8 @@ impl<P: Provider> AtomicMemoryOps<P> {
7474
where
7575
P: Sized + Clone,
7676
{
77-
let handler = SafeMemoryHandler::new(provider;
78-
let verification_level = handler.verification_level);
77+
let handler = SafeMemoryHandler::new(provider)?;
78+
let verification_level = handler.verification_level();
7979
Ok(Self { handler: WrtMutex::new(handler), verification_level })
8080
}
8181

@@ -92,8 +92,8 @@ impl<P: Provider> AtomicMemoryOps<P> {
9292
#[cfg(feature = "std")]
9393
pub fn read_data(&self, offset: usize, len: usize) -> Result<Vec<u8>> {
9494
// Lock the handler for atomic access
95-
let handler = self.handler.lock);
96-
record_global_operation(OperationType::MemoryRead, self.verification_level;
95+
let handler = self.handler.lock();
96+
record_global_operation(OperationType::MemoryRead, self.verification_level);
9797

9898
// Get the slice and copy the data to avoid lifetime issues
9999
let slice = handler.borrow_slice(offset, len)?;
@@ -119,8 +119,8 @@ impl<P: Provider> AtomicMemoryOps<P> {
119119
/// verification fails.
120120
pub fn atomic_write_with_checksum(&self, offset: usize, data: &[u8]) -> Result<()> {
121121
// Lock the handler for atomic access with Acquire ordering
122-
let mut handler = self.handler.lock);
123-
record_global_operation(OperationType::MemoryWrite, self.verification_level;
122+
let mut handler = self.handler.lock();
123+
record_global_operation(OperationType::MemoryWrite, self.verification_level);
124124

125125
// Verify that the access is valid
126126
handler.verify_access(offset, data.len())?;
@@ -132,11 +132,11 @@ impl<P: Provider> AtomicMemoryOps<P> {
132132
let slice_data = slice.data_mut()?;
133133

134134
// Copy the data while holding the lock
135-
slice_data.copy_from_slice(data;
135+
slice_data.copy_from_slice(data);
136136

137137
// Update the checksum while still holding the lock
138138
// This ensures no bit flips can occur between write and checksum update
139-
slice.update_checksum);
139+
slice.update_checksum();
140140

141141
// Lock is released automatically when handler goes out of scope
142142

@@ -157,8 +157,8 @@ impl<P: Provider> AtomicMemoryOps<P> {
157157
len: usize,
158158
) -> Result<()> {
159159
// Lock the handler for atomic access
160-
let mut handler = self.handler.lock);
161-
record_global_operation(OperationType::MemoryCopy, self.verification_level;
160+
let mut handler = self.handler.lock();
161+
record_global_operation(OperationType::MemoryCopy, self.verification_level);
162162

163163
// Verify that the source access is valid
164164
handler.verify_access(src_offset, len)?;
@@ -179,15 +179,15 @@ impl<P: Provider> AtomicMemoryOps<P> {
179179
{
180180
let source_slice = handler.borrow_slice(src_offset + src_pos, chunk_size)?;
181181
let source_data = source_slice.data()?;
182-
buffer[..chunk_size].copy_from_slice(&source_data[..chunk_size];
182+
buffer[..chunk_size].copy_from_slice(&source_data[..chunk_size]);
183183
} // source_slice is dropped here, releasing immutable borrow
184184

185185
// Write to the destination atomically with checksum update
186186
let mut dst_slice =
187187
handler.provider_mut().get_slice_mut(dst_offset + dst_pos, chunk_size)?;
188188
let dst_data = dst_slice.data_mut()?;
189-
dst_data.copy_from_slice(&buffer[..chunk_size];
190-
dst_slice.update_checksum);
189+
dst_data.copy_from_slice(&buffer[..chunk_size]);
190+
dst_slice.update_checksum();
191191

192192
remaining -= chunk_size;
193193
src_pos += chunk_size;
@@ -208,19 +208,19 @@ impl<P: Provider> AtomicMemoryOps<P> {
208208
/// underlying provider.
209209
pub fn set_verification_level(&mut self, level: VerificationLevel) {
210210
self.verification_level = level;
211-
let mut handler = self.handler.lock);
212-
handler.set_verification_level(level;
211+
let mut handler = self.handler.lock();
212+
handler.set_verification_level(level);
213213
}
214214

215215
/// Gets the underlying memory provider's size.
216216
pub fn size(&self) -> usize {
217-
let handler = self.handler.lock);
217+
let handler = self.handler.lock();
218218
handler.size()
219219
}
220220

221221
/// Gets the underlying memory provider's capacity.
222222
pub fn capacity(&self) -> usize {
223-
let handler = self.handler.lock);
223+
let handler = self.handler.lock();
224224
handler.capacity()
225225
}
226226

@@ -242,7 +242,7 @@ impl<P: Provider> AtomicMemoryOps<P> {
242242
///
243243
/// Returns an error if an integrity violation is detected.
244244
pub fn verify_integrity(&self) -> Result<()> {
245-
let handler = self.handler.lock);
245+
let handler = self.handler.lock();
246246
handler.provider().verify_integrity()
247247
}
248248
}
@@ -288,13 +288,13 @@ mod tests {
288288

289289
#[cfg(not(feature = "std"))]
290290
let read_data = {
291-
let handler = atomic_ops.handler.lock);
291+
let handler = atomic_ops.handler.lock();
292292
let slice = handler.borrow_slice(0, test_data.len()).unwrap();
293293
slice.data().unwrap()
294294
};
295295

296296
// Verify the data
297-
assert_eq!(read_data, &test_data;
297+
assert_eq!(read_data, &test_data);
298298
Ok(())
299299
}
300300

@@ -314,14 +314,14 @@ mod tests {
314314
atomic_ops.atomic_write_with_checksum(0, &test_data).unwrap();
315315

316316
// Verify integrity explicitly at both provider and slice levels
317-
let handler = atomic_ops.handler.lock);
318-
assert!(handler.provider().verify_integrity().is_ok();
317+
let handler = atomic_ops.handler.lock();
318+
assert!(handler.provider().verify_integrity().is_ok());
319319

320320
// Access the internal slice to check its checksum
321321
let slice = handler.borrow_slice(0, test_data.len()).unwrap();
322322

323323
// Verify integrity of the slice, which internally compares checksums
324-
assert!(slice.verify_integrity().is_ok();
324+
assert!(slice.verify_integrity().is_ok());
325325
Ok(())
326326
}
327327

@@ -349,13 +349,13 @@ mod tests {
349349

350350
#[cfg(not(feature = "std"))]
351351
let read_data = {
352-
let handler = atomic_ops.handler.lock);
352+
let handler = atomic_ops.handler.lock();
353353
let slice = handler.borrow_slice(20, 5).unwrap();
354354
slice.data().unwrap()
355355
};
356356

357357
// Verify the data was copied correctly
358-
assert_eq!(read_data, &[3, 4, 5, 6, 7];
358+
assert_eq!(read_data, &[3, 4, 5, 6, 7]);
359359
Ok(())
360360
}
361361
}

wrt-foundation/src/bounded.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ pub const MAX_TYPE_ENUM_NAMES: usize = 64;
115115
const MAX_ITEM_SERIALIZED_SIZE: usize = 256;
116116

117117
/// Size of the checksum in bytes, typically the size of a u32.
118-
pub const CHECKSUM_SIZE: usize = core::mem::size_of::<u32>);
118+
pub const CHECKSUM_SIZE: usize = core::mem::size_of::<u32>();
119119

120120
#[cfg(feature = "std")]
121121
extern crate alloc;
@@ -565,7 +565,7 @@ where
565565
provider_arg: P,
566566
level: VerificationLevel,
567567
) -> Result<Self> {
568-
let item_serialized_size = T::default().serialized_size);
568+
let item_serialized_size = T::default().serialized_size();
569569
if item_serialized_size == 0 && N_ELEMENTS > 0 {
570570
// Prevent division by zero or logical errors if N_ELEMENTS > 0 but items are
571571
// ZSTs. Or, if this is allowed, ensure memory_needed is handled
@@ -606,7 +606,7 @@ where
606606
let offset = self.length.saturating_mul(self.item_serialized_size;
607607
let mut item_bytes_buffer = [0u8; MAX_ITEM_SERIALIZED_SIZE];
608608

609-
let item_size = item.serialized_size);
609+
let item_size = item.serialized_size();
610610
if item_size > MAX_ITEM_SERIALIZED_SIZE {
611611
return Err(BoundedError::new(
612612
BoundedErrorKind::ItemTooLarge,
@@ -975,7 +975,7 @@ where
975975
/// Assumes all instances of T will have the same serialized size as
976976
/// T::default().
977977
pub fn new(provider_arg: P) -> Result<Self> {
978-
let item_s_size = T::default().serialized_size);
978+
let item_s_size = T::default().serialized_size();
979979
if item_s_size == 0 && N_ELEMENTS > 0 {
980980
return Err(crate::Error::runtime_execution_error("Item serialized size cannot be zero with non-zero capacity";
981981
}
@@ -999,7 +999,7 @@ where
999999
provider_arg: P, // Renamed provider to provider_arg
10001000
verification_level: VerificationLevel,
10011001
) -> Result<Self> {
1002-
let item_size = T::default().serialized_size);
1002+
let item_size = T::default().serialized_size();
10031003
if item_size == 0 && N_ELEMENTS > 0 {
10041004
return Err(crate::Error::foundation_bounded_capacity_exceeded(
10051005
"Item serialized size cannot be zero with non-zero capacity"
@@ -1048,7 +1048,7 @@ where
10481048
let offset = self.length.saturating_mul(self.item_serialized_size;
10491049
let mut item_bytes_buffer = [0u8; MAX_ITEM_SERIALIZED_SIZE];
10501050

1051-
let item_size = item.serialized_size);
1051+
let item_size = item.serialized_size();
10521052
if item_size > MAX_ITEM_SERIALIZED_SIZE {
10531053
return Err(BoundedError::runtime_execution_error("Operation failed";
10541054
}
@@ -1509,7 +1509,7 @@ where
15091509

15101510
// Serialize the new value
15111511
let mut item_bytes_buffer = [0u8; MAX_ITEM_SERIALIZED_SIZE];
1512-
let item_size = value.serialized_size);
1512+
let item_size = value.serialized_size();
15131513

15141514
if item_size > MAX_ITEM_SERIALIZED_SIZE {
15151515
return Err(BoundedError::new(
@@ -1615,7 +1615,7 @@ where
16151615
// Move it one position forward
16161616
let dest_offset = (i + 1) * self.item_serialized_size;
16171617
let mut item_bytes_buffer = [0u8; MAX_ITEM_SERIALIZED_SIZE];
1618-
let item_size = current_item.serialized_size);
1618+
let item_size = current_item.serialized_size();
16191619

16201620
if item_size > MAX_ITEM_SERIALIZED_SIZE {
16211621
return Err(BoundedError::new(
@@ -1649,7 +1649,7 @@ where
16491649
// Now write the new value at the specified index
16501650
let offset = index * self.item_serialized_size;
16511651
let mut item_bytes_buffer = [0u8; MAX_ITEM_SERIALIZED_SIZE];
1652-
let item_size = value.serialized_size);
1652+
let item_size = value.serialized_size();
16531653

16541654
if item_size > MAX_ITEM_SERIALIZED_SIZE {
16551655
return Err(BoundedError::new(
@@ -1759,7 +1759,7 @@ where
17591759
// Write it at the current position
17601760
let dest_offset = i * self.item_serialized_size;
17611761
let mut item_bytes_buffer = [0u8; MAX_ITEM_SERIALIZED_SIZE];
1762-
let item_size = next_item.serialized_size);
1762+
let item_size = next_item.serialized_size();
17631763

17641764
if item_size > MAX_ITEM_SERIALIZED_SIZE {
17651765
return Err(BoundedError::new(

wrt-foundation/src/capabilities/factory.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl<const N: usize> CapabilityGuardedProvider<N> {
4848
capability.verify_access(&operation)?;
4949

5050
if capability.max_allocation_size() < N {
51-
return Err(Error::security_access_denied("Provider size exceeds capability limit";
51+
return Err(Error::security_access_denied("Provider size exceeds capability limit"));
5252
}
5353

5454
Ok(Self { capability, provider: None, _phantom: PhantomData })
@@ -61,7 +61,7 @@ impl<const N: usize> CapabilityGuardedProvider<N> {
6161
use crate::{safe_managed_alloc, budget_aware_provider::CrateId};
6262
let provider = safe_managed_alloc!(N, CrateId::Foundation)
6363
.map_err(|_| Error::memory_error("Failed to allocate provider"))?;
64-
self.provider = Some(provider;
64+
self.provider = Some(provider);
6565
}
6666

6767
self.provider.as_mut().ok_or_else(|| Error::memory_error("Provider not initialized"))
@@ -78,7 +78,7 @@ impl<const N: usize> CapabilityGuardedProvider<N> {
7878
if offset + len > N {
7979
return Err(Error::runtime_execution_error(
8080
"Read range exceeds provider capacity"
81-
;
81+
));
8282
}
8383

8484
// Return a slice from the provider's buffer
@@ -97,12 +97,13 @@ impl<const N: usize> CapabilityGuardedProvider<N> {
9797
return Err(Error::new(
9898
ErrorCategory::Memory,
9999
codes::OUT_OF_BOUNDS,
100-
"Write range exceeds provider capacity";
100+
"Write range exceeds provider capacity"
101+
));
101102
}
102103

103104
// Write to the provider's buffer
104105
let mut slice = provider.get_slice_mut(offset, data.len())?;
105-
slice.data_mut()?.copy_from_slice(data;
106+
slice.data_mut()?.copy_from_slice(data);
106107
Ok(())
107108
}
108109

@@ -163,6 +164,6 @@ mod tests {
163164
let provider = MemoryFactory::create::<1024>(CrateId::Foundation).unwrap();
164165

165166
// Test basic provider properties
166-
assert_eq!(provider.size(), 1024;
167+
assert_eq!(provider.size(), 1024);
167168
}
168169
}

wrt-foundation/src/execution.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,17 @@ impl ExecutionStats {
9292

9393
/// Reset all statistics to zero
9494
pub fn reset(&mut self) {
95-
*self = Self::default);
95+
*self = Self::default();
9696
}
9797

9898
/// Add instruction count
9999
pub fn add_instructions(&mut self, count: u64) {
100-
self.instructions_executed = self.instructions_executed.saturating_add(count;
100+
self.instructions_executed = self.instructions_executed.saturating_add(count);
101101
}
102102

103103
/// Add fuel consumption
104104
pub fn add_fuel(&mut self, fuel: u64) {
105-
self.fuel_consumed = self.fuel_consumed.saturating_add(fuel;
105+
self.fuel_consumed = self.fuel_consumed.saturating_add(fuel);
106106
}
107107

108108
/// Update peak memory usage if current usage is higher
@@ -114,7 +114,7 @@ impl ExecutionStats {
114114

115115
/// Record a function call
116116
pub fn record_function_call(&mut self, call_depth: u32) {
117-
self.function_calls = self.function_calls.saturating_add(1;
117+
self.function_calls = self.function_calls.saturating_add(1);
118118
if call_depth > self.max_call_depth_reached {
119119
self.max_call_depth_reached = call_depth;
120120
}

0 commit comments

Comments
 (0)