Skip to content

Commit db6226c

Browse files
committed
Wrap variadic arg in paren before calling .into() (#168)
`libc::strlen(dummy as *const i8) as u64.into()` (without paren) errors because we can't write `as u64.into()`, we need to wrap the entire arg in a paren before calling .into(): `(libc::strlen(dummy as *const i8) as u64).into()`
1 parent c4580d2 commit db6226c

6 files changed

Lines changed: 21 additions & 14 deletions

File tree

tests/unit/out/refcount/va_arg_conditional.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ fn main_0() -> i32 {
2525
(((({
2626
let _verbose: i32 = 1;
2727
let _fmt: Ptr<u8> = Ptr::from_string_literal(b"%d");
28-
conditional_log_0(_verbose, _fmt, &[42.into()])
28+
conditional_log_0(_verbose, _fmt, &[(42).into()])
2929
}) == 42) as i32)
3030
!= 0)
3131
);
3232
assert!(
3333
(((({
3434
let _verbose: i32 = 0;
3535
let _fmt: Ptr<u8> = Ptr::from_string_literal(b"%d");
36-
conditional_log_0(_verbose, _fmt, &[99.into()])
36+
conditional_log_0(_verbose, _fmt, &[(99).into()])
3737
}) == -1_i32) as i32)
3838
!= 0)
3939
);

tests/unit/out/refcount/va_arg_non_primitive_ptrs.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn main_0() -> i32 {
9191
assert!(
9292
(((({
9393
let _option: i32 = (opt::OPT_FILE as i32);
94-
dispatch_0(_option, &[libcc2rs::cout().into()])
94+
dispatch_0(_option, &[(libcc2rs::cout()).into()])
9595
}) == 1) as i32)
9696
!= 0)
9797
);
@@ -100,10 +100,10 @@ fn main_0() -> i32 {
100100
let _option: i32 = (opt::OPT_FILE as i32);
101101
dispatch_0(
102102
_option,
103-
&[(AnyPtr::default())
103+
&[((AnyPtr::default())
104104
.cast::<::std::fs::File>()
105-
.expect("ub:wrong type")
106-
.into()],
105+
.expect("ub:wrong type"))
106+
.into()],
107107
)
108108
}) == 0) as i32)
109109
!= 0)

tests/unit/out/refcount/va_arg_printf.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,24 @@ pub fn main() {
3232
std::process::exit(main_0());
3333
}
3434
fn main_0() -> i32 {
35+
let dummy: Value<Ptr<u8>> = Rc::new(RefCell::new(Ptr::from_string_literal(b"dummy")));
3536
assert!(
3637
(((({
3738
let _fmt: Ptr<u8> = Ptr::from_string_literal(b"hello %d %d");
38-
logf_1(_fmt, &[10.into(), 32.into()])
39-
}) == 42) as i32)
39+
logf_1(
40+
_fmt,
41+
&[
42+
(10).into(),
43+
((*dummy.borrow()).to_string_iterator().count() as u64).into(),
44+
],
45+
)
46+
}) == 15) as i32)
4047
!= 0)
4148
);
4249
assert!(
4350
(((({
4451
let _fmt: Ptr<u8> = Ptr::from_string_literal(b"x %d %d");
45-
logf_1(_fmt, &[1.into(), 2.into()])
52+
logf_1(_fmt, &[(1).into(), (2).into()])
4653
}) == 3) as i32)
4754
!= 0)
4855
);

tests/unit/out/refcount/va_arg_snprintf.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn main_0() -> i32 {
2929
let _buf: Ptr<u8> = (buf.as_pointer() as Ptr<u8>);
3030
let _size: i32 = 1;
3131
let _fmt: Ptr<u8> = Ptr::from_string_literal(b"%d");
32-
extract_first_0(_buf, _size, _fmt, &[42.into()])
32+
extract_first_0(_buf, _size, _fmt, &[(42).into()])
3333
}) == 42) as i32)
3434
!= 0)
3535
);
@@ -39,7 +39,7 @@ fn main_0() -> i32 {
3939
let _buf: Ptr<u8> = (buf.as_pointer() as Ptr<u8>);
4040
let _size: i32 = 1;
4141
let _fmt: Ptr<u8> = Ptr::from_string_literal(b"%d");
42-
extract_first_0(_buf, _size, _fmt, &[65.into()])
42+
extract_first_0(_buf, _size, _fmt, &[(65).into()])
4343
}) == 65) as i32)
4444
!= 0)
4545
);

tests/unit/out/refcount/va_arg_struct_ctx.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ fn main_0() -> i32 {
4343
({
4444
let _ctx: Ptr<context> = (ctx.as_pointer());
4545
let _fmt: Ptr<u8> = Ptr::from_string_literal(b"error %d");
46-
set_error_0(_ctx, _fmt, &[42.into()])
46+
set_error_0(_ctx, _fmt, &[(42).into()])
4747
});
4848
assert!(((((*(*ctx.borrow()).last_error.borrow()) == 42) as i32) != 0));
4949
(*(*ctx.borrow()).verbose.borrow_mut()) = 0;
5050
({
5151
let _ctx: Ptr<context> = (ctx.as_pointer());
5252
let _fmt: Ptr<u8> = Ptr::from_string_literal(b"error %d");
53-
set_error_0(_ctx, _fmt, &[99.into()])
53+
set_error_0(_ctx, _fmt, &[(99).into()])
5454
});
5555
assert!(((((*(*ctx.borrow()).last_error.borrow()) == 42) as i32) != 0));
5656
return 0;

tests/unit/out/unsafe/va_arg_non_primitive_ptrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ unsafe fn main_0() -> i32 {
8484
assert!(
8585
((((unsafe {
8686
let _option: i32 = (opt::OPT_FILE as i32);
87-
dispatch_0(_option, &[libcc2rs::stdout_unsafe().into()])
87+
dispatch_0(_option, &[(libcc2rs::stdout_unsafe()).into()])
8888
}) == (1)) as i32)
8989
!= 0)
9090
);

0 commit comments

Comments
 (0)