Skip to content

Commit ad56b09

Browse files
committed
---
yaml --- r: 175853 b: refs/heads/try c: c366e43 h: refs/heads/master i: 175851: 601e9c6 v: v3
1 parent 3cd716e commit ad56b09

File tree

16 files changed

+266
-113
lines changed

16 files changed

+266
-113
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: a530cc9706324ad44dba464d541a807eb5afdb08
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 777435990e0e91df6b72ce80c9b6fa485eeb5daa
5-
refs/heads/try: 756466bfd0fd457623378ab461164dbaaa9ce971
5+
refs/heads/try: c366e433c14c49eee9144e6010a5fc54cbcdd341
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/librustc/metadata/filesearch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<'a> FileSearch<'a> {
5454

5555
debug!("filesearch: searching lib path");
5656
let tlib_path = make_target_lib_path(self.sysroot,
57-
self.triple);
57+
self.triple);
5858
if !visited_dirs.contains(tlib_path.as_vec()) {
5959
match f(&tlib_path) {
6060
FileMatches => found = true,

branches/try/src/librustc/session/search_paths.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use std::slice;
1212

13-
#[derive(Clone)]
13+
#[derive(Clone, Show)]
1414
pub struct SearchPaths {
1515
paths: Vec<(PathKind, Path)>,
1616
}
@@ -20,7 +20,7 @@ pub struct Iter<'a> {
2020
iter: slice::Iter<'a, (PathKind, Path)>,
2121
}
2222

23-
#[derive(Eq, PartialEq, Clone, Copy)]
23+
#[derive(Eq, PartialEq, Clone, Copy, Show)]
2424
pub enum PathKind {
2525
Native,
2626
Crate,

branches/try/src/librustc_driver/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ fn run_compiler(args: &[String]) {
186186
list_metadata(&sess, &(*ifile), &mut stdout).unwrap();
187187
}
188188
Input::Str(_) => {
189-
early_error("can not list metadata for stdin");
189+
early_error("cannot list metadata for stdin");
190190
}
191191
}
192192
return;

branches/try/src/librustc_trans/trans/base.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,9 +700,8 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
700700
let mut cx = cx;
701701

702702
for (i, &arg) in variant.args.iter().enumerate() {
703-
cx = (*f)(cx,
704-
adt::trans_field_ptr(cx, repr, av, variant.disr_val, i),
705-
arg.subst(tcx, substs));
703+
let arg = monomorphize::apply_param_substs(tcx, substs, &arg);
704+
cx = f(cx, adt::trans_field_ptr(cx, repr, av, variant.disr_val, i), arg);
706705
}
707706
return cx;
708707
}

branches/try/src/librustc_trans/trans/debuginfo.rs

Lines changed: 58 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -323,26 +323,28 @@ impl<'tcx> TypeMap<'tcx> {
323323
fn get_unique_type_id_of_type<'a>(&mut self, cx: &CrateContext<'a, 'tcx>,
324324
type_: Ty<'tcx>) -> UniqueTypeId {
325325

326-
// basic type -> {:name of the type:}
327-
// tuple -> {tuple_(:param-uid:)*}
328-
// struct -> {struct_:svh: / :node-id:_<(:param-uid:),*> }
329-
// enum -> {enum_:svh: / :node-id:_<(:param-uid:),*> }
330-
// enum variant -> {variant_:variant-name:_:enum-uid:}
331-
// reference (&) -> {& :pointee-uid:}
332-
// mut reference (&mut) -> {&mut :pointee-uid:}
333-
// ptr (*) -> {* :pointee-uid:}
334-
// mut ptr (*mut) -> {*mut :pointee-uid:}
335-
// unique ptr (~) -> {~ :pointee-uid:}
336-
// @-ptr (@) -> {@ :pointee-uid:}
337-
// sized vec ([T; x]) -> {[:size:] :element-uid:}
338-
// unsized vec ([T]) -> {[] :element-uid:}
339-
// trait (T) -> {trait_:svh: / :node-id:_<(:param-uid:),*> }
340-
// closure -> {<unsafe_> <once_> :store-sigil: |(:param-uid:),* <,_...>| -> \
341-
// :return-type-uid: : (:bounds:)*}
342-
// function -> {<unsafe_> <abi_> fn( (:param-uid:)* <,_...> ) -> \
343-
// :return-type-uid:}
344-
// unique vec box (~[]) -> {HEAP_VEC_BOX<:pointee-uid:>}
345-
// gc box -> {GC_BOX<:pointee-uid:>}
326+
// basic type -> {:name of the type:}
327+
// tuple -> {tuple_(:param-uid:)*}
328+
// struct -> {struct_:svh: / :node-id:_<(:param-uid:),*> }
329+
// enum -> {enum_:svh: / :node-id:_<(:param-uid:),*> }
330+
// enum variant -> {variant_:variant-name:_:enum-uid:}
331+
// reference (&) -> {& :pointee-uid:}
332+
// mut reference (&mut) -> {&mut :pointee-uid:}
333+
// ptr (*) -> {* :pointee-uid:}
334+
// mut ptr (*mut) -> {*mut :pointee-uid:}
335+
// unique ptr (~) -> {~ :pointee-uid:}
336+
// @-ptr (@) -> {@ :pointee-uid:}
337+
// sized vec ([T; x]) -> {[:size:] :element-uid:}
338+
// unsized vec ([T]) -> {[] :element-uid:}
339+
// trait (T) -> {trait_:svh: / :node-id:_<(:param-uid:),*> }
340+
// closure -> {<unsafe_> <once_> :store-sigil:
341+
// |(:param-uid:),* <,_...>| -> \
342+
// :return-type-uid: : (:bounds:)*}
343+
// function -> {<unsafe_> <abi_> fn( (:param-uid:)* <,_...> ) -> \
344+
// :return-type-uid:}
345+
// unique vec box (~[]) -> {HEAP_VEC_BOX<:pointee-uid:>}
346+
// gc box -> {GC_BOX<:pointee-uid:>}
347+
// projection (<T as U>::V) -> {<:ty-uid: as :trait-uid:> :: :name-uid: }
346348

347349
match self.type_to_unique_id.get(&type_).cloned() {
348350
Some(unique_type_id) => return unique_type_id,
@@ -435,6 +437,25 @@ impl<'tcx> TypeMap<'tcx> {
435437
principal.substs,
436438
&mut unique_type_id);
437439
},
440+
ty::ty_projection(ref projection) => {
441+
unique_type_id.push_str("<");
442+
443+
let self_ty = projection.trait_ref.self_ty();
444+
let self_type_id = self.get_unique_type_id_of_type(cx, self_ty);
445+
let self_type_id = self.get_unique_type_id_as_string(self_type_id);
446+
unique_type_id.push_str(&self_type_id[]);
447+
448+
unique_type_id.push_str(" as ");
449+
450+
from_def_id_and_substs(self,
451+
cx,
452+
projection.trait_ref.def_id,
453+
projection.trait_ref.substs,
454+
&mut unique_type_id);
455+
456+
unique_type_id.push_str(">::");
457+
unique_type_id.push_str(token::get_name(projection.item_name).get());
458+
},
438459
ty::ty_bare_fn(_, &ty::BareFnTy{ unsafety, abi, ref sig } ) => {
439460
if unsafety == ast::Unsafety::Unsafe {
440461
unique_type_id.push_str("unsafe ");
@@ -478,7 +499,10 @@ impl<'tcx> TypeMap<'tcx> {
478499
closure_ty,
479500
&mut unique_type_id);
480501
},
481-
_ => {
502+
ty::ty_err |
503+
ty::ty_infer(_) |
504+
ty::ty_open(_) |
505+
ty::ty_param(_) => {
482506
cx.sess().bug(&format!("get_unique_type_id_of_type() - unexpected type: {}, {:?}",
483507
&ppaux::ty_to_string(cx.tcx(), type_)[],
484508
type_.sty)[])
@@ -3855,10 +3879,22 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
38553879
ty::ty_unboxed_closure(..) => {
38563880
output.push_str("closure");
38573881
}
3882+
ty::ty_projection(ref projection) => {
3883+
output.push_str("<");
3884+
let self_ty = projection.trait_ref.self_ty();
3885+
push_debuginfo_type_name(cx, self_ty, true, output);
3886+
3887+
output.push_str(" as ");
3888+
3889+
push_item_name(cx, projection.trait_ref.def_id, false, output);
3890+
push_type_params(cx, projection.trait_ref.substs, output);
3891+
3892+
output.push_str(">::");
3893+
output.push_str(token::get_name(projection.item_name).get());
3894+
}
38583895
ty::ty_err |
38593896
ty::ty_infer(_) |
38603897
ty::ty_open(_) |
3861-
ty::ty_projection(..) |
38623898
ty::ty_param(_) => {
38633899
cx.sess().bug(&format!("debuginfo: Trying to create type name for \
38643900
unexpected type: {}", ppaux::ty_to_string(cx.tcx(), t))[]);

branches/try/src/librustc_trans/trans/monomorphize.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
274274
ast_map::NodeArg(..) |
275275
ast_map::NodeBlock(..) |
276276
ast_map::NodePat(..) |
277+
ast_map::NodeViewItem(..) |
277278
ast_map::NodeLocal(..) => {
278279
ccx.sess().bug(&format!("can't monomorphize a {:?}",
279280
map_node)[])

branches/try/src/librustc_typeck/check/_match.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,8 @@ pub fn check_struct_pat_fields<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
619619
}
620620
};
621621

622+
let field_type = pcx.fcx.normalize_associated_types_in(span, &field_type);
623+
622624
check_pat(pcx, &*field.pat, field_type);
623625
}
624626

branches/try/src/libstd/sys/windows/condvar.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,18 @@ impl Condvar {
2727

2828
#[inline]
2929
pub unsafe fn wait(&self, mutex: &Mutex) {
30-
let r = ffi::SleepConditionVariableCS(self.inner.get(),
31-
mutex::raw(mutex),
32-
libc::INFINITE);
30+
let r = ffi::SleepConditionVariableSRW(self.inner.get(),
31+
mutex::raw(mutex),
32+
libc::INFINITE,
33+
0);
3334
debug_assert!(r != 0);
3435
}
3536

3637
pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool {
37-
let r = ffi::SleepConditionVariableCS(self.inner.get(),
38-
mutex::raw(mutex),
39-
dur.num_milliseconds() as DWORD);
38+
let r = ffi::SleepConditionVariableSRW(self.inner.get(),
39+
mutex::raw(mutex),
40+
dur.num_milliseconds() as DWORD,
41+
0);
4042
if r == 0 {
4143
const ERROR_TIMEOUT: DWORD = 0x5B4;
4244
debug_assert_eq!(os::errno() as uint, ERROR_TIMEOUT as uint);

branches/try/src/libstd/sys/windows/mutex.rs

Lines changed: 25 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -8,73 +8,51 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use prelude::v1::*;
12-
13-
use sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
14-
use alloc::{self, heap};
15-
16-
use libc::DWORD;
11+
use marker::Sync;
12+
use cell::UnsafeCell;
1713
use sys::sync as ffi;
1814

19-
const SPIN_COUNT: DWORD = 4000;
15+
pub struct Mutex { inner: UnsafeCell<ffi::SRWLOCK> }
2016

21-
pub struct Mutex { inner: AtomicUsize }
22-
23-
pub const MUTEX_INIT: Mutex = Mutex { inner: ATOMIC_USIZE_INIT };
17+
pub const MUTEX_INIT: Mutex = Mutex {
18+
inner: UnsafeCell { value: ffi::SRWLOCK_INIT }
19+
};
2420

2521
unsafe impl Sync for Mutex {}
2622

2723
#[inline]
28-
pub unsafe fn raw(m: &Mutex) -> ffi::LPCRITICAL_SECTION {
29-
m.get()
24+
pub unsafe fn raw(m: &Mutex) -> ffi::PSRWLOCK {
25+
m.inner.get()
3026
}
3127

28+
// So you might be asking why we're using SRWLock instead of CriticalSection?
29+
//
30+
// 1. SRWLock is several times faster than CriticalSection according to benchmarks performed on both
31+
// Windows 8 and Windows 7.
32+
//
33+
// 2. CriticalSection allows recursive locking while SRWLock deadlocks. The Unix implementation
34+
// deadlocks so consistency is preferred. See #19962 for more details.
35+
//
36+
// 3. While CriticalSection is fair and SRWLock is not, the current Rust policy is there there are
37+
// no guarantees of fairness.
38+
3239
impl Mutex {
3340
#[inline]
34-
pub unsafe fn new() -> Mutex {
35-
Mutex { inner: AtomicUsize::new(init_lock() as uint) }
36-
}
41+
pub unsafe fn new() -> Mutex { MUTEX_INIT }
3742
#[inline]
3843
pub unsafe fn lock(&self) {
39-
ffi::EnterCriticalSection(self.get())
44+
ffi::AcquireSRWLockExclusive(self.inner.get())
4045
}
4146
#[inline]
4247
pub unsafe fn try_lock(&self) -> bool {
43-
ffi::TryEnterCriticalSection(self.get()) != 0
48+
ffi::TryAcquireSRWLockExclusive(self.inner.get()) != 0
4449
}
4550
#[inline]
4651
pub unsafe fn unlock(&self) {
47-
ffi::LeaveCriticalSection(self.get())
52+
ffi::ReleaseSRWLockExclusive(self.inner.get())
4853
}
54+
#[inline]
4955
pub unsafe fn destroy(&self) {
50-
let lock = self.inner.swap(0, Ordering::SeqCst);
51-
if lock != 0 { free_lock(lock as ffi::LPCRITICAL_SECTION) }
52-
}
53-
54-
unsafe fn get(&self) -> ffi::LPCRITICAL_SECTION {
55-
match self.inner.load(Ordering::SeqCst) {
56-
0 => {}
57-
n => return n as ffi::LPCRITICAL_SECTION
58-
}
59-
let lock = init_lock();
60-
match self.inner.compare_and_swap(0, lock as uint, Ordering::SeqCst) {
61-
0 => return lock as ffi::LPCRITICAL_SECTION,
62-
_ => {}
63-
}
64-
free_lock(lock);
65-
return self.inner.load(Ordering::SeqCst) as ffi::LPCRITICAL_SECTION;
56+
// ...
6657
}
6758
}
68-
69-
unsafe fn init_lock() -> ffi::LPCRITICAL_SECTION {
70-
let block = heap::allocate(ffi::CRITICAL_SECTION_SIZE, 8)
71-
as ffi::LPCRITICAL_SECTION;
72-
if block.is_null() { alloc::oom() }
73-
ffi::InitializeCriticalSectionAndSpinCount(block, SPIN_COUNT);
74-
return block;
75-
}
76-
77-
unsafe fn free_lock(h: ffi::LPCRITICAL_SECTION) {
78-
ffi::DeleteCriticalSection(h);
79-
heap::deallocate(h as *mut _, ffi::CRITICAL_SECTION_SIZE, 8);
80-
}

branches/try/src/libstd/sys/windows/sync.rs

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,12 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use libc::{BOOL, DWORD, c_void, LPVOID};
11+
use libc::{BOOL, DWORD, c_void, LPVOID, c_ulong};
1212
use libc::types::os::arch::extra::BOOLEAN;
1313

14-
pub type LPCRITICAL_SECTION = *mut c_void;
15-
pub type LPCONDITION_VARIABLE = *mut CONDITION_VARIABLE;
16-
pub type LPSRWLOCK = *mut SRWLOCK;
17-
18-
#[cfg(target_arch = "x86")]
19-
pub const CRITICAL_SECTION_SIZE: uint = 24;
20-
#[cfg(target_arch = "x86_64")]
21-
pub const CRITICAL_SECTION_SIZE: uint = 40;
14+
pub type PCONDITION_VARIABLE = *mut CONDITION_VARIABLE;
15+
pub type PSRWLOCK = *mut SRWLOCK;
16+
pub type ULONG = c_ulong;
2217

2318
#[repr(C)]
2419
pub struct CONDITION_VARIABLE { pub ptr: LPVOID }
@@ -31,28 +26,19 @@ pub const CONDITION_VARIABLE_INIT: CONDITION_VARIABLE = CONDITION_VARIABLE {
3126
pub const SRWLOCK_INIT: SRWLOCK = SRWLOCK { ptr: 0 as *mut _ };
3227

3328
extern "system" {
34-
// critical sections
35-
pub fn InitializeCriticalSectionAndSpinCount(
36-
lpCriticalSection: LPCRITICAL_SECTION,
37-
dwSpinCount: DWORD) -> BOOL;
38-
pub fn DeleteCriticalSection(lpCriticalSection: LPCRITICAL_SECTION);
39-
pub fn EnterCriticalSection(lpCriticalSection: LPCRITICAL_SECTION);
40-
pub fn LeaveCriticalSection(lpCriticalSection: LPCRITICAL_SECTION);
41-
pub fn TryEnterCriticalSection(lpCriticalSection: LPCRITICAL_SECTION) -> BOOL;
42-
4329
// condition variables
44-
pub fn SleepConditionVariableCS(ConditionVariable: LPCONDITION_VARIABLE,
45-
CriticalSection: LPCRITICAL_SECTION,
46-
dwMilliseconds: DWORD) -> BOOL;
47-
pub fn WakeConditionVariable(ConditionVariable: LPCONDITION_VARIABLE);
48-
pub fn WakeAllConditionVariable(ConditionVariable: LPCONDITION_VARIABLE);
30+
pub fn SleepConditionVariableSRW(ConditionVariable: PCONDITION_VARIABLE,
31+
SRWLock: PSRWLOCK,
32+
dwMilliseconds: DWORD,
33+
Flags: ULONG) -> BOOL;
34+
pub fn WakeConditionVariable(ConditionVariable: PCONDITION_VARIABLE);
35+
pub fn WakeAllConditionVariable(ConditionVariable: PCONDITION_VARIABLE);
4936

5037
// slim rwlocks
51-
pub fn AcquireSRWLockExclusive(SRWLock: LPSRWLOCK);
52-
pub fn AcquireSRWLockShared(SRWLock: LPSRWLOCK);
53-
pub fn ReleaseSRWLockExclusive(SRWLock: LPSRWLOCK);
54-
pub fn ReleaseSRWLockShared(SRWLock: LPSRWLOCK);
55-
pub fn TryAcquireSRWLockExclusive(SRWLock: LPSRWLOCK) -> BOOLEAN;
56-
pub fn TryAcquireSRWLockShared(SRWLock: LPSRWLOCK) -> BOOLEAN;
38+
pub fn AcquireSRWLockExclusive(SRWLock: PSRWLOCK);
39+
pub fn AcquireSRWLockShared(SRWLock: PSRWLOCK);
40+
pub fn ReleaseSRWLockExclusive(SRWLock: PSRWLOCK);
41+
pub fn ReleaseSRWLockShared(SRWLock: PSRWLOCK);
42+
pub fn TryAcquireSRWLockExclusive(SRWLock: PSRWLOCK) -> BOOLEAN;
43+
pub fn TryAcquireSRWLockShared(SRWLock: PSRWLOCK) -> BOOLEAN;
5744
}
58-

branches/try/src/libsyntax/ast.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,6 +1528,19 @@ pub struct ViewItem {
15281528
pub span: Span,
15291529
}
15301530

1531+
impl ViewItem {
1532+
pub fn id(&self) -> NodeId {
1533+
match self.node {
1534+
ViewItemExternCrate(_, _, id) => id,
1535+
ViewItemUse(ref vp) => match vp.node {
1536+
ViewPathSimple(_, _, id) => id,
1537+
ViewPathGlob(_, id) => id,
1538+
ViewPathList(_, _, id) => id,
1539+
}
1540+
}
1541+
}
1542+
}
1543+
15311544
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
15321545
pub enum ViewItem_ {
15331546
/// Ident: name used to refer to this crate in the code

0 commit comments

Comments
 (0)