Skip to content

Commit 1567d4d

Browse files
committed
Remove libc from more tests
1 parent 1dea922 commit 1567d4d

5 files changed

Lines changed: 30 additions & 45 deletions

File tree

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

Lines changed: 6 additions & 8 deletions
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-
externcrate 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-
fnrust_get_null_ptr() -> *mut::libc::c_char;
14+
fnrust_get_null_ptr() -> *mutc_char;
1715
}
1816

1917
#[cfg(unix)]
20-
fncheck_status(status:std::process::ExitStatus){
21-
use libc;
18+
fncheck_status(status:ExitStatus){
19+
externcrate 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-
fncheck_status(status:std::process::ExitStatus){
26+
fncheck_status(status:ExitStatus){
2927
assert!(!status.success());
3028
}
3129

‎tests/ui/attributes/unix_sigpipe/unix_sigpipe-and-child-processes.rs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111
// processes with and without the attribute. Search for
1212
// `unix_sigpipe_attr_specified()` in the code base to learn more.
1313

14-
#![feature(rustc_private)]
1514
#![cfg_attr(any(sig_dfl, sig_ign, inherit), feature(unix_sigpipe))]
1615

17-
externcrate libc;
1816
externcrate sigpipe_utils;
1917

2018
use sigpipe_utils::*;

‎tests/ui/extern-flag/auxiliary/panic_handler.rs‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
#![feature(lang_items)]
22
#![no_std]
33

4-
// Since `rustc` generally passes `-nodefaultlibs` to the linker,
5-
// Rust programs link necessary system libraries via `#[link()]`
6-
// attributes in the `libc` crate. `libc` is a dependency of `std`,
7-
// but as we are `#![no_std]`, we need to include it manually.
8-
#![feature(rustc_private)]
9-
externcrate libc;
10-
114
#[panic_handler]
125
pubfnbegin_panic_handler(_info:&core::panic::PanicInfo<'_>) -> ! {
136
loop{}
Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,28 @@
1+
// Test that println! to a closed stdout does not panic.
2+
// On Windows, close via SetStdHandle to 0.
13
//@ run-pass
2-
#![allow(dead_code)]
34

45
#![feature(rustc_private)]
56

6-
externcrate libc;
7-
8-
typeDWORD = u32;
9-
typeHANDLE = *mutu8;
10-
typeBOOL = i32;
11-
12-
#[cfg(windows)]
13-
extern"system"{
14-
fnSetStdHandle(nStdHandle:DWORD,nHandle:HANDLE) -> BOOL;
15-
}
16-
177
#[cfg(windows)]
188
fnclose_stdout(){
9+
typeDWORD = u32;
10+
typeHANDLE = *mutu8;
11+
typeBOOL = i32;
12+
13+
extern"system"{
14+
fnSetStdHandle(nStdHandle:DWORD,nHandle:HANDLE) -> BOOL;
15+
}
16+
1917
constSTD_OUTPUT_HANDLE:DWORD = -11i32asDWORD;
2018
unsafe{SetStdHandle(STD_OUTPUT_HANDLE,0asHANDLE);}
2119
}
2220

23-
#[cfg(windows)]
21+
#[cfg(not(windows))]
22+
fnclose_stdout(){}
23+
2424
fnmain(){
2525
close_stdout();
2626
println!("hello");
2727
println!("world");
2828
}
29-
30-
#[cfg(not(windows))]
31-
fnmain(){}

‎tests/ui/rfcs/rfc-1014-stdout-existential-crisis/rfc-1014.rs‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1+
// Test that println! to a closed stdout does not panic.
2+
// On Windows, close via CloseHandle.
13
//@ run-pass
2-
#![allow(dead_code)]
34
//@ ignore-sgx no libc
45

56
#![feature(rustc_private)]
67

7-
externcrate libc;
8-
9-
typeDWORD = u32;
10-
typeHANDLE = *mutu8;
11-
12-
#[cfg(windows)]
13-
extern"system"{
14-
fnGetStdHandle(which:DWORD) -> HANDLE;
15-
fnCloseHandle(handle:HANDLE) -> i32;
16-
}
17-
188
#[cfg(windows)]
199
fnclose_stdout(){
10+
typeDWORD = u32;
11+
typeHANDLE = *mutu8;
12+
13+
extern"system"{
14+
fnGetStdHandle(which:DWORD) -> HANDLE;
15+
fnCloseHandle(handle:HANDLE) -> i32;
16+
}
17+
2018
constSTD_OUTPUT_HANDLE:DWORD = -11i32asDWORD;
2119
unsafe{CloseHandle(GetStdHandle(STD_OUTPUT_HANDLE));}
2220
}
2321

2422
#[cfg(not(windows))]
2523
fnclose_stdout(){
24+
externcrate libc;
2625
unsafe{ libc::close(1);}
2726
}
2827

0 commit comments

Comments
 (0)