Skip to content

Commit 0cd54b8

Browse files
committed
Round 5 test fixes and rebase conflicts
1 parent cb29c46 commit 0cd54b8

File tree

8 files changed

+52
-10
lines changed

8 files changed

+52
-10
lines changed

src/libcore/hash/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pub trait Hasher {
158158
#[inline]
159159
#[unstable(feature = "hash", reason = "module was recently redesigned")]
160160
fn write_usize(&mut self, i: usize) {
161-
if cfg!(target_pointer_size = "32") {
161+
if cfg!(target_pointer_width = "32") {
162162
self.write_u32(i as u32)
163163
} else {
164164
self.write_u64(i as u64)
@@ -241,7 +241,7 @@ mod impls {
241241
#[inline]
242242
fn hash(&self, state: &mut S) {
243243
let a: [u8; ::$ty::BYTES] = unsafe {
244-
mem::transmute((*self as $uty).to_le() as $ty)
244+
mem::transmute(*self)
245245
};
246246
state.write(&a)
247247
}

src/libstd/old_io/process.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ struct EnvKey(CString);
104104
#[derive(Eq, Clone, Debug)]
105105
struct EnvKey(CString);
106106

107-
#[cfg(windows)]
107+
#[cfg(all(windows, stage0))]
108108
impl<H: hash::Writer + hash::Hasher> hash::Hash<H> for EnvKey {
109109
fn hash(&self, state: &mut H) {
110110
let &EnvKey(ref x) = self;
@@ -116,6 +116,18 @@ impl<H: hash::Writer + hash::Hasher> hash::Hash<H> for EnvKey {
116116
}
117117
}
118118
}
119+
#[cfg(all(windows, not(stage0)))]
120+
impl hash::Hash for EnvKey {
121+
fn hash<H: hash::Hasher>(&self, state: &mut H) {
122+
let &EnvKey(ref x) = self;
123+
match str::from_utf8(x.as_bytes()) {
124+
Ok(s) => for ch in s.chars() {
125+
(ch as u8 as char).to_lowercase().hash(state);
126+
},
127+
Err(..) => x.hash(state)
128+
}
129+
}
130+
}
119131

120132
#[cfg(windows)]
121133
impl PartialEq for EnvKey {

src/libstd/os.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -561,10 +561,11 @@ pub fn get_exit_status() -> int {
561561
#[cfg(target_os = "macos")]
562562
unsafe fn load_argc_and_argv(argc: int,
563563
argv: *const *const c_char) -> Vec<Vec<u8>> {
564+
use ffi::CStr;
564565
use iter::range;
565566

566-
(0..argc as uint).map(|i| {
567-
ffi::c_str_to_bytes(&*argv.offset(i as int)).to_vec()
567+
(0..argc).map(|i| {
568+
CStr::from_ptr(*argv.offset(i)).to_bytes().to_vec()
568569
}).collect()
569570
}
570571

src/libstd/sys/unix/os.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ pub fn args() -> Args {
266266
let (argc, argv) = (*_NSGetArgc() as isize,
267267
*_NSGetArgv() as *const *const c_char);
268268
range(0, argc as isize).map(|i| {
269-
let bytes = CStr::from_ptr(&*argv.offset(i)).to_bytes().to_vec();
269+
let bytes = CStr::from_ptr(*argv.offset(i)).to_bytes().to_vec();
270270
OsStringExt::from_vec(bytes)
271271
}).collect::<Vec<_>>()
272272
};

src/libstd/sys/windows/backtrace.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#![allow(dead_code)]
2626

2727
use dynamic_lib::DynamicLibrary;
28-
use ffi;
28+
use ffi::CStr;
2929
use intrinsics;
3030
use old_io::{IoResult, Writer};
3131
use libc;
@@ -362,7 +362,7 @@ pub fn write(w: &mut Writer) -> IoResult<()> {
362362
if ret == libc::TRUE {
363363
try!(write!(w, " - "));
364364
let ptr = info.Name.as_ptr() as *const libc::c_char;
365-
let bytes = unsafe { ffi::c_str_to_bytes(&ptr) };
365+
let bytes = unsafe { CStr::from_ptr(ptr).to_bytes() };
366366
match str::from_utf8(bytes) {
367367
Ok(s) => try!(demangle(w, s)),
368368
Err(..) => try!(w.write_all(&bytes[..bytes.len()-1])),

src/libstd/sys/windows/process.rs

+29
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ fn make_command_line(prog: &CString, args: &[CString]) -> String {
589589
}
590590
}
591591

592+
#[cfg(stage0)]
592593
fn with_envp<K, V, T, F>(env: Option<&collections::HashMap<K, V>>, cb: F) -> T
593594
where K: BytesContainer + Eq + Hash<Hasher>,
594595
V: BytesContainer,
@@ -616,6 +617,34 @@ fn with_envp<K, V, T, F>(env: Option<&collections::HashMap<K, V>>, cb: F) -> T
616617
_ => cb(ptr::null_mut())
617618
}
618619
}
620+
#[cfg(not(stage0))]
621+
fn with_envp<K, V, T, F>(env: Option<&collections::HashMap<K, V>>, cb: F) -> T
622+
where K: BytesContainer + Eq + Hash,
623+
V: BytesContainer,
624+
F: FnOnce(*mut c_void) -> T,
625+
{
626+
// On Windows we pass an "environment block" which is not a char**, but
627+
// rather a concatenation of null-terminated k=v\0 sequences, with a final
628+
// \0 to terminate.
629+
match env {
630+
Some(env) => {
631+
let mut blk = Vec::new();
632+
633+
for pair in env {
634+
let kv = format!("{}={}",
635+
pair.0.container_as_str().unwrap(),
636+
pair.1.container_as_str().unwrap());
637+
blk.extend(kv.utf16_units());
638+
blk.push(0);
639+
}
640+
641+
blk.push(0);
642+
643+
cb(blk.as_mut_ptr() as *mut c_void)
644+
}
645+
_ => cb(ptr::null_mut())
646+
}
647+
}
619648

620649
fn with_dirp<T, F>(d: Option<&CString>, cb: F) -> T where
621650
F: FnOnce(*const u16) -> T,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::marker::PhantomFn;
1818

1919
///////////////////////////////////////////////////////////////////////////
2020

21-
pub trait TheTrait<'b> : PhantomFn<Self,Self> {
21+
pub trait TheTrait<'b> : PhantomFn<&'b Self,Self> {
2222
type TheAssocType;
2323
}
2424

src/test/run-make/save-analysis/foo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use std::mem::size_of;
3434
static uni: &'static str = "Les Miséééééééérables";
3535
static yy: usize = 25;
3636

37-
static bob: Option<std::borrow::Cow<'static, [isize]>> = None;
37+
static bob: Option<&'static [isize]> = None;
3838

3939
// buglink test - see issue #1337.
4040

0 commit comments

Comments
 (0)