Skip to content

Commit 491f665

Browse files
committed
---
yaml --- r: 151511 b: refs/heads/try2 c: 061450d h: refs/heads/master i: 151509: c9dd0a9 151507: b13c5e2 151503: d6a36cf v: v3
1 parent 3c95ee7 commit 491f665

File tree

29 files changed

+595
-483
lines changed

29 files changed

+595
-483
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: 0f25aad746b04ddda26ea502bdb7081e024a0644
8+
refs/heads/try2: 061450dcf14ea88c77312764fd80d712ff47fdb8
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: 16 additions & 11 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=do,for,if,else,while,loop,impl,mod,unsafe,trait,struct,enum,fn,extern
16+
setlocal cinwords=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,11 +115,16 @@ function GetRustIndent(lnum)
115115
" };
116116

117117
" Search backwards for the previous non-empty line.
118-
let prevline = s:get_line_trimmed(prevnonblank(a:lnum - 1))
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
119124
if prevline[len(prevline) - 1] == ","
120-
\ && s:get_line_trimmed(a:lnum) !~ "^\\s*[\\[\\]{}]"
121-
\ && prevline !~ "^\\s*fn\\s"
122-
\ && prevline !~ "([^()]\\+,$"
125+
\ && s:get_line_trimmed(a:lnum) !~ '^\s*[\[\]{}]'
126+
\ && prevline !~ '^\s*fn\s'
127+
\ && prevline !~ '([^()]\+,$'
123128
" Oh ho! The previous line ended in a comma! I bet cindent will try to
124129
" take this too far... For now, let's normally use the previous line's
125130
" indent.
@@ -166,7 +171,7 @@ function GetRustIndent(lnum)
166171
" column zero)
167172

168173
call cursor(a:lnum, 1)
169-
if searchpair('{\|(', '', '}\|)', 'nbW'
174+
if searchpair('{\|(', '', '}\|)', 'nbW',
170175
\ 's:is_string_comment(line("."), col("."))') == 0
171176
if searchpair('\[', '', '\]', 'nbW',
172177
\ 's:is_string_comment(line("."), col("."))') == 0

branches/try2/src/libcore/lib.rs

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

110111
#[cfg(test)] pub use realstd::fmt; // needed for fail!()
111112
#[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_node_type_subst = 0x48,
131+
tag_table_item_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: 30 additions & 9 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 tys, ref vtable_res) => {
660+
typeck::vtable_static(def_id, ref substs, 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_tys(ecx, tys.as_slice()))
666+
Ok(ebml_w.emit_substs(ecx, substs))
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_tys_noxcx(tcx, cdata))
747+
Ok(this.read_substs_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 tys in tcx.node_type_substs.borrow().find(&id).iter() {
966-
ebml_w.tag(c::tag_table_node_type_subst, |ebml_w| {
965+
for &item_substs in tcx.item_substs.borrow().find(&id).iter() {
966+
ebml_w.tag(c::tag_table_item_subst, |ebml_w| {
967967
ebml_w.id(id);
968968
ebml_w.tag(c::tag_table_val, |ebml_w| {
969-
ebml_w.emit_tys(ecx, tys.as_slice())
969+
ebml_w.emit_substs(ecx, &item_substs.substs);
970970
})
971971
})
972972
}
@@ -1091,6 +1091,9 @@ 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;
10941097
}
10951098

10961099
impl<'a> ebml_decoder_decoder_helpers for reader::Decoder<'a> {
@@ -1115,6 +1118,21 @@ impl<'a> ebml_decoder_decoder_helpers for reader::Decoder<'a> {
11151118
.collect()
11161119
}
11171120

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+
11181136
fn read_ty(&mut self, xcx: &ExtendedDecodeContext) -> ty::t {
11191137
// Note: regions types embed local node ids. In principle, we
11201138
// should translate these node ids into the new decode
@@ -1312,9 +1330,12 @@ fn decode_side_tables(xcx: &ExtendedDecodeContext,
13121330
id, ty_to_str(dcx.tcx, ty));
13131331
dcx.tcx.node_types.borrow_mut().insert(id as uint, ty);
13141332
}
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);
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);
13181339
}
13191340
c::tag_table_freevars => {
13201341
let fv_info = val_dsr.read_to_vec(|val_dsr| {

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

Lines changed: 15 additions & 11 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 node_type_substs = cx.tcx.node_type_substs.borrow();
248+
let item_substs = cx.tcx.item_substs.borrow();
249249
let r = match method {
250250
Some(method) => Some(&method.substs.tps),
251-
None => node_type_substs.find(&e.id)
251+
None => item_substs.find(&e.id).map(|s| &s.substs.tps)
252252
};
253253
for ts in r.iter() {
254254
let def_map = cx.tcx.def_map.borrow();
@@ -341,15 +341,19 @@ 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-
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)
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+
}
353357
}
354358
}
355359
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,17 @@ 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+
198209
impl Subst for ty::RegionSubsts {
199210
fn subst_spanned(&self, tcx: &ty::ctxt,
200211
substs: &ty::substs,

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

Lines changed: 15 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -478,35 +478,29 @@ 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::t])
481+
substs: &ty::substs)
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-
if !substs.is_empty() {
489+
490+
if !substs.tps.is_empty() || !substs.self_ty.is_none() {
490491
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-
};
496492

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);
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);
499495

500496
val
501497
} else if did.krate == ast::LOCAL_CRATE {
502498
get_item_val(ccx, did.node)
503499
} else {
504500
let tcx = ccx.tcx();
505501
let name = csearch::get_symbol(&ccx.sess().cstore, did);
506-
let class_ty = ty::subst_tps(tcx,
507-
substs,
508-
None,
509-
ty::lookup_item_type(tcx, parent_id).ty);
502+
let class_ty = ty::subst(tcx, substs,
503+
ty::lookup_item_type(tcx, parent_id).ty);
510504
let llty = type_of_dtor(ccx, class_ty);
511505

512506
get_extern_fn(&mut *ccx.externs.borrow_mut(), ccx.llmod, name,
@@ -670,7 +664,7 @@ pub fn iter_structural_ty<'r,
670664
repr: &adt::Repr,
671665
av: ValueRef,
672666
variant: &ty::VariantInfo,
673-
tps: &[ty::t],
667+
substs: &ty::substs,
674668
f: val_and_ty_fn<'r,'b>)
675669
-> &'b Block<'b> {
676670
let _icx = push_ctxt("iter_variant");
@@ -680,7 +674,7 @@ pub fn iter_structural_ty<'r,
680674
for (i, &arg) in variant.args.iter().enumerate() {
681675
cx = f(cx,
682676
adt::trans_field_ptr(cx, repr, av, variant.disr_val, i),
683-
ty::subst_tps(tcx, tps, None, arg));
677+
ty::subst(tcx, substs, arg));
684678
}
685679
return cx;
686680
}
@@ -722,7 +716,7 @@ pub fn iter_structural_ty<'r,
722716
match adt::trans_switch(cx, &*repr, av) {
723717
(_match::single, None) => {
724718
cx = iter_variant(cx, &*repr, av, &**variants.get(0),
725-
substs.tps.as_slice(), f);
719+
substs, f);
726720
}
727721
(_match::switch, Some(lldiscrim_a)) => {
728722
cx = f(cx, lldiscrim_a, ty::mk_int());
@@ -748,7 +742,7 @@ pub fn iter_structural_ty<'r,
748742
&*repr,
749743
av,
750744
&**variant,
751-
substs.tps.as_slice(),
745+
substs,
752746
|x,y,z| f(x,y,z));
753747
Br(variant_cx, next_cx.llbb);
754748
}
@@ -1153,15 +1147,7 @@ pub fn new_fn_ctxt<'a>(ccx: &'a CrateContext,
11531147
},
11541148
id, param_substs.map(|s| s.repr(ccx.tcx())));
11551149

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-
};
1150+
let substd_output_type = output_type.substp(ccx.tcx(), param_substs);
11651151
let uses_outptr = type_of::return_uses_outptr(ccx, substd_output_type);
11661152
let debug_context = debuginfo::create_function_debug_context(ccx, id, param_substs, llfndecl);
11671153

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

12141200
// This shouldn't need to recompute the return type,
12151201
// as new_fn_ctxt did it already.
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-
};
1202+
let substd_output_type = output_type.substp(fcx.ccx.tcx(), fcx.param_substs);
12251203

12261204
if !return_type_is_void(fcx.ccx, substd_output_type) {
12271205
// If the function returns nil/bot, there is no real return
@@ -1508,18 +1486,8 @@ fn trans_enum_variant_or_tuple_like_struct(ccx: &CrateContext,
15081486
disr: ty::Disr,
15091487
param_substs: Option<&param_substs>,
15101488
llfndecl: ValueRef) {
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-
};
1489+
let ctor_ty = ty::node_id_to_type(ccx.tcx(), ctor_id);
1490+
let ctor_ty = ctor_ty.substp(ccx.tcx(), param_substs);
15231491

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

0 commit comments

Comments
 (0)