Skip to content

Commit b7813da

Browse files
committed
---
yaml --- r: 213099 b: refs/heads/auto c: a54bbac h: refs/heads/master i: 213097: d9a15cb 213095: c6f1668 v: v3
1 parent 7ef862c commit b7813da

File tree

165 files changed

+447
-712
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+447
-712
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: 7517ecf4fc9cfe2adff8a38ecc2ef660692a4b5b
13+
refs/heads/auto: a54bbac99af8240d78e161ac68653726c4ff27cc
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/liballoc/heap.rs

Lines changed: 17 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -345,94 +345,47 @@ mod imp {
345345
not(jemalloc),
346346
windows))]
347347
mod imp {
348-
use core::mem::size_of;
349-
use libc::{BOOL, DWORD, HANDLE, LPVOID, SIZE_T, INVALID_HANDLE_VALUE};
350-
use libc::{WriteFile};
348+
use libc::{c_void, size_t};
349+
use libc;
351350
use super::MIN_ALIGN;
352351

353-
extern "system" {
354-
fn GetProcessHeap() -> HANDLE;
355-
fn GetStdHandle(nStdHandle: DWORD) -> HANDLE;
356-
fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) -> LPVOID;
357-
fn HeapReAlloc(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID, dwBytes: SIZE_T) -> LPVOID;
358-
fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID) -> BOOL;
359-
fn HeapSummary(hHeap: HANDLE, dwFlags: DWORD, lpSummary: LPHEAP_SUMMARY) -> BOOL;
360-
}
361-
362-
#[repr(C)] #[allow(non_snake_case)]
363-
struct HEAP_SUMMARY {
364-
cb: DWORD,
365-
cbAllocated: SIZE_T,
366-
cbCommitted: SIZE_T,
367-
cbReserved: SIZE_T,
368-
cbMaxReserve: SIZE_T,
369-
}
370-
#[allow(non_camel_case_types)]
371-
type LPHEAP_SUMMARY = *mut HEAP_SUMMARY;
372-
373-
#[repr(C)]
374-
struct Header(*mut u8);
375-
376-
const HEAP_REALLOC_IN_PLACE_ONLY: DWORD = 0x00000010;
377-
const STD_OUTPUT_HANDLE: DWORD = -11i32 as u32;
378-
379-
#[inline]
380-
unsafe fn get_header<'a>(ptr: *mut u8) -> &'a mut Header {
381-
&mut *(ptr as *mut Header).offset(-1)
382-
}
383-
384-
#[inline]
385-
unsafe fn align_ptr(ptr: *mut u8, align: usize) -> *mut u8 {
386-
let aligned = ptr.offset((align - (ptr as usize & (align - 1))) as isize);
387-
*get_header(aligned) = Header(ptr);
388-
aligned
352+
extern {
353+
fn _aligned_malloc(size: size_t, align: size_t) -> *mut c_void;
354+
fn _aligned_realloc(block: *mut c_void, size: size_t,
355+
align: size_t) -> *mut c_void;
356+
fn _aligned_free(ptr: *mut c_void);
389357
}
390358

391359
#[inline]
392360
pub unsafe fn allocate(size: usize, align: usize) -> *mut u8 {
393361
if align <= MIN_ALIGN {
394-
HeapAlloc(GetProcessHeap(), 0, size as SIZE_T) as *mut u8
362+
libc::malloc(size as size_t) as *mut u8
395363
} else {
396-
let ptr = HeapAlloc(GetProcessHeap(), 0, (size + align) as SIZE_T) as *mut u8;
397-
if ptr.is_null() { return ptr }
398-
align_ptr(ptr, align)
364+
_aligned_malloc(size as size_t, align as size_t) as *mut u8
399365
}
400366
}
401367

402368
#[inline]
403369
pub unsafe fn reallocate(ptr: *mut u8, _old_size: usize, size: usize, align: usize) -> *mut u8 {
404370
if align <= MIN_ALIGN {
405-
HeapReAlloc(GetProcessHeap(), 0, ptr as LPVOID, size as SIZE_T) as *mut u8
371+
libc::realloc(ptr as *mut c_void, size as size_t) as *mut u8
406372
} else {
407-
let header = get_header(ptr);
408-
let new = HeapReAlloc(GetProcessHeap(), 0, header.0 as LPVOID,
409-
(size + align) as SIZE_T) as *mut u8;
410-
if new.is_null() { return new }
411-
align_ptr(new, align)
373+
_aligned_realloc(ptr as *mut c_void, size as size_t, align as size_t) as *mut u8
412374
}
413375
}
414376

415377
#[inline]
416-
pub unsafe fn reallocate_inplace(ptr: *mut u8, old_size: usize, size: usize,
417-
align: usize) -> usize {
418-
if align <= MIN_ALIGN {
419-
let new = HeapReAlloc(GetProcessHeap(), HEAP_REALLOC_IN_PLACE_ONLY, ptr as LPVOID,
420-
size as SIZE_T) as *mut u8;
421-
if new.is_null() { old_size } else { size }
422-
} else {
423-
old_size
424-
}
378+
pub unsafe fn reallocate_inplace(_ptr: *mut u8, old_size: usize, _size: usize,
379+
_align: usize) -> usize {
380+
old_size
425381
}
426382

427383
#[inline]
428384
pub unsafe fn deallocate(ptr: *mut u8, _old_size: usize, align: usize) {
429385
if align <= MIN_ALIGN {
430-
let err = HeapFree(GetProcessHeap(), 0, ptr as LPVOID);
431-
debug_assert!(err != 0);
386+
libc::free(ptr as *mut libc::c_void)
432387
} else {
433-
let header = get_header(ptr);
434-
let err = HeapFree(GetProcessHeap(), 0, header.0 as LPVOID);
435-
debug_assert!(err != 0);
388+
_aligned_free(ptr as *mut c_void)
436389
}
437390
}
438391

@@ -441,45 +394,7 @@ mod imp {
441394
size
442395
}
443396

444-
pub fn stats_print() {
445-
use core::fmt::{Error, Result, Write};
446-
use core::ptr::null_mut;
447-
use core::raw::Repr;
448-
use core::result::Result::{Ok, Err};
449-
struct Console(HANDLE);
450-
impl Write for Console {
451-
fn write_str(&mut self, s: &str) -> Result {
452-
let repr = s.repr();
453-
let mut written = 0;
454-
let err = unsafe { WriteFile(self.0, repr.data as LPVOID, repr.len as DWORD,
455-
&mut written, null_mut()) };
456-
if written as usize != repr.len { return Err(Error) }
457-
if err == 0 { return Err(Error) }
458-
Ok(())
459-
}
460-
}
461-
let mut hs = HEAP_SUMMARY {
462-
cb: size_of::<HEAP_SUMMARY>() as DWORD,
463-
cbAllocated: 0,
464-
cbCommitted: 0,
465-
cbReserved: 0,
466-
cbMaxReserve: 0,
467-
};
468-
let err = unsafe { HeapSummary(GetProcessHeap(), 0, &mut hs) };
469-
assert!(err != 0);
470-
let handle = unsafe { GetStdHandle(STD_OUTPUT_HANDLE) };
471-
if handle.is_null() || handle == INVALID_HANDLE_VALUE { panic!("Failed to open stdout") }
472-
let mut out = Console(handle);
473-
writeln!(&mut out, "Allocated: {}", hs.cbAllocated).unwrap();
474-
writeln!(&mut out, "Committed: {}", hs.cbCommitted).unwrap();
475-
writeln!(&mut out, "Reserved: {}", hs.cbReserved).unwrap();
476-
writeln!(&mut out, "MaxReserve: {}", hs.cbMaxReserve).unwrap();
477-
}
478-
479-
#[test]
480-
fn alignment_header_size() {
481-
assert!(size_of::<Header>() <= MIN_ALIGN);
482-
}
397+
pub fn stats_print() {}
483398
}
484399

485400
#[cfg(test)]

branches/auto/src/libcore/result.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -731,26 +731,6 @@ impl<T, E: fmt::Debug> Result<T, E> {
731731
panic!("called `Result::unwrap()` on an `Err` value: {:?}", e)
732732
}
733733
}
734-
735-
/// Unwraps a result, yielding the content of an `Ok`.
736-
///
737-
/// Panics if the value is an `Err`, with a panic message including the
738-
/// passed message, and the content of the `Err`.
739-
///
740-
/// # Examples
741-
/// ```{.should_panic}
742-
/// #![feature(result_expect)]
743-
/// let x: Result<u32, &str> = Err("emergency failure");
744-
/// x.expect("Testing expect"); // panics with `Testing expect: emergency failure`
745-
/// ```
746-
#[inline]
747-
#[unstable(feature = "result_expect", reason = "newly introduced")]
748-
pub fn expect(self, msg: &str) -> T {
749-
match self {
750-
Ok(t) => t,
751-
Err(e) => panic!("{}: {:?}", msg, e),
752-
}
753-
}
754734
}
755735

756736
#[stable(feature = "rust1", since = "1.0.0")]

branches/auto/src/libcoretest/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#![feature(cell_extras)]
2929
#![feature(iter_empty)]
3030
#![feature(iter_once)]
31-
#![feature(result_expect)]
3231

3332
extern crate core;
3433
extern crate test;

branches/auto/src/libcoretest/result.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,3 @@ pub fn test_unwrap_or_else_panic() {
137137
let bad_err: Result<isize, &'static str> = Err("Unrecoverable mess.");
138138
let _ : isize = bad_err.unwrap_or_else(handler);
139139
}
140-
141-
142-
#[test]
143-
pub fn test_expect_ok() {
144-
let ok: Result<isize, &'static str> = Ok(100);
145-
assert_eq!(ok.expect("Unexpected error"), 100);
146-
}
147-
#[test]
148-
#[should_panic(expected="Got expected error: \"All good\"")]
149-
pub fn test_expect_err() {
150-
let err: Result<isize, &'static str> = Err("All good");
151-
err.expect("Got expected error");
152-
}

branches/auto/src/librustc_trans/save/mod.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,16 +255,17 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
255255
match typ.node {
256256
// Common case impl for a struct or something basic.
257257
ast::TyPath(None, ref path) => {
258-
sub_span = self.span_utils.sub_span_for_type_name(path.span);
258+
sub_span = self.span_utils.sub_span_for_type_name(path.span).unwrap();
259259
type_data = self.lookup_ref_id(typ.id).map(|id| TypeRefData {
260-
span: sub_span.unwrap(),
260+
span: sub_span,
261261
scope: parent,
262262
ref_id: id,
263263
});
264264
},
265265
_ => {
266266
// Less useful case, impl for a compound type.
267-
sub_span = self.span_utils.sub_span_for_type_name(typ.span);
267+
let span = typ.span;
268+
sub_span = self.span_utils.sub_span_for_type_name(span).unwrap_or(span);
268269
}
269270
}
270271

@@ -273,7 +274,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
273274

274275
Data::ImplData(ImplData {
275276
id: item.id,
276-
span: sub_span.unwrap(),
277+
span: sub_span,
277278
scope: parent,
278279
trait_ref: trait_data,
279280
self_ref: type_data,
@@ -320,9 +321,10 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
320321
parent: NodeId)
321322
-> Option<TypeRefData> {
322323
self.lookup_ref_id(trait_ref.ref_id).map(|def_id| {
323-
let sub_span = self.span_utils.sub_span_for_type_name(trait_ref.path.span);
324+
let span = trait_ref.path.span;
325+
let sub_span = self.span_utils.sub_span_for_type_name(span).unwrap_or(span);
324326
TypeRefData {
325-
span: sub_span.unwrap(),
327+
span: sub_span,
326328
scope: parent,
327329
ref_id: def_id,
328330
}

0 commit comments

Comments
 (0)