From 88205c854fbfc92c1be56e114e78bc9981888f03 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Sat, 13 Jun 2026 14:04:02 +0100 Subject: [PATCH 01/17] Update tests --- tests/ub/out/refcount/ub21.rs | 14 +- tests/ub/out/refcount/ub7.rs | 23 +- tests/ub/out/unsafe/ub21.rs | 10 +- tests/ub/out/unsafe/ub7.rs | 23 +- tests/unit/out/refcount/array_const_init.rs | 6 +- tests/unit/out/refcount/assign_as_value.rs | 18 +- tests/unit/out/refcount/bool_condition_int.rs | 2 +- .../unit/out/refcount/bool_condition_int_c.rs | 3 +- .../out/refcount/bool_condition_logical.rs | 6 +- .../out/refcount/bool_condition_logical_c.rs | 6 +- tests/unit/out/refcount/borrow_mut_opt.rs | 10 +- .../refcount/cast_array_to_pointer_decay.rs | 16 +- tests/unit/out/refcount/char_printing.rs | 26 +- tests/unit/out/refcount/char_printing_cerr.rs | 26 +- tests/unit/out/refcount/clone_vs_move.rs | 54 ++- tests/unit/out/refcount/default_in_statics.rs | 20 +- tests/unit/out/refcount/doubly_linked_list.rs | 52 +- tests/unit/out/refcount/enum_int_interop.rs | 2 +- tests/unit/out/refcount/enum_int_interop_c.rs | 2 +- tests/unit/out/refcount/expr_as_bool_c.rs | 34 +- tests/unit/out/refcount/expr_as_bool_cpp.rs | 34 +- .../out/refcount/fn_ptr_stdlib_compare.rs | 200 +++++--- tests/unit/out/refcount/fopen.rs | 6 +- tests/unit/out/refcount/global_pointers.rs | 13 +- .../out/refcount/goto_aggregate_default.rs | 6 +- tests/unit/out/refcount/huffman.rs | 51 +- tests/unit/out/refcount/iterators.rs | 15 +- tests/unit/out/refcount/macros.rs | 8 +- tests/unit/out/refcount/main.rs | 18 +- tests/unit/out/refcount/null_in_statics.rs | 6 +- tests/unit/out/refcount/printfs.rs | 22 +- tests/unit/out/refcount/push_emplace_back.rs | 18 +- .../out/refcount/reinterpret_cast_string.rs | 26 +- tests/unit/out/refcount/stdcopy_ostream.rs | 21 +- tests/unit/out/refcount/string.rs | 383 ++++++++------- tests/unit/out/refcount/string2.rs | 26 +- tests/unit/out/refcount/string_escape.rs | 91 ++-- tests/unit/out/refcount/string_literals.rs | 64 +-- tests/unit/out/refcount/string_literals_c.rs | 93 ++-- .../out/refcount/string_literals_concat.rs | 45 +- .../out/refcount/string_literals_concat_c.rs | 5 +- .../out/refcount/string_literals_return.rs | 64 ++- .../out/refcount/string_literals_return_c.rs | 14 +- .../out/refcount/string_literals_sized.rs | 78 ++- .../out/refcount/string_literals_sized_c.rs | 26 +- tests/unit/out/refcount/strlen.rs | 25 +- tests/unit/out/refcount/strlen_diff.rs | 25 +- tests/unit/out/refcount/strlen_rec.rs | 19 +- .../unit/out/refcount/struct_default_ctor.rs | 8 +- tests/unit/out/refcount/switch_char.rs | 22 +- .../out/refcount/user_defined_same_as_libc.rs | 9 +- tests/unit/out/refcount/va_arg_conditional.rs | 4 +- .../out/refcount/va_arg_non_primitive_ptrs.rs | 7 +- tests/unit/out/refcount/va_arg_printf.rs | 13 +- tests/unit/out/refcount/va_arg_promotion.rs | 3 +- tests/unit/out/refcount/va_arg_snprintf.rs | 23 +- tests/unit/out/refcount/va_arg_struct_ctx.rs | 4 +- tests/unit/out/refcount/vector.rs | 20 +- tests/unit/out/unsafe/array_const_init.rs | 4 +- tests/unit/out/unsafe/assign_as_value.rs | 10 +- tests/unit/out/unsafe/bool_condition_int.rs | 2 +- tests/unit/out/unsafe/bool_condition_int_c.rs | 2 +- .../unit/out/unsafe/bool_condition_logical.rs | 4 +- .../out/unsafe/bool_condition_logical_c.rs | 4 +- tests/unit/out/unsafe/borrow_mut_opt.rs | 8 +- .../out/unsafe/cast_array_to_pointer_decay.rs | 11 +- tests/unit/out/unsafe/char_printing.rs | 26 +- tests/unit/out/unsafe/char_printing_cerr.rs | 26 +- tests/unit/out/unsafe/clone_vs_move.rs | 22 +- tests/unit/out/unsafe/cstring.rs | 452 +++++++++--------- tests/unit/out/unsafe/default_in_statics.rs | 14 +- tests/unit/out/unsafe/doubly_linked_list.rs | 40 +- tests/unit/out/unsafe/enum_int_interop.rs | 8 +- tests/unit/out/unsafe/enum_int_interop_c.rs | 8 +- tests/unit/out/unsafe/errno.rs | 5 +- tests/unit/out/unsafe/expr_as_bool_c.rs | 30 +- tests/unit/out/unsafe/expr_as_bool_cpp.rs | 30 +- .../unit/out/unsafe/fn_ptr_stdlib_compare.rs | 122 ++--- tests/unit/out/unsafe/fopen.rs | 6 +- tests/unit/out/unsafe/global_pointers.rs | 10 +- .../unit/out/unsafe/goto_aggregate_default.rs | 2 +- tests/unit/out/unsafe/huffman.rs | 43 +- tests/unit/out/unsafe/iterators.rs | 10 +- tests/unit/out/unsafe/libc_char_ptr_field.rs | 9 +- tests/unit/out/unsafe/macros.rs | 18 +- tests/unit/out/unsafe/main.rs | 9 +- tests/unit/out/unsafe/map-reallocation.rs | 10 +- tests/unit/out/unsafe/null_in_statics.rs | 4 +- tests/unit/out/unsafe/pointer_printf.rs | 2 +- tests/unit/out/unsafe/printfs.rs | 35 +- .../out/unsafe/reinterpret_cast_string.rs | 12 +- tests/unit/out/unsafe/stdcopy_ostream.rs | 17 +- tests/unit/out/unsafe/stdio.rs | 37 +- tests/unit/out/unsafe/stdlib_h.rs | 29 +- tests/unit/out/unsafe/string.rs | 204 ++++---- tests/unit/out/unsafe/string2.rs | 12 +- tests/unit/out/unsafe/string_escape.rs | 93 ++-- tests/unit/out/unsafe/string_h.rs | 421 ++++++++-------- tests/unit/out/unsafe/string_literals.rs | 38 +- tests/unit/out/unsafe/string_literals_c.rs | 68 +-- .../unit/out/unsafe/string_literals_concat.rs | 40 +- .../out/unsafe/string_literals_concat_c.rs | 5 +- .../unit/out/unsafe/string_literals_return.rs | 42 +- .../out/unsafe/string_literals_return_c.rs | 22 +- .../unit/out/unsafe/string_literals_sized.rs | 49 +- .../out/unsafe/string_literals_sized_c.rs | 23 +- tests/unit/out/unsafe/strlen.rs | 21 +- tests/unit/out/unsafe/strlen_diff.rs | 25 +- tests/unit/out/unsafe/strlen_rec.rs | 13 +- tests/unit/out/unsafe/struct_default_ctor.rs | 4 +- tests/unit/out/unsafe/switch_char.rs | 20 +- tests/unit/out/unsafe/sys_stat.rs | 32 +- .../unit/out/unsafe/union_addrof_external.rs | 6 +- tests/unit/out/unsafe/union_cross_arm_cast.rs | 12 +- tests/unit/out/unsafe/union_memset_memcpy.rs | 18 +- tests/unit/out/unsafe/union_nested.rs | 8 +- .../unit/out/unsafe/union_struct_dual_use.rs | 2 +- .../unit/out/unsafe/union_tagged_many_arms.rs | 4 +- .../out/unsafe/union_tagged_struct_arms.rs | 10 +- .../out/unsafe/union_void_ptr_sized_deref.rs | 2 +- tests/unit/out/unsafe/unistd.rs | 161 ++++--- .../out/unsafe/user_defined_same_as_libc.rs | 9 +- tests/unit/out/unsafe/va_arg_conditional.rs | 18 +- .../out/unsafe/va_arg_non_primitive_ptrs.rs | 12 +- tests/unit/out/unsafe/va_arg_printf.rs | 14 +- tests/unit/out/unsafe/va_arg_promotion.rs | 2 +- tests/unit/out/unsafe/va_arg_snprintf.rs | 16 +- tests/unit/out/unsafe/va_arg_struct_ctx.rs | 10 +- tests/unit/out/unsafe/vector3.rs | 4 +- 129 files changed, 2384 insertions(+), 2005 deletions(-) diff --git a/tests/ub/out/refcount/ub21.rs b/tests/ub/out/refcount/ub21.rs index 02973f0f..6e435202 100644 --- a/tests/ub/out/refcount/ub21.rs +++ b/tests/ub/out/refcount/ub21.rs @@ -6,8 +6,8 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -pub fn strlen_0(s: Ptr) -> usize { - let s: Value> = Rc::new(RefCell::new(s)); +pub fn strlen_0(s: Ptr<::core::ffi::c_char>) -> usize { + let s: Value> = Rc::new(RefCell::new(s)); let count: Value = Rc::new(RefCell::new(0_usize)); 'loop_: while (((*s.borrow_mut()).postfix_inc().read()) != 0) { (*count.borrow_mut()).prefix_inc(); @@ -18,13 +18,13 @@ pub fn main() { std::process::exit(main_0()); } fn main_0() -> i32 { - let s: Value> = Rc::new(RefCell::new(Box::new([ - ('s' as u8), - ('t' as u8), - ('r' as u8), + let s: Value> = Rc::new(RefCell::new(Box::new([ + ('s' as ::core::ffi::c_char), + ('t' as ::core::ffi::c_char), + ('r' as ::core::ffi::c_char), ]))); return (({ - let _s: Ptr = (s.as_pointer() as Ptr); + let _s: Ptr<::core::ffi::c_char> = (s.as_pointer() as Ptr<::core::ffi::c_char>); strlen_0(_s) }) as i32); } diff --git a/tests/ub/out/refcount/ub7.rs b/tests/ub/out/refcount/ub7.rs index e1b03163..dc332112 100644 --- a/tests/ub/out/refcount/ub7.rs +++ b/tests/ub/out/refcount/ub7.rs @@ -6,9 +6,9 @@ use std::io::prelude::*; use std::io::{Read, Seek, Write}; use std::os::fd::AsFd; use std::rc::{Rc, Weak}; -pub fn strlen_0(s: Ptr) -> usize { - let s: Value> = Rc::new(RefCell::new(s)); - let begin: Value> = Rc::new(RefCell::new((*s.borrow()).clone())); +pub fn strlen_0(s: Ptr<::core::ffi::c_char>) -> usize { + let s: Value> = Rc::new(RefCell::new(s)); + let begin: Value> = Rc::new(RefCell::new((*s.borrow()).clone())); 'loop_: while (((*s.borrow()).read()) != 0) { (*s.borrow_mut()).prefix_inc(); } @@ -18,16 +18,17 @@ pub fn main() { std::process::exit(main_0()); } fn main_0() -> i32 { - let s: Value> = Rc::new(RefCell::new(Box::new([ - ('s' as u8), - ('t' as u8), - ('r' as u8), - ('i' as u8), - ('n' as u8), - ('g' as u8), + let s: Value> = Rc::new(RefCell::new(Box::new([ + ('s' as ::core::ffi::c_char), + ('t' as ::core::ffi::c_char), + ('r' as ::core::ffi::c_char), + ('i' as ::core::ffi::c_char), + ('n' as ::core::ffi::c_char), + ('g' as ::core::ffi::c_char), ]))); return (({ - let _s: Ptr = ((s.as_pointer() as Ptr).offset(0 as isize)); + let _s: Ptr<::core::ffi::c_char> = + ((s.as_pointer() as Ptr<::core::ffi::c_char>).offset(0 as isize)); strlen_0(_s) }) as i32); } diff --git a/tests/ub/out/unsafe/ub21.rs b/tests/ub/out/unsafe/ub21.rs index a444049a..dd36b66b 100644 --- a/tests/ub/out/unsafe/ub21.rs +++ b/tests/ub/out/unsafe/ub21.rs @@ -6,7 +6,7 @@ use std::collections::BTreeMap; use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; -pub unsafe fn strlen_0(mut s: *const u8) -> usize { +pub unsafe fn strlen_0(mut s: *const ::core::ffi::c_char) -> usize { let mut count: usize = 0_usize; 'loop_: while ((*s.postfix_inc()) != 0) { count.prefix_inc(); @@ -19,9 +19,13 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let s: [u8; 3] = [('s' as u8), ('t' as u8), ('r' as u8)]; + let s: [::core::ffi::c_char; 3] = [ + ('s' as ::core::ffi::c_char), + ('t' as ::core::ffi::c_char), + ('r' as ::core::ffi::c_char), + ]; return ((unsafe { - let _s: *const u8 = s.as_ptr(); + let _s: *const ::core::ffi::c_char = s.as_ptr(); strlen_0(_s) }) as i32); } diff --git a/tests/ub/out/unsafe/ub7.rs b/tests/ub/out/unsafe/ub7.rs index 7c3fa594..b5132edb 100644 --- a/tests/ub/out/unsafe/ub7.rs +++ b/tests/ub/out/unsafe/ub7.rs @@ -6,12 +6,13 @@ use std::collections::BTreeMap; use std::io::{Read, Seek, Write}; use std::os::fd::{AsFd, FromRawFd, IntoRawFd}; use std::rc::Rc; -pub unsafe fn strlen_0(mut s: *const u8) -> usize { - let mut begin: *const u8 = s; +pub unsafe fn strlen_0(mut s: *const ::core::ffi::c_char) -> usize { + let mut begin: *const ::core::ffi::c_char = s; 'loop_: while ((*s) != 0) { s.prefix_inc(); } - return ((((s as usize - begin as usize) / ::std::mem::size_of::()) as i64) as usize); + return ((((s as usize - begin as usize) / ::std::mem::size_of::<::core::ffi::c_char>()) as i64) + as usize); } pub fn main() { unsafe { @@ -19,16 +20,16 @@ pub fn main() { } } unsafe fn main_0() -> i32 { - let s: [u8; 6] = [ - ('s' as u8), - ('t' as u8), - ('r' as u8), - ('i' as u8), - ('n' as u8), - ('g' as u8), + let s: [::core::ffi::c_char; 6] = [ + ('s' as ::core::ffi::c_char), + ('t' as ::core::ffi::c_char), + ('r' as ::core::ffi::c_char), + ('i' as ::core::ffi::c_char), + ('n' as ::core::ffi::c_char), + ('g' as ::core::ffi::c_char), ]; return ((unsafe { - let _s: *const u8 = (&s[(0) as usize] as *const u8); + let _s: *const ::core::ffi::c_char = (&s[(0) as usize] as *const ::core::ffi::c_char); strlen_0(_s) }) as i32); } diff --git a/tests/unit/out/refcount/array_const_init.rs b/tests/unit/out/refcount/array_const_init.rs index 784f3a73..07bded20 100644 --- a/tests/unit/out/refcount/array_const_init.rs +++ b/tests/unit/out/refcount/array_const_init.rs @@ -10,7 +10,7 @@ use std::rc::{Rc, Weak}; pub struct S { pub head: Value, pub tail: Value>, - pub buf: Value>, + pub buf: Value>, } impl Default for S { fn default() -> Self { @@ -20,7 +20,9 @@ impl Default for S { (0..3).map(|_| ::default()).collect::>(), )), buf: Rc::new(RefCell::new( - (0..4).map(|_| ::default()).collect::>(), + (0..4) + .map(|_| <::core::ffi::c_char>::default()) + .collect::>(), )), } } diff --git a/tests/unit/out/refcount/assign_as_value.rs b/tests/unit/out/refcount/assign_as_value.rs index bf16523b..098442e4 100644 --- a/tests/unit/out/refcount/assign_as_value.rs +++ b/tests/unit/out/refcount/assign_as_value.rs @@ -10,11 +10,15 @@ pub fn main() { std::process::exit(main_0()); } fn main_0() -> i32 { - let buf: Value> = Rc::new(RefCell::new( - (0..2).map(|_| ::default()).collect::>(), + let buf: Value> = Rc::new(RefCell::new( + (0..2) + .map(|_| <::core::ffi::c_char>::default()) + .collect::>(), )); - let p: Value> = Rc::new(RefCell::new((buf.as_pointer() as Ptr))); - let q: Value> = Rc::new(RefCell::new(Ptr::::null())); + let p: Value> = + Rc::new(RefCell::new((buf.as_pointer() as Ptr<::core::ffi::c_char>))); + let q: Value> = + Rc::new(RefCell::new(Ptr::<::core::ffi::c_char>::null())); (*q.borrow_mut()) = { (*p.borrow_mut()) += 1; (*p.borrow()).clone() @@ -22,14 +26,14 @@ fn main_0() -> i32 { assert!( ((({ let _lhs = (*q.borrow()).clone(); - _lhs == (buf.as_pointer() as Ptr).offset((1) as isize) + _lhs == (buf.as_pointer() as Ptr<::core::ffi::c_char>).offset((1) as isize) }) as i32) != 0) ); - let out: Value = >::default(); + let out: Value<::core::ffi::c_char> = >::default(); 'switch: { let __match_cond = (({ - (*out.borrow_mut()) = (('x' as i32) as u8); + (*out.borrow_mut()) = (('x' as i32) as ::core::ffi::c_char); (*out.borrow()) }) as i32); match __match_cond { diff --git a/tests/unit/out/refcount/bool_condition_int.rs b/tests/unit/out/refcount/bool_condition_int.rs index ad21faed..3b82871a 100644 --- a/tests/unit/out/refcount/bool_condition_int.rs +++ b/tests/unit/out/refcount/bool_condition_int.rs @@ -15,7 +15,7 @@ fn main_0() -> i32 { let u: Value = Rc::new(RefCell::new(4_u32)); let ul: Value = Rc::new(RefCell::new(5_u64)); let ll: Value = Rc::new(RefCell::new(6_i64)); - let ch: Value = Rc::new(RefCell::new(('a' as u8))); + let ch: Value<::core::ffi::c_char> = Rc::new(RefCell::new(('a' as ::core::ffi::c_char))); if ((*n.borrow()) != 0) { assert!(true); } diff --git a/tests/unit/out/refcount/bool_condition_int_c.rs b/tests/unit/out/refcount/bool_condition_int_c.rs index 7578ebc0..6bfdd615 100644 --- a/tests/unit/out/refcount/bool_condition_int_c.rs +++ b/tests/unit/out/refcount/bool_condition_int_c.rs @@ -15,7 +15,8 @@ fn main_0() -> i32 { let u: Value = Rc::new(RefCell::new(4_u32)); let ul: Value = Rc::new(RefCell::new(5_u64)); let ll: Value = Rc::new(RefCell::new(6_i64)); - let ch: Value = Rc::new(RefCell::new((('a' as i32) as u8))); + let ch: Value<::core::ffi::c_char> = + Rc::new(RefCell::new((('a' as i32) as ::core::ffi::c_char))); if ((*n.borrow()) != 0) { assert!((1 != 0)); } diff --git a/tests/unit/out/refcount/bool_condition_logical.rs b/tests/unit/out/refcount/bool_condition_logical.rs index 9b340849..ce191909 100644 --- a/tests/unit/out/refcount/bool_condition_logical.rs +++ b/tests/unit/out/refcount/bool_condition_logical.rs @@ -117,8 +117,10 @@ fn main_0() -> i32 { if ((*n.borrow()) != 0) || (((*bits.borrow()) & 256_i64) != 0) { assert!(true); } - let cp: Value> = Rc::new(RefCell::new(Ptr::from_string_literal(b"hi"))); - let cnp: Value> = Rc::new(RefCell::new(Ptr::::null())); + let cp: Value> = + Rc::new(RefCell::new(Ptr::from_string_literal(b"hi"))); + let cnp: Value> = + Rc::new(RefCell::new(Ptr::<::core::ffi::c_char>::null())); if ((*x.borrow()) > (*y.borrow())) && (!(*cp.borrow()).is_null()) { assert!(true); } diff --git a/tests/unit/out/refcount/bool_condition_logical_c.rs b/tests/unit/out/refcount/bool_condition_logical_c.rs index a878ce93..3af035f3 100644 --- a/tests/unit/out/refcount/bool_condition_logical_c.rs +++ b/tests/unit/out/refcount/bool_condition_logical_c.rs @@ -140,8 +140,10 @@ fn main_0() -> i32 { { assert!((1 != 0)); } - let cp: Value> = Rc::new(RefCell::new(Ptr::from_string_literal(b"hi"))); - let cnp: Value> = Rc::new(RefCell::new(Ptr::::null())); + let cp: Value> = + Rc::new(RefCell::new(Ptr::from_string_literal(b"hi"))); + let cnp: Value> = + Rc::new(RefCell::new(Ptr::<::core::ffi::c_char>::null())); if (((((((*x.borrow()) > (*y.borrow())) as i32) != 0) && (!(*cp.borrow()).is_null())) as i32) != 0) { diff --git a/tests/unit/out/refcount/borrow_mut_opt.rs b/tests/unit/out/refcount/borrow_mut_opt.rs index c5af8da9..6fb2e494 100644 --- a/tests/unit/out/refcount/borrow_mut_opt.rs +++ b/tests/unit/out/refcount/borrow_mut_opt.rs @@ -24,13 +24,13 @@ pub fn convert_without_rhs_0() { ((*arr.borrow())[(*y.borrow()) as usize] + (*arr.borrow())[(*x.borrow()) as usize]), )); (*w.borrow_mut()) += (((*z.borrow()) + (*y.borrow())) + (*x.borrow())); - let arr2: Value> = Rc::new(RefCell::new(Box::new([ - ('a' as u8), - ('b' as u8), - ('c' as u8), + let arr2: Value> = Rc::new(RefCell::new(Box::new([ + ('a' as ::core::ffi::c_char), + ('b' as ::core::ffi::c_char), + ('c' as ::core::ffi::c_char), ]))); let p1: Value> = Rc::new(RefCell::new((x.as_pointer()))); - let c: Value = Rc::new(RefCell::new( + let c: Value<::core::ffi::c_char> = Rc::new(RefCell::new( (*arr2.borrow())[((*p1.borrow()).read()) as usize], )); (*c.borrow_mut()) = (*arr2.borrow())[((*p1.borrow()).read()) as usize]; diff --git a/tests/unit/out/refcount/cast_array_to_pointer_decay.rs b/tests/unit/out/refcount/cast_array_to_pointer_decay.rs index fe7cc8d0..91236e0d 100644 --- a/tests/unit/out/refcount/cast_array_to_pointer_decay.rs +++ b/tests/unit/out/refcount/cast_array_to_pointer_decay.rs @@ -10,8 +10,8 @@ pub fn deref_0(p: Ptr) -> i32 { let p: Value> = Rc::new(RefCell::new(p)); return ((*p.borrow()).read()); } -pub fn strlen_1(s: Ptr) -> i32 { - let s: Value> = Rc::new(RefCell::new(s)); +pub fn strlen_1(s: Ptr<::core::ffi::c_char>) -> i32 { + let s: Value> = Rc::new(RefCell::new(s)); let c: Value = Rc::new(RefCell::new(0)); 'loop_: while (((*s.borrow_mut()).postfix_inc().read()) != 0) { (*c.borrow_mut()).prefix_inc(); @@ -23,17 +23,17 @@ pub fn main() { } fn main_0() -> i32 { let a: Value> = Rc::new(RefCell::new(Box::new([1, 2]))); - let s: Value> = Rc::new(RefCell::new(Box::new([ - ('a' as u8), - ('b' as u8), - ('c' as u8), - ('\0' as u8), + let s: Value> = Rc::new(RefCell::new(Box::new([ + ('a' as ::core::ffi::c_char), + ('b' as ::core::ffi::c_char), + ('c' as ::core::ffi::c_char), + ('\0' as ::core::ffi::c_char), ]))); return (({ let _p: Ptr = (a.as_pointer() as Ptr); deref_0(_p) }) + ({ - let _s: Ptr = (s.as_pointer() as Ptr); + let _s: Ptr<::core::ffi::c_char> = (s.as_pointer() as Ptr<::core::ffi::c_char>); strlen_1(_s) })); } diff --git a/tests/unit/out/refcount/char_printing.rs b/tests/unit/out/refcount/char_printing.rs index 74bd0914..fb15160f 100644 --- a/tests/unit/out/refcount/char_printing.rs +++ b/tests/unit/out/refcount/char_printing.rs @@ -12,23 +12,27 @@ pub fn main() { fn main_0() -> i32 { let vec_: Value> = Rc::new(RefCell::new(vec![195_u8, 167_u8])); let i: Value = Rc::new(RefCell::new(27)); - let str: Value> = Rc::new(RefCell::new( + let str: Value> = Rc::new(RefCell::new( Ptr::from_string_literal(b"rdas.") .to_c_string_iterator() .chain(std::iter::once(0)) - .collect::>(), + .collect::>(), )); write!(libcc2rs::cout(), "{:} a", (*i.borrow()),); libcc2rs::cout().write_all( &([ (&[((vec_.as_pointer() as Ptr) .offset(0_usize as isize) - .read())] as &[u8]), + .read()) as u8] as &[u8]), (&[((vec_.as_pointer() as Ptr) .offset(1_usize as isize) - .read())] as &[u8]), - (&[('o' as u8)] as &[u8]), - (&(*str.borrow())[..(*str.borrow()).len() - 1] as &[u8]), + .read()) as u8] as &[u8]), + (&[('o' as ::core::ffi::c_char) as u8] as &[u8]), + (&(*str.borrow()) + .iter() + .take((*str.borrow()).len() - 1) + .map(|&c| c as u8) + .collect::>()[..] as &[u8]), (&[b'\n'] as &[u8]), ] .concat()), @@ -37,7 +41,7 @@ fn main_0() -> i32 { libcc2rs::cout().write_all( &([ (b" a\xc3\xa7ordas?" as &[u8]), - (&[('\n' as u8)] as &[u8]), + (&[('\n' as ::core::ffi::c_char) as u8] as &[u8]), (b"Sim, 0x" as &[u8]), ] .concat()), @@ -48,12 +52,12 @@ fn main_0() -> i32 { &([ (&[((vec_.as_pointer() as Ptr) .offset(0_usize as isize) - .read())] as &[u8]), - (&[('\n' as u8)] as &[u8]), + .read()) as u8] as &[u8]), + (&[('\n' as ::core::ffi::c_char) as u8] as &[u8]), (&[((vec_.as_pointer() as Ptr) .offset(1_usize as isize) - .read())] as &[u8]), - (&[('\n' as u8)] as &[u8]), + .read()) as u8] as &[u8]), + (&[('\n' as ::core::ffi::c_char) as u8] as &[u8]), ] .concat()), ); diff --git a/tests/unit/out/refcount/char_printing_cerr.rs b/tests/unit/out/refcount/char_printing_cerr.rs index 7db45655..94afdeeb 100644 --- a/tests/unit/out/refcount/char_printing_cerr.rs +++ b/tests/unit/out/refcount/char_printing_cerr.rs @@ -12,23 +12,27 @@ pub fn main() { fn main_0() -> i32 { let vec_: Value> = Rc::new(RefCell::new(vec![195_u8, 167_u8])); let i: Value = Rc::new(RefCell::new(27)); - let str: Value> = Rc::new(RefCell::new( + let str: Value> = Rc::new(RefCell::new( Ptr::from_string_literal(b"rdas.") .to_c_string_iterator() .chain(std::iter::once(0)) - .collect::>(), + .collect::>(), )); write!(libcc2rs::cerr(), "{:} a", (*i.borrow()),); libcc2rs::cerr().write_all( &([ (&[((vec_.as_pointer() as Ptr) .offset(0_usize as isize) - .read())] as &[u8]), + .read()) as u8] as &[u8]), (&[((vec_.as_pointer() as Ptr) .offset(1_usize as isize) - .read())] as &[u8]), - (&[('o' as u8)] as &[u8]), - (&(*str.borrow())[..(*str.borrow()).len() - 1] as &[u8]), + .read()) as u8] as &[u8]), + (&[('o' as ::core::ffi::c_char) as u8] as &[u8]), + (&(*str.borrow()) + .iter() + .take((*str.borrow()).len() - 1) + .map(|&c| c as u8) + .collect::>()[..] as &[u8]), (&[b'\n'] as &[u8]), ] .concat()), @@ -37,7 +41,7 @@ fn main_0() -> i32 { libcc2rs::cerr().write_all( &([ (b" a\xc3\xa7ordas?" as &[u8]), - (&[('\n' as u8)] as &[u8]), + (&[('\n' as ::core::ffi::c_char) as u8] as &[u8]), (b"Sim, 0x" as &[u8]), ] .concat()), @@ -48,12 +52,12 @@ fn main_0() -> i32 { &([ (&[((vec_.as_pointer() as Ptr) .offset(0_usize as isize) - .read())] as &[u8]), - (&[('\n' as u8)] as &[u8]), + .read()) as u8] as &[u8]), + (&[('\n' as ::core::ffi::c_char) as u8] as &[u8]), (&[((vec_.as_pointer() as Ptr) .offset(1_usize as isize) - .read())] as &[u8]), - (&[('\n' as u8)] as &[u8]), + .read()) as u8] as &[u8]), + (&[('\n' as ::core::ffi::c_char) as u8] as &[u8]), ] .concat()), ); diff --git a/tests/unit/out/refcount/clone_vs_move.rs b/tests/unit/out/refcount/clone_vs_move.rs index 9f6ee411..3a781e74 100644 --- a/tests/unit/out/refcount/clone_vs_move.rs +++ b/tests/unit/out/refcount/clone_vs_move.rs @@ -424,46 +424,58 @@ fn main_0() -> i32 { assert!(((*(*pair4.borrow()).1.borrow()) == 1)); assert!(((*(*pair3.borrow()).0.borrow()).len() == 0_usize)); assert!(((*(*pair3.borrow()).1.borrow()) == 0)); - let s1: Value> = Rc::new(RefCell::new( - vec![('a' as u8); (3_usize) as usize] + let s1: Value> = Rc::new(RefCell::new( + vec![('a' as ::core::ffi::c_char); (3_usize) as usize] .iter() .cloned() .chain(std::iter::once(0)) .collect(), )); - let s2: Value> = Rc::new(RefCell::new((*s1.borrow()).clone())); - (s2.as_pointer() as Ptr) + let s2: Value> = Rc::new(RefCell::new((*s1.borrow()).clone())); + (s2.as_pointer() as Ptr<::core::ffi::c_char>) .offset(0_usize as isize) - .write(('b' as u8)); - (s2.as_pointer() as Ptr) + .write(('b' as ::core::ffi::c_char)); + (s2.as_pointer() as Ptr<::core::ffi::c_char>) .offset(1_usize as isize) - .write(('b' as u8)); - (s2.as_pointer() as Ptr) + .write(('b' as ::core::ffi::c_char)); + (s2.as_pointer() as Ptr<::core::ffi::c_char>) .offset(2_usize as isize) - .write(('b' as u8)); + .write(('b' as ::core::ffi::c_char)); assert!( - ((((s2.as_pointer() as Ptr).offset(0_usize as isize).read()) as i32) - == (('b' as u8) as i32)) + ((((s2.as_pointer() as Ptr<::core::ffi::c_char>) + .offset(0_usize as isize) + .read()) as i32) + == (('b' as ::core::ffi::c_char) as i32)) ); assert!( - ((((s2.as_pointer() as Ptr).offset(1_usize as isize).read()) as i32) - == (('b' as u8) as i32)) + ((((s2.as_pointer() as Ptr<::core::ffi::c_char>) + .offset(1_usize as isize) + .read()) as i32) + == (('b' as ::core::ffi::c_char) as i32)) ); assert!( - ((((s2.as_pointer() as Ptr).offset(2_usize as isize).read()) as i32) - == (('b' as u8) as i32)) + ((((s2.as_pointer() as Ptr<::core::ffi::c_char>) + .offset(2_usize as isize) + .read()) as i32) + == (('b' as ::core::ffi::c_char) as i32)) ); assert!( - ((((s1.as_pointer() as Ptr).offset(0_usize as isize).read()) as i32) - == (('a' as u8) as i32)) + ((((s1.as_pointer() as Ptr<::core::ffi::c_char>) + .offset(0_usize as isize) + .read()) as i32) + == (('a' as ::core::ffi::c_char) as i32)) ); assert!( - ((((s1.as_pointer() as Ptr).offset(1_usize as isize).read()) as i32) - == (('a' as u8) as i32)) + ((((s1.as_pointer() as Ptr<::core::ffi::c_char>) + .offset(1_usize as isize) + .read()) as i32) + == (('a' as ::core::ffi::c_char) as i32)) ); assert!( - ((((s1.as_pointer() as Ptr).offset(2_usize as isize).read()) as i32) - == (('a' as u8) as i32)) + ((((s1.as_pointer() as Ptr<::core::ffi::c_char>) + .offset(2_usize as isize) + .read()) as i32) + == (('a' as ::core::ffi::c_char) as i32)) ); let b1: Value = Rc::new(RefCell::new(Bar { w: Rc::new(RefCell::new(1)), diff --git a/tests/unit/out/refcount/default_in_statics.rs b/tests/unit/out/refcount/default_in_statics.rs index 7936846d..48a970fc 100644 --- a/tests/unit/out/refcount/default_in_statics.rs +++ b/tests/unit/out/refcount/default_in_statics.rs @@ -9,7 +9,7 @@ use std::rc::{Rc, Weak}; #[derive(Default)] pub struct Inner { pub v: Value, - pub name: Value>, + pub name: Value>, } impl Clone for Inner { fn clone(&self) -> Self { @@ -26,7 +26,7 @@ pub struct Outer { pub p1: Value>, pub p2: Value>, pub arr: Value]>>, - pub cp: Value>, + pub cp: Value>, pub pp: Value>>, pub inner: Value, pub x: Value, @@ -57,7 +57,7 @@ impl Default for Outer { .map(|_| Ptr::::null()) .collect::]>>(), )), - cp: Rc::new(RefCell::new(Ptr::::null())), + cp: Rc::new(RefCell::new(Ptr::<::core::ffi::c_char>::null())), pp: Rc::new(RefCell::new(Ptr::>::null())), inner: >::default(), x: >::default(), @@ -68,8 +68,8 @@ impl Default for Outer { impl ByteRepr for Outer {} #[derive()] pub struct Foo { - pub s1: Value>, - pub s2: Value>, + pub s1: Value>, + pub s2: Value>, pub fn1: Value i32>>, pub fn2: Value i32>>, pub n: Value, @@ -89,8 +89,8 @@ impl Clone for Foo { impl Default for Foo { fn default() -> Self { Foo { - s1: Rc::new(RefCell::new(Ptr::::null())), - s2: Rc::new(RefCell::new(Ptr::::null())), + s1: Rc::new(RefCell::new(Ptr::<::core::ffi::c_char>::null())), + s2: Rc::new(RefCell::new(Ptr::<::core::ffi::c_char>::null())), fn1: Rc::new(RefCell::new(FnPtr::null())), fn2: Rc::new(RefCell::new(FnPtr::null())), n: >::default(), @@ -112,7 +112,7 @@ thread_local!( thread_local!( pub static static_foo_3: Value = Rc::new(RefCell::new(Foo { s1: Rc::new(RefCell::new(Ptr::from_string_literal(b"hello"))), - s2: Rc::new(RefCell::new(Ptr::::null())), + s2: Rc::new(RefCell::new(Ptr::<::core::ffi::c_char>::null())), fn1: Rc::new(RefCell::new(FnPtr::null())), fn2: Rc::new(RefCell::new(FnPtr::null())), n: Rc::new(RefCell::new(42)), @@ -122,14 +122,14 @@ thread_local!( pub static static_foo_array_4: Value> = Rc::new(RefCell::new(Box::new([ Foo { s1: Rc::new(RefCell::new(Ptr::from_string_literal(b"first"))), - s2: Rc::new(RefCell::new(Ptr::::null())), + s2: Rc::new(RefCell::new(Ptr::<::core::ffi::c_char>::null())), fn1: Rc::new(RefCell::new(FnPtr::null())), fn2: Rc::new(RefCell::new(FnPtr::null())), n: Rc::new(RefCell::new(1)), }, Foo { s1: Rc::new(RefCell::new(Ptr::from_string_literal(b"second"))), - s2: Rc::new(RefCell::new(Ptr::::null())), + s2: Rc::new(RefCell::new(Ptr::<::core::ffi::c_char>::null())), fn1: Rc::new(RefCell::new(FnPtr::null())), fn2: Rc::new(RefCell::new(FnPtr::null())), n: Rc::new(RefCell::new(2)), diff --git a/tests/unit/out/refcount/doubly_linked_list.rs b/tests/unit/out/refcount/doubly_linked_list.rs index ff45aed2..ee761c14 100644 --- a/tests/unit/out/refcount/doubly_linked_list.rs +++ b/tests/unit/out/refcount/doubly_linked_list.rs @@ -272,11 +272,13 @@ fn main_0() -> i32 { .borrow()) == -1_i32) ); - assert!(({ - let _head: Ptr = (*head.borrow()).clone(); - Find_0(_head, 5) - }) - .is_null()); + assert!( + ({ + let _head: Ptr = (*head.borrow()).clone(); + Find_0(_head, 5) + }) + .is_null() + ); assert!( ((*(*({ let _tail: Ptr = (*tail.borrow()).clone(); @@ -332,15 +334,17 @@ fn main_0() -> i32 { .borrow()) == 4) ); - assert!((*(*({ - let _tail: Ptr = (*tail.borrow()).clone(); - FindBack_1(_tail, 4) - }) - .upgrade() - .deref()) - .prev - .borrow()) - .is_null()); + assert!( + (*(*({ + let _tail: Ptr = (*tail.borrow()).clone(); + FindBack_1(_tail, 4) + }) + .upgrade() + .deref()) + .prev + .borrow()) + .is_null() + ); assert!( ((*(*(*(*({ let _head: Ptr = (*head.borrow()).clone(); @@ -390,15 +394,17 @@ fn main_0() -> i32 { .borrow()) == 3) ); - assert!((*(*({ - let _head: Ptr = (*head.borrow()).clone(); - Find_0(_head, 4) - }) - .upgrade() - .deref()) - .next - .borrow()) - .is_null()); + assert!( + (*(*({ + let _head: Ptr = (*head.borrow()).clone(); + Find_0(_head, 4) + }) + .upgrade() + .deref()) + .next + .borrow()) + .is_null() + ); assert!( ((*(*(*(*(*(*({ let _tail: Ptr = (*tail.borrow()).clone(); diff --git a/tests/unit/out/refcount/enum_int_interop.rs b/tests/unit/out/refcount/enum_int_interop.rs index 01a28cd8..ea124dac 100644 --- a/tests/unit/out/refcount/enum_int_interop.rs +++ b/tests/unit/out/refcount/enum_int_interop.rs @@ -64,7 +64,7 @@ impl From for Tag { libcc2rs::impl_enum_inc_dec!(Tag); #[derive(Default)] pub struct Entry { - pub name: Value>, + pub name: Value>, pub color: Value, pub opt: Value