mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Rollup merge of #139606 - jieyouxu:compiletest-edition2024, r=compiler-errors
Update compiletest to Edition 2024 r? bootstrap (or compiler) try-job: x86_64-apple-1 try-job: x86_64-msvc-1 try-jbo: x86_64-mingw-1
This commit is contained in:
commit
af3b892ca3
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "compiletest"
|
||||
version = "0.0.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
@ -40,7 +40,9 @@ pub(crate) fn configure_gdb(config: &Config) -> Option<Arc<Config>> {
|
||||
//
|
||||
// we should figure out how to lift this restriction! (run them all
|
||||
// on different ports allocated dynamically).
|
||||
env::set_var("RUST_TEST_THREADS", "1");
|
||||
//
|
||||
// SAFETY: at this point we are still single-threaded.
|
||||
unsafe { env::set_var("RUST_TEST_THREADS", "1") };
|
||||
}
|
||||
|
||||
Some(Arc::new(Config { debugger: Some(Debugger::Gdb), ..config.clone() }))
|
||||
|
@ -529,10 +529,14 @@ pub fn run_tests(config: Arc<Config>) {
|
||||
}
|
||||
// Prevent issue #21352 UAC blocking .exe containing 'patch' etc. on Windows
|
||||
// If #11207 is resolved (adding manifest to .exe) this becomes unnecessary
|
||||
env::set_var("__COMPAT_LAYER", "RunAsInvoker");
|
||||
//
|
||||
// SAFETY: at this point we're still single-threaded.
|
||||
unsafe { env::set_var("__COMPAT_LAYER", "RunAsInvoker") };
|
||||
|
||||
// Let tests know which target they're running as
|
||||
env::set_var("TARGET", &config.target);
|
||||
// Let tests know which target they're running as.
|
||||
//
|
||||
// SAFETY: at this point we're still single-threaded.
|
||||
unsafe { env::set_var("TARGET", &config.target) };
|
||||
|
||||
let mut configs = Vec::new();
|
||||
if let Mode::DebugInfo = config.mode {
|
||||
|
@ -6,6 +6,7 @@
|
||||
/// This fixes issue #7772.
|
||||
#[cfg(target_vendor = "apple")]
|
||||
#[allow(non_camel_case_types)]
|
||||
// FIXME(#139616): document caller contract.
|
||||
pub unsafe fn raise_fd_limit() {
|
||||
use std::ptr::null_mut;
|
||||
use std::{cmp, io};
|
||||
@ -21,8 +22,10 @@ pub unsafe fn raise_fd_limit() {
|
||||
let mut mib: [libc::c_int; 2] = [CTL_KERN, KERN_MAXFILESPERPROC];
|
||||
let mut maxfiles: libc::c_int = 0;
|
||||
let mut size: libc::size_t = size_of_val(&maxfiles) as libc::size_t;
|
||||
if libc::sysctl(&mut mib[0], 2, &mut maxfiles as *mut _ as *mut _, &mut size, null_mut(), 0)
|
||||
!= 0
|
||||
// FIXME(#139616): justify why this is sound.
|
||||
if unsafe {
|
||||
libc::sysctl(&mut mib[0], 2, &mut maxfiles as *mut _ as *mut _, &mut size, null_mut(), 0)
|
||||
} != 0
|
||||
{
|
||||
let err = io::Error::last_os_error();
|
||||
panic!("raise_fd_limit: error calling sysctl: {}", err);
|
||||
@ -30,7 +33,8 @@ pub unsafe fn raise_fd_limit() {
|
||||
|
||||
// Fetch the current resource limits
|
||||
let mut rlim = libc::rlimit { rlim_cur: 0, rlim_max: 0 };
|
||||
if libc::getrlimit(libc::RLIMIT_NOFILE, &mut rlim) != 0 {
|
||||
// FIXME(#139616): justify why this is sound.
|
||||
if unsafe { libc::getrlimit(libc::RLIMIT_NOFILE, &mut rlim) } != 0 {
|
||||
let err = io::Error::last_os_error();
|
||||
panic!("raise_fd_limit: error calling getrlimit: {}", err);
|
||||
}
|
||||
@ -41,7 +45,8 @@ pub unsafe fn raise_fd_limit() {
|
||||
rlim.rlim_cur = cmp::min(maxfiles as libc::rlim_t, rlim.rlim_max);
|
||||
|
||||
// Set our newly-increased resource limit.
|
||||
if libc::setrlimit(libc::RLIMIT_NOFILE, &rlim) != 0 {
|
||||
// FIXME(#139616): justify why this is sound.
|
||||
if unsafe { libc::setrlimit(libc::RLIMIT_NOFILE, &rlim) } != 0 {
|
||||
let err = io::Error::last_os_error();
|
||||
panic!("raise_fd_limit: error calling setrlimit: {}", err);
|
||||
}
|
||||
|
@ -165,6 +165,7 @@ mod imp {
|
||||
mut err_pipe: ChildStderr,
|
||||
data: &mut dyn FnMut(bool, &mut Vec<u8>, bool),
|
||||
) -> io::Result<()> {
|
||||
// FIXME(#139616): justify why this is sound.
|
||||
unsafe {
|
||||
libc::fcntl(out_pipe.as_raw_fd(), libc::F_SETFL, libc::O_NONBLOCK);
|
||||
libc::fcntl(err_pipe.as_raw_fd(), libc::F_SETFL, libc::O_NONBLOCK);
|
||||
@ -175,6 +176,7 @@ mod imp {
|
||||
let mut out = Vec::new();
|
||||
let mut err = Vec::new();
|
||||
|
||||
// FIXME(#139616): justify why this is sound.
|
||||
let mut fds: [libc::pollfd; 2] = unsafe { mem::zeroed() };
|
||||
fds[0].fd = out_pipe.as_raw_fd();
|
||||
fds[0].events = libc::POLLIN;
|
||||
@ -185,6 +187,7 @@ mod imp {
|
||||
|
||||
while nfds > 0 {
|
||||
// wait for either pipe to become readable using `select`
|
||||
// FIXME(#139616): justify why this is sound.
|
||||
let r = unsafe { libc::poll(fds.as_mut_ptr(), nfds, -1) };
|
||||
if r == -1 {
|
||||
let err = io::Error::last_os_error();
|
||||
@ -256,6 +259,7 @@ mod imp {
|
||||
port.add_handle(0, &out_pipe)?;
|
||||
port.add_handle(1, &err_pipe)?;
|
||||
|
||||
// FIXME(#139616): justify why this is sound.
|
||||
unsafe {
|
||||
let mut out_pipe = Pipe::new(out_pipe, &mut out);
|
||||
let mut err_pipe = Pipe::new(err_pipe, &mut err);
|
||||
@ -284,18 +288,23 @@ mod imp {
|
||||
}
|
||||
|
||||
impl<'a> Pipe<'a> {
|
||||
// FIXME(#139616): document caller contract.
|
||||
unsafe fn new<P: IntoRawHandle>(p: P, dst: &'a mut Vec<u8>) -> Pipe<'a> {
|
||||
Pipe {
|
||||
dst,
|
||||
pipe: NamedPipe::from_raw_handle(p.into_raw_handle()),
|
||||
// FIXME(#139616): justify why this is sound.
|
||||
pipe: unsafe { NamedPipe::from_raw_handle(p.into_raw_handle()) },
|
||||
overlapped: Overlapped::zero(),
|
||||
done: false,
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME(#139616): document caller contract.
|
||||
unsafe fn read(&mut self) -> io::Result<()> {
|
||||
let dst = slice_to_end(self.dst);
|
||||
match self.pipe.read_overlapped(dst, self.overlapped.raw()) {
|
||||
// FIXME(#139616): justify why this is sound.
|
||||
let dst = unsafe { slice_to_end(self.dst) };
|
||||
// FIXME(#139616): justify why this is sound.
|
||||
match unsafe { self.pipe.read_overlapped(dst, self.overlapped.raw()) } {
|
||||
Ok(_) => Ok(()),
|
||||
Err(e) => {
|
||||
if e.raw_os_error() == Some(ERROR_BROKEN_PIPE.0 as i32) {
|
||||
@ -308,15 +317,18 @@ mod imp {
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME(#139616): document caller contract.
|
||||
unsafe fn complete(&mut self, status: &CompletionStatus) {
|
||||
let prev = self.dst.len();
|
||||
self.dst.set_len(prev + status.bytes_transferred() as usize);
|
||||
// FIXME(#139616): justify why this is sound.
|
||||
unsafe { self.dst.set_len(prev + status.bytes_transferred() as usize) };
|
||||
if status.bytes_transferred() == 0 {
|
||||
self.done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME(#139616): document caller contract.
|
||||
unsafe fn slice_to_end(v: &mut Vec<u8>) -> &mut [u8] {
|
||||
if v.capacity() == 0 {
|
||||
v.reserve(16);
|
||||
@ -324,6 +336,12 @@ mod imp {
|
||||
if v.capacity() == v.len() {
|
||||
v.reserve(1);
|
||||
}
|
||||
slice::from_raw_parts_mut(v.as_mut_ptr().offset(v.len() as isize), v.capacity() - v.len())
|
||||
// FIXME(#139616): justify why this is sound.
|
||||
unsafe {
|
||||
slice::from_raw_parts_mut(
|
||||
v.as_mut_ptr().offset(v.len() as isize),
|
||||
v.capacity() - v.len(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user