Skip to content

Commit 00b6a8e

Browse files
committed
---
yaml --- r: 151010 b: refs/heads/try2 c: 3fbc578 h: refs/heads/master v: v3
1 parent 791f6c3 commit 00b6a8e

File tree

10 files changed

+62
-66
lines changed

10 files changed

+62
-66
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: 7b3d6afe0a1d7fb2c918e9ba1ed8c2d859c6e772
8+
refs/heads/try2: 3fbc57894a4d5ce682df8ad5edb5df387b05e822
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

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

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,15 +1112,15 @@ pub fn new_fn_ctxt<'a>(ccx: &'a CrateContext,
11121112
id: ast::NodeId,
11131113
has_env: bool,
11141114
output_type: ty::t,
1115-
param_substs: Option<@param_substs>,
1115+
param_substs: Option<&'a param_substs>,
11161116
sp: Option<Span>,
11171117
block_arena: &'a TypedArena<Block<'a>>)
11181118
-> FunctionContext<'a> {
11191119
for p in param_substs.iter() { p.validate(); }
11201120

11211121
debug!("new_fn_ctxt(path={}, id={}, param_substs={})",
11221122
if id == -1 { "".to_owned() } else { ccx.tcx.map.path_to_str(id) },
1123-
id, param_substs.repr(ccx.tcx()));
1123+
id, param_substs.map(|s| s.repr(ccx.tcx())));
11241124

11251125
let substd_output_type = match param_substs {
11261126
None => output_type,
@@ -1166,11 +1166,9 @@ pub fn new_fn_ctxt<'a>(ccx: &'a CrateContext,
11661166

11671167
/// Performs setup on a newly created function, creating the entry scope block
11681168
/// and allocating space for the return pointer.
1169-
pub fn init_function<'a>(
1170-
fcx: &'a FunctionContext<'a>,
1171-
skip_retptr: bool,
1172-
output_type: ty::t,
1173-
param_substs: Option<@param_substs>) {
1169+
pub fn init_function<'a>(fcx: &'a FunctionContext<'a>,
1170+
skip_retptr: bool,
1171+
output_type: ty::t) {
11741172
let entry_bcx = fcx.new_temp_block("entry-block");
11751173

11761174
*fcx.entry_bcx.borrow_mut() = Some(entry_bcx);
@@ -1182,7 +1180,9 @@ pub fn init_function<'a>(
11821180
llvm::LLVMGetFirstInstruction(entry_bcx.llbb)
11831181
}));
11841182

1185-
let substd_output_type = match param_substs {
1183+
// This shouldn't need to recompute the return type,
1184+
// as new_fn_ctxt did it already.
1185+
let substd_output_type = match fcx.param_substs {
11861186
None => output_type,
11871187
Some(substs) => {
11881188
ty::subst_tps(fcx.ccx.tcx(),
@@ -1329,7 +1329,7 @@ pub fn trans_closure(ccx: &CrateContext,
13291329
decl: &ast::FnDecl,
13301330
body: &ast::Block,
13311331
llfndecl: ValueRef,
1332-
param_substs: Option<@param_substs>,
1332+
param_substs: Option<&param_substs>,
13331333
id: ast::NodeId,
13341334
_attributes: &[ast::Attribute],
13351335
output_type: ty::t,
@@ -1340,7 +1340,7 @@ pub fn trans_closure(ccx: &CrateContext,
13401340
set_uwtable(llfndecl);
13411341

13421342
debug!("trans_closure(..., param_substs={})",
1343-
param_substs.repr(ccx.tcx()));
1343+
param_substs.map(|s| s.repr(ccx.tcx())));
13441344

13451345
let has_env = match ty::get(ty::node_id_to_type(ccx.tcx(), id)).sty {
13461346
ty::ty_closure(_) => true,
@@ -1353,10 +1353,10 @@ pub fn trans_closure(ccx: &CrateContext,
13531353
id,
13541354
has_env,
13551355
output_type,
1356-
param_substs,
1356+
param_substs.map(|s| &*s),
13571357
Some(body.span),
13581358
&arena);
1359-
init_function(&fcx, false, output_type, param_substs);
1359+
init_function(&fcx, false, output_type);
13601360

13611361
// cleanup scope for the incoming arguments
13621362
let arg_scope = fcx.push_custom_cleanup_scope();
@@ -1429,11 +1429,11 @@ pub fn trans_fn(ccx: &CrateContext,
14291429
decl: &ast::FnDecl,
14301430
body: &ast::Block,
14311431
llfndecl: ValueRef,
1432-
param_substs: Option<@param_substs>,
1432+
param_substs: Option<&param_substs>,
14331433
id: ast::NodeId,
14341434
attrs: &[ast::Attribute]) {
14351435
let _s = StatRecorder::new(ccx, ccx.tcx.map.path_to_str(id));
1436-
debug!("trans_fn(param_substs={})", param_substs.repr(ccx.tcx()));
1436+
debug!("trans_fn(param_substs={})", param_substs.map(|s| s.repr(ccx.tcx())));
14371437
let _icx = push_ctxt("trans_fn");
14381438
let output_type = ty::ty_fn_ret(ty::node_id_to_type(ccx.tcx(), id));
14391439
trans_closure(ccx, decl, body, llfndecl,
@@ -1445,7 +1445,7 @@ pub fn trans_enum_variant(ccx: &CrateContext,
14451445
variant: &ast::Variant,
14461446
_args: &[ast::VariantArg],
14471447
disr: ty::Disr,
1448-
param_substs: Option<@param_substs>,
1448+
param_substs: Option<&param_substs>,
14491449
llfndecl: ValueRef) {
14501450
let _icx = push_ctxt("trans_enum_variant");
14511451

@@ -1460,7 +1460,7 @@ pub fn trans_enum_variant(ccx: &CrateContext,
14601460
pub fn trans_tuple_struct(ccx: &CrateContext,
14611461
_fields: &[ast::StructField],
14621462
ctor_id: ast::NodeId,
1463-
param_substs: Option<@param_substs>,
1463+
param_substs: Option<&param_substs>,
14641464
llfndecl: ValueRef) {
14651465
let _icx = push_ctxt("trans_tuple_struct");
14661466

@@ -1475,24 +1475,20 @@ pub fn trans_tuple_struct(ccx: &CrateContext,
14751475
fn trans_enum_variant_or_tuple_like_struct(ccx: &CrateContext,
14761476
ctor_id: ast::NodeId,
14771477
disr: ty::Disr,
1478-
param_substs: Option<@param_substs>,
1478+
param_substs: Option<&param_substs>,
14791479
llfndecl: ValueRef) {
1480-
let no_substs: &[ty::t] = [];
1481-
let ty_param_substs = match param_substs {
1482-
Some(ref substs) => {
1483-
let v: &[ty::t] = substs.tys.as_slice();
1484-
v
1485-
}
1486-
None => {
1487-
let v: &[ty::t] = no_substs;
1488-
v
1489-
}
1490-
};
1480+
let ctor_ty = {
1481+
let no_substs: &[ty::t] = [];
1482+
let ty_param_substs: &[ty::t] = match param_substs {
1483+
Some(substs) => substs.tys.as_slice(),
1484+
None => no_substs
1485+
};
14911486

1492-
let ctor_ty = ty::subst_tps(ccx.tcx(),
1493-
ty_param_substs,
1494-
None,
1495-
ty::node_id_to_type(ccx.tcx(), ctor_id));
1487+
ty::subst_tps(ccx.tcx(),
1488+
ty_param_substs,
1489+
None,
1490+
ty::node_id_to_type(ccx.tcx(), ctor_id))
1491+
};
14961492

14971493
let result_ty = match ty::get(ctor_ty).sty {
14981494
ty::ty_bare_fn(ref bft) => bft.sig.output,
@@ -1504,8 +1500,8 @@ fn trans_enum_variant_or_tuple_like_struct(ccx: &CrateContext,
15041500

15051501
let arena = TypedArena::new();
15061502
let fcx = new_fn_ctxt(ccx, llfndecl, ctor_id, false, result_ty,
1507-
param_substs, None, &arena);
1508-
init_function(&fcx, false, result_ty, param_substs);
1503+
param_substs.map(|s| &*s), None, &arena);
1504+
init_function(&fcx, false, result_ty);
15091505

15101506
let arg_tys = ty::ty_fn_args(ctor_ty);
15111507

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,15 @@ fn resolve_default_method_vtables(bcx: &Block,
203203

204204
// Build up a param_substs that we are going to resolve the
205205
// trait_vtables under.
206-
let param_substs = Some(@param_substs {
206+
let param_substs = param_substs {
207207
tys: substs.tps.clone(),
208208
self_ty: substs.self_ty,
209209
vtables: impl_vtables.clone(),
210210
self_vtables: None
211-
});
211+
};
212212

213213
let mut param_vtables = resolve_vtables_under_param_substs(
214-
bcx.tcx(), param_substs, impl_res.trait_vtables.as_slice());
214+
bcx.tcx(), Some(&param_substs), impl_res.trait_vtables.as_slice());
215215

216216
// Now we pull any vtables for parameters on the actual method.
217217
let num_method_vtables = method.generics.type_param_defs().len();
@@ -231,7 +231,7 @@ fn resolve_default_method_vtables(bcx: &Block,
231231
}
232232

233233
let self_vtables = resolve_param_vtables_under_param_substs(
234-
bcx.tcx(), param_substs, impl_res.self_vtables.as_slice());
234+
bcx.tcx(), Some(&param_substs), impl_res.self_vtables.as_slice());
235235

236236
(param_vtables, self_vtables)
237237
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ pub fn get_wrapper_for_bare_fn(ccx: &CrateContext,
466466

467467
let arena = TypedArena::new();
468468
let fcx = new_fn_ctxt(ccx, llfn, -1, true, f.sig.output, None, None, &arena);
469-
init_function(&fcx, true, f.sig.output, None);
469+
init_function(&fcx, true, f.sig.output);
470470
let bcx = fcx.entry_bcx.borrow().clone().unwrap();
471471

472472
let args = create_datums_for_fn_args(&fcx,

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ pub struct FunctionContext<'a> {
274274

275275
// If this function is being monomorphized, this contains the type
276276
// substitutions used.
277-
pub param_substs: Option<@param_substs>,
277+
pub param_substs: Option<&'a param_substs>,
278278

279279
// The source span and nesting context where this function comes from, for
280280
// error reporting and symbol generation.
@@ -688,7 +688,7 @@ pub fn is_null(val: ValueRef) -> bool {
688688

689689
pub fn monomorphize_type(bcx: &Block, t: ty::t) -> ty::t {
690690
match bcx.fcx.param_substs {
691-
Some(substs) => {
691+
Some(ref substs) => {
692692
ty::subst_tps(bcx.tcx(), substs.tys.as_slice(), substs.self_ty, t)
693693
}
694694
_ => {
@@ -742,12 +742,12 @@ pub fn node_id_type_params(bcx: &Block, node: ExprOrMethodCall) -> Vec<ty::t> {
742742
}
743743

744744
match bcx.fcx.param_substs {
745-
Some(substs) => {
746-
params.iter().map(|t| {
747-
ty::subst_tps(tcx, substs.tys.as_slice(), substs.self_ty, *t)
748-
}).collect()
749-
}
750-
_ => params
745+
Some(ref substs) => {
746+
params.iter().map(|t| {
747+
ty::subst_tps(tcx, substs.tys.as_slice(), substs.self_ty, *t)
748+
}).collect()
749+
}
750+
_ => params
751751
}
752752
}
753753

@@ -769,7 +769,7 @@ pub fn resolve_vtables_in_fn_ctxt(fcx: &FunctionContext,
769769
}
770770

771771
pub fn resolve_vtables_under_param_substs(tcx: &ty::ctxt,
772-
param_substs: Option<@param_substs>,
772+
param_substs: Option<&param_substs>,
773773
vts: &[typeck::vtable_param_res])
774774
-> typeck::vtable_res {
775775
vts.iter().map(|ds| {
@@ -781,7 +781,7 @@ pub fn resolve_vtables_under_param_substs(tcx: &ty::ctxt,
781781

782782
pub fn resolve_param_vtables_under_param_substs(
783783
tcx: &ty::ctxt,
784-
param_substs: Option<@param_substs>,
784+
param_substs: Option<&param_substs>,
785785
ds: &[typeck::vtable_origin])
786786
-> typeck::vtable_param_res {
787787
ds.iter().map(|d| {
@@ -794,7 +794,7 @@ pub fn resolve_param_vtables_under_param_substs(
794794

795795

796796
pub fn resolve_vtable_under_param_substs(tcx: &ty::ctxt,
797-
param_substs: Option<@param_substs>,
797+
param_substs: Option<&param_substs>,
798798
vt: &typeck::vtable_origin)
799799
-> typeck::vtable_origin {
800800
match *vt {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ pub fn start_emitting_source_locations(fcx: &FunctionContext) {
609609
/// indicates why no debuginfo should be created for the function.
610610
pub fn create_function_debug_context(cx: &CrateContext,
611611
fn_ast_id: ast::NodeId,
612-
param_substs: Option<@param_substs>,
612+
param_substs: Option<&param_substs>,
613613
llfn: ValueRef) -> FunctionDebugContext {
614614
if cx.sess().opts.debuginfo == NoDebugInfo {
615615
return FunctionDebugContext { repr: DebugInfoDisabled };
@@ -775,7 +775,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
775775
fn get_function_signature(cx: &CrateContext,
776776
fn_ast_id: ast::NodeId,
777777
fn_decl: &ast::FnDecl,
778-
param_substs: Option<@param_substs>,
778+
param_substs: Option<&param_substs>,
779779
error_span: Span) -> DIArray {
780780
if cx.sess().opts.debuginfo == LimitedDebugInfo {
781781
return create_DIArray(DIB(cx), []);
@@ -828,7 +828,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
828828

829829
fn get_template_parameters(cx: &CrateContext,
830830
generics: &ast::Generics,
831-
param_substs: Option<@param_substs>,
831+
param_substs: Option<&param_substs>,
832832
file_metadata: DIFile,
833833
name_to_append_suffix_to: &mut StrBuf)
834834
-> DIArray {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ fn make_generic_glue(ccx: &CrateContext,
466466
let arena = TypedArena::new();
467467
let fcx = new_fn_ctxt(ccx, llfn, -1, false, ty::mk_nil(), None, None, &arena);
468468

469-
init_function(&fcx, false, ty::mk_nil(), None);
469+
init_function(&fcx, false, ty::mk_nil());
470470

471471
lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage);
472472
ccx.stats.n_glues_created.set(ccx.stats.n_glues_created.get() + 1u);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub fn get_simple_intrinsic(ccx: &CrateContext, item: &ast::ForeignItem) -> Opti
8585
pub fn trans_intrinsic(ccx: &CrateContext,
8686
decl: ValueRef,
8787
item: &ast::ForeignItem,
88-
substs: @param_substs,
88+
substs: &param_substs,
8989
ref_id: Option<ast::NodeId>) {
9090
debug!("trans_intrinsic(item.ident={})", token::get_ident(item.ident));
9191

@@ -194,8 +194,8 @@ pub fn trans_intrinsic(ccx: &CrateContext,
194194

195195
let arena = TypedArena::new();
196196
let fcx = new_fn_ctxt(ccx, decl, item.id, false, output_type,
197-
Some(substs), Some(item.span), &arena);
198-
init_function(&fcx, true, output_type, Some(substs));
197+
Some(&*substs), Some(item.span), &arena);
198+
init_function(&fcx, true, output_type);
199199

200200
set_always_inline(fcx.llfn);
201201

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
8484
None => ()
8585
}
8686

87-
let psubsts = @param_substs {
87+
let psubsts = param_substs {
8888
tys: real_substs.tps.clone(),
8989
vtables: vtables,
9090
self_ty: real_substs.self_ty.clone(),
@@ -221,7 +221,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
221221
} => {
222222
let d = mk_lldecl();
223223
set_llvm_fn_attrs(i.attrs.as_slice(), d);
224-
trans_fn(ccx, decl, body, d, Some(psubsts), fn_id.node, []);
224+
trans_fn(ccx, decl, body, d, Some(&psubsts), fn_id.node, []);
225225
d
226226
}
227227
_ => {
@@ -235,7 +235,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
235235
Some(decl) => decl,
236236
None => {
237237
let d = mk_lldecl();
238-
intrinsic::trans_intrinsic(ccx, d, i, psubsts, ref_id);
238+
intrinsic::trans_intrinsic(ccx, d, i, &psubsts, ref_id);
239239
d
240240
}
241241
}
@@ -253,7 +253,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
253253
v,
254254
args.as_slice(),
255255
this_tv.disr_val,
256-
Some(psubsts),
256+
Some(&psubsts),
257257
d);
258258
}
259259
ast::StructVariantKind(_) =>
@@ -264,15 +264,15 @@ pub fn monomorphic_fn(ccx: &CrateContext,
264264
ast_map::NodeMethod(mth) => {
265265
let d = mk_lldecl();
266266
set_llvm_fn_attrs(mth.attrs.as_slice(), d);
267-
trans_fn(ccx, mth.decl, mth.body, d, Some(psubsts), mth.id, []);
267+
trans_fn(ccx, mth.decl, mth.body, d, Some(&psubsts), mth.id, []);
268268
d
269269
}
270270
ast_map::NodeTraitMethod(method) => {
271271
match *method {
272272
ast::Provided(mth) => {
273273
let d = mk_lldecl();
274274
set_llvm_fn_attrs(mth.attrs.as_slice(), d);
275-
trans_fn(ccx, mth.decl, mth.body, d, Some(psubsts), mth.id, []);
275+
trans_fn(ccx, mth.decl, mth.body, d, Some(&psubsts), mth.id, []);
276276
d
277277
}
278278
_ => {
@@ -288,7 +288,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
288288
struct_def.fields.as_slice(),
289289
struct_def.ctor_id.expect("ast-mapped tuple struct \
290290
didn't have a ctor id"),
291-
Some(psubsts),
291+
Some(&psubsts),
292292
d);
293293
d
294294
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ impl<'a> Reflector<'a> {
307307
let arena = TypedArena::new();
308308
let fcx = new_fn_ctxt(ccx, llfdecl, -1, false,
309309
ty::mk_u64(), None, None, &arena);
310-
init_function(&fcx, false, ty::mk_u64(), None);
310+
init_function(&fcx, false, ty::mk_u64());
311311

312312
let arg = unsafe {
313313
//

0 commit comments

Comments
 (0)