Skip to content

Commit b7c0813

Browse files
committed
Round 4 test fixes and rebase conflicts
1 parent 63f51ee commit b7c0813

File tree

11 files changed

+180
-19
lines changed

11 files changed

+180
-19
lines changed

src/libcollections/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ mod std {
147147
#[cfg(test)]
148148
mod prelude {
149149
// from core.
150-
pub use core::borrow::IntoCow;
151150
pub use core::clone::Clone;
152151
pub use core::cmp::{PartialEq, Eq, PartialOrd, Ord};
153152
pub use core::cmp::Ordering::{Less, Equal, Greater};
@@ -173,6 +172,7 @@ mod prelude {
173172
pub use unicode::char::CharExt;
174173

175174
// from collections.
175+
pub use borrow::IntoCow;
176176
pub use slice::SliceConcatExt;
177177
pub use string::{String, ToString};
178178
pub use vec::Vec;

src/libcollections/linked_list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ mod tests {
10411041
}
10421042

10431043
#[cfg(test)]
1044-
fn list_from<T: Clone>(v: &[T]) -> DList<T> {
1044+
fn list_from<T: Clone>(v: &[T]) -> LinkedList<T> {
10451045
v.iter().cloned().collect()
10461046
}
10471047

src/libcollections/slice.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,9 +1997,9 @@ mod tests {
19971997

19981998
#[test]
19991999
fn test_lexicographic_permutations_empty_and_short() {
2000-
let empty : &mut[i32] = &mut[..];
2000+
let empty : &mut[i32] = &mut[];
20012001
assert!(empty.next_permutation() == false);
2002-
let b: &mut[i32] = &mut[..];
2002+
let b: &mut[i32] = &mut[];
20032003
assert!(empty == b);
20042004
assert!(empty.prev_permutation() == false);
20052005
assert!(empty == b);

src/libcore/marker.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ impl<T:?Sized> MarkerTrait for T { }
301301
/// As an example, consider a trait with no methods like `Even`, meant
302302
/// to represent types that are "even":
303303
///
304-
/// ```rust
304+
/// ```rust,ignore
305305
/// trait Even { }
306306
/// ```
307307
///
@@ -310,7 +310,7 @@ impl<T:?Sized> MarkerTrait for T { }
310310
/// categorize types (and hence instances of those types) as "even" or
311311
/// not, so if we *were* going to have a method, it might look like:
312312
///
313-
/// ```rust
313+
/// ```rust,ignore
314314
/// trait Even {
315315
/// fn is_even(self) -> bool { true }
316316
/// }
@@ -319,7 +319,7 @@ impl<T:?Sized> MarkerTrait for T { }
319319
/// Therefore, we can model a method like this as follows:
320320
///
321321
/// ```rust
322-
/// use std::marker::PhantomFn
322+
/// use std::marker::PhantomFn;
323323
/// trait Even : PhantomFn<Self> { }
324324
/// ```
325325
///

src/libstd/sys/windows/c.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ pub mod compat {
283283
fallback: usize) -> usize {
284284
let mut module: Vec<u16> = module.utf16_units().collect();
285285
module.push(0);
286-
let symbol = CString::from_slice(symbol.as_bytes());
286+
let symbol = CString::new(symbol).unwrap();
287287
let func = unsafe {
288288
let handle = GetModuleHandleW(module.as_ptr());
289289
GetProcAddress(handle, symbol.as_ptr()) as usize

src/libstd/sys/windows/process.rs

Lines changed: 165 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use prelude::v1::*;
1212

13-
use collections::hash_map::Hasher;
13+
#[cfg(stage0)] use collections::hash_map::Hasher;
1414
use collections;
1515
use env;
1616
use ffi::CString;
@@ -106,6 +106,7 @@ impl Process {
106106
}
107107

108108
#[allow(deprecated)]
109+
#[cfg(stage0)]
109110
pub fn spawn<K, V, C, P>(cfg: &C, in_fd: Option<P>,
110111
out_fd: Option<P>, err_fd: Option<P>)
111112
-> IoResult<Process>
@@ -267,6 +268,169 @@ impl Process {
267268
})
268269
}
269270
}
271+
#[allow(deprecated)]
272+
#[cfg(not(stage0))]
273+
pub fn spawn<K, V, C, P>(cfg: &C, in_fd: Option<P>,
274+
out_fd: Option<P>, err_fd: Option<P>)
275+
-> IoResult<Process>
276+
where C: ProcessConfig<K, V>, P: AsInner<FileDesc>,
277+
K: BytesContainer + Eq + Hash, V: BytesContainer
278+
{
279+
use libc::types::os::arch::extra::{DWORD, HANDLE, STARTUPINFO};
280+
use libc::consts::os::extra::{
281+
TRUE, FALSE,
282+
STARTF_USESTDHANDLES,
283+
INVALID_HANDLE_VALUE,
284+
DUPLICATE_SAME_ACCESS
285+
};
286+
use libc::funcs::extra::kernel32::{
287+
GetCurrentProcess,
288+
DuplicateHandle,
289+
CloseHandle,
290+
CreateProcessW
291+
};
292+
use libc::funcs::extra::msvcrt::get_osfhandle;
293+
294+
use mem;
295+
use iter::IteratorExt;
296+
use str::StrExt;
297+
298+
if cfg.gid().is_some() || cfg.uid().is_some() {
299+
return Err(IoError {
300+
kind: old_io::IoUnavailable,
301+
desc: "unsupported gid/uid requested on windows",
302+
detail: None,
303+
})
304+
}
305+
306+
// To have the spawning semantics of unix/windows stay the same, we need to
307+
// read the *child's* PATH if one is provided. See #15149 for more details.
308+
let program = cfg.env().and_then(|env| {
309+
for (key, v) in env {
310+
if b"PATH" != key.container_as_bytes() { continue }
311+
312+
// Split the value and test each path to see if the
313+
// program exists.
314+
for path in os::split_paths(v.container_as_bytes()) {
315+
let path = path.join(cfg.program().as_bytes())
316+
.with_extension(env::consts::EXE_EXTENSION);
317+
if path.exists() {
318+
return Some(CString::from_slice(path.as_vec()))
319+
}
320+
}
321+
break
322+
}
323+
None
324+
});
325+
326+
unsafe {
327+
let mut si = zeroed_startupinfo();
328+
si.cb = mem::size_of::<STARTUPINFO>() as DWORD;
329+
si.dwFlags = STARTF_USESTDHANDLES;
330+
331+
let cur_proc = GetCurrentProcess();
332+
333+
// Similarly to unix, we don't actually leave holes for the stdio file
334+
// descriptors, but rather open up /dev/null equivalents. These
335+
// equivalents are drawn from libuv's windows process spawning.
336+
let set_fd = |fd: &Option<P>, slot: &mut HANDLE,
337+
is_stdin: bool| {
338+
match *fd {
339+
None => {
340+
let access = if is_stdin {
341+
libc::FILE_GENERIC_READ
342+
} else {
343+
libc::FILE_GENERIC_WRITE | libc::FILE_READ_ATTRIBUTES
344+
};
345+
let size = mem::size_of::<libc::SECURITY_ATTRIBUTES>();
346+
let mut sa = libc::SECURITY_ATTRIBUTES {
347+
nLength: size as libc::DWORD,
348+
lpSecurityDescriptor: ptr::null_mut(),
349+
bInheritHandle: 1,
350+
};
351+
let mut filename: Vec<u16> = "NUL".utf16_units().collect();
352+
filename.push(0);
353+
*slot = libc::CreateFileW(filename.as_ptr(),
354+
access,
355+
libc::FILE_SHARE_READ |
356+
libc::FILE_SHARE_WRITE,
357+
&mut sa,
358+
libc::OPEN_EXISTING,
359+
0,
360+
ptr::null_mut());
361+
if *slot == INVALID_HANDLE_VALUE {
362+
return Err(super::last_error())
363+
}
364+
}
365+
Some(ref fd) => {
366+
let orig = get_osfhandle(fd.as_inner().fd()) as HANDLE;
367+
if orig == INVALID_HANDLE_VALUE {
368+
return Err(super::last_error())
369+
}
370+
if DuplicateHandle(cur_proc, orig, cur_proc, slot,
371+
0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE {
372+
return Err(super::last_error())
373+
}
374+
}
375+
}
376+
Ok(())
377+
};
378+
379+
try!(set_fd(&in_fd, &mut si.hStdInput, true));
380+
try!(set_fd(&out_fd, &mut si.hStdOutput, false));
381+
try!(set_fd(&err_fd, &mut si.hStdError, false));
382+
383+
let cmd_str = make_command_line(program.as_ref().unwrap_or(cfg.program()),
384+
cfg.args());
385+
let mut pi = zeroed_process_information();
386+
let mut create_err = None;
387+
388+
// stolen from the libuv code.
389+
let mut flags = libc::CREATE_UNICODE_ENVIRONMENT;
390+
if cfg.detach() {
391+
flags |= libc::DETACHED_PROCESS | libc::CREATE_NEW_PROCESS_GROUP;
392+
}
393+
394+
with_envp(cfg.env(), |envp| {
395+
with_dirp(cfg.cwd(), |dirp| {
396+
let mut cmd_str: Vec<u16> = cmd_str.utf16_units().collect();
397+
cmd_str.push(0);
398+
let _lock = CREATE_PROCESS_LOCK.lock().unwrap();
399+
let created = CreateProcessW(ptr::null(),
400+
cmd_str.as_mut_ptr(),
401+
ptr::null_mut(),
402+
ptr::null_mut(),
403+
TRUE,
404+
flags, envp, dirp,
405+
&mut si, &mut pi);
406+
if created == FALSE {
407+
create_err = Some(super::last_error());
408+
}
409+
})
410+
});
411+
412+
assert!(CloseHandle(si.hStdInput) != 0);
413+
assert!(CloseHandle(si.hStdOutput) != 0);
414+
assert!(CloseHandle(si.hStdError) != 0);
415+
416+
match create_err {
417+
Some(err) => return Err(err),
418+
None => {}
419+
}
420+
421+
// We close the thread handle because we don't care about keeping the
422+
// thread id valid, and we aren't keeping the thread handle around to be
423+
// able to close it later. We don't close the process handle however
424+
// because std::we want the process id to stay valid at least until the
425+
// calling code closes the process handle.
426+
assert!(CloseHandle(pi.hThread) != 0);
427+
428+
Ok(Process {
429+
pid: pi.dwProcessId as pid_t,
430+
handle: pi.hProcess as *mut ()
431+
})
432+
}
433+
}
270434

271435
/// Waits for a process to exit and returns the exit code, failing
272436
/// if there is no process with the specified id.

src/test/compile-fail/object-safety-phantom-fn.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@
1111
// Check that `Self` appearing in a phantom fn does not make a trait not object safe.
1212

1313
#![feature(rustc_attrs)]
14+
#![allow(dead_code)]
15+
16+
use std::marker::PhantomFn;
1417

1518
trait Baz : PhantomFn<Self> {
1619
}
1720

21+
trait Bar<T> : PhantomFn<(Self, T)> {
22+
}
23+
1824
fn make_bar<T:Bar<u32>>(t: &T) -> &Bar<u32> {
1925
t
2026
}

src/test/compile-fail/regions-assoc-type-in-supertrait-outlives-container.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515

1616
#![allow(dead_code)]
1717

18-
use std::mem::transmute;
19-
use std::ops::Deref;
20-
2118
///////////////////////////////////////////////////////////////////////////
2219

2320
pub trait TheTrait {

src/test/compile-fail/regions-assoc-type-outlives-container-wc.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515

1616
#![allow(dead_code)]
1717

18-
use std::mem::transmute;
19-
use std::ops::Deref;
20-
2118
///////////////////////////////////////////////////////////////////////////
2219

2320
pub trait TheTrait {

src/test/compile-fail/regions-assoc-type-outlives-container.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414

1515
#![allow(dead_code)]
1616

17-
use std::mem::transmute;
18-
use std::ops::Deref;
19-
2017
///////////////////////////////////////////////////////////////////////////
2118

2219
pub trait TheTrait {

src/test/run-pass/trait-impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use traitimpl::Bar;
1717
static mut COUNT: uint = 1;
1818

1919
trait T {
20-
fn foo(&self) {}
20+
fn t(&self) {}
2121
}
2222

2323
impl<'a> T+'a {

0 commit comments

Comments
 (0)