Skip to content

Commit

Permalink
Auto merge of #56129 - RalfJung:before-exec, r=<try>
Browse files Browse the repository at this point in the history
[DO NOT MERGE] make before_exec an unsafe fn

This is an experiment for #39575.
  • Loading branch information
bors committed Nov 21, 2018
2 parents 289ad6e + 39c3fd7 commit aaadaed
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/Cargo.lock
Expand Up @@ -201,7 +201,7 @@ dependencies = [
"hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"home 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ignore 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"jobserver 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"jobserver 0.1.11 (git+https://github.com/RalfJung/jobserver-rs)",
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazycell 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -1024,7 +1024,7 @@ dependencies = [
[[package]]
name = "jobserver"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
source = "git+https://github.com/RalfJung/jobserver-rs#3de40df347fcaeb0591dab77af47d3071ffa7b3b"
dependencies = [
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -1919,7 +1919,7 @@ dependencies = [
"flate2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"fmt_macros 0.0.0",
"graphviz 0.0.0",
"jobserver 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"jobserver 0.1.11 (git+https://github.com/RalfJung/jobserver-rs)",
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -3309,7 +3309,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450"
"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b"
"checksum jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "bfc62c8e50e381768ce8ee0428ee53741929f7ebd73e4d83f669bcf7693e00ae"
"checksum jobserver 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "60af5f849e1981434e4a31d3d782c4774ae9b434ce55b101a96ecfd09147e8be"
"checksum jobserver 0.1.11 (git+https://github.com/RalfJung/jobserver-rs)" = "<none>"
"checksum json 0.11.13 (registry+https://github.com/rust-lang/crates.io-index)" = "9ad0485404155f45cce53a40d4b2d6ac356418300daed05273d9e26f91c390be"
"checksum jsonrpc-core 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ddf83704f4e79979a424d1082dd2c1e52683058056c9280efa19ac5f6bc9033c"
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
Expand Down
1 change: 1 addition & 0 deletions src/Cargo.toml
Expand Up @@ -57,6 +57,7 @@ cargo = { path = "tools/cargo" }
# that we're shipping as well (to ensure that the rustfmt in RLS and the
# `rustfmt` executable are the same exact version).
rustfmt-nightly = { path = "tools/rustfmt" }
jobserver = { git = 'https://github.com/RalfJung/jobserver-rs' }

# See comments in `tools/rustc-workspace-hack/README.md` for what's going on
# here
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/sys/redox/ext/process.rs
Expand Up @@ -59,7 +59,7 @@ pub trait CommandExt {
/// working directory have successfully been changed, so output to these
/// locations may not appear where intended.
#[stable(feature = "process_exec", since = "1.15.0")]
fn before_exec<F>(&mut self, f: F) -> &mut process::Command
unsafe fn before_exec<F>(&mut self, f: F) -> &mut process::Command
where F: FnMut() -> io::Result<()> + Send + Sync + 'static;

/// Performs all the required setup by this `Command`, followed by calling
Expand Down Expand Up @@ -97,7 +97,7 @@ impl CommandExt for process::Command {
self
}

fn before_exec<F>(&mut self, f: F) -> &mut process::Command
unsafe fn before_exec<F>(&mut self, f: F) -> &mut process::Command
where F: FnMut() -> io::Result<()> + Send + Sync + 'static
{
self.as_inner_mut().before_exec(Box::new(f));
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/redox/process.rs
Expand Up @@ -126,7 +126,7 @@ impl Command {
self.gid = Some(id);
}

pub fn before_exec(&mut self,
pub unsafe fn before_exec(&mut self,
f: Box<dyn FnMut() -> io::Result<()> + Send + Sync>) {
self.closures.push(f);
}
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/sys/unix/ext/process.rs
Expand Up @@ -59,7 +59,7 @@ pub trait CommandExt {
/// working directory have successfully been changed, so output to these
/// locations may not appear where intended.
#[stable(feature = "process_exec", since = "1.15.0")]
fn before_exec<F>(&mut self, f: F) -> &mut process::Command
unsafe fn before_exec<F>(&mut self, f: F) -> &mut process::Command
where F: FnMut() -> io::Result<()> + Send + Sync + 'static;

/// Performs all the required setup by this `Command`, followed by calling
Expand Down Expand Up @@ -107,7 +107,7 @@ impl CommandExt for process::Command {
self
}

fn before_exec<F>(&mut self, f: F) -> &mut process::Command
unsafe fn before_exec<F>(&mut self, f: F) -> &mut process::Command
where F: FnMut() -> io::Result<()> + Send + Sync + 'static
{
self.as_inner_mut().before_exec(Box::new(f));
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/unix/process/process_common.rs
Expand Up @@ -159,7 +159,7 @@ impl Command {
&mut self.closures
}

pub fn before_exec(&mut self,
pub unsafe fn before_exec(&mut self,
f: Box<dyn FnMut() -> io::Result<()> + Send + Sync>) {
self.closures.push(f);
}
Expand Down

0 comments on commit aaadaed

Please sign in to comment.