Skip to content

Commit 9fe011f

Browse files
committed
fix: resolve additional syntax errors in wrt-error crate
- Fix missing closing parentheses in struct definitions in kinds.rs - Fix missing closing parentheses in various function calls in recovery.rs - These errors were preventing successful compilation and CI builds
1 parent e3982cd commit 9fe011f

File tree

2 files changed

+59
-59
lines changed

2 files changed

+59
-59
lines changed

wrt-error/src/kinds.rs

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@
99

1010
/// Validation error for integrity or consistency checks
1111
#[derive(Debug, Clone)]
12-
pub struct ValidationError(pub &'static str;
12+
pub struct ValidationError(pub &'static str);
1313

1414
/// Out of bounds error for memory access or index violations
1515
#[derive(Debug, Clone)]
16-
pub struct OutOfBoundsError(pub &'static str;
16+
pub struct OutOfBoundsError(pub &'static str);
1717

1818
/// Parse error for decoding binary formats
1919
#[derive(Debug, Clone)]
20-
pub struct ParseError(pub &'static str;
20+
pub struct ParseError(pub &'static str);
2121

2222
/// Type error for type mismatches or invalid types
2323
#[derive(Debug, Clone)]
24-
pub struct InvalidType(pub &'static str;
24+
pub struct InvalidType(pub &'static str);
2525

2626
/// Conversion error
2727
#[derive(Debug, Clone)]
28-
pub struct ConversionError(pub &'static str;
28+
pub struct ConversionError(pub &'static str);
2929

3030
/// Division by zero error
3131
#[derive(Debug, Clone, Copy)]
@@ -41,31 +41,31 @@ pub struct StackUnderflow;
4141

4242
/// Type mismatch error
4343
#[derive(Debug, Clone)]
44-
pub struct TypeMismatch(pub &'static str;
44+
pub struct TypeMismatch(pub &'static str);
4545

4646
/// Invalid table index error
4747
#[derive(Debug, Clone, Copy)]
48-
pub struct InvalidTableIndexError(pub u32;
48+
pub struct InvalidTableIndexError(pub u32);
4949

5050
/// Invalid local index error
5151
#[derive(Debug, Clone, Copy)]
52-
pub struct InvalidLocalIndexError(pub u32;
52+
pub struct InvalidLocalIndexError(pub u32);
5353

5454
/// Resource error for resource access or creation issues
5555
#[derive(Debug, Clone)]
56-
pub struct ResourceError(pub &'static str;
56+
pub struct ResourceError(pub &'static str);
5757

5858
/// Component error for component instantiation or linking issues
5959
#[derive(Debug, Clone)]
60-
pub struct ComponentError(pub &'static str;
60+
pub struct ComponentError(pub &'static str);
6161

6262
/// Runtime error for generic execution issues
6363
#[derive(Debug, Clone)]
64-
pub struct RuntimeError(pub &'static str;
64+
pub struct RuntimeError(pub &'static str);
6565

6666
/// Poisoned lock error for mutex failures
6767
#[derive(Debug, Clone)]
68-
pub struct PoisonedLockError(pub &'static str;
68+
pub struct PoisonedLockError(pub &'static str);
6969

7070
/// Memory access out of bounds error
7171
#[derive(Debug, Clone, Copy)]
@@ -78,107 +78,107 @@ pub struct MemoryAccessOutOfBoundsError {
7878

7979
/// Type mismatch error
8080
#[derive(Debug, Clone)]
81-
pub struct TypeMismatchError(pub &'static str;
81+
pub struct TypeMismatchError(pub &'static str);
8282

8383
/// Table access out of bounds error
8484
#[derive(Debug, Clone, Copy)]
8585
pub struct TableAccessOutOfBounds;
8686

8787
/// Arithmetic error for math operations
8888
#[derive(Debug, Clone)]
89-
pub struct ArithmeticError(pub &'static str;
89+
pub struct ArithmeticError(pub &'static str);
9090

9191
/// Memory access error
9292
#[derive(Debug, Clone)]
93-
pub struct MemoryAccessError(pub &'static str;
93+
pub struct MemoryAccessError(pub &'static str);
9494

9595
/// Resource exhaustion error
9696
#[derive(Debug, Clone)]
97-
pub struct ResourceExhaustionError(pub &'static str;
97+
pub struct ResourceExhaustionError(pub &'static str);
9898

9999
/// Invalid index error
100100
#[derive(Debug, Clone)]
101-
pub struct InvalidIndexError(pub &'static str;
101+
pub struct InvalidIndexError(pub &'static str);
102102

103103
/// Error during execution
104104
#[derive(Debug, Clone)]
105-
pub struct ExecutionError(pub &'static str;
105+
pub struct ExecutionError(pub &'static str);
106106

107107
/// Stack underflow error (empty stack)
108108
#[derive(Debug, Clone)]
109-
pub struct StackUnderflowError(pub &'static str;
109+
pub struct StackUnderflowError(pub &'static str);
110110

111111
/// Export not found error
112112
#[derive(Debug, Clone)]
113-
pub struct ExportNotFoundError(pub &'static str;
113+
pub struct ExportNotFoundError(pub &'static str);
114114

115115
/// Invalid instance index error
116116
#[derive(Debug, Clone, Copy)]
117-
pub struct InvalidInstanceIndexError(pub u32;
117+
pub struct InvalidInstanceIndexError(pub u32);
118118

119119
/// Invalid function index error
120120
#[derive(Debug, Clone, Copy)]
121-
pub struct InvalidFunctionIndexError(pub u32;
121+
pub struct InvalidFunctionIndexError(pub u32);
122122

123123
/// Invalid element index error
124124
#[derive(Debug, Clone, Copy)]
125-
pub struct InvalidElementIndexError(pub usize;
125+
pub struct InvalidElementIndexError(pub usize);
126126

127127
/// Invalid memory index error
128128
#[derive(Debug, Clone, Copy)]
129-
pub struct InvalidMemoryIndexError(pub u32;
129+
pub struct InvalidMemoryIndexError(pub u32);
130130

131131
/// Invalid global index error
132132
#[derive(Debug, Clone, Copy)]
133-
pub struct InvalidGlobalIndexError(pub u32;
133+
pub struct InvalidGlobalIndexError(pub u32);
134134

135135
/// Invalid data segment index error
136136
#[derive(Debug, Clone, Copy)]
137-
pub struct InvalidDataSegmentIndexError(pub usize;
137+
pub struct InvalidDataSegmentIndexError(pub usize);
138138

139139
/// Invalid function type error
140140
#[derive(Debug, Clone)]
141-
pub struct InvalidFunctionTypeError(pub &'static str;
141+
pub struct InvalidFunctionTypeError(pub &'static str);
142142

143143
/// Not implemented error
144144
#[derive(Debug, Clone)]
145-
pub struct NotImplementedError(pub &'static str;
145+
pub struct NotImplementedError(pub &'static str);
146146

147147
/// Out of bounds access error
148148
#[derive(Debug, Clone)]
149-
pub struct OutOfBoundsAccess(pub &'static str;
149+
pub struct OutOfBoundsAccess(pub &'static str);
150150

151151
/// Invalid value error
152152
#[derive(Debug, Clone)]
153-
pub struct InvalidValue(pub &'static str;
153+
pub struct InvalidValue(pub &'static str);
154154

155155
/// Value out of range error
156156
#[derive(Debug, Clone)]
157-
pub struct ValueOutOfRangeError(pub &'static str;
157+
pub struct ValueOutOfRangeError(pub &'static str);
158158

159159
/// Invalid state error
160160
#[derive(Debug, Clone)]
161-
pub struct InvalidState(pub &'static str;
161+
pub struct InvalidState(pub &'static str);
162162

163163
/// Decoding error
164164
#[derive(Debug, Clone)]
165-
pub struct DecodingError(pub &'static str;
165+
pub struct DecodingError(pub &'static str);
166166

167167
/// Execution limit exceeded error
168168
#[derive(Debug, Clone)]
169-
pub struct ExecutionLimitExceeded(pub &'static str;
169+
pub struct ExecutionLimitExceeded(pub &'static str);
170170

171171
/// Execution timeout error
172172
#[derive(Debug, Clone)]
173-
pub struct ExecutionTimeoutError(pub &'static str;
173+
pub struct ExecutionTimeoutError(pub &'static str);
174174

175175
/// Resource limit exceeded error
176176
#[derive(Debug, Clone)]
177-
pub struct ResourceLimitExceeded(pub &'static str;
177+
pub struct ResourceLimitExceeded(pub &'static str);
178178

179179
/// Invalid argument error
180180
#[derive(Debug, Clone)]
181-
pub struct InvalidArgumentError(pub &'static str;
181+
pub struct InvalidArgumentError(pub &'static str);
182182

183183
/// Error when a Wasm 3.0 specific construct is encountered in a Wasm 2.0 module
184184
/// or context.
@@ -197,7 +197,7 @@ pub struct InvalidWasm30InstructionImmediate {
197197

198198
/// Error for a malformed Wasm 3.0 `TypeInformation` section.
199199
#[derive(Debug, Clone, PartialEq, Eq)]
200-
pub struct MalformedWasm30TypeInformationSection(pub &'static str;
200+
pub struct MalformedWasm30TypeInformationSection(pub &'static str);
201201

202202
/// Error for an invalid memory index used with Wasm 3.0 multi-memory features.
203203
#[derive(Debug, Clone, Copy)]

wrt-error/src/recovery.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ impl ErrorContext {
7373

7474
/// Add context information
7575
pub fn with_context(mut self, key: impl Into<String>, value: impl Into<String>) -> Self {
76-
self.context.insert(key.into(), value.into();
76+
self.context.insert(key.into(), value.into());
7777
self
7878
}
7979

8080
/// Add stack frame
8181
pub fn with_stack_frame(mut self, frame: impl Into<String>) -> Self {
82-
self.stack_trace.push(frame.into();
82+
self.stack_trace.push(frame.into());
8383
self
8484
}
8585

@@ -110,14 +110,14 @@ impl Default for ErrorRecoveryManager {
110110
impl ErrorRecoveryManager {
111111
/// Create a new error recovery manager
112112
pub fn new() -> Self {
113-
let mut strategies = HashMap::new);
113+
let mut strategies = HashMap::new();
114114

115115
// Set default recovery strategies
116-
strategies.insert(ErrorCategory::Parse, RecoveryStrategy::Skip;
117-
strategies.insert(ErrorCategory::Type, RecoveryStrategy::LogAndContinue;
118-
strategies.insert(ErrorCategory::Runtime, RecoveryStrategy::Abort;
119-
strategies.insert(ErrorCategory::Memory, RecoveryStrategy::Abort;
120-
strategies.insert(ErrorCategory::Validation, RecoveryStrategy::UseDefault;
116+
strategies.insert(ErrorCategory::Parse, RecoveryStrategy::Skip);
117+
strategies.insert(ErrorCategory::Type, RecoveryStrategy::LogAndContinue);
118+
strategies.insert(ErrorCategory::Runtime, RecoveryStrategy::Abort);
119+
strategies.insert(ErrorCategory::Memory, RecoveryStrategy::Abort);
120+
strategies.insert(ErrorCategory::Validation, RecoveryStrategy::UseDefault);
121121

122122
Self {
123123
strategies,
@@ -128,7 +128,7 @@ impl ErrorRecoveryManager {
128128

129129
/// Set recovery strategy for an error category
130130
pub fn set_strategy(&mut self, category: ErrorCategory, strategy: RecoveryStrategy) {
131-
self.strategies.insert(category, strategy;
131+
self.strategies.insert(category, strategy);
132132
}
133133

134134
/// Get recovery strategy for an error category
@@ -138,19 +138,19 @@ impl ErrorRecoveryManager {
138138

139139
/// Record an error with context
140140
pub fn record_error(&mut self, error: Error, context: ErrorContext) {
141-
self.error_history.push((error, context);
141+
self.error_history.push((error, context));
142142

143143
// Limit history size
144144
if self.error_history.len() > self.max_history {
145-
self.error_history.remove(0;
145+
self.error_history.remove(0);
146146
}
147147
}
148148

149149
/// Analyze error patterns
150150
pub fn analyze_patterns(&self) -> ErrorPatternAnalysis {
151-
let mut category_counts = HashMap::new);
152-
let mut location_counts = HashMap::new);
153-
let mut recent_errors = Vec::new);
151+
let mut category_counts = HashMap::new();
152+
let mut location_counts = HashMap::new();
153+
let mut recent_errors = Vec::new();
154154

155155
for (error, context) in &self.error_history {
156156
// Count by category
@@ -161,7 +161,7 @@ impl ErrorRecoveryManager {
161161

162162
// Collect recent errors (last 10)
163163
if recent_errors.len() < 10 {
164-
recent_errors.push((error.clone(), context.clone();
164+
recent_errors.push((error.clone(), context.clone()));
165165
}
166166
}
167167

@@ -191,7 +191,7 @@ impl ErrorRecoveryManager {
191191
#[cfg(feature = "std")]
192192
{
193193
use std::println;
194-
println!("Warning: {} at {}", error.message, context.location;
194+
println!("Warning: {} at {}", error.message, context.location;)
195195
}
196196
RecoveryResult::Continue
197197
},
@@ -267,7 +267,7 @@ pub struct RecoverableError {
267267
impl RecoverableError {
268268
/// Create a new recoverable error
269269
pub fn new(error: Error, context: ErrorContext) -> Self {
270-
let manager = ErrorRecoveryManager::new);
270+
let manager = ErrorRecoveryManager::new();
271271
let recovery_suggestion = manager.recover(&error, &context;
272272

273273
Self {
@@ -294,7 +294,7 @@ pub struct DebugUtils;
294294
impl DebugUtils {
295295
/// Format error with full debugging information
296296
pub fn format_detailed_error(error: &Error, context: &ErrorContext) -> String {
297-
let mut output = String::new);
297+
let mut output = String::new();
298298

299299
output.push_str(&format!(
300300
"Error: {} (Code: {})\n",
@@ -388,7 +388,7 @@ macro_rules! recoverable {
388388
| $crate::recovery::RecoveryResult::Skip => {
389389
// Log and continue
390390
#[cfg(feature = "std")]
391-
eprintln!("Recovered from error: {}", recoverable.error.message;
391+
eprintln!("Recovered from error: {}", recoverable.error.message;))
392392
return recoverable.into_result);
393393
},
394394
_ => Err(recoverable.error),
@@ -408,7 +408,7 @@ mod tests {
408408

409409
#[test]
410410
fn test_error_recovery_manager() {
411-
let mut manager = ErrorRecoveryManager::new);
411+
let mut manager = ErrorRecoveryManager::new();
412412

413413
// Test setting and getting strategies
414414
manager.set_strategy(ErrorCategory::Parse, RecoveryStrategy::Skip;
@@ -440,7 +440,7 @@ mod tests {
440440

441441
#[test]
442442
fn test_pattern_analysis() {
443-
let mut manager = ErrorRecoveryManager::new);
443+
let mut manager = ErrorRecoveryManager::new();
444444

445445
// Add multiple errors
446446
for i in 0..5 {

0 commit comments

Comments
 (0)