Skip to content

Commit 3c95ee7

Browse files
committed
---
yaml --- r: 151510 b: refs/heads/try2 c: 0f25aad h: refs/heads/master v: v3
1 parent c9dd0a9 commit 3c95ee7

File tree

30 files changed

+502
-597
lines changed

30 files changed

+502
-597
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: a7d877ce620cc26a9d8549154c9e3e81456212d5
8+
refs/heads/try2: 0f25aad746b04ddda26ea502bdb7081e024a0644
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/indent/rust.vim

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ setlocal cindent
1313
setlocal cinoptions=L0,(0,Ws,JN,j1
1414
setlocal cinkeys=0{,0},!^F,o,O,0[,0]
1515
" Don't think cinwords will actually do anything at all... never mind
16-
setlocal cinwords=for,if,else,while,loop,impl,mod,unsafe,trait,struct,enum,fn,extern
16+
setlocal cinwords=do,for,if,else,while,loop,impl,mod,unsafe,trait,struct,enum,fn,extern
1717

1818
" Some preliminary settings
1919
setlocal nolisp " Make sure lisp indenting doesn't supersede us
@@ -40,12 +40,12 @@ function! s:get_line_trimmed(lnum)
4040
" If the last character in the line is a comment, do a binary search for
4141
" the start of the comment. synID() is slow, a linear search would take
4242
" too long on a long line.
43-
if synIDattr(synID(a:lnum, line_len, 1), "name") =~ 'Comment\|Todo'
43+
if synIDattr(synID(a:lnum, line_len, 1), "name") =~ "Comment\|Todo"
4444
let min = 1
4545
let max = line_len
4646
while min < max
4747
let col = (min + max) / 2
48-
if synIDattr(synID(a:lnum, col, 1), "name") =~ 'Comment\|Todo'
48+
if synIDattr(synID(a:lnum, col, 1), "name") =~ "Comment\|Todo"
4949
let max = col
5050
else
5151
let min = col + 1
@@ -87,10 +87,10 @@ function GetRustIndent(lnum)
8787
if synname == "rustString"
8888
" If the start of the line is in a string, don't change the indent
8989
return -1
90-
elseif synname =~ '\(Comment\|Todo\)'
91-
\ && line !~ '^\s*/\*' " not /* opening line
90+
elseif synname =~ "\\(Comment\\|Todo\\)"
91+
\ && line !~ "^\\s*/\\*" " not /* opening line
9292
if synname =~ "CommentML" " multi-line
93-
if line !~ '^\s*\*' && getline(a:lnum - 1) =~ '^\s*/\*'
93+
if line !~ "^\\s*\\*" && getline(a:lnum - 1) =~ "^\\s*/\\*"
9494
" This is (hopefully) the line after a /*, and it has no
9595
" leader, so the correct indentation is that of the
9696
" previous line.
@@ -115,16 +115,11 @@ function GetRustIndent(lnum)
115115
" };
116116

117117
" Search backwards for the previous non-empty line.
118-
let prevlinenum = prevnonblank(a:lnum - 1)
119-
let prevline = s:get_line_trimmed(prevlinenum)
120-
while prevlinenum > 1 && prevline !~ '[^[:blank:]]'
121-
let prevlinenum = prevnonblank(prevlinenum - 1)
122-
let prevline = s:get_line_trimmed(prevlinenum)
123-
endwhile
118+
let prevline = s:get_line_trimmed(prevnonblank(a:lnum - 1))
124119
if prevline[len(prevline) - 1] == ","
125-
\ && s:get_line_trimmed(a:lnum) !~ '^\s*[\[\]{}]'
126-
\ && prevline !~ '^\s*fn\s'
127-
\ && prevline !~ '([^()]\+,$'
120+
\ && s:get_line_trimmed(a:lnum) !~ "^\\s*[\\[\\]{}]"
121+
\ && prevline !~ "^\\s*fn\\s"
122+
\ && prevline !~ "([^()]\\+,$"
128123
" Oh ho! The previous line ended in a comma! I bet cindent will try to
129124
" take this too far... For now, let's normally use the previous line's
130125
" indent.
@@ -171,7 +166,7 @@ function GetRustIndent(lnum)
171166
" column zero)
172167

173168
call cursor(a:lnum, 1)
174-
if searchpair('{\|(', '', '}\|)', 'nbW',
169+
if searchpair('{\|(', '', '}\|)', 'nbW'
175170
\ 's:is_string_comment(line("."), col("."))') == 0
176171
if searchpair('\[', '', '\]', 'nbW',
177172
\ 's:is_string_comment(line("."), col("."))') == 0

branches/try2/src/libcore/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ mod should_not_exist;
106106
mod std {
107107
pub use clone;
108108
pub use cmp;
109-
pub use kinds;
110109

111110
#[cfg(test)] pub use realstd::fmt; // needed for fail!()
112111
#[cfg(test)] pub use realstd::rt; // needed for fail!()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ pub enum astencode_tag { // Reserves 0x40 -- 0x5f
128128
tag_table_val = 0x45,
129129
tag_table_def = 0x46,
130130
tag_table_node_type = 0x47,
131-
tag_table_item_subst = 0x48,
131+
tag_table_node_type_subst = 0x48,
132132
tag_table_freevars = 0x49,
133133
tag_table_tcache = 0x4a,
134134
tag_table_param_defs = 0x4b,

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

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -657,13 +657,13 @@ pub fn encode_vtable_origin(ecx: &e::EncodeContext,
657657
vtable_origin: &typeck::vtable_origin) {
658658
ebml_w.emit_enum("vtable_origin", |ebml_w| {
659659
match *vtable_origin {
660-
typeck::vtable_static(def_id, ref substs, ref vtable_res) => {
660+
typeck::vtable_static(def_id, ref tys, ref vtable_res) => {
661661
ebml_w.emit_enum_variant("vtable_static", 0u, 3u, |ebml_w| {
662662
ebml_w.emit_enum_variant_arg(0u, |ebml_w| {
663663
Ok(ebml_w.emit_def_id(def_id))
664664
});
665665
ebml_w.emit_enum_variant_arg(1u, |ebml_w| {
666-
Ok(ebml_w.emit_substs(ecx, substs))
666+
Ok(ebml_w.emit_tys(ecx, tys.as_slice()))
667667
});
668668
ebml_w.emit_enum_variant_arg(2u, |ebml_w| {
669669
Ok(encode_vtable_res(ecx, ebml_w, vtable_res))
@@ -744,7 +744,7 @@ impl<'a> vtable_decoder_helpers for reader::Decoder<'a> {
744744
Ok(this.read_def_id_noxcx(cdata))
745745
}).unwrap(),
746746
this.read_enum_variant_arg(1u, |this| {
747-
Ok(this.read_substs_noxcx(tcx, cdata))
747+
Ok(this.read_tys_noxcx(tcx, cdata))
748748
}).unwrap(),
749749
this.read_enum_variant_arg(2u, |this| {
750750
Ok(this.read_vtable_res(tcx, cdata))
@@ -962,11 +962,11 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
962962
})
963963
}
964964

965-
for &item_substs in tcx.item_substs.borrow().find(&id).iter() {
966-
ebml_w.tag(c::tag_table_item_subst, |ebml_w| {
965+
for tys in tcx.node_type_substs.borrow().find(&id).iter() {
966+
ebml_w.tag(c::tag_table_node_type_subst, |ebml_w| {
967967
ebml_w.id(id);
968968
ebml_w.tag(c::tag_table_val, |ebml_w| {
969-
ebml_w.emit_substs(ecx, &item_substs.substs);
969+
ebml_w.emit_tys(ecx, tys.as_slice())
970970
})
971971
})
972972
}
@@ -1091,9 +1091,6 @@ trait ebml_decoder_decoder_helpers {
10911091
fn read_tys_noxcx(&mut self,
10921092
tcx: &ty::ctxt,
10931093
cdata: &cstore::crate_metadata) -> Vec<ty::t>;
1094-
fn read_substs_noxcx(&mut self, tcx: &ty::ctxt,
1095-
cdata: &cstore::crate_metadata)
1096-
-> ty::substs;
10971094
}
10981095

10991096
impl<'a> ebml_decoder_decoder_helpers for reader::Decoder<'a> {
@@ -1118,21 +1115,6 @@ impl<'a> ebml_decoder_decoder_helpers for reader::Decoder<'a> {
11181115
.collect()
11191116
}
11201117

1121-
fn read_substs_noxcx(&mut self,
1122-
tcx: &ty::ctxt,
1123-
cdata: &cstore::crate_metadata)
1124-
-> ty::substs
1125-
{
1126-
self.read_opaque(|_, doc| {
1127-
Ok(tydecode::parse_substs_data(
1128-
doc.data,
1129-
cdata.cnum,
1130-
doc.start,
1131-
tcx,
1132-
|_, id| decoder::translate_def_id(cdata, id)))
1133-
}).unwrap()
1134-
}
1135-
11361118
fn read_ty(&mut self, xcx: &ExtendedDecodeContext) -> ty::t {
11371119
// Note: regions types embed local node ids. In principle, we
11381120
// should translate these node ids into the new decode
@@ -1330,12 +1312,9 @@ fn decode_side_tables(xcx: &ExtendedDecodeContext,
13301312
id, ty_to_str(dcx.tcx, ty));
13311313
dcx.tcx.node_types.borrow_mut().insert(id as uint, ty);
13321314
}
1333-
c::tag_table_item_subst => {
1334-
let item_substs = ty::ItemSubsts {
1335-
substs: val_dsr.read_substs(xcx)
1336-
};
1337-
dcx.tcx.item_substs.borrow_mut().insert(
1338-
id, item_substs);
1315+
c::tag_table_node_type_subst => {
1316+
let tys = val_dsr.read_tys(xcx);
1317+
dcx.tcx.node_type_substs.borrow_mut().insert(id, tys);
13391318
}
13401319
c::tag_table_freevars => {
13411320
let fv_info = val_dsr.read_to_vec(|val_dsr| {

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

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,10 @@ pub fn check_expr(cx: &mut Context, e: &Expr) {
245245
{
246246
let method_map = cx.tcx.method_map.borrow();
247247
let method = method_map.find(&typeck::MethodCall::expr(e.id));
248-
let item_substs = cx.tcx.item_substs.borrow();
248+
let node_type_substs = cx.tcx.node_type_substs.borrow();
249249
let r = match method {
250250
Some(method) => Some(&method.substs.tps),
251-
None => item_substs.find(&e.id).map(|s| &s.substs.tps)
251+
None => node_type_substs.find(&e.id)
252252
};
253253
for ts in r.iter() {
254254
let def_map = cx.tcx.def_map.borrow();
@@ -341,19 +341,15 @@ fn check_trait_cast(cx: &mut Context, source_ty: ty::t, target_ty: ty::t, span:
341341
fn check_ty(cx: &mut Context, aty: &Ty) {
342342
match aty.node {
343343
TyPath(_, _, id) => {
344-
match cx.tcx.item_substs.borrow().find(&id) {
345-
None => { }
346-
Some(ref item_substs) => {
347-
let def_map = cx.tcx.def_map.borrow();
348-
let did = ast_util::def_id_of_def(def_map.get_copy(&id));
349-
let generics = ty::lookup_item_type(cx.tcx, did).generics;
350-
let type_param_defs = generics.type_param_defs();
351-
for (&ty, type_param_def) in
352-
item_substs.substs.tps.iter().zip(
353-
type_param_defs.iter())
354-
{
355-
check_typaram_bounds(cx, aty.span, ty, type_param_def)
356-
}
344+
let node_type_substs = cx.tcx.node_type_substs.borrow();
345+
let r = node_type_substs.find(&id);
346+
for ts in r.iter() {
347+
let def_map = cx.tcx.def_map.borrow();
348+
let did = ast_util::def_id_of_def(def_map.get_copy(&id));
349+
let generics = ty::lookup_item_type(cx.tcx, did).generics;
350+
let type_param_defs = generics.type_param_defs();
351+
for (&ty, type_param_def) in ts.iter().zip(type_param_defs.iter()) {
352+
check_typaram_bounds(cx, aty.span, ty, type_param_def)
357353
}
358354
}
359355
}

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -195,17 +195,6 @@ impl Subst for ty::substs {
195195
}
196196
}
197197

198-
impl Subst for ty::ItemSubsts {
199-
fn subst_spanned(&self, tcx: &ty::ctxt,
200-
substs: &ty::substs,
201-
span: Option<Span>)
202-
-> ty::ItemSubsts {
203-
ty::ItemSubsts {
204-
substs: self.substs.subst_spanned(tcx, substs, span)
205-
}
206-
}
207-
}
208-
209198
impl Subst for ty::RegionSubsts {
210199
fn subst_spanned(&self, tcx: &ty::ctxt,
211200
substs: &ty::substs,

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

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -478,29 +478,35 @@ pub fn note_unique_llvm_symbol(ccx: &CrateContext, sym: ~str) {
478478
pub fn get_res_dtor(ccx: &CrateContext,
479479
did: ast::DefId,
480480
parent_id: ast::DefId,
481-
substs: &ty::substs)
481+
substs: &[ty::t])
482482
-> ValueRef {
483483
let _icx = push_ctxt("trans_res_dtor");
484484
let did = if did.krate != ast::LOCAL_CRATE {
485485
inline::maybe_instantiate_inline(ccx, did)
486486
} else {
487487
did
488488
};
489-
490-
if !substs.tps.is_empty() || !substs.self_ty.is_none() {
489+
if !substs.is_empty() {
491490
assert_eq!(did.krate, ast::LOCAL_CRATE);
491+
let tsubsts = ty::substs {
492+
regions: ty::ErasedRegions,
493+
self_ty: None,
494+
tps: Vec::from_slice(substs),
495+
};
492496

493-
let vtables = typeck::check::vtable::trans_resolve_method(ccx.tcx(), did.node, substs);
494-
let (val, _) = monomorphize::monomorphic_fn(ccx, did, substs, vtables, None, None);
497+
let vtables = typeck::check::vtable::trans_resolve_method(ccx.tcx(), did.node, &tsubsts);
498+
let (val, _) = monomorphize::monomorphic_fn(ccx, did, &tsubsts, vtables, None, None);
495499

496500
val
497501
} else if did.krate == ast::LOCAL_CRATE {
498502
get_item_val(ccx, did.node)
499503
} else {
500504
let tcx = ccx.tcx();
501505
let name = csearch::get_symbol(&ccx.sess().cstore, did);
502-
let class_ty = ty::subst(tcx, substs,
503-
ty::lookup_item_type(tcx, parent_id).ty);
506+
let class_ty = ty::subst_tps(tcx,
507+
substs,
508+
None,
509+
ty::lookup_item_type(tcx, parent_id).ty);
504510
let llty = type_of_dtor(ccx, class_ty);
505511

506512
get_extern_fn(&mut *ccx.externs.borrow_mut(), ccx.llmod, name,
@@ -664,7 +670,7 @@ pub fn iter_structural_ty<'r,
664670
repr: &adt::Repr,
665671
av: ValueRef,
666672
variant: &ty::VariantInfo,
667-
substs: &ty::substs,
673+
tps: &[ty::t],
668674
f: val_and_ty_fn<'r,'b>)
669675
-> &'b Block<'b> {
670676
let _icx = push_ctxt("iter_variant");
@@ -674,7 +680,7 @@ pub fn iter_structural_ty<'r,
674680
for (i, &arg) in variant.args.iter().enumerate() {
675681
cx = f(cx,
676682
adt::trans_field_ptr(cx, repr, av, variant.disr_val, i),
677-
ty::subst(tcx, substs, arg));
683+
ty::subst_tps(tcx, tps, None, arg));
678684
}
679685
return cx;
680686
}
@@ -716,7 +722,7 @@ pub fn iter_structural_ty<'r,
716722
match adt::trans_switch(cx, &*repr, av) {
717723
(_match::single, None) => {
718724
cx = iter_variant(cx, &*repr, av, &**variants.get(0),
719-
substs, f);
725+
substs.tps.as_slice(), f);
720726
}
721727
(_match::switch, Some(lldiscrim_a)) => {
722728
cx = f(cx, lldiscrim_a, ty::mk_int());
@@ -742,7 +748,7 @@ pub fn iter_structural_ty<'r,
742748
&*repr,
743749
av,
744750
&**variant,
745-
substs,
751+
substs.tps.as_slice(),
746752
|x,y,z| f(x,y,z));
747753
Br(variant_cx, next_cx.llbb);
748754
}
@@ -1147,7 +1153,15 @@ pub fn new_fn_ctxt<'a>(ccx: &'a CrateContext,
11471153
},
11481154
id, param_substs.map(|s| s.repr(ccx.tcx())));
11491155

1150-
let substd_output_type = output_type.substp(ccx.tcx(), param_substs);
1156+
let substd_output_type = match param_substs {
1157+
None => output_type,
1158+
Some(substs) => {
1159+
ty::subst_tps(ccx.tcx(),
1160+
substs.tys.as_slice(),
1161+
substs.self_ty,
1162+
output_type)
1163+
}
1164+
};
11511165
let uses_outptr = type_of::return_uses_outptr(ccx, substd_output_type);
11521166
let debug_context = debuginfo::create_function_debug_context(ccx, id, param_substs, llfndecl);
11531167

@@ -1199,7 +1213,15 @@ pub fn init_function<'a>(fcx: &'a FunctionContext<'a>,
11991213

12001214
// This shouldn't need to recompute the return type,
12011215
// as new_fn_ctxt did it already.
1202-
let substd_output_type = output_type.substp(fcx.ccx.tcx(), fcx.param_substs);
1216+
let substd_output_type = match fcx.param_substs {
1217+
None => output_type,
1218+
Some(substs) => {
1219+
ty::subst_tps(fcx.ccx.tcx(),
1220+
substs.tys.as_slice(),
1221+
substs.self_ty,
1222+
output_type)
1223+
}
1224+
};
12031225

12041226
if !return_type_is_void(fcx.ccx, substd_output_type) {
12051227
// If the function returns nil/bot, there is no real return
@@ -1486,8 +1508,18 @@ fn trans_enum_variant_or_tuple_like_struct(ccx: &CrateContext,
14861508
disr: ty::Disr,
14871509
param_substs: Option<&param_substs>,
14881510
llfndecl: ValueRef) {
1489-
let ctor_ty = ty::node_id_to_type(ccx.tcx(), ctor_id);
1490-
let ctor_ty = ctor_ty.substp(ccx.tcx(), param_substs);
1511+
let ctor_ty = {
1512+
let no_substs: &[ty::t] = [];
1513+
let ty_param_substs: &[ty::t] = match param_substs {
1514+
Some(substs) => substs.tys.as_slice(),
1515+
None => no_substs
1516+
};
1517+
1518+
ty::subst_tps(ccx.tcx(),
1519+
ty_param_substs,
1520+
None,
1521+
ty::node_id_to_type(ccx.tcx(), ctor_id))
1522+
};
14911523

14921524
let result_ty = match ty::get(ctor_ty).sty {
14931525
ty::ty_bare_fn(ref bft) => bft.sig.output,

0 commit comments

Comments
 (0)