Skip to content

Commit 794ccdd

Browse files
committed
chore: update transpiled test outputs after constants/Display fixes
- Add missing imports for Display trait implementations - Update panic formatting in error handling tests - Regenerate outputs with proper type imports
1 parent b1aa65b commit 794ccdd

File tree

9 files changed

+34
-25
lines changed

9 files changed

+34
-25
lines changed

go/decl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ func transpileConstDeclWithCase(out *strings.Builder, genDecl *ast.GenDecl, toUp
451451
} else {
452452
// Check if this is a type definition and get underlying type
453453
baseType := goTypeToRustBase(valueSpec.Type)
454-
// If it's a custom type (like Color), we need to use the underlying type
454+
// If it's a custom type, we need to use the underlying type
455455
// For now, assume custom int types map to i32
456456
if ident, ok := valueSpec.Type.(*ast.Ident); ok {
457457
// Check if this is a known type definition

tests/XFAIL/cross_file_methods/types.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
use std::cell::{RefCell};
2+
use std::rc::{Rc};
3+
14
/// Counter holds a numeric value
25
#[derive(Debug, Clone, Default)]
36
struct Counter {

tests/XFAIL/cross_file_types/types.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
use std::cell::{RefCell};
2+
use std::rc::{Rc};
3+
14
/// Person represents a person with name and age
25
#[derive(Debug, Clone, Default)]
36
struct Person {

tests/XFAIL/enums_iota/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const STATE_RETRYING: i32 = 3;
1212
struct ServerState(Rc<RefCell<Option<i32>>>);
1313

1414
impl Display for ServerState {
15-
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
15+
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
1616
write!(f, "{}", self.0.borrow().as_ref().unwrap())
1717
}
1818
}

tests/XFAIL/error_handling/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl CustomError {
1818
impl Error for CustomError {}
1919

2020
impl Display for CustomError {
21-
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
21+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
2222
write!(f, "{}", (*self.error().borrow_mut().as_mut().unwrap()))
2323
}
2424
}

tests/XFAIL/errors_custom/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl argError {
1818
impl Error for argError {}
1919

2020
impl Display for argError {
21-
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
21+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
2222
write!(f, "{}", (*self.error().borrow_mut().as_mut().unwrap()))
2323
}
2424
}

tests/XFAIL/init_order_complex/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
use std::cell::{RefCell};
2+
use std::rc::{Rc};
3+
14
pub fn f() -> Rc<RefCell<Option<i32>>> {
25

36
{ let mut guard = d.borrow_mut(); *guard = Some(guard.as_ref().unwrap() + 1); }

tests/XFAIL/named_types_methods/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::rc::{Rc};
66
struct Celsius(Rc<RefCell<Option<f64>>>);
77

88
impl Display for Celsius {
9-
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
9+
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
1010
write!(f, "{}", self.0.borrow().as_ref().unwrap())
1111
}
1212
}
@@ -16,7 +16,7 @@ impl Display for Celsius {
1616
struct Fahrenheit(Rc<RefCell<Option<f64>>>);
1717

1818
impl Display for Fahrenheit {
19-
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
19+
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
2020
write!(f, "{}", self.0.borrow().as_ref().unwrap())
2121
}
2222
}

tests/XFAIL/nested_structures/main.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -125,34 +125,34 @@ fn main() {
125125
println!("{}", "\n=== Accessing nested data ===".to_string());
126126

127127
print!("Company: {}\n", (*(*company.borrow().as_ref().unwrap()).name.borrow().as_ref().unwrap()));
128-
print!("HQ Address: {}, {}, {} {}\n", (*company.borrow_mut().as_mut().unwrap()).headquarters.street, (*company.borrow_mut().as_mut().unwrap()).headquarters.city, (*company.borrow_mut().as_mut().unwrap()).headquarters.state, (*company.borrow_mut().as_mut().unwrap()).headquarters.zip_code);
128+
print!("HQ Address: {}, {}, {} {}\n", (*(*(*company.borrow_mut().as_mut().unwrap()).headquarters.borrow().as_ref().unwrap()).street.borrow().as_ref().unwrap()), (*(*(*company.borrow_mut().as_mut().unwrap()).headquarters.borrow().as_ref().unwrap()).city.borrow().as_ref().unwrap()), (*(*(*company.borrow_mut().as_mut().unwrap()).headquarters.borrow().as_ref().unwrap()).state.borrow().as_ref().unwrap()), (*(*(*company.borrow_mut().as_mut().unwrap()).headquarters.borrow().as_ref().unwrap()).zip_code.borrow().as_ref().unwrap()));
129129

130-
print!("Department: {}\n", (*(*company.borrow_mut().as_mut().unwrap()).departments.borrow().as_ref().unwrap())[0 as usize].clone().name);
131-
print!("Department Budget: ${:.2}\n", (*(*company.borrow_mut().as_mut().unwrap()).departments.borrow().as_ref().unwrap())[0 as usize].clone().budget);
130+
print!("Department: {}\n", (*(*(*company.borrow_mut().as_mut().unwrap()).departments.borrow().as_ref().unwrap())[0 as usize].clone().name.borrow().as_ref().unwrap()));
131+
print!("Department Budget: ${:.2}\n", (*(*(*company.borrow_mut().as_mut().unwrap()).departments.borrow().as_ref().unwrap())[0 as usize].clone().budget.borrow().as_ref().unwrap()));
132132

133-
print!("Manager: {} (Age: {})\n", (*(*company.borrow_mut().as_mut().unwrap()).departments.borrow().as_ref().unwrap())[0 as usize].clone().manager.name, (*(*company.borrow_mut().as_mut().unwrap()).departments.borrow().as_ref().unwrap())[0 as usize].clone().manager.age);
133+
print!("Manager: {} (Age: {})\n", (*(*(*(*company.borrow_mut().as_mut().unwrap()).departments.borrow().as_ref().unwrap())[0 as usize].clone().manager.borrow().as_ref().unwrap()).name.borrow().as_ref().unwrap()), (*(*(*(*company.borrow_mut().as_mut().unwrap()).departments.borrow().as_ref().unwrap())[0 as usize].clone().manager.borrow().as_ref().unwrap()).age.borrow().as_ref().unwrap()));
134134

135-
print!("Manager Email: {}\n", (*(*company.borrow_mut().as_mut().unwrap()).departments.borrow().as_ref().unwrap())[0 as usize].clone().manager.contact.email);
135+
print!("Manager Email: {}\n", (*(*(*(*(*company.borrow_mut().as_mut().unwrap()).departments.borrow().as_ref().unwrap())[0 as usize].clone().manager.borrow().as_ref().unwrap()).contact.borrow().as_ref().unwrap()).email.borrow().as_ref().unwrap()));
136136

137-
print!("Manager Address: {}, {}\n", (*(*company.borrow_mut().as_mut().unwrap()).departments.borrow().as_ref().unwrap())[0 as usize].clone().manager.address.city, (*(*company.borrow_mut().as_mut().unwrap()).departments.borrow().as_ref().unwrap())[0 as usize].clone().manager.address.state);
137+
print!("Manager Address: {}, {}\n", (*(*(*(*(*company.borrow_mut().as_mut().unwrap()).departments.borrow().as_ref().unwrap())[0 as usize].clone().manager.borrow().as_ref().unwrap()).address.borrow().as_ref().unwrap()).city.borrow().as_ref().unwrap()), (*(*(*(*(*company.borrow_mut().as_mut().unwrap()).departments.borrow().as_ref().unwrap())[0 as usize].clone().manager.borrow().as_ref().unwrap()).address.borrow().as_ref().unwrap()).state.borrow().as_ref().unwrap()));
138138

139139
// Iterate through employees
140140
println!("{}", "\n=== Department employees ===".to_string());
141141

142-
for (i, emp) in (*(*company.borrow_mut().as_mut().unwrap()).departments.borrow().as_ref().unwrap())[0 as usize].clone().employees.iter().enumerate() {
143-
print!("Employee {}: {}\n", i + 1, emp.name);
144-
print!(" Age: {}\n", emp.age);
145-
print!(" Email: {}\n", emp.contact.email);
146-
print!(" Phone: {}\n", emp.contact.phone);
147-
print!(" Address: {}, {}, {}\n", emp.address.street, emp.address.city, emp.address.state);
142+
for (i, emp) in (*(*(*company.borrow_mut().as_mut().unwrap()).departments.borrow().as_ref().unwrap())[0 as usize].clone().employees.borrow().as_ref().unwrap()).iter().enumerate() {
143+
print!("Employee {}: {}\n", i + 1, (*emp.name.borrow().as_ref().unwrap()));
144+
print!(" Age: {}\n", (*emp.age.borrow().as_ref().unwrap()));
145+
print!(" Email: {}\n", (*(*emp.contact.borrow().as_ref().unwrap()).email.borrow().as_ref().unwrap()));
146+
print!(" Phone: {}\n", (*(*emp.contact.borrow().as_ref().unwrap()).phone.borrow().as_ref().unwrap()));
147+
print!(" Address: {}, {}, {}\n", (*(*emp.address.borrow().as_ref().unwrap()).street.borrow().as_ref().unwrap()), (*(*emp.address.borrow().as_ref().unwrap()).city.borrow().as_ref().unwrap()), (*(*emp.address.borrow().as_ref().unwrap()).state.borrow().as_ref().unwrap()));
148148
println!();
149149
}
150150

151151
// Nested maps
152152
println!("{}", "=== Nested maps ===".to_string());
153153

154154
// Map of maps
155-
let mut inventory = Rc::new(RefCell::new(Some(HashMap::<String, Rc<RefCell<Option<HashMap<String, i32>>>>>::from([("electronics".to_string(), Rc::new(RefCell::new(Some()))), ("furniture".to_string(), Rc::new(RefCell::new(Some()))), ("supplies".to_string(), Rc::new(RefCell::new(Some())))]))));
155+
let mut inventory = Rc::new(RefCell::new(Some(HashMap::<String, Rc<RefCell<Option<HashMap<String, i32>>>>>::from([("electronics".to_string(), Rc::new(RefCell::new(Some(/* ERROR: CompositeLit with nil Type - type inference failed */unimplemented!())))), ("furniture".to_string(), Rc::new(RefCell::new(Some(/* ERROR: CompositeLit with nil Type - type inference failed */unimplemented!())))), ("supplies".to_string(), Rc::new(RefCell::new(Some(/* ERROR: CompositeLit with nil Type - type inference failed */unimplemented!()))))]))));
156156

157157
println!("{}", "Inventory:".to_string());
158158
for (category, items) in (*inventory.borrow().as_ref().unwrap()).clone() {
@@ -170,7 +170,7 @@ fn main() {
170170
println!("{}", "\n=== Nested slices ===".to_string());
171171

172172
// Matrix (slice of slices)
173-
let mut matrix = Rc::new(RefCell::new(Some(vec![, , ])));
173+
let mut matrix = Rc::new(RefCell::new(Some(vec![Rc::new(RefCell::new(Some(vec![1, 2, 3]))), Rc::new(RefCell::new(Some(vec![4, 5, 6]))), Rc::new(RefCell::new(Some(vec![7, 8, 9])))])));
174174

175175
println!("{}", "Matrix:".to_string());
176176
for (i, row) in (*matrix.borrow_mut().as_mut().unwrap()).iter().enumerate() {
@@ -189,7 +189,7 @@ fn main() {
189189
print!("Center element: {}\n", (*centerElement.borrow_mut().as_mut().unwrap()));
190190

191191
// 3D slice
192-
let mut cube = Rc::new(RefCell::new(Some(vec![, ])));
192+
let mut cube = Rc::new(RefCell::new(Some(vec![Rc::new(RefCell::new(Some(vec![Rc::new(RefCell::new(Some(vec![1, 2]))), Rc::new(RefCell::new(Some(vec![3, 4])))]))), Rc::new(RefCell::new(Some(vec![Rc::new(RefCell::new(Some(vec![5, 6]))), Rc::new(RefCell::new(Some(vec![7, 8])))])))])));
193193

194194
println!("{}", "\n3D Cube:".to_string());
195195
for (i, layer) in (*cube.borrow_mut().as_mut().unwrap()).iter().enumerate() {
@@ -209,21 +209,21 @@ fn main() {
209209
let mut canvas = Rc::new(RefCell::new(Some(Canvas { name: Rc::new(RefCell::new(Some("My Drawing".to_string()))), shapes: Rc::new(RefCell::new(Some(Rc::new(RefCell::new(Some(vec![Circle { radius: Rc::new(RefCell::new(Some(5.0))) }, Rectangle { width: Rc::new(RefCell::new(Some(10.0))), height: Rc::new(RefCell::new(Some(8.0))) }, Circle { radius: Rc::new(RefCell::new(Some(3.0))) }])))))) })));
210210

211211
print!("Canvas: {}\n", (*(*canvas.borrow().as_ref().unwrap()).name.borrow().as_ref().unwrap()));
212-
for (i, shape) in (*canvas.borrow().as_ref().unwrap()).shapes.iter().enumerate() {
212+
for (i, shape) in (*(*canvas.borrow().as_ref().unwrap()).shapes.borrow().as_ref().unwrap()).iter().enumerate() {
213213
print!("Shape {}: {}\n", i + 1, (*shape.draw().borrow().as_ref().unwrap()));
214214
}
215215

216216
// Modify nested structures
217217
println!("{}", "\n=== Modifying nested structures ===".to_string());
218218

219219
// Update employee contact
220-
{ let new_val = "[email protected]".to_string(); *(*(*(*company.borrow_mut().as_mut().unwrap()).departments.borrow().as_ref().unwrap())[0 as usize].clone().employees.borrow().as_ref().unwrap())[0 as usize].clone().contact.email.borrow_mut() = Some(new_val); };
221-
print!("Updated employee email: {}\n", (*(*(*company.borrow_mut().as_mut().unwrap()).departments.borrow().as_ref().unwrap())[0 as usize].clone().employees.borrow().as_ref().unwrap())[0 as usize].clone().contact.email);
220+
{ let new_val = "[email protected]".to_string(); *(*(*(*(*company.borrow_mut().as_mut().unwrap()).departments.borrow().as_ref().unwrap())[0 as usize].clone().employees.borrow().as_ref().unwrap())[0 as usize].clone().contact.borrow().as_ref().unwrap()).email.borrow_mut() = Some(new_val); };
221+
print!("Updated employee email: {}\n", (*(*(*(*(*company.borrow_mut().as_mut().unwrap()).departments.borrow().as_ref().unwrap())[0 as usize].clone().employees.borrow().as_ref().unwrap())[0 as usize].clone().contact.borrow().as_ref().unwrap()).email.borrow().as_ref().unwrap()));
222222

223223
// Add new employee
224224
let mut newEmployee = Rc::new(RefCell::new(Some(Person { name: Rc::new(RefCell::new(Some("Dave Newbie".to_string()))), age: Rc::new(RefCell::new(Some(25))), address: Rc::new(RefCell::new(Some(Address { street: Rc::new(RefCell::new(Some("999 New St".to_string()))), city: Rc::new(RefCell::new(Some("Newtown".to_string()))), state: Rc::new(RefCell::new(Some("CA".to_string()))), zip_code: Rc::new(RefCell::new(Some("90214".to_string()))), country: Rc::new(RefCell::new(Some("USA".to_string()))) }))), contact: Rc::new(RefCell::new(Some(Contact { email: Rc::new(RefCell::new(Some("[email protected]".to_string()))), phone: Rc::new(RefCell::new(Some("555-0004".to_string()))) }))) })));
225225

226-
{(*(*(*company.borrow_mut().as_mut().unwrap()).departments.borrow().as_ref().unwrap())[0 as usize].clone().employees.borrow_mut().as_mut().unwrap()).push((*newEmployee.borrow_mut().as_mut().unwrap())); (*(*company.borrow_mut().as_mut().unwrap()).departments.borrow().as_ref().unwrap())[0 as usize].clone().employees.clone()};
226+
{(*(*(*(*company.borrow_mut().as_mut().unwrap()).departments.borrow().as_ref().unwrap())[0 as usize].clone().employees.borrow().as_ref().unwrap()).borrow_mut().as_mut().unwrap()).push((*newEmployee.borrow_mut().as_mut().unwrap())); (*(*(*company.borrow_mut().as_mut().unwrap()).departments.borrow().as_ref().unwrap())[0 as usize].clone().employees.borrow().as_ref().unwrap()).clone()};
227227
print!("Added new employee: {}\n", (*(*newEmployee.borrow().as_ref().unwrap()).name.borrow().as_ref().unwrap()));
228228
print!("Total employees now: {}\n", (*(*(*company.borrow_mut().as_mut().unwrap()).departments.borrow().as_ref().unwrap())[0 as usize].clone().employees.borrow().as_ref().unwrap()).len());
229229
}

0 commit comments

Comments
 (0)