Skip to content

Commit d37ebfe

Browse files
authored
Rollup merge of rust-lang#129332 - cuviper:cstr-cast, r=compiler-errors
Avoid extra `cast()`s after `CStr::as_ptr()` These used to be `&str` literals that did need a pointer cast, but that became a no-op after switching to `c""` literals in rust-lang#118566.
2 parents 6d01ed8 + 32b574e commit d37ebfe

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: std/src/sys/pal/unix/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
116116
if pfd.revents & libc::POLLNVAL == 0 {
117117
continue;
118118
}
119-
if open64(c"/dev/null".as_ptr().cast(), libc::O_RDWR, 0) == -1 {
119+
if open64(c"/dev/null".as_ptr(), libc::O_RDWR, 0) == -1 {
120120
// If the stream is closed but we failed to reopen it, abort the
121121
// process. Otherwise we wouldn't preserve the safety of
122122
// operations on the corresponding Rust object Stdin, Stdout, or
@@ -147,7 +147,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
147147
use crate::sys::os::errno;
148148
for fd in 0..3 {
149149
if libc::fcntl(fd, libc::F_GETFD) == -1 && errno() == libc::EBADF {
150-
if open64(c"/dev/null".as_ptr().cast(), libc::O_RDWR, 0) == -1 {
150+
if open64(c"/dev/null".as_ptr(), libc::O_RDWR, 0) == -1 {
151151
// If the stream is closed but we failed to reopen it, abort the
152152
// process. Otherwise we wouldn't preserve the safety of
153153
// operations on the corresponding Rust object Stdin, Stdout, or

0 commit comments

Comments
 (0)