Skip to content

Commit efaaa89

Browse files
committed
---
yaml --- r: 158638 b: refs/heads/try c: 7d2da3a h: refs/heads/master v: v3
1 parent cc16146 commit efaaa89

File tree

12 files changed

+59
-96
lines changed

12 files changed

+59
-96
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: a0a7ab461283322215f0343cd2b5e66fc19a7bd5
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 1b2ad7831f1745bf4a4709a1fa1772afb47c933c
5-
refs/heads/try: fba86567a95ca5e8711f3cfd92e347a37281a92c
5+
refs/heads/try: 7d2da3a8dbe8284678607e0b07f4d94ab22a37c8
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use middle::astencode;
3939
use middle::lang_items::{LangItem, ExchangeMallocFnLangItem, StartFnLangItem};
4040
use middle::subst;
4141
use middle::weak_lang_items;
42-
use middle::subst::Subst;
42+
use middle::subst::{Subst, Substs};
4343
use middle::trans::_match;
4444
use middle::trans::adt;
4545
use middle::trans::build::*;
@@ -51,8 +51,8 @@ use middle::trans::cleanup;
5151
use middle::trans::common::{Block, C_bool, C_bytes_in_context, C_i32, C_integral, C_nil};
5252
use middle::trans::common::{C_null, C_struct_in_context, C_u64, C_u8, C_uint, C_undef};
5353
use middle::trans::common::{CrateContext, ExternMap, FunctionContext};
54-
use middle::trans::common::{NodeInfo, Result, SubstP};
55-
use middle::trans::common::{node_id_type, param_substs, return_type_is_void};
54+
use middle::trans::common::{NodeInfo, Result};
55+
use middle::trans::common::{node_id_type, return_type_is_void};
5656
use middle::trans::common::{tydesc_info, type_is_immediate};
5757
use middle::trans::common::{type_is_zero_size, val_ty};
5858
use middle::trans::common;
@@ -1431,11 +1431,11 @@ pub fn new_fn_ctxt<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>,
14311431
id: ast::NodeId,
14321432
has_env: bool,
14331433
output_type: ty::FnOutput<'tcx>,
1434-
param_substs: &'a param_substs<'tcx>,
1434+
param_substs: &'a Substs<'tcx>,
14351435
sp: Option<Span>,
14361436
block_arena: &'a TypedArena<common::BlockS<'a, 'tcx>>)
14371437
-> FunctionContext<'a, 'tcx> {
1438-
param_substs.validate();
1438+
common::validate_substs(param_substs);
14391439

14401440
debug!("new_fn_ctxt(path={}, id={}, param_substs={})",
14411441
if id == -1 {
@@ -1447,7 +1447,7 @@ pub fn new_fn_ctxt<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>,
14471447

14481448
let uses_outptr = match output_type {
14491449
ty::FnConverging(output_type) => {
1450-
let substd_output_type = output_type.substp(ccx.tcx(), param_substs);
1450+
let substd_output_type = output_type.subst(ccx.tcx(), param_substs);
14511451
type_of::return_uses_outptr(ccx, substd_output_type)
14521452
}
14531453
ty::FnDiverging => false
@@ -1500,7 +1500,7 @@ pub fn init_function<'a, 'tcx>(fcx: &'a FunctionContext<'a, 'tcx>,
15001500
if let ty::FnConverging(output_type) = output {
15011501
// This shouldn't need to recompute the return type,
15021502
// as new_fn_ctxt did it already.
1503-
let substd_output_type = output_type.substp(fcx.ccx.tcx(), fcx.param_substs);
1503+
let substd_output_type = output_type.subst(fcx.ccx.tcx(), fcx.param_substs);
15041504
if !return_type_is_void(fcx.ccx, substd_output_type) {
15051505
// If the function returns nil/bot, there is no real return
15061506
// value, so do not set `llretslotptr`.
@@ -1729,7 +1729,7 @@ pub fn finish_fn<'blk, 'tcx>(fcx: &'blk FunctionContext<'blk, 'tcx>,
17291729

17301730
// This shouldn't need to recompute the return type,
17311731
// as new_fn_ctxt did it already.
1732-
let substd_retty = retty.substp(fcx.ccx.tcx(), fcx.param_substs);
1732+
let substd_retty = retty.subst(fcx.ccx.tcx(), fcx.param_substs);
17331733
build_return_block(fcx, ret_cx, substd_retty);
17341734

17351735
debuginfo::clear_source_location(fcx);
@@ -1805,7 +1805,7 @@ pub fn trans_closure<'a, 'b, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
18051805
decl: &ast::FnDecl,
18061806
body: &ast::Block,
18071807
llfndecl: ValueRef,
1808-
param_substs: &param_substs<'tcx>,
1808+
param_substs: &Substs<'tcx>,
18091809
fn_ast_id: ast::NodeId,
18101810
_attributes: &[ast::Attribute],
18111811
output_type: ty::FnOutput<'tcx>,
@@ -1950,7 +1950,7 @@ pub fn trans_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
19501950
decl: &ast::FnDecl,
19511951
body: &ast::Block,
19521952
llfndecl: ValueRef,
1953-
param_substs: &param_substs<'tcx>,
1953+
param_substs: &Substs<'tcx>,
19541954
id: ast::NodeId,
19551955
attrs: &[ast::Attribute]) {
19561956
let _s = StatRecorder::new(ccx, ccx.tcx().map.path_to_string(id).to_string());
@@ -1976,7 +1976,7 @@ pub fn trans_enum_variant<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
19761976
variant: &ast::Variant,
19771977
_args: &[ast::VariantArg],
19781978
disr: ty::Disr,
1979-
param_substs: &param_substs<'tcx>,
1979+
param_substs: &Substs<'tcx>,
19801980
llfndecl: ValueRef) {
19811981
let _icx = push_ctxt("trans_enum_variant");
19821982

@@ -2051,7 +2051,7 @@ pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
20512051
pub fn trans_tuple_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
20522052
_fields: &[ast::StructField],
20532053
ctor_id: ast::NodeId,
2054-
param_substs: &param_substs<'tcx>,
2054+
param_substs: &Substs<'tcx>,
20552055
llfndecl: ValueRef) {
20562056
let _icx = push_ctxt("trans_tuple_struct");
20572057

@@ -2066,10 +2066,10 @@ pub fn trans_tuple_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
20662066
fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
20672067
ctor_id: ast::NodeId,
20682068
disr: ty::Disr,
2069-
param_substs: &param_substs<'tcx>,
2069+
param_substs: &Substs<'tcx>,
20702070
llfndecl: ValueRef) {
20712071
let ctor_ty = ty::node_id_to_type(ccx.tcx(), ctor_id);
2072-
let ctor_ty = ctor_ty.substp(ccx.tcx(), param_substs);
2072+
let ctor_ty = ctor_ty.subst(ccx.tcx(), param_substs);
20732073

20742074
let result_ty = match ty::get(ctor_ty).sty {
20752075
ty::ty_bare_fn(ref bft) => bft.sig.output,
@@ -2242,15 +2242,15 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
22422242
&**body,
22432243
item.attrs.as_slice(),
22442244
llfn,
2245-
&param_substs::empty(),
2245+
&Substs::trans_empty(),
22462246
item.id,
22472247
None);
22482248
} else {
22492249
trans_fn(ccx,
22502250
&**decl,
22512251
&**body,
22522252
llfn,
2253-
&param_substs::empty(),
2253+
&Substs::trans_empty(),
22542254
item.id,
22552255
item.attrs.as_slice());
22562256
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use llvm;
2525
use metadata::csearch;
2626
use middle::def;
2727
use middle::subst;
28-
use middle::subst::{Subst};
28+
use middle::subst::{Subst, Substs};
2929
use middle::trans::adt;
3030
use middle::trans::base;
3131
use middle::trans::base::*;
@@ -316,7 +316,7 @@ pub fn trans_unboxing_shim<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
316316
function_name.as_slice());
317317

318318
let block_arena = TypedArena::new();
319-
let empty_param_substs = param_substs::empty();
319+
let empty_param_substs = Substs::trans_empty();
320320
let return_type = ty::ty_fn_ret(boxed_function_type);
321321
let fcx = new_fn_ctxt(ccx,
322322
llfn,

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use driver::config::FullDebugInfo;
1515
use llvm::ValueRef;
1616
use middle::def;
1717
use middle::mem_categorization::Typer;
18+
use middle::subst::Substs;
1819
use middle::trans::adt;
1920
use middle::trans::base::*;
2021
use middle::trans::build::*;
@@ -627,7 +628,7 @@ pub fn get_wrapper_for_bare_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
627628
let _icx = push_ctxt("closure::get_wrapper_for_bare_fn");
628629

629630
let arena = TypedArena::new();
630-
let empty_param_substs = param_substs::empty();
631+
let empty_param_substs = Substs::trans_empty();
631632
let fcx = new_fn_ctxt(ccx, llfn, ast::DUMMY_NODE_ID, true, f.sig.output,
632633
&empty_param_substs, None, &arena);
633634
let bcx = init_function(&fcx, true, f.sig.output);

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

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use middle::def;
2020
use middle::lang_items::LangItem;
2121
use middle::mem_categorization as mc;
2222
use middle::subst;
23-
use middle::subst::Subst;
23+
use middle::subst::{Subst, Substs};
2424
use middle::trans::base;
2525
use middle::trans::build;
2626
use middle::trans::cleanup;
@@ -188,39 +188,8 @@ pub fn BuilderRef_res(b: BuilderRef) -> BuilderRef_res {
188188

189189
pub type ExternMap = HashMap<String, ValueRef>;
190190

191-
// Here `self_ty` is the real type of the self parameter to this method. It
192-
// will only be set in the case of default methods.
193-
pub struct param_substs<'tcx> {
194-
pub substs: subst::Substs<'tcx>,
195-
}
196-
197-
impl<'tcx> param_substs<'tcx> {
198-
pub fn empty() -> param_substs<'tcx> {
199-
param_substs {
200-
substs: subst::Substs::trans_empty(),
201-
}
202-
}
203-
204-
pub fn validate(&self) {
205-
assert!(self.substs.types.all(|t| !ty::type_needs_infer(*t)));
206-
}
207-
}
208-
209-
impl<'tcx> Repr<'tcx> for param_substs<'tcx> {
210-
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
211-
self.substs.repr(tcx)
212-
}
213-
}
214-
215-
pub trait SubstP<'tcx> {
216-
fn substp(&self, tcx: &ty::ctxt<'tcx>, param_substs: &param_substs<'tcx>)
217-
-> Self;
218-
}
219-
220-
impl<'tcx, T: Subst<'tcx> + Clone> SubstP<'tcx> for T {
221-
fn substp(&self, tcx: &ty::ctxt<'tcx>, substs: &param_substs<'tcx>) -> T {
222-
self.subst(tcx, &substs.substs)
223-
}
191+
pub fn validate_substs(substs: &Substs) {
192+
assert!(substs.types.all(|t| !ty::type_needs_infer(*t)));
224193
}
225194

226195
// work around bizarre resolve errors
@@ -280,7 +249,7 @@ pub struct FunctionContext<'a, 'tcx: 'a> {
280249

281250
// If this function is being monomorphized, this contains the type
282251
// substitutions used.
283-
pub param_substs: &'a param_substs<'tcx>,
252+
pub param_substs: &'a Substs<'tcx>,
284253

285254
// The source span and nesting context where this function comes from, for
286255
// error reporting and symbol generation.
@@ -780,7 +749,7 @@ pub fn is_null(val: ValueRef) -> bool {
780749
}
781750

782751
pub fn monomorphize_type<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, t: Ty<'tcx>) -> Ty<'tcx> {
783-
t.subst(bcx.tcx(), &bcx.fcx.param_substs.substs)
752+
t.subst(bcx.tcx(), bcx.fcx.param_substs)
784753
}
785754

786755
pub fn node_id_type<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, id: ast::NodeId) -> Ty<'tcx> {
@@ -936,7 +905,7 @@ pub fn node_id_substs<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
936905
}
937906

938907
let substs = substs.erase_regions();
939-
substs.substp(tcx, bcx.fcx.param_substs)
908+
substs.subst(tcx, bcx.fcx.param_substs)
940909
}
941910

942911
pub fn langcall(bcx: Block,

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ use llvm;
190190
use llvm::{ModuleRef, ContextRef, ValueRef};
191191
use llvm::debuginfo::*;
192192
use metadata::csearch;
193-
use middle::subst::{mod, Subst};
193+
use middle::subst::{mod, Subst, Substs};
194194
use middle::trans::adt;
195195
use middle::trans::common::*;
196196
use middle::trans::machine;
@@ -1163,7 +1163,7 @@ pub fn start_emitting_source_locations(fcx: &FunctionContext) {
11631163
/// for the function.
11641164
pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
11651165
fn_ast_id: ast::NodeId,
1166-
param_substs: &param_substs<'tcx>,
1166+
param_substs: &Substs<'tcx>,
11671167
llfn: ValueRef) -> FunctionDebugContext {
11681168
if cx.sess().opts.debuginfo == NoDebugInfo {
11691169
return FunctionDebugContext { repr: DebugInfoDisabled };
@@ -1365,7 +1365,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
13651365
fn get_function_signature<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
13661366
fn_ast_id: ast::NodeId,
13671367
fn_decl: &ast::FnDecl,
1368-
param_substs: &param_substs<'tcx>,
1368+
param_substs: &Substs<'tcx>,
13691369
error_reporting_span: Span) -> DIArray {
13701370
if cx.sess().opts.debuginfo == LimitedDebugInfo {
13711371
return create_DIArray(DIB(cx), []);
@@ -1382,7 +1382,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
13821382
assert_type_for_node_id(cx, fn_ast_id, error_reporting_span);
13831383

13841384
let return_type = ty::node_id_to_type(cx.tcx(), fn_ast_id);
1385-
let return_type = return_type.substp(cx.tcx(), param_substs);
1385+
let return_type = return_type.subst(cx.tcx(), param_substs);
13861386
signature.push(type_metadata(cx, return_type, codemap::DUMMY_SP));
13871387
}
13881388
}
@@ -1391,7 +1391,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
13911391
for arg in fn_decl.inputs.iter() {
13921392
assert_type_for_node_id(cx, arg.pat.id, arg.pat.span);
13931393
let arg_type = ty::node_id_to_type(cx.tcx(), arg.pat.id);
1394-
let arg_type = arg_type.substp(cx.tcx(), param_substs);
1394+
let arg_type = arg_type.subst(cx.tcx(), param_substs);
13951395
signature.push(type_metadata(cx, arg_type, codemap::DUMMY_SP));
13961396
}
13971397

@@ -1400,11 +1400,11 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
14001400

14011401
fn get_template_parameters<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
14021402
generics: &ast::Generics,
1403-
param_substs: &param_substs<'tcx>,
1403+
param_substs: &Substs<'tcx>,
14041404
file_metadata: DIFile,
14051405
name_to_append_suffix_to: &mut String)
14061406
-> DIArray {
1407-
let self_type = param_substs.substs.self_ty();
1407+
let self_type = param_substs.self_ty();
14081408

14091409
// Only true for static default methods:
14101410
let has_self_type = self_type.is_some();
@@ -1461,7 +1461,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
14611461
}
14621462

14631463
// Handle other generic parameters
1464-
let actual_types = param_substs.substs.types.get_slice(subst::FnSpace);
1464+
let actual_types = param_substs.types.get_slice(subst::FnSpace);
14651465
for (index, &ast::TyParam{ ident, .. }) in generics.ty_params.iter().enumerate() {
14661466
let actual_type = actual_types[index];
14671467
// Add actual type name to <...> clause of function name

branches/try/src/librustc/middle/trans/expr.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
329329
let trait_ref =
330330
Rc::new(ty::TraitRef { def_id: def_id,
331331
substs: substs });
332-
let trait_ref =
333-
trait_ref.subst(bcx.tcx(), &bcx.fcx.param_substs.substs);
332+
let trait_ref = trait_ref.subst(bcx.tcx(), bcx.fcx.param_substs);
334333
let box_ty = mk_ty(unsized_ty);
335334
PointerCast(bcx,
336335
meth::get_vtable(bcx, box_ty, trait_ref),
@@ -1117,8 +1116,7 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
11171116
.find(&expr.id)
11181117
.map(|t| (*t).clone())
11191118
.unwrap();
1120-
let trait_ref =
1121-
trait_ref.subst(bcx.tcx(), &bcx.fcx.param_substs.substs);
1119+
let trait_ref = trait_ref.subst(bcx.tcx(), bcx.fcx.param_substs);
11221120
let datum = unpack_datum!(bcx, trans(bcx, &**val));
11231121
meth::trans_trait_cast(bcx, datum, expr.id,
11241122
trait_ref, dest)

branches/try/src/librustc/middle/trans/foreign.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use middle::trans::type_of::*;
2424
use middle::trans::type_of;
2525
use middle::ty::FnSig;
2626
use middle::ty::{mod, Ty};
27-
use middle::subst::Subst;
27+
use middle::subst::{Subst, Substs};
2828
use std::cmp;
2929
use libc::c_uint;
3030
use syntax::abi::{Cdecl, Aapcs, C, Win64, Abi};
@@ -556,13 +556,13 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
556556
body: &ast::Block,
557557
attrs: &[ast::Attribute],
558558
llwrapfn: ValueRef,
559-
param_substs: &param_substs<'tcx>,
559+
param_substs: &Substs<'tcx>,
560560
id: ast::NodeId,
561561
hash: Option<&str>) {
562562
let _icx = push_ctxt("foreign::build_foreign_fn");
563563

564564
let fnty = ty::node_id_to_type(ccx.tcx(), id);
565-
let mty = fnty.subst(ccx.tcx(), &param_substs.substs);
565+
let mty = fnty.subst(ccx.tcx(), param_substs);
566566
let tys = foreign_types_for_fn_ty(ccx, mty);
567567

568568
unsafe { // unsafe because we call LLVM operations
@@ -576,15 +576,14 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
576576
fn build_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
577577
decl: &ast::FnDecl,
578578
body: &ast::Block,
579-
param_substs: &param_substs<'tcx>,
579+
param_substs: &Substs<'tcx>,
580580
attrs: &[ast::Attribute],
581581
id: ast::NodeId,
582582
hash: Option<&str>)
583583
-> ValueRef {
584584
let _icx = push_ctxt("foreign::foreign::build_rust_fn");
585585
let tcx = ccx.tcx();
586-
let t = ty::node_id_to_type(tcx, id).subst(
587-
ccx.tcx(), &param_substs.substs);
586+
let t = ty::node_id_to_type(tcx, id).subst(ccx.tcx(), param_substs);
588587

589588
let ps = ccx.tcx().map.with_path(id, |path| {
590589
let abi = Some(ast_map::PathName(special_idents::clownshoe_abi.name));

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use llvm::{ValueRef, True, get_param};
1919
use llvm;
2020
use middle::lang_items::ExchangeFreeFnLangItem;
2121
use middle::subst;
22-
use middle::subst::Subst;
22+
use middle::subst::{Subst, Substs};
2323
use middle::trans::adt;
2424
use middle::trans::base::*;
2525
use middle::trans::build::*;
@@ -540,7 +540,7 @@ fn make_generic_glue<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
540540
let _s = StatRecorder::new(ccx, glue_name);
541541

542542
let arena = TypedArena::new();
543-
let empty_param_substs = param_substs::empty();
543+
let empty_param_substs = Substs::trans_empty();
544544
let fcx = new_fn_ctxt(ccx, llfn, ast::DUMMY_NODE_ID, false, ty::FnConverging(ty::mk_nil()),
545545
&empty_param_substs, None, &arena);
546546

0 commit comments

Comments
 (0)