Skip to content

Commit 9226c76

Browse files
committed
---
yaml --- r: 55993 b: refs/heads/auto c: 9963bd2 h: refs/heads/master i: 55991: 085407e v: v3
1 parent bb4e29d commit 9226c76

35 files changed

+1254
-671
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 412a07055c211f2dec4fb87f25b87d2d71fb13de
17+
refs/heads/auto: 9963bd24138999e745584a138f8381f91e3a308c
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/src/libcore/num/int-template.rs

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,11 @@ pub fn range_step(start: T, stop: T, step: T, it: &fn(T) -> bool) {
107107
} else if step > 0 { // ascending
108108
while i < stop {
109109
if !it(i) { break }
110-
// avoiding overflow. break if i + step > max_value
111-
if i > max_value - step { break; }
112110
i += step;
113111
}
114112
} else { // descending
115113
while i > stop {
116114
if !it(i) { break }
117-
// avoiding underflow. break if i + step < min_value
118-
if i < min_value - step { break; }
119115
i += step;
120116
}
121117
}
@@ -425,26 +421,10 @@ pub fn test_ranges() {
425421
for range_step(36,30,-2) |i| {
426422
l.push(i);
427423
}
428-
for range_step(max_value - 2, max_value, 2) |i| {
429-
l.push(i);
430-
}
431-
for range_step(max_value - 3, max_value, 2) |i| {
432-
l.push(i);
433-
}
434-
for range_step(min_value + 2, min_value, -2) |i| {
435-
l.push(i);
436-
}
437-
for range_step(min_value + 3, min_value, -2) |i| {
438-
l.push(i);
439-
}
440-
assert_eq!(l, ~[0,1,2,
441-
13,12,11,
442-
20,22,24,
443-
36,34,32,
444-
max_value-2,
445-
max_value-3,max_value-1,
446-
min_value+2,
447-
min_value+3,min_value+1]);
424+
assert!(l == ~[0,1,2,
425+
13,12,11,
426+
20,22,24,
427+
36,34,32]);
448428
449429
// None of the `fail`s should execute.
450430
for range(10,0) |_i| {

branches/auto/src/libcore/num/uint-template.rs

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,12 @@ pub fn range_step(start: T,
7878
if step >= 0 {
7979
while i < stop {
8080
if !it(i) { break }
81-
// avoiding overflow. break if i + step > max_value
82-
if i > max_value - (step as T) { break; }
8381
i += step as T;
8482
}
85-
} else {
83+
}
84+
else {
8685
while i > stop {
8786
if !it(i) { break }
88-
// avoiding underflow. break if i + step < min_value
89-
if i < min_value + ((-step) as T) { break; }
9087
i -= -step as T;
9188
}
9289
}
@@ -374,27 +371,11 @@ pub fn test_ranges() {
374371
for range_step(36,30,-2) |i| {
375372
l.push(i);
376373
}
377-
for range_step(max_value - 2, max_value, 2) |i| {
378-
l.push(i);
379-
}
380-
for range_step(max_value - 3, max_value, 2) |i| {
381-
l.push(i);
382-
}
383-
for range_step(min_value + 2, min_value, -2) |i| {
384-
l.push(i);
385-
}
386-
for range_step(min_value + 3, min_value, -2) |i| {
387-
l.push(i);
388-
}
389374
390-
assert_eq!(l, ~[0,1,2,
391-
13,12,11,
392-
20,22,24,
393-
36,34,32,
394-
max_value-2,
395-
max_value-3,max_value-1,
396-
min_value+2,
397-
min_value+3,min_value+1]);
375+
assert!(l == ~[0,1,2,
376+
13,12,11,
377+
20,22,24,
378+
36,34,32]);
398379
399380
// None of the `fail`s should execute.
400381
for range(0,0) |_i| {

branches/auto/src/librustc/metadata/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub enum astencode_tag { // Reserves 0x50 -- 0x6f
127127
tag_table_node_type_subst = 0x58,
128128
tag_table_freevars = 0x59,
129129
tag_table_tcache = 0x5a,
130-
tag_table_param_bounds = 0x5b,
130+
tag_table_param_defs = 0x5b,
131131
tag_table_inferred_modes = 0x5c,
132132
tag_table_mutbl = 0x5d,
133133
tag_table_last_use = 0x5e,

branches/auto/src/librustc/metadata/csearch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ pub fn get_field_type(tcx: ty::ctxt, class_id: ast::def_id,
210210
debug!("got field data %?", the_field);
211211
let ty = decoder::item_type(def, the_field, tcx, cdata);
212212
ty::ty_param_bounds_and_ty {
213-
generics: ty::Generics {bounds: @~[],
213+
generics: ty::Generics {type_param_defs: @~[],
214214
region_param: None},
215215
ty: ty
216216
}

branches/auto/src/librustc/metadata/decoder.rs

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ use metadata::csearch::{ProvidedTraitMethodInfo, StaticMethodInfo};
1919
use metadata::csearch;
2020
use metadata::cstore;
2121
use metadata::decoder;
22-
use metadata::tydecode::{parse_ty_data, parse_def_id, parse_bounds_data,
22+
use metadata::tydecode::{parse_ty_data, parse_def_id,
23+
parse_type_param_def_data,
2324
parse_bare_fn_ty_data, parse_trait_ref_data};
2425
use middle::{ty, resolve};
2526

@@ -266,13 +267,14 @@ fn item_trait_ref(doc: ebml::Doc, tcx: ty::ctxt, cdata: cmd) -> ty::TraitRef {
266267
doc_trait_ref(tp, tcx, cdata)
267268
}
268269
269-
fn item_ty_param_bounds(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd,
270-
tag: uint)
271-
-> @~[ty::param_bounds] {
270+
fn item_ty_param_defs(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd,
271+
tag: uint)
272+
-> @~[ty::TypeParameterDef] {
272273
let mut bounds = ~[];
273274
for reader::tagged_docs(item, tag) |p| {
274-
let bd = parse_bounds_data(p.data, p.start, cdata.cnum, tcx,
275-
|_, did| translate_def_id(cdata, did));
275+
let bd = parse_type_param_def_data(
276+
p.data, p.start, cdata.cnum, tcx,
277+
|_, did| translate_def_id(cdata, did));
276278
bounds.push(bd);
277279
}
278280
@bounds
@@ -378,11 +380,11 @@ pub fn get_trait_def(cdata: cmd,
378380
tcx: ty::ctxt) -> ty::TraitDef
379381
{
380382
let item_doc = lookup_item(item_id, cdata.data);
381-
let tp_bounds = item_ty_param_bounds(item_doc, tcx, cdata,
382-
tag_items_data_item_ty_param_bounds);
383+
let tp_defs = item_ty_param_defs(item_doc, tcx, cdata,
384+
tag_items_data_item_ty_param_bounds);
383385
let rp = item_ty_region_param(item_doc);
384386
ty::TraitDef {
385-
generics: ty::Generics {bounds: tp_bounds,
387+
generics: ty::Generics {type_param_defs: tp_defs,
386388
region_param: rp},
387389
trait_ref: @item_trait_ref(item_doc, tcx, cdata)
388390
}
@@ -394,12 +396,12 @@ pub fn get_type(cdata: cmd, id: ast::node_id, tcx: ty::ctxt)
394396
let item = lookup_item(id, cdata.data);
395397
let t = item_type(ast::def_id { crate: cdata.cnum, node: id }, item, tcx,
396398
cdata);
397-
let tp_bounds = if family_has_type_params(item_family(item)) {
398-
item_ty_param_bounds(item, tcx, cdata, tag_items_data_item_ty_param_bounds)
399+
let tp_defs = if family_has_type_params(item_family(item)) {
400+
item_ty_param_defs(item, tcx, cdata, tag_items_data_item_ty_param_bounds)
399401
} else { @~[] };
400402
let rp = item_ty_region_param(item);
401403
ty::ty_param_bounds_and_ty {
402-
generics: ty::Generics {bounds: tp_bounds,
404+
generics: ty::Generics {type_param_defs: tp_defs,
403405
region_param: rp},
404406
ty: t
405407
}
@@ -753,17 +755,16 @@ pub fn get_method(intr: @ident_interner, cdata: cmd, id: ast::node_id,
753755
let method_doc = lookup_item(id, cdata.data);
754756
let def_id = item_def_id(method_doc, cdata);
755757
let name = item_name(intr, method_doc);
756-
let bounds =
757-
item_ty_param_bounds(method_doc, tcx, cdata,
758-
tag_item_method_tps);
758+
let type_param_defs = item_ty_param_defs(method_doc, tcx, cdata,
759+
tag_item_method_tps);
759760
let transformed_self_ty = doc_transformed_self_ty(method_doc, tcx, cdata);
760761
let fty = doc_method_fty(method_doc, tcx, cdata);
761762
let vis = item_visibility(method_doc);
762763
let self_ty = get_self_ty(method_doc);
763764
ty::method {
764765
ident: name,
765766
generics: ty::Generics {
766-
bounds: bounds,
767+
type_param_defs: type_param_defs,
767768
region_param: None
768769
},
769770
transformed_self_ty: transformed_self_ty,
@@ -797,8 +798,9 @@ pub fn get_provided_trait_methods(intr: @ident_interner, cdata: cmd,
797798

798799
let did = item_def_id(mth, cdata);
799800

800-
let bounds = item_ty_param_bounds(mth, tcx, cdata,
801-
tag_items_data_item_ty_param_bounds);
801+
let type_param_defs =
802+
item_ty_param_defs(mth, tcx, cdata,
803+
tag_items_data_item_ty_param_bounds);
802804
let name = item_name(intr, mth);
803805
let ty = doc_type(mth, tcx, cdata);
804806

@@ -815,7 +817,7 @@ pub fn get_provided_trait_methods(intr: @ident_interner, cdata: cmd,
815817
let ty_method = ty::method {
816818
ident: name,
817819
generics: ty::Generics {
818-
bounds: bounds,
820+
type_param_defs: type_param_defs,
819821
region_param: None
820822
},
821823
transformed_self_ty: transformed_self_ty,

branches/auto/src/librustc/metadata/encoder.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@ fn encode_family(ebml_w: writer::Encoder, c: char) {
179179

180180
pub fn def_to_str(did: def_id) -> ~str { fmt!("%d:%d", did.crate, did.node) }
181181

182-
fn encode_ty_type_param_bounds(ebml_w: writer::Encoder,
183-
ecx: @EncodeContext,
184-
params: @~[ty::param_bounds],
185-
tag: uint) {
182+
fn encode_ty_type_param_defs(ebml_w: writer::Encoder,
183+
ecx: @EncodeContext,
184+
params: @~[ty::TypeParameterDef],
185+
tag: uint) {
186186
let ty_str_ctxt = @tyencode::ctxt {
187187
diag: ecx.diag,
188188
ds: def_to_str,
@@ -191,18 +191,18 @@ fn encode_ty_type_param_bounds(ebml_w: writer::Encoder,
191191
abbrevs: tyencode::ac_use_abbrevs(ecx.type_abbrevs)};
192192
for params.each |param| {
193193
ebml_w.start_tag(tag);
194-
tyencode::enc_bounds(ebml_w.writer, ty_str_ctxt, *param);
194+
tyencode::enc_type_param_def(ebml_w.writer, ty_str_ctxt, param);
195195
ebml_w.end_tag();
196196
}
197197
}
198198

199199
fn encode_type_param_bounds(ebml_w: writer::Encoder,
200200
ecx: @EncodeContext,
201201
params: &OptVec<TyParam>) {
202-
let ty_param_bounds =
203-
@params.map_to_vec(|param| *ecx.tcx.ty_param_bounds.get(&param.id));
204-
encode_ty_type_param_bounds(ebml_w, ecx, ty_param_bounds,
205-
tag_items_data_item_ty_param_bounds);
202+
let ty_param_defs =
203+
@params.map_to_vec(|param| *ecx.tcx.ty_param_defs.get(&param.id));
204+
encode_ty_type_param_defs(ebml_w, ecx, ty_param_defs,
205+
tag_items_data_item_ty_param_bounds);
206206
}
207207

208208

@@ -588,8 +588,9 @@ fn encode_method_ty_fields(ecx: @EncodeContext,
588588
{
589589
encode_def_id(ebml_w, method_ty.def_id);
590590
encode_name(ecx, ebml_w, method_ty.ident);
591-
encode_ty_type_param_bounds(ebml_w, ecx, method_ty.generics.bounds,
592-
tag_item_method_tps);
591+
encode_ty_type_param_defs(ebml_w, ecx,
592+
method_ty.generics.type_param_defs,
593+
tag_item_method_tps);
593594
encode_transformed_self_ty(ecx, ebml_w, method_ty.transformed_self_ty);
594595
encode_method_fty(ecx, ebml_w, &method_ty.fty);
595596
encode_visibility(ebml_w, method_ty.vis);
@@ -952,8 +953,9 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
952953
method_ty.fty.purity));
953954
954955
let tpt = ty::lookup_item_type(tcx, method_def_id);
955-
encode_ty_type_param_bounds(ebml_w, ecx, tpt.generics.bounds,
956-
tag_items_data_item_ty_param_bounds);
956+
encode_ty_type_param_defs(ebml_w, ecx,
957+
tpt.generics.type_param_defs,
958+
tag_items_data_item_ty_param_bounds);
957959
encode_type(ecx, ebml_w, tpt.ty);
958960
}
959961

branches/auto/src/librustc/metadata/tydecode.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -547,11 +547,17 @@ pub fn parse_def_id(buf: &[u8]) -> ast::def_id {
547547
ast::def_id { crate: crate_num, node: def_num }
548548
}
549549
550-
pub fn parse_bounds_data(data: @~[u8], start: uint,
551-
crate_num: int, tcx: ty::ctxt, conv: conv_did)
552-
-> @~[ty::param_bound] {
550+
pub fn parse_type_param_def_data(data: @~[u8], start: uint,
551+
crate_num: int, tcx: ty::ctxt,
552+
conv: conv_did) -> ty::TypeParameterDef
553+
{
553554
let st = parse_state_from_data(data, crate_num, start, tcx);
554-
parse_bounds(st, conv)
555+
parse_type_param_def(st, conv)
556+
}
557+
558+
fn parse_type_param_def(st: @mut PState, conv: conv_did) -> ty::TypeParameterDef {
559+
ty::TypeParameterDef {def_id: parse_def(st, NominalType, conv),
560+
bounds: parse_bounds(st, conv)}
555561
}
556562
557563
fn parse_bounds(st: @mut PState, conv: conv_did) -> @~[ty::param_bound] {

branches/auto/src/librustc/metadata/tyencode.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ fn enc_fn_sig(w: @io::Writer, cx: @ctxt, fsig: &ty::FnSig) {
412412
enc_ty(w, cx, fsig.output);
413413
}
414414

415-
pub fn enc_bounds(w: @io::Writer, cx: @ctxt, bs: @~[ty::param_bound]) {
415+
fn enc_bounds(w: @io::Writer, cx: @ctxt, bs: @~[ty::param_bound]) {
416416
for vec::each(*bs) |bound| {
417417
match *bound {
418418
ty::bound_owned => w.write_char('S'),
@@ -428,6 +428,12 @@ pub fn enc_bounds(w: @io::Writer, cx: @ctxt, bs: @~[ty::param_bound]) {
428428
w.write_char('.');
429429
}
430430

431+
pub fn enc_type_param_def(w: @io::Writer, cx: @ctxt, v: &ty::TypeParameterDef) {
432+
w.write_str((cx.ds)(v.def_id));
433+
w.write_char('|');
434+
enc_bounds(w, cx, v.bounds);
435+
}
436+
431437
//
432438
// Local Variables:
433439
// mode: rust

0 commit comments

Comments
 (0)