Skip to content

Commit 7ee3c0f

Browse files
committed
refactor: address unsafe-op-in-unsafe-fn for Windows
We don't run clippy on Windows so we never catch that.
1 parent 15165ca commit 7ee3c0f

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/cargo/util/job.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ mod imp {
8787
// use job objects, so we instead just ignore errors and assume that
8888
// we're otherwise part of someone else's job object in this case.
8989

90-
let job = CreateJobObjectW(ptr::null_mut(), ptr::null());
90+
let job = unsafe { CreateJobObjectW(ptr::null_mut(), ptr::null()) };
9191
if job == INVALID_HANDLE_VALUE {
9292
return None;
9393
}
@@ -98,22 +98,24 @@ mod imp {
9898
// entire process tree by default because we've added ourselves and
9999
// our children will reside in the job once we spawn a process.
100100
let mut info: JOBOBJECT_EXTENDED_LIMIT_INFORMATION;
101-
info = mem::zeroed();
101+
info = unsafe { mem::zeroed() };
102102
info.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
103-
let r = SetInformationJobObject(
104-
job.inner,
105-
JobObjectExtendedLimitInformation,
106-
addr_of!(info) as *const _,
107-
mem::size_of_val(&info) as u32,
108-
);
103+
let r = unsafe {
104+
SetInformationJobObject(
105+
job.inner,
106+
JobObjectExtendedLimitInformation,
107+
addr_of!(info) as *const _,
108+
mem::size_of_val(&info) as u32,
109+
)
110+
};
109111
if r == 0 {
110112
return None;
111113
}
112114

113115
// Assign our process to this job object, meaning that our children will
114116
// now live or die based on our existence.
115-
let me = GetCurrentProcess();
116-
let r = AssignProcessToJobObject(job.inner, me);
117+
let me = unsafe { GetCurrentProcess() };
118+
let r = unsafe { AssignProcessToJobObject(job.inner, me) };
117119
if r == 0 {
118120
return None;
119121
}

0 commit comments

Comments
 (0)