Skip to content

Commit b2b1d98

Browse files
committed
---
yaml --- r: 138586 b: refs/heads/try2 c: dbbdca3 h: refs/heads/master v: v3
1 parent e42ebcc commit b2b1d98

Some content is hidden

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

42 files changed

+759
-1115
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: 6bff18ea0de2f96a4103c11bc183b380f6d2c83a
8+
refs/heads/try2: dbbdca31b45997604d4bf99662cb32939c838149
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/rust.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ the following forms:
297297
num_lit : nonzero_dec [ dec_digit | '_' ] * num_suffix ?
298298
| '0' [ [ dec_digit | '_' ] + num_suffix ?
299299
| 'b' [ '1' | '0' | '_' ] + int_suffix ?
300-
| 'x' [ hex_digit | '_' ] + int_suffix ? ] ;
300+
| 'x' [ hex_digit | '-' ] + int_suffix ? ] ;
301301
302302
num_suffix : int_suffix | float_suffix ;
303303

branches/try2/src/libcore/to_str.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -137,6 +137,15 @@ impl<A:ToStr> ToStr for @[A] {
137137
}
138138
}
139139
140+
impl<A:ToStr> ToStr for @A {
141+
#[inline(always)]
142+
pure fn to_str(&self) -> ~str { ~"@" + (**self).to_str() }
143+
}
144+
impl<A:ToStr> ToStr for ~A {
145+
#[inline(always)]
146+
pure fn to_str(&self) -> ~str { ~"~" + (**self).to_str() }
147+
}
148+
140149
#[cfg(test)]
141150
#[allow(non_implicitly_copyable_typarams)]
142151
mod tests {
@@ -161,12 +170,19 @@ mod tests {
161170
}
162171

163172
#[test]
173+
#[ignore]
164174
fn test_vectors() {
165175
let x: ~[int] = ~[];
166-
assert x.to_str() == ~"[]";
167-
assert (~[1]).to_str() == ~"[1]";
168-
assert (~[1, 2, 3]).to_str() == ~"[1, 2, 3]";
176+
assert x.to_str() == ~"~[]";
177+
assert (~[1]).to_str() == ~"~[1]";
178+
assert (~[1, 2, 3]).to_str() == ~"~[1, 2, 3]";
169179
assert (~[~[], ~[1], ~[1, 1]]).to_str() ==
170-
~"[[], [1], [1, 1]]";
180+
~"~[~[], ~[1], ~[1, 1]]";
181+
}
182+
183+
#[test]
184+
fn test_pointer_types() {
185+
assert (@1).to_str() == ~"@1";
186+
assert (~(true, false)).to_str() == ~"~(true, false)";
171187
}
172188
}

branches/try2/src/librustc/front/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,14 @@ fn is_bench_fn(i: @ast::item) -> bool {
200200
vec::len(attr::find_attrs_by_name(i.attrs, ~"bench")) > 0u;
201201

202202
fn has_test_signature(i: @ast::item) -> bool {
203-
match i.node {
204-
ast::item_fn(ref decl, _, ref generics, _) => {
203+
match /*bad*/copy i.node {
204+
ast::item_fn(decl, _, tps, _) => {
205205
let input_cnt = vec::len(decl.inputs);
206206
let no_output = match decl.output.node {
207207
ast::ty_nil => true,
208208
_ => false
209209
};
210-
let tparm_cnt = generics.ty_params.len();
210+
let tparm_cnt = vec::len(tps);
211211
// NB: inadequate check, but we're running
212212
// well before resolve, can't get too deep.
213213
input_cnt == 1u

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

Lines changed: 39 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ use syntax::diagnostic::span_handler;
4949
use syntax::parse::token::special_idents;
5050
use syntax::print::pprust;
5151
use syntax::{ast_util, visit};
52-
use syntax::opt_vec::OptVec;
53-
use syntax::opt_vec;
5452
use syntax;
5553
use writer = std::ebml::writer;
5654

@@ -189,11 +187,10 @@ fn encode_ty_type_param_bounds(ebml_w: writer::Encoder, ecx: @EncodeContext,
189187
}
190188
}
191189

192-
fn encode_type_param_bounds(ebml_w: writer::Encoder,
193-
ecx: @EncodeContext,
194-
params: &OptVec<TyParam>) {
190+
fn encode_type_param_bounds(ebml_w: writer::Encoder, ecx: @EncodeContext,
191+
params: &[ty_param]) {
195192
let ty_param_bounds =
196-
@params.map_to_vec(|param| ecx.tcx.ty_param_bounds.get(&param.id));
193+
@params.map(|param| ecx.tcx.ty_param_bounds.get(&param.id));
197194
encode_ty_type_param_bounds(ebml_w, ecx, ty_param_bounds);
198195
}
199196

@@ -268,7 +265,7 @@ fn encode_enum_variant_info(ecx: @EncodeContext, ebml_w: writer::Encoder,
268265
id: node_id, variants: &[variant],
269266
path: &[ast_map::path_elt],
270267
index: @mut ~[entry<int>],
271-
generics: &ast::Generics) {
268+
ty_params: &[ty_param]) {
272269
let mut disr_val = 0;
273270
let mut i = 0;
274271
let vi = ty::enum_variants(ecx.tcx,
@@ -284,7 +281,7 @@ fn encode_enum_variant_info(ecx: @EncodeContext, ebml_w: writer::Encoder,
284281
node_id_to_type(ecx.tcx, variant.node.id));
285282
match variant.node.kind {
286283
ast::tuple_variant_kind(ref args)
287-
if args.len() > 0 && generics.ty_params.len() == 0 => {
284+
if args.len() > 0 && ty_params.len() == 0 => {
288285
encode_symbol(ecx, ebml_w, variant.node.id);
289286
}
290287
ast::tuple_variant_kind(_) | ast::struct_variant_kind(_) |
@@ -295,7 +292,7 @@ fn encode_enum_variant_info(ecx: @EncodeContext, ebml_w: writer::Encoder,
295292
encode_disr_val(ecx, ebml_w, vi[i].disr_val);
296293
disr_val = vi[i].disr_val;
297294
}
298-
encode_type_param_bounds(ebml_w, ecx, &generics.ty_params);
295+
encode_type_param_bounds(ebml_w, ecx, ty_params);
299296
encode_path(ecx, ebml_w, path,
300297
ast_map::path_name(variant.node.name));
301298
ebml_w.end_tag();
@@ -468,18 +465,14 @@ fn encode_info_for_struct(ecx: @EncodeContext, ebml_w: writer::Encoder,
468465
}
469466

470467
// This is for encoding info for ctors and dtors
471-
fn encode_info_for_ctor(ecx: @EncodeContext,
472-
ebml_w: writer::Encoder,
473-
id: node_id,
474-
ident: ident,
475-
path: &[ast_map::path_elt],
476-
item: Option<inlined_item>,
477-
generics: &ast::Generics) {
468+
fn encode_info_for_ctor(ecx: @EncodeContext, ebml_w: writer::Encoder,
469+
id: node_id, ident: ident, path: &[ast_map::path_elt],
470+
item: Option<inlined_item>, tps: &[ty_param]) {
478471
ebml_w.start_tag(tag_items_data_item);
479472
encode_name(ecx, ebml_w, ident);
480473
encode_def_id(ebml_w, local_def(id));
481474
encode_family(ebml_w, purity_fn_family(ast::impure_fn));
482-
encode_type_param_bounds(ebml_w, ecx, &generics.ty_params);
475+
encode_type_param_bounds(ebml_w, ecx, tps);
483476
let its_ty = node_id_to_type(ecx.tcx, id);
484477
debug!("fn name = %s ty = %s its node id = %d",
485478
*ecx.tcx.sess.str_of(ident),
@@ -525,12 +518,9 @@ fn encode_info_for_method(ecx: @EncodeContext,
525518
should_inline: bool,
526519
parent_id: node_id,
527520
m: @method,
528-
owner_generics: &ast::Generics,
529-
method_generics: &ast::Generics) {
530-
debug!("encode_info_for_method: %d %s %u %u", m.id,
531-
*ecx.tcx.sess.str_of(m.ident),
532-
owner_generics.ty_params.len(),
533-
method_generics.ty_params.len());
521+
+all_tps: ~[ty_param]) {
522+
debug!("encode_info_for_method: %d %s %u", m.id,
523+
*ecx.tcx.sess.str_of(m.ident), all_tps.len());
534524
ebml_w.start_tag(tag_items_data_item);
535525
encode_def_id(ebml_w, local_def(m.id));
536526
match m.self_ty.node {
@@ -539,13 +529,8 @@ fn encode_info_for_method(ecx: @EncodeContext,
539529
}
540530
_ => encode_family(ebml_w, purity_fn_family(m.purity))
541531
}
542-
543-
let mut combined_ty_params = opt_vec::Empty;
544-
combined_ty_params.push_all(&owner_generics.ty_params);
545-
combined_ty_params.push_all(&method_generics.ty_params);
546-
let len = combined_ty_params.len();
547-
encode_type_param_bounds(ebml_w, ecx, &combined_ty_params);
548-
532+
let len = all_tps.len();
533+
encode_type_param_bounds(ebml_w, ecx, all_tps);
549534
encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, m.id));
550535
encode_name(ecx, ebml_w, m.ident);
551536
encode_path(ecx, ebml_w, impl_path, ast_map::path_name(m.ident));
@@ -619,13 +604,13 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
619604
encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident));
620605
ebml_w.end_tag();
621606
}
622-
item_fn(_, purity, ref generics, _) => {
607+
item_fn(_, purity, tps, _) => {
623608
add_to_index();
624609
ebml_w.start_tag(tag_items_data_item);
625610
encode_def_id(ebml_w, local_def(item.id));
626611
encode_family(ebml_w, purity_fn_family(purity));
627-
let tps_len = generics.ty_params.len();
628-
encode_type_param_bounds(ebml_w, ecx, &generics.ty_params);
612+
let tps_len = tps.len();
613+
encode_type_param_bounds(ebml_w, ecx, tps);
629614
encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id));
630615
encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident));
631616
encode_attributes(ebml_w, item.attrs);
@@ -649,24 +634,24 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
649634
encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident));
650635
ebml_w.end_tag();
651636
}
652-
item_ty(_, ref generics) => {
637+
item_ty(_, tps) => {
653638
add_to_index();
654639
ebml_w.start_tag(tag_items_data_item);
655640
encode_def_id(ebml_w, local_def(item.id));
656641
encode_family(ebml_w, 'y');
657-
encode_type_param_bounds(ebml_w, ecx, &generics.ty_params);
642+
encode_type_param_bounds(ebml_w, ecx, tps);
658643
encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id));
659644
encode_name(ecx, ebml_w, item.ident);
660645
encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident));
661646
encode_region_param(ecx, ebml_w, item);
662647
ebml_w.end_tag();
663648
}
664-
item_enum(ref enum_definition, ref generics) => {
649+
item_enum(ref enum_definition, ref tps) => {
665650
add_to_index();
666651
do ebml_w.wr_tag(tag_items_data_item) {
667652
encode_def_id(ebml_w, local_def(item.id));
668653
encode_family(ebml_w, 't');
669-
encode_type_param_bounds(ebml_w, ecx, &generics.ty_params);
654+
encode_type_param_bounds(ebml_w, ecx, *tps);
670655
encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id));
671656
encode_name(ecx, ebml_w, item.ident);
672657
for (*enum_definition).variants.each |v| {
@@ -682,9 +667,9 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
682667
(*enum_definition).variants,
683668
path,
684669
index,
685-
generics);
670+
*tps);
686671
}
687-
item_struct(struct_def, ref generics) => {
672+
item_struct(struct_def, tps) => {
688673
/* First, encode the fields
689674
These come first because we need to write them to make
690675
the index, and the index needs to be in the item for the
@@ -701,25 +686,24 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
701686
*ecx.tcx.sess.str_of(item.ident) +
702687
~"_dtor"),
703688
path,
704-
if generics.ty_params.len() > 0u {
689+
if tps.len() > 0u {
705690
Some(ii_dtor(copy *dtor,
706691
item.ident,
707-
copy *generics,
692+
copy tps,
708693
local_def(item.id))) }
709694
else {
710695
None
711696
},
712-
generics);
697+
tps);
713698
}
714699
715700
/* Index the class*/
716701
add_to_index();
717-
718702
/* Now, make an item for the class itself */
719703
ebml_w.start_tag(tag_items_data_item);
720704
encode_def_id(ebml_w, local_def(item.id));
721705
encode_family(ebml_w, 'S');
722-
encode_type_param_bounds(ebml_w, ecx, &generics.ty_params);
706+
encode_type_param_bounds(ebml_w, ecx, tps);
723707
encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id));
724708
725709
// If this is a tuple- or enum-like struct, encode the type of the
@@ -775,13 +759,13 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
775759
encode_index(ebml_w, bkts, write_int);
776760
ebml_w.end_tag();
777761
}
778-
item_impl(ref generics, opt_trait, ty, ref methods) => {
762+
item_impl(tps, opt_trait, ty, methods) => {
779763
add_to_index();
780764
ebml_w.start_tag(tag_items_data_item);
781765
encode_def_id(ebml_w, local_def(item.id));
782766
encode_family(ebml_w, 'i');
783767
encode_region_param(ecx, ebml_w, item);
784-
encode_type_param_bounds(ebml_w, ecx, &generics.ty_params);
768+
encode_type_param_bounds(ebml_w, ecx, tps);
785769
encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id));
786770
encode_name(ecx, ebml_w, item.ident);
787771
encode_attributes(ebml_w, item.attrs);
@@ -813,18 +797,18 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
813797
encode_info_for_method(ecx, ebml_w, impl_path,
814798
should_inline(m.attrs),
815799
item.id, *m,
816-
generics, &m.generics);
800+
vec::append(/*bad*/copy tps, m.tps));
817801
}
818802
}
819-
item_trait(ref generics, ref traits, ref ms) => {
803+
item_trait(ref tps, ref traits, ref ms) => {
820804
let provided_methods = dvec::DVec();
821805
822806
add_to_index();
823807
ebml_w.start_tag(tag_items_data_item);
824808
encode_def_id(ebml_w, local_def(item.id));
825809
encode_family(ebml_w, 'I');
826810
encode_region_param(ecx, ebml_w, item);
827-
encode_type_param_bounds(ebml_w, ecx, &generics.ty_params);
811+
encode_type_param_bounds(ebml_w, ecx, *tps);
828812
encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id));
829813
encode_name(ecx, ebml_w, item.ident);
830814
encode_attributes(ebml_w, item.attrs);
@@ -836,7 +820,7 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
836820
encode_def_id(ebml_w, local_def((*ty_m).id));
837821
encode_name(ecx, ebml_w, mty.ident);
838822
encode_type_param_bounds(ebml_w, ecx,
839-
&ty_m.generics.ty_params);
823+
(*ty_m).tps);
840824
encode_type(ecx, ebml_w,
841825
ty::mk_bare_fn(tcx, copy mty.fty));
842826
encode_family(ebml_w, purity_fn_family(mty.fty.purity));
@@ -850,8 +834,7 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
850834
ebml_w.start_tag(tag_item_trait_method);
851835
encode_def_id(ebml_w, local_def(m.id));
852836
encode_name(ecx, ebml_w, mty.ident);
853-
encode_type_param_bounds(ebml_w, ecx,
854-
&m.generics.ty_params);
837+
encode_type_param_bounds(ebml_w, ecx, m.tps);
855838
encode_type(ecx, ebml_w,
856839
ty::mk_bare_fn(tcx, copy mty.fty));
857840
encode_family(ebml_w, purity_fn_family(mty.fty.purity));
@@ -897,14 +880,8 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
897880
// Finally, output all the provided methods as items.
898881
for provided_methods.each |m| {
899882
index.push(entry { val: m.id, pos: ebml_w.writer.tell() });
900-
901-
// We do not concatenate the generics of the owning impl and that
902-
// of provided methods. I am not sure why this is. -ndm
903-
let owner_generics = ast_util::empty_generics();
904-
905883
encode_info_for_method(ecx, ebml_w, /*bad*/copy path,
906-
true, item.id, *m,
907-
&owner_generics, &m.generics);
884+
true, item.id, *m, /*bad*/copy m.tps);
908885
}
909886
}
910887
item_mac(*) => fail!(~"item macros unimplemented")
@@ -921,11 +898,11 @@ fn encode_info_for_foreign_item(ecx: @EncodeContext,
921898
index.push(entry { val: nitem.id, pos: ebml_w.writer.tell() });
922899
923900
ebml_w.start_tag(tag_items_data_item);
924-
match nitem.node {
925-
foreign_item_fn(_, purity, ref generics) => {
901+
match /*bad*/copy nitem.node {
902+
foreign_item_fn(_, purity, tps) => {
926903
encode_def_id(ebml_w, local_def(nitem.id));
927904
encode_family(ebml_w, purity_fn_family(purity));
928-
encode_type_param_bounds(ebml_w, ecx, &generics.ty_params);
905+
encode_type_param_bounds(ebml_w, ecx, tps);
929906
encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, nitem.id));
930907
if abi == foreign_abi_rust_intrinsic {
931908
(ecx.encode_inlined_item)(ecx, ebml_w, path, ii_foreign(nitem));

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,10 @@ fn renumber_ast(xcx: @ExtendedDecodeContext, ii: ast::inlined_item)
371371
ast::ii_foreign(i) => {
372372
ast::ii_foreign(fld.fold_foreign_item(i))
373373
}
374-
ast::ii_dtor(ref dtor, nm, ref generics, parent_id) => {
374+
ast::ii_dtor(ref dtor, nm, ref tps, parent_id) => {
375375
let dtor_body = fld.fold_block((*dtor).node.body);
376-
let dtor_attrs = fld.fold_attributes(copy dtor.node.attrs);
377-
let new_generics = fold::fold_generics(generics, fld);
376+
let dtor_attrs = fld.fold_attributes(/*bad*/copy (*dtor).node.attrs);
377+
let new_params = fold::fold_ty_params(/*bad*/copy *tps, fld);
378378
let dtor_id = fld.new_id((*dtor).node.id);
379379
let new_parent = xcx.tr_def_id(parent_id);
380380
let new_self = fld.new_id((*dtor).node.self_id);
@@ -386,7 +386,7 @@ fn renumber_ast(xcx: @ExtendedDecodeContext, ii: ast::inlined_item)
386386
body: dtor_body },
387387
.. (/*bad*/copy *dtor)
388388
},
389-
nm, new_generics, new_parent)
389+
nm, new_params, new_parent)
390390
}
391391
}
392392
}

0 commit comments

Comments
 (0)