about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-08-15 23:56:14 -0700
committerbors <bors@rust-lang.org>2013-08-15 23:56:14 -0700
commit92af0db0a3919f5371de362cb6060ff87190aafe (patch)
treee819447f3c4ce9faf88009a643ca0141fba57b64
parent253337de825306a6080d65266eb2a5b101509e63 (diff)
parent5be4408ef20af3f6852095b81249e81f81d344b7 (diff)
downloadrust-92af0db0a3919f5371de362cb6060ff87190aafe.tar.gz
rust-92af0db0a3919f5371de362cb6060ff87190aafe.zip
auto merge of #8518 : catamorphism/rust/issue-8498-workaround, r=brson
r? @brson
-rw-r--r--src/compiletest/procsrv.rs2
-rw-r--r--src/librustpkg/tests.rs10
-rw-r--r--src/libstd/run.rs20
-rw-r--r--src/test/run-pass/issue-8498.rs44
4 files changed, 61 insertions, 15 deletions
diff --git a/src/compiletest/procsrv.rs b/src/compiletest/procsrv.rs
index a5d308007b4..45e4f756d7a 100644
--- a/src/compiletest/procsrv.rs
+++ b/src/compiletest/procsrv.rs
@@ -49,7 +49,7 @@ pub fn run(lib_path: &str,
 
     let env = env + target_env(lib_path, prog);
     let mut proc = run::Process::new(prog, args, run::ProcessOptions {
-        env: Some(env.slice(0, env.len())),
+        env: Some(env),
         dir: None,
         in_fd: None,
         out_fd: None,
diff --git a/src/librustpkg/tests.rs b/src/librustpkg/tests.rs
index 121dcf40150..be3cb644edb 100644
--- a/src/librustpkg/tests.rs
+++ b/src/librustpkg/tests.rs
@@ -114,7 +114,7 @@ fn mk_temp_workspace(short_name: &Path, version: &Version) -> Path {
 fn run_git(args: &[~str], env: Option<~[(~str, ~str)]>, cwd: &Path, err_msg: &str) {
     let cwd = (*cwd).clone();
     let mut prog = run::Process::new("git", args, run::ProcessOptions {
-        env: env.map(|v| v.slice(0, v.len())),
+        env: env,
         dir: Some(&cwd),
         in_fd: None,
         out_fd: None,
@@ -222,7 +222,7 @@ fn command_line_test_with_env(args: &[~str], cwd: &Path, env: Option<~[(~str, ~s
     assert!(os::path_is_dir(&*cwd));
     let cwd = (*cwd).clone();
     let mut prog = run::Process::new(cmd, args, run::ProcessOptions {
-        env: env.map(|v| v.slice(0, v.len())),
+        env: env,
         dir: Some(&cwd),
         in_fd: None,
         out_fd: None,
@@ -757,7 +757,9 @@ fn rust_path_test() {
                                      // use command_line_test_with_env
     let mut prog = run::Process::new("rustpkg",
                                      [~"install", ~"foo"],
-                                     run::ProcessOptions { env: Some(&[(~"RUST_LOG",
+// This should actually extend the environment; then we can probably
+// un-ignore it
+                                     run::ProcessOptions { env: Some(~[(~"RUST_LOG",
                                                                         ~"rustpkg"),
                                                                        (~"RUST_PATH",
                                                                        dir_for_path.to_str())]),
@@ -1039,7 +1041,7 @@ fn test_extern_mod() {
                                                       ~"--sysroot", test_sysroot().to_str(),
                                                ~"-o", exec_file.to_str()],
                                      run::ProcessOptions {
-        env: env.map(|v| v.slice(0, v.len())),
+        env: env,
         dir: Some(&dir),
         in_fd: None,
         out_fd: None,
diff --git a/src/libstd/run.rs b/src/libstd/run.rs
index 31e317604c7..4d751101d73 100644
--- a/src/libstd/run.rs
+++ b/src/libstd/run.rs
@@ -68,7 +68,7 @@ pub struct ProcessOptions<'self> {
      * If this is Some(vec-of-names-and-values) then the new process will
      * have an environment containing the given named values only.
      */
-    env: Option<&'self [(~str, ~str)]>,
+    env: Option<~[(~str, ~str)]>,
 
     /**
      * If this is None then the new process will use the same initial working
@@ -171,7 +171,7 @@ impl Process {
             Some(fd) => (None, fd)
         };
 
-        let res = spawn_process_os(prog, args, options.env, options.dir,
+        let res = spawn_process_os(prog, args, options.env.clone(), options.dir,
                                    in_fd, out_fd, err_fd);
 
         unsafe {
@@ -444,7 +444,7 @@ struct SpawnProcessResult {
 
 #[cfg(windows)]
 fn spawn_process_os(prog: &str, args: &[~str],
-                    env: Option<&[(~str, ~str)]>,
+                    env: Option<~[(~str, ~str)]>,
                     dir: Option<&Path>,
                     in_fd: c_int, out_fd: c_int, err_fd: c_int) -> SpawnProcessResult {
 
@@ -627,7 +627,7 @@ pub fn make_command_line(prog: &str, args: &[~str]) -> ~str {
 
 #[cfg(unix)]
 fn spawn_process_os(prog: &str, args: &[~str],
-                    env: Option<&[(~str, ~str)]>,
+                    env: Option<~[(~str, ~str)]>,
                     dir: Option<&Path>,
                     in_fd: c_int, out_fd: c_int, err_fd: c_int) -> SpawnProcessResult {
 
@@ -717,7 +717,7 @@ fn with_argv<T>(prog: &str, args: &[~str], cb: &fn(**libc::c_char) -> T) -> T {
 }
 
 #[cfg(unix)]
-fn with_envp<T>(env: Option<&[(~str, ~str)]>, cb: &fn(*c_void) -> T) -> T {
+fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: &fn(*c_void) -> T) -> T {
     use vec;
 
     // On posixy systems we can pass a char** for envp, which is a
@@ -749,7 +749,7 @@ fn with_envp<T>(env: Option<&[(~str, ~str)]>, cb: &fn(*c_void) -> T) -> T {
 }
 
 #[cfg(windows)]
-fn with_envp<T>(env: Option<&[(~str, ~str)]>, cb: &fn(*mut c_void) -> T) -> T {
+fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: &fn(*mut c_void) -> T) -> T {
     // On win32 we pass an "environment block" which is not a char**, but
     // rather a concatenation of null-terminated k=v\0 sequences, with a final
     // \0 to terminate.
@@ -1284,14 +1284,14 @@ mod tests {
     }
 
     #[cfg(unix,not(target_os="android"))]
-    fn run_env(env: Option<&[(~str, ~str)]>) -> run::Process {
+    fn run_env(env: Option<~[(~str, ~str)]>) -> run::Process {
         run::Process::new("env", [], run::ProcessOptions {
             env: env,
             .. run::ProcessOptions::new()
         })
     }
     #[cfg(unix,target_os="android")]
-    fn run_env(env: Option<&[(~str, ~str)]>) -> run::Process {
+    fn run_env(env: Option<~[(~str, ~str)]>) -> run::Process {
         run::Process::new("/system/bin/sh", [~"-c",~"set"], run::ProcessOptions {
             env: env,
             .. run::ProcessOptions::new()
@@ -1299,7 +1299,7 @@ mod tests {
     }
 
     #[cfg(windows)]
-    fn run_env(env: Option<&[(~str, ~str)]>) -> run::Process {
+    fn run_env(env: Option<~[(~str, ~str)]>) -> run::Process {
         run::Process::new("cmd", [~"/c", ~"set"], run::ProcessOptions {
             env: env,
             .. run::ProcessOptions::new()
@@ -1344,7 +1344,7 @@ mod tests {
         let mut new_env = os::env();
         new_env.push((~"RUN_TEST_NEW_ENV", ~"123"));
 
-        let mut prog = run_env(Some(new_env.slice(0, new_env.len())));
+        let mut prog = run_env(Some(new_env));
         let output = str::from_bytes(prog.finish_with_output().output);
 
         assert!(output.contains("RUN_TEST_NEW_ENV=123"));
diff --git a/src/test/run-pass/issue-8498.rs b/src/test/run-pass/issue-8498.rs
new file mode 100644
index 00000000000..40f98355f34
--- /dev/null
+++ b/src/test/run-pass/issue-8498.rs
@@ -0,0 +1,44 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// xfail-test
+use std::io;
+
+fn main() {
+// This is ok
+    match &[(~5,~7)] {
+        ps => {
+           let (ref y, _) = ps[0];
+           io::println(fmt!("1. y = %d", **y));
+           assert!(**y == 5);
+        }
+    }
+
+// This is not entirely ok
+    match Some(&[(~5,)]) {
+        Some(ps) => {
+           let (ref y,) = ps[0];
+           io::println(fmt!("2. y = %d", **y));
+           if **y != 5 { io::println("sadness"); }
+        }
+        None => ()
+    }
+
+// This is not ok
+    match Some(&[(~5,~7)]) {
+        Some(ps) => {
+           let (ref y, ref z) = ps[0];
+           io::println(fmt!("3. y = %d z = %d", **y, **z));
+           assert!(**y == 5);
+        }
+        None => ()
+    }
+}
+