Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e7cb951

Browse files
committedApr 17, 2024
Remove libc from more tests
1 parent 1dea922 commit e7cb951

20 files changed

+57
-134
lines changed
 

‎tests/ui/abi/anon-extern-mod.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
//@ run-pass
22
//@ pretty-expanded FIXME #23616
33

4-
#![feature(rustc_private)]
5-
6-
extern crate libc;
7-
84
#[link(name = "rust_test_helpers", kind = "static")]
95
extern "C" {
10-
fn rust_get_test_int() -> libc::intptr_t;
6+
fn rust_get_test_int() -> isize;
117
}
128

139
pub fn main() {

‎tests/ui/abi/c-stack-as-value.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
//@ run-pass
22
//@ pretty-expanded FIXME #23616
33

4-
#![feature(rustc_private)]
5-
64
mod rustrt {
7-
extern crate libc;
8-
95
#[link(name = "rust_test_helpers", kind = "static")]
106
extern "C" {
11-
pub fn rust_get_test_int() -> libc::intptr_t;
7+
pub fn rust_get_test_int() -> isize;
128
}
139
}
1410

Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#![crate_name = "anonexternmod"]
2-
#![feature(rustc_private)]
3-
4-
extern crate libc;
52

63
#[link(name = "rust_test_helpers", kind = "static")]
74
extern "C" {
8-
pub fn rust_get_test_int() -> libc::intptr_t;
5+
pub fn rust_get_test_int() -> isize;
96
}
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
11
#![crate_name = "externcallback"]
22
#![crate_type = "lib"]
3-
#![feature(rustc_private)]
4-
5-
extern crate libc;
63

74
pub mod rustrt {
8-
extern crate libc;
9-
105
#[link(name = "rust_test_helpers", kind = "static")]
116
extern "C" {
127
pub fn rust_dbg_call(
13-
cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t,
14-
data: libc::uintptr_t,
15-
) -> libc::uintptr_t;
8+
cb: extern "C" fn(usize) -> usize,
9+
data: usize,
10+
) -> usize;
1611
}
1712
}
1813

19-
pub fn fact(n: libc::uintptr_t) -> libc::uintptr_t {
14+
pub fn fact(n: usize) -> usize {
2015
unsafe {
21-
println!("n = {}", n);
16+
println!("n = {:?}", n);
2217
rustrt::rust_dbg_call(cb, n)
2318
}
2419
}
2520

26-
pub extern "C" fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
21+
pub extern "C" fn cb(data: usize) -> usize {
2722
if data == 1 { data } else { fact(data - 1) * data }
2823
}

‎tests/ui/abi/extern/extern-call-deep.rs

+6-12
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
11
//@ run-pass
22
//@ ignore-emscripten blows the JS stack
33

4-
#![feature(rustc_private)]
5-
6-
extern crate libc;
7-
84
mod rustrt {
9-
extern crate libc;
10-
115
#[link(name = "rust_test_helpers", kind = "static")]
126
extern "C" {
137
pub fn rust_dbg_call(
14-
cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t,
15-
data: libc::uintptr_t,
16-
) -> libc::uintptr_t;
8+
cb: extern "C" fn(usize) -> usize,
9+
data: usize,
10+
) -> usize;
1711
}
1812
}
1913

20-
extern "C" fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
14+
extern "C" fn cb(data: usize) -> usize {
2115
if data == 1 { data } else { count(data - 1) + 1 }
2216
}
2317

24-
fn count(n: libc::uintptr_t) -> libc::uintptr_t {
18+
fn count(n: usize) -> usize {
2519
unsafe {
26-
println!("n = {}", n);
20+
println!("n = {:?}", n);
2721
rustrt::rust_dbg_call(cb, n)
2822
}
2923
}
+9-14
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
11
//@ run-pass
2-
#![allow(unused_must_use)]
32
//@ needs-threads
4-
#![feature(rustc_private)]
53

6-
extern crate libc;
74
use std::thread;
85

96
mod rustrt {
10-
extern crate libc;
11-
127
#[link(name = "rust_test_helpers", kind = "static")]
138
extern "C" {
149
pub fn rust_dbg_call(
15-
cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t,
16-
data: libc::uintptr_t,
17-
) -> libc::uintptr_t;
10+
cb: extern "C" fn(usize) -> usize,
11+
data: usize,
12+
) -> usize;
1813
}
1914
}
2015

21-
extern "C" fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
22-
if data == 1 { data } else { count(data - 1) + 1 }
16+
extern "C" fn cb(data: usize) -> usize {
17+
if data == 1 { data } else { count(data - 1 ) + 1 }
2318
}
2419

25-
fn count(n: libc::uintptr_t) -> libc::uintptr_t {
20+
fn count(n: usize) -> usize {
2621
unsafe {
27-
println!("n = {}", n);
22+
println!("n = {:?}", n);
2823
rustrt::rust_dbg_call(cb, n)
2924
}
3025
}
@@ -34,8 +29,8 @@ pub fn main() {
3429
// has a large stack)
3530
thread::spawn(move || {
3631
let result = count(1000);
37-
println!("result = {}", result);
32+
println!("result = {:?}", result);
3833
assert_eq!(result, 1000);
3934
})
40-
.join();
35+
.join().unwrap();
4136
}

‎tests/ui/abi/extern/extern-call-indirect.rs

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
11
//@ run-pass
22

3-
#![feature(rustc_private)]
4-
5-
extern crate libc;
6-
73
mod rustrt {
8-
extern crate libc;
9-
104
#[link(name = "rust_test_helpers", kind = "static")]
115
extern "C" {
126
pub fn rust_dbg_call(
13-
cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t,
14-
data: libc::uintptr_t,
15-
) -> libc::uintptr_t;
7+
cb: extern "C" fn(usize) -> usize,
8+
data: usize,
9+
) -> usize;
1610
}
1711
}
1812

19-
extern "C" fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
13+
extern "C" fn cb(data: usize) -> usize {
2014
if data == 1 { data } else { fact(data - 1) * data }
2115
}
2216

23-
fn fact(n: libc::uintptr_t) -> libc::uintptr_t {
17+
fn fact(n: usize) -> usize {
2418
unsafe {
2519
println!("n = {}", n);
2620
rustrt::rust_dbg_call(cb, n)
+7-13
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,26 @@
11
//@ run-pass
2-
#![allow(unused_must_use)]
2+
//@ needs-threads
33
// This time we're testing repeatedly going up and down both stacks to
44
// make sure the stack pointers are maintained properly in both
55
// directions
66

7-
//@ needs-threads
8-
#![feature(rustc_private)]
9-
10-
extern crate libc;
117
use std::thread;
128

139
mod rustrt {
14-
extern crate libc;
15-
1610
#[link(name = "rust_test_helpers", kind = "static")]
1711
extern "C" {
1812
pub fn rust_dbg_call(
19-
cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t,
20-
data: libc::uintptr_t,
21-
) -> libc::uintptr_t;
13+
cb: extern "C" fn(usize) -> usize,
14+
data: usize,
15+
) -> usize;
2216
}
2317
}
2418

25-
extern "C" fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
19+
extern "C" fn cb(data: usize) -> usize {
2620
if data == 1 { data } else { count(data - 1) + count(data - 1) }
2721
}
2822

29-
fn count(n: libc::uintptr_t) -> libc::uintptr_t {
23+
fn count(n: usize) -> usize {
3024
unsafe {
3125
println!("n = {}", n);
3226
rustrt::rust_dbg_call(cb, n)
@@ -41,5 +35,5 @@ pub fn main() {
4135
println!("result = {}", result);
4236
assert_eq!(result, 2048);
4337
})
44-
.join();
38+
.join().unwrap();
4539
}

‎tests/ui/abi/extern/extern-crosscrate.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
//@ run-pass
22
//@ aux-build:extern-crosscrate-source.rs
33

4-
#![feature(rustc_private)]
5-
64
extern crate externcallback;
7-
extern crate libc;
85

9-
fn fact(n: libc::uintptr_t) -> libc::uintptr_t {
6+
fn fact(n: usize) -> usize {
107
unsafe {
11-
println!("n = {}", n);
8+
println!("n = {:?}", n);
129
externcallback::rustrt::rust_dbg_call(externcallback::cb, n)
1310
}
1411
}

‎tests/ui/abi/foreign/auxiliary/foreign_lib.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
#![crate_name = "foreign_lib"]
2-
#![feature(rustc_private)]
32

43
pub mod rustrt {
5-
extern crate libc;
6-
74
#[link(name = "rust_test_helpers", kind = "static")]
85
extern "C" {
9-
pub fn rust_get_test_int() -> libc::intptr_t;
6+
pub fn rust_get_test_int() -> isize;
107
}
118
}
129

1310
pub mod rustrt2 {
14-
extern crate libc;
15-
1611
extern "C" {
17-
pub fn rust_get_test_int() -> libc::intptr_t;
12+
pub fn rust_get_test_int() -> isize;
1813
}
1914
}
2015

@@ -32,6 +27,6 @@ pub fn local_uses() {
3227
unsafe {
3328
let x = rustrt::rust_get_test_int();
3429
assert_eq!(x, rustrt2::rust_get_test_int());
35-
assert_eq!(x as *const _, rustrt3::rust_get_test_int());
30+
assert_eq!(x as *const u8, rustrt3::rust_get_test_int());
3631
}
3732
}

‎tests/ui/abi/foreign/foreign-call-no-runtime.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
//@ run-pass
22
//@ needs-threads
33

4-
#![feature(rustc_private)]
5-
6-
extern crate libc;
7-
4+
use std::ffi::c_void;
85
use std::mem;
96
use std::thread;
107

118
#[link(name = "rust_test_helpers", kind = "static")]
129
extern "C" {
13-
fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t), data: libc::uintptr_t) -> libc::uintptr_t;
10+
fn rust_dbg_call(cb: extern "C" fn(*const c_void), data: *const c_void) -> *const c_void;
1411
}
1512

1613
pub fn main() {
@@ -38,21 +35,21 @@ pub fn main() {
3835
}
3936
}
4037

41-
extern "C" fn callback_isize(data: libc::uintptr_t) {
38+
extern "C" fn callback_isize(data: *const c_void) {
4239
unsafe {
4340
let data = data as *const isize;
4441
assert_eq!(*data, 100);
4542
}
4643
}
4744

48-
extern "C" fn callback_i64(data: libc::uintptr_t) {
45+
extern "C" fn callback_i64(data: *const c_void) {
4946
unsafe {
5047
let data = data as *const i64;
5148
assert_eq!(*data, 100);
5249
}
5350
}
5451

55-
extern "C" fn callback_i32(data: libc::uintptr_t) {
52+
extern "C" fn callback_i32(data: *const c_void) {
5653
unsafe {
5754
let data = data as *const i32;
5855
assert_eq!(*data, 100);

‎tests/ui/abi/foreign/foreign-dupe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ pub fn main() {
1111
unsafe {
1212
let x = foreign_lib::rustrt::rust_get_test_int();
1313
assert_eq!(x, foreign_lib::rustrt2::rust_get_test_int());
14-
assert_eq!(x as *const _, foreign_lib::rustrt3::rust_get_test_int());
14+
assert_eq!(x as *const u8, foreign_lib::rustrt3::rust_get_test_int());
1515
}
1616
}

‎tests/ui/abi/foreign/foreign-no-abi.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@
33

44
//@ pretty-expanded FIXME #23616
55

6-
#![feature(rustc_private)]
7-
86
mod rustrt {
9-
extern crate libc;
10-
117
#[link(name = "rust_test_helpers", kind = "static")]
128
extern "C" {
13-
pub fn rust_get_test_int() -> libc::intptr_t;
9+
pub fn rust_get_test_int() -> isize;
1410
}
1511
}
1612

‎tests/ui/abi/segfault-no-out-of-stack.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
11
//@ run-pass
2-
3-
#![allow(unused_imports)]
42
//@ ignore-wasm32 can't run commands
53
//@ ignore-sgx no processes
64
//@ ignore-fuchsia must translate zircon signal to SIGSEGV/SIGBUS, FIXME (#58590)
7-
#![feature(rustc_private)]
85

9-
extern crate libc;
6+
#![feature(rustc_private)]
107

118
use std::env;
9+
use std::ffi::c_char;
1210
use std::process::{Command, ExitStatus};
1311

1412
#[link(name = "rust_test_helpers", kind = "static")]
1513
extern "C" {
16-
fn rust_get_null_ptr() -> *mut ::libc::c_char;
14+
fn rust_get_null_ptr() -> *mut c_char;
1715
}
1816

1917
#[cfg(unix)]
20-
fn check_status(status: std::process::ExitStatus) {
21-
use libc;
18+
fn check_status(status: ExitStatus) {
19+
extern crate libc;
2220
use std::os::unix::process::ExitStatusExt;
2321

2422
assert!(status.signal() == Some(libc::SIGSEGV) || status.signal() == Some(libc::SIGBUS));
2523
}
2624

2725
#[cfg(not(unix))]
28-
fn check_status(status: std::process::ExitStatus) {
26+
fn check_status(status: ExitStatus) {
2927
assert!(!status.success());
3028
}
3129

There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.