Skip to content

Commit 68c186c

Browse files
committed
---
yaml --- r: 71911 b: refs/heads/dist-snap c: 49de82c h: refs/heads/master i: 71909: e852396 71907: b21778b 71903: ca43ca0 v: v3
1 parent 914c407 commit 68c186c

Some content is hidden

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

90 files changed

+1888
-2733
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: b50030718cf28f2a5a81857a26b57442734fe854
10-
refs/heads/dist-snap: 26ecb30f550a46d52528a7d45d9327ebce938e81
10+
refs/heads/dist-snap: 49de82cdca2064a909d3104f4e5eccacb0425fd0
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/doc/tutorial.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -495,11 +495,7 @@ omitted.
495495

496496
A powerful application of pattern matching is *destructuring*:
497497
matching in order to bind names to the contents of data
498-
types.
499-
500-
> ***Note:*** The following code makes use of tuples (`(float, float)`) which
501-
> are explained in section 5.3. For now you can think of tuples as a list of
502-
> items.
498+
types. Assuming that `(float, float)` is a tuple of two floats:
503499

504500
~~~~
505501
fn angle(vector: (float, float)) -> float {

branches/dist-snap/src/libcore/cmp.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,19 @@ totalord_impl!(i64)
116116
totalord_impl!(int)
117117
totalord_impl!(uint)
118118

119+
pub fn cmp2<A:TotalOrd,B:TotalOrd>(
120+
a1: &A, b1: &B,
121+
a2: &A, b2: &B) -> Ordering
122+
{
123+
//! Compares (a1, b1) against (a2, b2), where the a values are more significant.
124+
125+
match a1.cmp(a2) {
126+
Less => Less,
127+
Greater => Greater,
128+
Equal => b1.cmp(b2)
129+
}
130+
}
131+
119132
/**
120133
* Trait for values that can be compared for a sort-order.
121134
*
@@ -193,6 +206,14 @@ mod test {
193206
assert_eq!(12.cmp(-5), Greater);
194207
}
195208

209+
#[test]
210+
fn test_cmp2() {
211+
assert_eq!(cmp2(1, 2, 3, 4), Less);
212+
assert_eq!(cmp2(3, 2, 3, 4), Less);
213+
assert_eq!(cmp2(5, 2, 3, 4), Greater);
214+
assert_eq!(cmp2(5, 5, 5, 4), Greater);
215+
}
216+
196217
#[test]
197218
fn test_int_totaleq() {
198219
assert!(5.equals(&5));

branches/dist-snap/src/libcore/iter.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -344,29 +344,3 @@ pub fn copy_seq<T:Copy,IT:BaseIter<T>,BT:Buildable<T>>(v: &IT) -> BT {
344344
for v.each |x| { push(*x); }
345345
}
346346
}
347-
348-
/**
349-
* Helper function to transform an internal iterator into an owned vector.
350-
*
351-
* # Example:
352-
*
353-
* ~~~
354-
* let v = ~[1, 2, 3];
355-
* let v2 = do iter_to_vec |f| { v.each(|e| f(*e)) };
356-
* if v != v2 { fail!() }
357-
* ~~~
358-
*/
359-
#[inline(always)]
360-
pub fn iter_to_vec<T>(pusher: &fn(it: &fn(T) -> bool)) -> ~[T] {
361-
let mut v = ~[];
362-
let pushf = |e| {v.push(e); true};
363-
pusher(pushf);
364-
v
365-
}
366-
367-
#[test]
368-
fn test_iter_to_vec() {
369-
let v = ~[1, 2, 3];
370-
let v2 = do iter_to_vec |f| { v.each(|e| f(*e)) };
371-
if v != v2 { fail!() }
372-
}

branches/dist-snap/src/libcore/str.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,11 @@ pub fn slice_shift_char<'a>(s: &'a str) -> (char, &'a str) {
301301

302302
/// Prepend a char to a string
303303
pub fn unshift_char(s: &mut ~str, ch: char) {
304-
*s = from_char(ch) + *s;
304+
// This could be more efficient.
305+
let mut new_str = ~"";
306+
new_str.push_char(ch);
307+
new_str.push_str(*s);
308+
*s = new_str;
305309
}
306310

307311
/**

branches/dist-snap/src/libcore/tuple.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ impl<A:Ord> Ord for (A,) {
161161
fn gt(&self, other: &(A,)) -> bool { other.lt(&(*self)) }
162162
}
163163

164-
165164
#[cfg(notest)]
166165
impl<A:Eq,B:Eq> Eq for (A, B) {
167166
#[inline(always)]

branches/dist-snap/src/librustc/front/core_inject.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fn inject_libcore_ref(sess: Session,
7777
fold_mod: |module, fld| {
7878
let n2 = sess.next_node_id();
7979

80-
let prelude_path = @ast::Path {
80+
let prelude_path = @ast::path {
8181
span: dummy_sp(),
8282
global: false,
8383
idents: ~[

branches/dist-snap/src/librustc/front/test.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,16 +336,16 @@ fn nospan<T:Copy>(t: T) -> codemap::spanned<T> {
336336
codemap::spanned { node: t, span: dummy_sp() }
337337
}
338338

339-
fn path_node(+ids: ~[ast::ident]) -> @ast::Path {
340-
@ast::Path { span: dummy_sp(),
339+
fn path_node(+ids: ~[ast::ident]) -> @ast::path {
340+
@ast::path { span: dummy_sp(),
341341
global: false,
342342
idents: ids,
343343
rp: None,
344344
types: ~[] }
345345
}
346346

347-
fn path_node_global(+ids: ~[ast::ident]) -> @ast::Path {
348-
@ast::Path { span: dummy_sp(),
347+
fn path_node_global(+ids: ~[ast::ident]) -> @ast::path {
348+
@ast::path { span: dummy_sp(),
349349
global: true,
350350
idents: ids,
351351
rp: None,

branches/dist-snap/src/librustc/metadata/tydecode.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub fn parse_arg_data(data: @~[u8], crate_num: int, pos: uint, tcx: ty::ctxt,
137137
parse_arg(st, conv)
138138
}
139139

140-
fn parse_path(st: @mut PState) -> @ast::Path {
140+
fn parse_path(st: @mut PState) -> @ast::path {
141141
let mut idents: ~[ast::ident] = ~[];
142142
fn is_last(c: char) -> bool { return c == '(' || c == ':'; }
143143
idents.push(parse_ident_(st, is_last));
@@ -146,7 +146,7 @@ fn parse_path(st: @mut PState) -> @ast::Path {
146146
':' => { next(st); next(st); }
147147
c => {
148148
if c == '(' {
149-
return @ast::Path { span: dummy_sp(),
149+
return @ast::path { span: dummy_sp(),
150150
global: false,
151151
idents: idents,
152152
rp: None,
@@ -239,7 +239,8 @@ fn parse_region(st: @mut PState) -> ty::Region {
239239
assert!(next(st) == '|');
240240
let br = parse_bound_region(st);
241241
assert!(next(st) == ']');
242-
ty::re_free(id, br)
242+
ty::re_free(ty::FreeRegion {scope_id: id,
243+
bound_region: br})
243244
}
244245
's' => {
245246
let id = parse_int(st);

branches/dist-snap/src/librustc/metadata/tyencode.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ fn enc_region(w: @io::Writer, cx: @ctxt, r: ty::Region) {
146146
w.write_char('b');
147147
enc_bound_region(w, cx, br);
148148
}
149-
ty::re_free(id, br) => {
149+
ty::re_free(ref fr) => {
150150
w.write_char('f');
151151
w.write_char('[');
152-
w.write_int(id);
152+
w.write_int(fr.scope_id);
153153
w.write_char('|');
154-
enc_bound_region(w, cx, br);
154+
enc_bound_region(w, cx, fr.bound_region);
155155
w.write_char(']');
156156
}
157157
ty::re_scope(nid) => {

branches/dist-snap/src/librustc/middle/astencode.rs

Lines changed: 4 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,12 @@ impl tr for ty::Region {
475475
fn tr(&self, xcx: @ExtendedDecodeContext) -> ty::Region {
476476
match *self {
477477
ty::re_bound(br) => ty::re_bound(br.tr(xcx)),
478-
ty::re_free(id, br) => ty::re_free(xcx.tr_id(id), br.tr(xcx)),
479478
ty::re_scope(id) => ty::re_scope(xcx.tr_id(id)),
480479
ty::re_static | ty::re_infer(*) => *self,
480+
ty::re_free(ref fr) => {
481+
ty::re_free(ty::FreeRegion {scope_id: xcx.tr_id(fr.scope_id),
482+
bound_region: fr.bound_region.tr(xcx)})
483+
}
481484
}
482485
}
483486
}
@@ -556,7 +559,6 @@ trait read_method_map_entry_helper {
556559
-> method_map_entry;
557560
}
558561
559-
#[cfg(stage0)]
560562
fn encode_method_map_entry(ecx: @e::EncodeContext,
561563
ebml_w: writer::Encoder,
562564
mme: method_map_entry) {
@@ -573,27 +575,7 @@ fn encode_method_map_entry(ecx: @e::EncodeContext,
573575
}
574576
}
575577
576-
#[cfg(stage1)]
577-
#[cfg(stage2)]
578-
#[cfg(stage3)]
579-
fn encode_method_map_entry(ecx: @e::EncodeContext,
580-
ebml_w: writer::Encoder,
581-
mme: method_map_entry) {
582-
do ebml_w.emit_struct("method_map_entry", 3) {
583-
do ebml_w.emit_struct_field("self_arg", 0u) {
584-
ebml_w.emit_arg(ecx, mme.self_arg);
585-
}
586-
do ebml_w.emit_struct_field("explicit_self", 2u) {
587-
mme.explicit_self.encode(&ebml_w);
588-
}
589-
do ebml_w.emit_struct_field("origin", 1u) {
590-
mme.origin.encode(&ebml_w);
591-
}
592-
}
593-
}
594-
595578
impl read_method_map_entry_helper for reader::Decoder {
596-
#[cfg(stage0)]
597579
fn read_method_map_entry(&self, xcx: @ExtendedDecodeContext)
598580
-> method_map_entry {
599581
do self.read_struct("method_map_entry", 3) {
@@ -613,29 +595,6 @@ impl read_method_map_entry_helper for reader::Decoder {
613595
}
614596
}
615597
}
616-
617-
#[cfg(stage1)]
618-
#[cfg(stage2)]
619-
#[cfg(stage3)]
620-
fn read_method_map_entry(&self, xcx: @ExtendedDecodeContext)
621-
-> method_map_entry {
622-
do self.read_struct("method_map_entry", 3) {
623-
method_map_entry {
624-
self_arg: self.read_struct_field("self_arg", 0u, || {
625-
self.read_arg(xcx)
626-
}),
627-
explicit_self: self.read_struct_field("explicit_self", 2u, || {
628-
let self_type: ast::self_ty_ = Decodable::decode(self);
629-
self_type
630-
}),
631-
origin: self.read_struct_field("origin", 1u, || {
632-
let method_origin: method_origin =
633-
Decodable::decode(self);
634-
method_origin.tr(xcx)
635-
}),
636-
}
637-
}
638-
}
639598
}
640599
641600
impl tr for method_origin {
@@ -826,7 +785,6 @@ impl ebml_writer_helpers for writer::Encoder {
826785
}
827786
}
828787
829-
#[cfg(stage0)]
830788
fn emit_tpbt(&self, ecx: @e::EncodeContext,
831789
tpbt: ty::ty_param_bounds_and_ty) {
832790
do self.emit_struct("ty_param_bounds_and_ty", 2) {
@@ -849,32 +807,6 @@ impl ebml_writer_helpers for writer::Encoder {
849807
}
850808
}
851809
}
852-
853-
#[cfg(stage1)]
854-
#[cfg(stage2)]
855-
#[cfg(stage3)]
856-
fn emit_tpbt(&self, ecx: @e::EncodeContext,
857-
tpbt: ty::ty_param_bounds_and_ty) {
858-
do self.emit_struct("ty_param_bounds_and_ty", 2) {
859-
do self.emit_struct_field("generics", 0) {
860-
do self.emit_struct("Generics", 2) {
861-
do self.emit_struct_field("type_param_defs", 0) {
862-
do self.emit_from_vec(*tpbt.generics.type_param_defs)
863-
|type_param_def|
864-
{
865-
self.emit_type_param_def(ecx, type_param_def);
866-
}
867-
}
868-
do self.emit_struct_field("region_param", 1) {
869-
tpbt.generics.region_param.encode(self);
870-
}
871-
}
872-
}
873-
do self.emit_struct_field("ty", 1) {
874-
self.emit_ty(ecx, tpbt.ty);
875-
}
876-
}
877-
}
878810
}
879811
880812
trait write_tag_and_id {
@@ -1124,7 +1056,6 @@ impl ebml_decoder_decoder_helpers for reader::Decoder {
11241056
}
11251057
}
11261058
1127-
#[cfg(stage0)]
11281059
fn read_ty_param_bounds_and_ty(&self, xcx: @ExtendedDecodeContext)
11291060
-> ty::ty_param_bounds_and_ty
11301061
{
@@ -1147,31 +1078,6 @@ impl ebml_decoder_decoder_helpers for reader::Decoder {
11471078
}
11481079
}
11491080
1150-
#[cfg(stage1)]
1151-
#[cfg(stage2)]
1152-
#[cfg(stage3)]
1153-
fn read_ty_param_bounds_and_ty(&self, xcx: @ExtendedDecodeContext)
1154-
-> ty::ty_param_bounds_and_ty
1155-
{
1156-
do self.read_struct("ty_param_bounds_and_ty", 2) {
1157-
ty::ty_param_bounds_and_ty {
1158-
generics: do self.read_struct("Generics", 2) {
1159-
ty::Generics {
1160-
type_param_defs: self.read_struct_field("type_param_defs", 0, || {
1161-
@self.read_to_vec(|| self.read_type_param_def(xcx))
1162-
}),
1163-
region_param: self.read_struct_field(~"region_param", 1, || {
1164-
Decodable::decode(self)
1165-
})
1166-
}
1167-
},
1168-
ty: self.read_struct_field("ty", 1, || {
1169-
self.read_ty(xcx)
1170-
})
1171-
}
1172-
}
1173-
}
1174-
11751081
fn convert_def_id(&self, xcx: @ExtendedDecodeContext,
11761082
source: tydecode::DefIdSource,
11771083
did: ast::def_id) -> ast::def_id {

branches/dist-snap/src/librustc/middle/borrowck/check_loans.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ pub impl CheckLoanCtxt {
128128
Some(e) => return Some(pc_cmt(*e))
129129
}
130130
131-
match self.tcx().region_map.find(&scope_id) {
131+
match self.tcx().region_maps.opt_encl_scope(scope_id) {
132132
None => return default_purity,
133-
Some(&next_scope_id) => scope_id = next_scope_id
133+
Some(next_scope_id) => scope_id = next_scope_id
134134
}
135135
}
136136
}
@@ -146,9 +146,9 @@ pub impl CheckLoanCtxt {
146146
}
147147
}
148148
149-
match self.tcx().region_map.find(&scope_id) {
149+
match self.tcx().region_maps.opt_encl_scope(scope_id) {
150150
None => return,
151-
Some(&next_scope_id) => scope_id = next_scope_id,
151+
Some(next_scope_id) => scope_id = next_scope_id,
152152
}
153153
}
154154
}
@@ -270,7 +270,7 @@ pub impl CheckLoanCtxt {
270270

271271
debug!("new_loans has length %?", new_loans.len());
272272

273-
let par_scope_id = *self.tcx().region_map.get(&scope_id);
273+
let par_scope_id = self.tcx().region_maps.encl_scope(scope_id);
274274
for self.walk_loans(par_scope_id) |old_loan| {
275275
debug!("old_loan=%?", self.bccx.loan_to_repr(old_loan));
276276

branches/dist-snap/src/librustc/middle/borrowck/gather_loans.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ fn req_loans_in_expr(ex: @ast::expr,
242242
// (if used like `a.b(...)`), the call where it's an argument
243243
// (if used like `x(a.b)`), or the block (if used like `let x
244244
// = a.b`).
245-
let scope_r = ty::re_scope(*self.tcx().region_map.get(&ex.id));
245+
let scope_r = self.tcx().region_maps.encl_region(ex.id);
246246
let rcvr_cmt = self.bccx.cat_expr(rcvr);
247247
self.guarantee_valid(rcvr_cmt, m_imm, scope_r);
248248
visit::visit_expr(ex, self, vt);
@@ -524,7 +524,10 @@ pub impl GatherLoanCtxt {
524524
// immutable structures, this is just the converse I suppose)
525525

526526
let scope_id = match scope_r {
527-
ty::re_scope(scope_id) | ty::re_free(scope_id, _) => scope_id,
527+
ty::re_scope(scope_id) |
528+
ty::re_free(ty::FreeRegion {scope_id, _}) => {
529+
scope_id
530+
}
528531
_ => {
529532
self.bccx.tcx.sess.span_bug(
530533
cmt.span,

0 commit comments

Comments
 (0)