Skip to content

Commit 09df6b2

Browse files
committed
compiletest: update to Edition 2024
1 parent 934880f commit 09df6b2

File tree

5 files changed

+27
-15
lines changed

5 files changed

+27
-15
lines changed

src/tools/compiletest/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "compiletest"
33
version = "0.0.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
[lib]
77
doctest = false

src/tools/compiletest/src/debuggers.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ pub(crate) fn configure_gdb(config: &Config) -> Option<Arc<Config>> {
4040
//
4141
// we should figure out how to lift this restriction! (run them all
4242
// on different ports allocated dynamically).
43-
env::set_var("RUST_TEST_THREADS", "1");
43+
//
44+
// SAFETY: at this point we are still single-threaded.
45+
unsafe { env::set_var("RUST_TEST_THREADS", "1") };
4446
}
4547

4648
Some(Arc::new(Config { debugger: Some(Debugger::Gdb), ..config.clone() }))

src/tools/compiletest/src/lib.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -529,10 +529,14 @@ pub fn run_tests(config: Arc<Config>) {
529529
}
530530
// Prevent issue #21352 UAC blocking .exe containing 'patch' etc. on Windows
531531
// If #11207 is resolved (adding manifest to .exe) this becomes unnecessary
532-
env::set_var("__COMPAT_LAYER", "RunAsInvoker");
533-
534-
// Let tests know which target they're running as
535-
env::set_var("TARGET", &config.target);
532+
//
533+
// SAFETY: at this point we're still single-threaded.
534+
unsafe { env::set_var("__COMPAT_LAYER", "RunAsInvoker") };
535+
536+
// Let tests know which target they're running as.
537+
//
538+
// SAFETY: at this point we're still single-threaded.
539+
unsafe { env::set_var("TARGET", &config.target) };
536540

537541
let mut configs = Vec::new();
538542
if let Mode::DebugInfo = config.mode {

src/tools/compiletest/src/raise_fd_limit.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,17 @@ pub unsafe fn raise_fd_limit() {
2121
let mut mib: [libc::c_int; 2] = [CTL_KERN, KERN_MAXFILESPERPROC];
2222
let mut maxfiles: libc::c_int = 0;
2323
let mut size: libc::size_t = size_of_val(&maxfiles) as libc::size_t;
24-
if libc::sysctl(&mut mib[0], 2, &mut maxfiles as *mut _ as *mut _, &mut size, null_mut(), 0)
25-
!= 0
24+
if unsafe {
25+
libc::sysctl(&mut mib[0], 2, &mut maxfiles as *mut _ as *mut _, &mut size, null_mut(), 0)
26+
} != 0
2627
{
2728
let err = io::Error::last_os_error();
2829
panic!("raise_fd_limit: error calling sysctl: {}", err);
2930
}
3031

3132
// Fetch the current resource limits
3233
let mut rlim = libc::rlimit { rlim_cur: 0, rlim_max: 0 };
33-
if libc::getrlimit(libc::RLIMIT_NOFILE, &mut rlim) != 0 {
34+
if unsafe { libc::getrlimit(libc::RLIMIT_NOFILE, &mut rlim) } != 0 {
3435
let err = io::Error::last_os_error();
3536
panic!("raise_fd_limit: error calling getrlimit: {}", err);
3637
}
@@ -41,7 +42,7 @@ pub unsafe fn raise_fd_limit() {
4142
rlim.rlim_cur = cmp::min(maxfiles as libc::rlim_t, rlim.rlim_max);
4243

4344
// Set our newly-increased resource limit.
44-
if libc::setrlimit(libc::RLIMIT_NOFILE, &rlim) != 0 {
45+
if unsafe { libc::setrlimit(libc::RLIMIT_NOFILE, &rlim) } != 0 {
4546
let err = io::Error::last_os_error();
4647
panic!("raise_fd_limit: error calling setrlimit: {}", err);
4748
}

src/tools/compiletest/src/read2.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -287,15 +287,15 @@ mod imp {
287287
unsafe fn new<P: IntoRawHandle>(p: P, dst: &'a mut Vec<u8>) -> Pipe<'a> {
288288
Pipe {
289289
dst,
290-
pipe: NamedPipe::from_raw_handle(p.into_raw_handle()),
290+
pipe: unsafe { NamedPipe::from_raw_handle(p.into_raw_handle()) },
291291
overlapped: Overlapped::zero(),
292292
done: false,
293293
}
294294
}
295295

296296
unsafe fn read(&mut self) -> io::Result<()> {
297-
let dst = slice_to_end(self.dst);
298-
match self.pipe.read_overlapped(dst, self.overlapped.raw()) {
297+
let dst = unsafe { slice_to_end(self.dst) };
298+
match unsafe { self.pipe.read_overlapped(dst, self.overlapped.raw()) } {
299299
Ok(_) => Ok(()),
300300
Err(e) => {
301301
if e.raw_os_error() == Some(ERROR_BROKEN_PIPE.0 as i32) {
@@ -310,7 +310,7 @@ mod imp {
310310

311311
unsafe fn complete(&mut self, status: &CompletionStatus) {
312312
let prev = self.dst.len();
313-
self.dst.set_len(prev + status.bytes_transferred() as usize);
313+
unsafe { self.dst.set_len(prev + status.bytes_transferred() as usize) };
314314
if status.bytes_transferred() == 0 {
315315
self.done = true;
316316
}
@@ -324,6 +324,11 @@ mod imp {
324324
if v.capacity() == v.len() {
325325
v.reserve(1);
326326
}
327-
slice::from_raw_parts_mut(v.as_mut_ptr().offset(v.len() as isize), v.capacity() - v.len())
327+
unsafe {
328+
slice::from_raw_parts_mut(
329+
v.as_mut_ptr().offset(v.len() as isize),
330+
v.capacity() - v.len(),
331+
)
332+
}
328333
}
329334
}

0 commit comments

Comments
 (0)