Skip to content

Commit 23b03d6

Browse files
committed
transpile: tests: snapshots: update for const unsafe changes
this should probably be merged with the individual commits changing behavior, but this history is already messy and should be cleaned up before hitting master
1 parent 83ded08 commit 23b03d6

File tree

2 files changed

+31
-35
lines changed

2 files changed

+31
-35
lines changed

c2rust-transpile/tests/snapshots/[email protected]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ pub unsafe extern "C" fn c11_atomics(mut x: std::ffi::c_int) -> std::ffi::c_int
3737
fresh1.1;
3838
return x;
3939
}
40-
pub const __ATOMIC_SEQ_CST: std::ffi::c_int = unsafe { 5 as std::ffi::c_int };
40+
pub const __ATOMIC_SEQ_CST: std::ffi::c_int = 5 as std::ffi::c_int;

c2rust-transpile/tests/snapshots/[email protected]

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -30,35 +30,31 @@ pub struct fn_ptrs {
3030
pub fn2: Option<unsafe extern "C" fn(std::ffi::c_int) -> std::ffi::c_int>,
3131
}
3232
pub type zstd_platform_dependent_type = std::ffi::c_long;
33-
pub const UINTPTR_MAX: std::ffi::c_ulong = unsafe { 18446744073709551615 as std::ffi::c_ulong };
34-
pub const true_0: std::ffi::c_int = unsafe { 1 as std::ffi::c_int };
35-
pub const LITERAL_INT: std::ffi::c_int = unsafe { 0xffff as std::ffi::c_int };
36-
pub const LITERAL_BOOL: std::ffi::c_int = unsafe { true_0 };
37-
pub const LITERAL_FLOAT: std::ffi::c_double = unsafe { 3.14f64 };
38-
pub const LITERAL_CHAR: std::ffi::c_int = unsafe { 'x' as i32 };
39-
pub const LITERAL_STRUCT: S = unsafe {
40-
{
41-
let mut init = S {
42-
i: 5 as std::ffi::c_int,
43-
};
44-
init
45-
}
33+
pub const UINTPTR_MAX: std::ffi::c_ulong = 18446744073709551615 as std::ffi::c_ulong;
34+
pub const true_0: std::ffi::c_int = 1 as std::ffi::c_int;
35+
pub const LITERAL_INT: std::ffi::c_int = 0xffff as std::ffi::c_int;
36+
pub const LITERAL_BOOL: std::ffi::c_int = true_0;
37+
pub const LITERAL_FLOAT: std::ffi::c_double = 3.14f64;
38+
pub const LITERAL_CHAR: std::ffi::c_int = 'x' as i32;
39+
pub const LITERAL_STRUCT: S = {
40+
let mut init = S {
41+
i: 5 as std::ffi::c_int,
42+
};
43+
init
4644
};
47-
pub const NESTED_INT: std::ffi::c_int = unsafe { LITERAL_INT };
48-
pub const NESTED_BOOL: std::ffi::c_int = unsafe { 1 as std::ffi::c_int };
49-
pub const NESTED_FLOAT: std::ffi::c_double = unsafe { LITERAL_FLOAT };
50-
pub const NESTED_CHAR: std::ffi::c_int = unsafe { 'x' as i32 };
51-
pub const NESTED_STRUCT: S = unsafe {
52-
{
53-
let mut init = S {
54-
i: 5 as std::ffi::c_int,
55-
};
56-
init
57-
}
45+
pub const NESTED_INT: std::ffi::c_int = LITERAL_INT;
46+
pub const NESTED_BOOL: std::ffi::c_int = 1 as std::ffi::c_int;
47+
pub const NESTED_FLOAT: std::ffi::c_double = LITERAL_FLOAT;
48+
pub const NESTED_CHAR: std::ffi::c_int = 'x' as i32;
49+
pub const NESTED_STRUCT: S = {
50+
let mut init = S {
51+
i: 5 as std::ffi::c_int,
52+
};
53+
init
5854
};
59-
pub const PARENS: std::ffi::c_int = unsafe { NESTED_INT * (LITERAL_CHAR + true_0) };
60-
pub const WIDENING_CAST: std::ffi::c_int = unsafe { LITERAL_INT };
61-
pub const CONVERSION_CAST: std::ffi::c_int = unsafe { LITERAL_INT };
55+
pub const PARENS: std::ffi::c_int = NESTED_INT * (LITERAL_CHAR + true_0);
56+
pub const WIDENING_CAST: std::ffi::c_int = LITERAL_INT;
57+
pub const CONVERSION_CAST: std::ffi::c_int = LITERAL_INT;
6258
#[no_mangle]
6359
pub unsafe extern "C" fn local_muts() {
6460
let mut literal_int: std::ffi::c_int = LITERAL_INT;
@@ -324,11 +320,11 @@ pub static mut global_const_member: std::ffi::c_int = 0;
324320
pub unsafe extern "C" fn test_fn_macro(mut x: std::ffi::c_int) -> std::ffi::c_int {
325321
return x * x;
326322
}
327-
pub const TEST_CONST1: std::ffi::c_int = unsafe { 1 as std::ffi::c_int };
328-
pub const TEST_NESTED: std::ffi::c_int = unsafe { 2 as std::ffi::c_int };
329-
pub const TEST_CONST2: std::ffi::c_int = unsafe { TEST_NESTED };
323+
pub const TEST_CONST1: std::ffi::c_int = 1 as std::ffi::c_int;
324+
pub const TEST_NESTED: std::ffi::c_int = 2 as std::ffi::c_int;
325+
pub const TEST_CONST2: std::ffi::c_int = TEST_NESTED;
330326
pub const TEST_PARENS: std::ffi::c_int =
331-
unsafe { (TEST_CONST2 + 1 as std::ffi::c_int) * 3 as std::ffi::c_int };
327+
(TEST_CONST2 + 1 as std::ffi::c_int) * 3 as std::ffi::c_int;
332328
#[no_mangle]
333329
pub unsafe extern "C" fn reference_define() -> std::ffi::c_int {
334330
let mut x: std::ffi::c_int = TEST_CONST1;
@@ -349,8 +345,8 @@ pub static mut fns: fn_ptrs = {
349345
};
350346
#[no_mangle]
351347
pub static mut p: *const fn_ptrs = unsafe { &fns as *const fn_ptrs };
352-
pub const ZSTD_WINDOWLOG_MAX_32: std::ffi::c_int = unsafe { 30 as std::ffi::c_int };
353-
pub const ZSTD_WINDOWLOG_MAX_64: std::ffi::c_int = unsafe { 31 as std::ffi::c_int };
348+
pub const ZSTD_WINDOWLOG_MAX_32: std::ffi::c_int = 30 as std::ffi::c_int;
349+
pub const ZSTD_WINDOWLOG_MAX_64: std::ffi::c_int = 31 as std::ffi::c_int;
354350
#[no_mangle]
355351
pub unsafe extern "C" fn test_zstd() -> U64 {
356352
return (if ::core::mem::size_of::<zstd_platform_dependent_type>() as std::ffi::c_ulong
@@ -386,7 +382,7 @@ pub unsafe extern "C" fn test_switch(mut x: std::ffi::c_int) -> std::ffi::c_int
386382
}
387383
return 0 as std::ffi::c_int;
388384
}
389-
pub const silk_int16_MIN: std::ffi::c_int = unsafe { 0x8000 as std::ffi::c_int };
385+
pub const silk_int16_MIN: std::ffi::c_int = 0x8000 as std::ffi::c_int;
390386
#[no_mangle]
391387
pub unsafe extern "C" fn test_silk_int16_MIN() -> std::ffi::c_int {
392388
let mut _null: std::ffi::c_char =

0 commit comments

Comments
 (0)