about summary refs log tree commit diff
path: root/library/std/src/sys/unix/process
diff options
context:
space:
mode:
authorfee1-dead <ent3rm4n@gmail.com>2023-07-06 09:20:33 +0800
committerGitHub <noreply@github.com>2023-07-06 09:20:33 +0800
commit1830b80c2daf5b03d45ec69289e15b25cee97c7f (patch)
treeb37334e0cebeff760f865d586d9ef3e497e54b9d /library/std/src/sys/unix/process
parent01627265e3e2e84f4fee44ecf8cad892ed72a02a (diff)
parent22fd6a6abf1f97b488278cd142cc7fe721beb92a (diff)
downloadrust-1830b80c2daf5b03d45ec69289e15b25cee97c7f.tar.gz
rust-1830b80c2daf5b03d45ec69289e15b25cee97c7f.zip
Rollup merge of #113334 - fmease:revert-lexing-c-str-lits, r=compiler-errors
Revert the lexing of `c"…"` string literals

Fixes \[after beta-backport\] #113235.
Further progress is tracked in #113333.

This PR *manually* reverts parts of #108801 (since a git-revert would've been too coarse-grained & messy)
and git-reverts #111647.

CC `@fee1-dead` (#108801) `@klensy` (#111647)
r? `@compiler-errors`

`@rustbot` label F-c_str_literals beta-nominated
Diffstat (limited to 'library/std/src/sys/unix/process')
-rw-r--r--library/std/src/sys/unix/process/process_common.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/library/std/src/sys/unix/process/process_common.rs b/library/std/src/sys/unix/process/process_common.rs
index 5f316b12b62..640648e8707 100644
--- a/library/std/src/sys/unix/process/process_common.rs
+++ b/library/std/src/sys/unix/process/process_common.rs
@@ -24,11 +24,11 @@ cfg_if::cfg_if! {
     if #[cfg(target_os = "fuchsia")] {
         // fuchsia doesn't have /dev/null
     } else if #[cfg(target_os = "redox")] {
-        const DEV_NULL: &CStr = c"null:";
+        const DEV_NULL: &str = "null:\0";
     } else if #[cfg(target_os = "vxworks")] {
-        const DEV_NULL: &CStr = c"/null";
+        const DEV_NULL: &str = "/null\0";
     } else {
-        const DEV_NULL: &CStr = c"/dev/null";
+        const DEV_NULL: &str = "/dev/null\0";
     }
 }
 
@@ -474,7 +474,8 @@ impl Stdio {
                 let mut opts = OpenOptions::new();
                 opts.read(readable);
                 opts.write(!readable);
-                let fd = File::open_c(DEV_NULL, &opts)?;
+                let path = unsafe { CStr::from_ptr(DEV_NULL.as_ptr() as *const _) };
+                let fd = File::open_c(&path, &opts)?;
                 Ok((ChildStdio::Owned(fd.into_inner()), None))
             }