Skip to content

Commit 88e6976

Browse files
committed
Auto merge of #25653 - dotdash:unsize_c, r=luqmana
Fixes #25581
2 parents d113990 + a3c4ce4 commit 88e6976

File tree

4 files changed

+56
-1
lines changed

4 files changed

+56
-1
lines changed

src/librustc_trans/trans/callee.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ pub fn trans_call_inner<'a, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
846846

847847
let mut llargs = Vec::new();
848848
let arg_tys = match args {
849-
ArgExprs(a) => a.iter().map(|x| common::expr_ty(bcx, &**x)).collect(),
849+
ArgExprs(a) => a.iter().map(|x| common::expr_ty_adjusted(bcx, &**x)).collect(),
850850
_ => panic!("expected arg exprs.")
851851
};
852852
bcx = trans_args(bcx,
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-include ../tools.mk
2+
3+
all:
4+
$(CC) -std=c99 test.c -c -o $(TMPDIR)/test.o
5+
$(AR) rcs $(TMPDIR)/libtest.a $(TMPDIR)/test.o
6+
$(RUSTC) test.rs -L $(TMPDIR)
7+
$(call RUN,test) || exit 1

src/test/run-make/issue-25581/test.c

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// ignore-license
2+
#include <stddef.h>
3+
#include <stdint.h>
4+
5+
struct ByteSlice {
6+
uint8_t *data;
7+
size_t len;
8+
};
9+
10+
size_t slice_len(struct ByteSlice bs) {
11+
return bs.len;
12+
}
13+
14+
uint8_t slice_elem(struct ByteSlice bs, size_t idx) {
15+
return bs.data[idx];
16+
}

src/test/run-make/issue-25581/test.rs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(libc)]
12+
13+
extern crate libc;
14+
15+
#[link(name = "test")]
16+
extern {
17+
fn slice_len(s: &[u8]) -> libc::size_t;
18+
fn slice_elem(s: &[u8], idx: libc::size_t) -> u8;
19+
}
20+
21+
fn main() {
22+
let data = [1,2,3,4,5];
23+
24+
unsafe {
25+
assert_eq!(data.len(), slice_len(&data) as usize);
26+
assert_eq!(data[0], slice_elem(&data, 0));
27+
assert_eq!(data[1], slice_elem(&data, 1));
28+
assert_eq!(data[2], slice_elem(&data, 2));
29+
assert_eq!(data[3], slice_elem(&data, 3));
30+
assert_eq!(data[4], slice_elem(&data, 4));
31+
}
32+
}

0 commit comments

Comments
 (0)