Skip to content

Commit 84f5d48

Browse files
committed
---
yaml --- r: 151928 b: refs/heads/try2 c: 9411cec h: refs/heads/master v: v3
1 parent d9f5eab commit 84f5d48

File tree

32 files changed

+528
-115
lines changed

32 files changed

+528
-115
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: e5d883101c27ab7c7a232337ffebaa85edc9d64f
8+
refs/heads/try2: 9411cec580932f38e0e017245ce28ad2ff8e936c
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/etc/vim/syntax/rust.vim

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,40 @@ syn keyword rustOperator as
1818

1919
syn match rustAssert "\<assert\(\w\)*!" contained
2020
syn match rustFail "\<fail\(\w\)*!" contained
21-
syn keyword rustKeyword break box continue
22-
syn keyword rustKeyword extern nextgroup=rustExternCrate,rustObsoleteExternMod skipwhite
21+
syn keyword rustKeyword break
22+
syn keyword rustKeyword box nextgroup=rustBoxPlacement skipwhite skipempty
23+
syn keyword rustKeyword continue
24+
syn keyword rustKeyword extern nextgroup=rustExternCrate,rustObsoleteExternMod skipwhite skipempty
25+
syn keyword rustKeyword fn nextgroup=rustFuncName skipwhite skipempty
2326
syn keyword rustKeyword for in if impl let
24-
syn keyword rustKeyword loop once priv pub
25-
syn keyword rustKeyword return
26-
syn keyword rustKeyword unsafe while
27-
syn keyword rustKeyword use nextgroup=rustModPath skipwhite
27+
syn keyword rustKeyword loop once proc pub
28+
syn keyword rustKeyword return super
29+
syn keyword rustKeyword unsafe virtual while
30+
syn keyword rustKeyword use nextgroup=rustModPath skipwhite skipempty
2831
" FIXME: Scoped impl's name is also fallen in this category
29-
syn keyword rustKeyword mod trait struct enum type nextgroup=rustIdentifier skipwhite
30-
syn keyword rustKeyword fn nextgroup=rustFuncName skipwhite
31-
syn keyword rustKeyword proc
32+
syn keyword rustKeyword mod trait struct enum type nextgroup=rustIdentifier skipwhite skipempty
3233
syn keyword rustStorage mut ref static
3334
syn keyword rustObsoleteStorage const
3435

3536
syn keyword rustInvalidBareKeyword crate
3637

37-
syn keyword rustExternCrate crate contained nextgroup=rustIdentifier skipwhite
38-
syn keyword rustObsoleteExternMod mod contained nextgroup=rustIdentifier skipwhite
38+
syn keyword rustExternCrate crate contained nextgroup=rustIdentifier skipwhite skipempty
39+
syn keyword rustObsoleteExternMod mod contained nextgroup=rustIdentifier skipwhite skipempty
3940

4041
syn match rustIdentifier contains=rustIdentifierPrime "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
4142
syn match rustFuncName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
4243

44+
syn region rustBoxPlacement matchgroup=rustBoxPlacementParens start="(" end=")" contains=TOP contained
45+
syn keyword rustBoxPlacementExpr GC containedin=rustBoxPlacement
46+
" Ideally we'd have syntax rules set up to match arbitrary expressions. Since
47+
" we don't, we'll just define temporary contained rules to handle balancing
48+
" delimiters.
49+
syn region rustBoxPlacementBalance start="(" end=")" containedin=rustBoxPlacement transparent
50+
syn region rustBoxPlacementBalance start="\[" end="\]" containedin=rustBoxPlacement transparent
51+
" {} are handled by rustFoldBraces
52+
4353
" Reserved (but not yet used) keywords {{{2
44-
syn keyword rustReservedKeyword alignof be do offsetof pure sizeof typeof yield
54+
syn keyword rustReservedKeyword alignof be do offsetof priv pure sizeof typeof unsized yield
4555

4656
" Built-in types {{{2
4757
syn keyword rustType int uint float char bool u8 u16 u32 u64 f32
@@ -52,10 +62,10 @@ syn keyword rustType f64 i8 i16 i32 i64 str Self
5262
" to make it easy to update.
5363

5464
" Core operators {{{3
55-
syn keyword rustTrait Share Copy Send Sized
65+
syn keyword rustTrait Copy Send Sized Share
5666
syn keyword rustTrait Add Sub Mul Div Rem Neg Not
5767
syn keyword rustTrait BitAnd BitOr BitXor
58-
syn keyword rustTrait Drop
68+
syn keyword rustTrait Drop Deref DerefMut
5969
syn keyword rustTrait Shl Shr Index
6070
syn keyword rustEnum Option
6171
syn keyword rustEnumVariant Some None
@@ -68,7 +78,6 @@ syn keyword rustEnumVariant Ok Err
6878
"syn keyword rustFunction drop
6979

7080
" Types and traits {{{3
71-
syn keyword rustTrait Any AnyOwnExt AnyRefExt AnyMutRefExt
7281
syn keyword rustTrait Ascii AsciiCast OwnedAsciiCast AsciiStr IntoBytes
7382
syn keyword rustTrait ToCStr
7483
syn keyword rustTrait Char
@@ -80,25 +89,32 @@ syn keyword rustTrait FromIterator Extendable
8089
syn keyword rustTrait Iterator DoubleEndedIterator RandomAccessIterator CloneableIterator
8190
syn keyword rustTrait OrdIterator MutableDoubleEndedIterator ExactSize
8291
syn keyword rustTrait Num NumCast CheckedAdd CheckedSub CheckedMul
83-
syn keyword rustTrait Signed Unsigned Round
84-
syn keyword rustTrait Primitive Int Float ToPrimitive FromPrimitive
92+
syn keyword rustTrait Signed Unsigned
93+
syn keyword rustTrait Primitive Int Float FloatMath ToPrimitive FromPrimitive
94+
"syn keyword rustTrait Expect
95+
syn keyword rustTrait Box
8596
syn keyword rustTrait GenericPath Path PosixPath WindowsPath
8697
syn keyword rustTrait RawPtr
8798
syn keyword rustTrait Buffer Writer Reader Seek
88-
syn keyword rustTrait Str StrVector StrSlice OwnedStr IntoMaybeOwned StrBuf
99+
syn keyword rustTrait Str StrVector StrSlice OwnedStr IntoMaybeOwned
100+
syn keyword rustTrait StrAllocating
89101
syn keyword rustTrait ToStr IntoStr
90102
syn keyword rustTrait Tuple1 Tuple2 Tuple3 Tuple4
91103
syn keyword rustTrait Tuple5 Tuple6 Tuple7 Tuple8
92104
syn keyword rustTrait Tuple9 Tuple10 Tuple11 Tuple12
93-
syn keyword rustTrait ImmutableEqVector ImmutableTotalOrdVector ImmutableCloneableVector
94-
syn keyword rustTrait OwnedVector OwnedCloneableVector OwnedEqVector
95-
syn keyword rustTrait MutableVector MutableTotalOrdVector
96-
syn keyword rustTrait Vector VectorVector CloneableVector ImmutableVector
97-
98-
"syn keyword rustFunction stream
99-
syn keyword rustTrait Sender Receiver
105+
syn keyword rustTrait CloneableVector ImmutableCloneableVector MutableCloneableVector
106+
syn keyword rustTrait ImmutableVector MutableVector
107+
syn keyword rustTrait ImmutableEqVector ImmutableTotalOrdVector MutableTotalOrdVector
108+
syn keyword rustTrait Vector VectorVector OwnedVector MutableVectorAllocating
109+
syn keyword rustTrait StrBuf
110+
syn keyword rustTrait Vec
111+
112+
"syn keyword rustFunction sync_channel channel
113+
syn keyword rustTrait SyncSender Sender Receiver
100114
"syn keyword rustFunction spawn
101115

116+
"syn keyword rustConstant GC
117+
102118
syn keyword rustSelf self
103119
syn keyword rustBoolean true false
104120

@@ -239,6 +255,8 @@ hi def link rustLifetime Special
239255
hi def link rustInvalidBareKeyword Error
240256
hi def link rustExternCrate rustKeyword
241257
hi def link rustObsoleteExternMod Error
258+
hi def link rustBoxPlacementParens Delimiter
259+
hi def link rustBoxPlacementExpr rustKeyword
242260

243261
" Other Suggestions:
244262
" hi rustAttribute ctermfg=cyan

branches/try2/src/liballoc/heap.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
// FIXME: #13994: port to the sized deallocation API when available
12-
// FIXME: #13996: need a way to mark the `allocate` and `reallocate` return values as `noalias`
12+
// FIXME: #13996: mark the `allocate` and `reallocate` return value as `noalias` and `nonnull`
1313

1414
use core::intrinsics::{abort, cttz32};
1515
use core::option::{None, Option};
@@ -119,14 +119,8 @@ pub fn stats_print() {
119119
/// The allocator for unique pointers.
120120
#[cfg(not(test))]
121121
#[lang="exchange_malloc"]
122-
#[inline(always)]
123-
pub unsafe fn exchange_malloc_(size: uint, align: uint) -> *mut u8 {
124-
exchange_malloc(size, align)
125-
}
126-
127-
/// The allocator for unique pointers.
128122
#[inline]
129-
pub unsafe fn exchange_malloc(size: uint, align: uint) -> *mut u8 {
123+
unsafe fn exchange_malloc(size: uint, align: uint) -> *mut u8 {
130124
// The compiler never calls `exchange_free` on ~ZeroSizeType, so zero-size
131125
// allocations can point to this `static`. It would be incorrect to use a null
132126
// pointer, due to enums assuming types like unique pointers are never null.
@@ -139,14 +133,20 @@ pub unsafe fn exchange_malloc(size: uint, align: uint) -> *mut u8 {
139133
}
140134
}
141135

142-
#[cfg(not(test))]
136+
#[cfg(not(test), stage0)]
143137
#[lang="exchange_free"]
144138
#[inline]
145-
// FIXME: #13994 (rustc should pass align and size here)
146139
unsafe fn exchange_free(ptr: *mut u8) {
147140
deallocate(ptr, 0, 8);
148141
}
149142

143+
#[cfg(not(test), not(stage0))]
144+
#[lang="exchange_free"]
145+
#[inline]
146+
unsafe fn exchange_free(ptr: *mut u8, size: uint, align: uint) {
147+
deallocate(ptr, size, align);
148+
}
149+
150150
// FIXME: #7496
151151
#[cfg(not(test))]
152152
#[lang="closure_exchange_malloc"]
@@ -167,16 +167,16 @@ unsafe fn closure_exchange_malloc(drop_glue: fn(*mut u8), size: uint, align: uin
167167
#[doc(hidden)]
168168
#[deprecated]
169169
#[cfg(not(test))]
170-
pub unsafe extern "C" fn rust_malloc(size: uint, align: uint) -> *mut u8 {
171-
exchange_malloc(size, align)
170+
pub unsafe extern "C" fn rust_allocate(size: uint, align: uint) -> *mut u8 {
171+
allocate(size, align)
172172
}
173173

174174
// hack for libcore
175175
#[no_mangle]
176176
#[doc(hidden)]
177177
#[deprecated]
178178
#[cfg(not(test))]
179-
pub unsafe extern "C" fn rust_free(ptr: *mut u8, size: uint, align: uint) {
179+
pub unsafe extern "C" fn rust_deallocate(ptr: *mut u8, size: uint, align: uint) {
180180
deallocate(ptr, size, align)
181181
}
182182

branches/try2/src/libarena/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use std::mem;
3838
use std::num;
3939
use std::ptr::read;
4040
use std::rc::Rc;
41-
use std::rt::heap::exchange_malloc;
41+
use std::rt::heap::allocate;
4242

4343
// The way arena uses arrays is really deeply awful. The arrays are
4444
// allocated, and have capacities reserved, but the fill for the array
@@ -358,8 +358,7 @@ impl<T> TypedArenaChunk<T> {
358358
size = size.checked_add(&elems_size).unwrap();
359359

360360
let mut chunk = unsafe {
361-
let chunk = exchange_malloc(size,
362-
mem::min_align_of::<TypedArenaChunk<T>>());
361+
let chunk = allocate(size, mem::min_align_of::<TypedArenaChunk<T>>());
363362
let mut chunk: Box<TypedArenaChunk<T>> = mem::transmute(chunk);
364363
mem::overwrite(&mut chunk.next, next);
365364
chunk

branches/try2/src/libcore/should_not_exist.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ use str::StrSlice;
4444

4545
#[allow(ctypes)]
4646
extern {
47-
fn rust_malloc(size: uint, align: uint) -> *u8;
48-
fn rust_free(ptr: *u8, size: uint, align: uint);
47+
fn rust_allocate(size: uint, align: uint) -> *u8;
48+
fn rust_deallocate(ptr: *u8, size: uint, align: uint);
4949
}
5050

5151
unsafe fn alloc(cap: uint) -> *mut Vec<()> {
5252
let cap = cap.checked_add(&mem::size_of::<Vec<()>>()).unwrap();
5353
// this should use the real alignment, but the new representation will take care of that
54-
let ret = rust_malloc(cap, 8) as *mut Vec<()>;
54+
let ret = rust_allocate(cap, 8) as *mut Vec<()>;
5555
if ret.is_null() {
5656
intrinsics::abort();
5757
}
@@ -119,7 +119,7 @@ impl FromIterator<char> for ~str {
119119
&(*ptr).data,
120120
len);
121121
// FIXME: #13994: port to the sized deallocation API when available
122-
rust_free(ptr as *u8, 0, 8);
122+
rust_deallocate(ptr as *u8, 0, 8);
123123
mem::forget(ret);
124124
ret = mem::transmute(ptr2);
125125
ptr = ptr2;
@@ -191,7 +191,7 @@ impl<A: Clone> Clone for ~[A] {
191191
for j in range(0, *i as int) {
192192
ptr::read(&*p.offset(j));
193193
}
194-
rust_free(ret as *u8, 0, 8);
194+
rust_deallocate(ret as *u8, 0, 8);
195195
});
196196
mem::transmute(ret)
197197
}

branches/try2/src/libcore/str.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,9 @@ pub trait StrSlice<'a> {
11121112
///
11131113
/// let v: Vec<&str> = "lionXXtigerXleopard".split('X').collect();
11141114
/// assert_eq!(v, vec!["lion", "", "tiger", "leopard"]);
1115+
///
1116+
/// let v: Vec<&str> = "".split('X').collect();
1117+
/// assert_eq!(v, vec![""]);
11151118
/// ```
11161119
fn split<Sep: CharEq>(&self, sep: Sep) -> CharSplits<'a, Sep>;
11171120

@@ -1130,6 +1133,12 @@ pub trait StrSlice<'a> {
11301133
///
11311134
/// let v: Vec<&str> = "lionXXtigerXleopard".splitn('X', 2).collect();
11321135
/// assert_eq!(v, vec!["lion", "", "tigerXleopard"]);
1136+
///
1137+
/// let v: Vec<&str> = "abcXdef".splitn('X', 0).collect();
1138+
/// assert_eq!(v, vec!["abcXdef"]);
1139+
///
1140+
/// let v: Vec<&str> = "".splitn('X', 1).collect();
1141+
/// assert_eq!(v, vec![""]);
11331142
/// ```
11341143
fn splitn<Sep: CharEq>(&self, sep: Sep, count: uint) -> CharSplitsN<'a, Sep>;
11351144

branches/try2/src/librustc/middle/check_match.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@Pat]) -> useful {
247247
_ => *r.get(0)
248248
}
249249
}
250+
None if v.len() == 0 => return not_useful,
250251
None => v[0]
251252
};
252253
let left_ty = if real_pat.id == 0 { ty::mk_nil() }
@@ -341,8 +342,10 @@ fn is_useful_specialized(cx: &MatchCheckCtxt,
341342
let ms = m.iter().filter_map(|r| {
342343
specialize(cx, r.as_slice(), &ctor, arity, lty)
343344
}).collect::<matrix>();
344-
let could_be_useful = is_useful(
345-
cx, &ms, specialize(cx, v, &ctor, arity, lty).unwrap().as_slice());
345+
let could_be_useful = match specialize(cx, v, &ctor, arity, lty) {
346+
Some(v) => is_useful(cx, &ms, v.as_slice()),
347+
None => return not_useful,
348+
};
346349
match could_be_useful {
347350
useful_ => useful(lty, ctor),
348351
u => u,

branches/try2/src/librustc/middle/resolve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2040,7 +2040,7 @@ impl<'a> Resolver<'a> {
20402040
return;
20412041
}
20422042

2043-
let mut imports = module.imports.borrow_mut();
2043+
let imports = module.imports.borrow();
20442044
let import_count = imports.len();
20452045
while module.resolved_import_count.get() < import_count {
20462046
let import_index = module.resolved_import_count.get();

branches/try2/src/librustc/middle/trans/cleanup.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,13 +278,14 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> {
278278
fn schedule_free_value(&self,
279279
cleanup_scope: ScopeId,
280280
val: ValueRef,
281-
heap: Heap) {
281+
heap: Heap,
282+
content_ty: ty::t) {
282283
/*!
283284
* Schedules a call to `free(val)`. Note that this is a shallow
284285
* operation.
285286
*/
286287

287-
let drop = box FreeValue { ptr: val, heap: heap };
288+
let drop = box FreeValue { ptr: val, heap: heap, content_ty: content_ty };
288289

289290
debug!("schedule_free_value({:?}, val={}, heap={:?})",
290291
cleanup_scope,
@@ -847,6 +848,7 @@ pub enum Heap {
847848
pub struct FreeValue {
848849
ptr: ValueRef,
849850
heap: Heap,
851+
content_ty: ty::t
850852
}
851853

852854
impl Cleanup for FreeValue {
@@ -860,7 +862,7 @@ impl Cleanup for FreeValue {
860862
glue::trans_free(bcx, self.ptr)
861863
}
862864
HeapExchange => {
863-
glue::trans_exchange_free(bcx, self.ptr)
865+
glue::trans_exchange_free_ty(bcx, self.ptr, self.content_ty)
864866
}
865867
}
866868
}
@@ -931,7 +933,8 @@ pub trait CleanupMethods<'a> {
931933
fn schedule_free_value(&self,
932934
cleanup_scope: ScopeId,
933935
val: ValueRef,
934-
heap: Heap);
936+
heap: Heap,
937+
content_ty: ty::t);
935938
fn schedule_clean(&self,
936939
cleanup_scope: ScopeId,
937940
cleanup: Box<Cleanup>);

branches/try2/src/librustc/middle/trans/expr.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ fn trans_uniq_expr<'a>(bcx: &'a Block<'a>,
11831183
} else {
11841184
let custom_cleanup_scope = fcx.push_custom_cleanup_scope();
11851185
fcx.schedule_free_value(cleanup::CustomScope(custom_cleanup_scope),
1186-
val, cleanup::HeapExchange);
1186+
val, cleanup::HeapExchange, contents_ty);
11871187
let bcx = trans_into(bcx, contents, SaveIn(val));
11881188
fcx.pop_custom_cleanup_scope(custom_cleanup_scope);
11891189
bcx
@@ -1205,7 +1205,7 @@ fn trans_managed_expr<'a>(bcx: &'a Block<'a>,
12051205

12061206
let custom_cleanup_scope = fcx.push_custom_cleanup_scope();
12071207
fcx.schedule_free_value(cleanup::CustomScope(custom_cleanup_scope),
1208-
bx, cleanup::HeapManaged);
1208+
bx, cleanup::HeapManaged, contents_ty);
12091209
let bcx = trans_into(bcx, contents, SaveIn(body));
12101210
fcx.pop_custom_cleanup_scope(custom_cleanup_scope);
12111211
immediate_rvalue_bcx(bcx, bx, box_ty).to_expr_datumblock()
@@ -1789,13 +1789,14 @@ fn deref_once<'a>(bcx: &'a Block<'a>,
17891789
let scope = cleanup::temporary_scope(bcx.tcx(), expr.id);
17901790
let ptr = Load(bcx, datum.val);
17911791
if !type_is_zero_size(bcx.ccx(), content_ty) {
1792-
bcx.fcx.schedule_free_value(scope, ptr, cleanup::HeapExchange);
1792+
bcx.fcx.schedule_free_value(scope, ptr, cleanup::HeapExchange, content_ty);
17931793
}
17941794
}
17951795
RvalueExpr(Rvalue { mode: ByValue }) => {
17961796
let scope = cleanup::temporary_scope(bcx.tcx(), expr.id);
17971797
if !type_is_zero_size(bcx.ccx(), content_ty) {
1798-
bcx.fcx.schedule_free_value(scope, datum.val, cleanup::HeapExchange);
1798+
bcx.fcx.schedule_free_value(scope, datum.val, cleanup::HeapExchange,
1799+
content_ty);
17991800
}
18001801
}
18011802
LvalueExpr => { }

0 commit comments

Comments
 (0)