Skip to content

Commit 4c3ad48

Browse files
committed
rustc: fix fallout of making Ty an alias for &TyS instead of a wrapper.
1 parent 5bc9895 commit 4c3ad48

File tree

11 files changed

+59
-106
lines changed

11 files changed

+59
-106
lines changed

src/librustc_trans/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::ty::{mod, Ty};
4444
use session::config::{mod, NoDebugInfo, FullDebugInfo};
4545
use session::Session;
@@ -54,8 +54,8 @@ use trans::closure;
5454
use trans::common::{Block, C_bool, C_bytes_in_context, C_i32, C_integral};
5555
use trans::common::{C_null, C_struct_in_context, C_u64, C_u8, C_uint, C_undef};
5656
use trans::common::{CrateContext, ExternMap, FunctionContext};
57-
use trans::common::{NodeInfo, Result, SubstP};
58-
use trans::common::{node_id_type, param_substs, return_type_is_void};
57+
use trans::common::{NodeInfo, Result};
58+
use trans::common::{node_id_type, return_type_is_void};
5959
use trans::common::{tydesc_info, type_is_immediate};
6060
use trans::common::{type_is_zero_size, val_ty};
6161
use trans::common;
@@ -1422,11 +1422,11 @@ pub fn new_fn_ctxt<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>,
14221422
id: ast::NodeId,
14231423
has_env: bool,
14241424
output_type: ty::FnOutput<'tcx>,
1425-
param_substs: &'a param_substs<'tcx>,
1425+
param_substs: &'a Substs<'tcx>,
14261426
sp: Option<Span>,
14271427
block_arena: &'a TypedArena<common::BlockS<'a, 'tcx>>)
14281428
-> FunctionContext<'a, 'tcx> {
1429-
param_substs.validate();
1429+
common::validate_substs(param_substs);
14301430

14311431
debug!("new_fn_ctxt(path={}, id={}, param_substs={})",
14321432
if id == -1 {
@@ -1438,7 +1438,7 @@ pub fn new_fn_ctxt<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>,
14381438

14391439
let uses_outptr = match output_type {
14401440
ty::FnConverging(output_type) => {
1441-
let substd_output_type = output_type.substp(ccx.tcx(), param_substs);
1441+
let substd_output_type = output_type.subst(ccx.tcx(), param_substs);
14421442
type_of::return_uses_outptr(ccx, substd_output_type)
14431443
}
14441444
ty::FnDiverging => false
@@ -1491,7 +1491,7 @@ pub fn init_function<'a, 'tcx>(fcx: &'a FunctionContext<'a, 'tcx>,
14911491
if let ty::FnConverging(output_type) = output {
14921492
// This shouldn't need to recompute the return type,
14931493
// as new_fn_ctxt did it already.
1494-
let substd_output_type = output_type.substp(fcx.ccx.tcx(), fcx.param_substs);
1494+
let substd_output_type = output_type.subst(fcx.ccx.tcx(), fcx.param_substs);
14951495
if !return_type_is_void(fcx.ccx, substd_output_type) {
14961496
// If the function returns nil/bot, there is no real return
14971497
// value, so do not set `llretslotptr`.
@@ -1712,7 +1712,7 @@ pub fn finish_fn<'blk, 'tcx>(fcx: &'blk FunctionContext<'blk, 'tcx>,
17121712

17131713
// This shouldn't need to recompute the return type,
17141714
// as new_fn_ctxt did it already.
1715-
let substd_retty = retty.substp(fcx.ccx.tcx(), fcx.param_substs);
1715+
let substd_retty = retty.subst(fcx.ccx.tcx(), fcx.param_substs);
17161716
build_return_block(fcx, ret_cx, substd_retty);
17171717

17181718
debuginfo::clear_source_location(fcx);
@@ -1788,7 +1788,7 @@ pub fn trans_closure<'a, 'b, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
17881788
decl: &ast::FnDecl,
17891789
body: &ast::Block,
17901790
llfndecl: ValueRef,
1791-
param_substs: &param_substs<'tcx>,
1791+
param_substs: &Substs<'tcx>,
17921792
fn_ast_id: ast::NodeId,
17931793
_attributes: &[ast::Attribute],
17941794
output_type: ty::FnOutput<'tcx>,
@@ -1929,7 +1929,7 @@ pub fn trans_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
19291929
decl: &ast::FnDecl,
19301930
body: &ast::Block,
19311931
llfndecl: ValueRef,
1932-
param_substs: &param_substs<'tcx>,
1932+
param_substs: &Substs<'tcx>,
19331933
id: ast::NodeId,
19341934
attrs: &[ast::Attribute]) {
19351935
let _s = StatRecorder::new(ccx, ccx.tcx().map.path_to_string(id).to_string());
@@ -1955,7 +1955,7 @@ pub fn trans_enum_variant<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
19551955
variant: &ast::Variant,
19561956
_args: &[ast::VariantArg],
19571957
disr: ty::Disr,
1958-
param_substs: &param_substs<'tcx>,
1958+
param_substs: &Substs<'tcx>,
19591959
llfndecl: ValueRef) {
19601960
let _icx = push_ctxt("trans_enum_variant");
19611961

@@ -2030,7 +2030,7 @@ pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
20302030
pub fn trans_tuple_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
20312031
_fields: &[ast::StructField],
20322032
ctor_id: ast::NodeId,
2033-
param_substs: &param_substs<'tcx>,
2033+
param_substs: &Substs<'tcx>,
20342034
llfndecl: ValueRef) {
20352035
let _icx = push_ctxt("trans_tuple_struct");
20362036

@@ -2045,10 +2045,10 @@ pub fn trans_tuple_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
20452045
fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
20462046
ctor_id: ast::NodeId,
20472047
disr: ty::Disr,
2048-
param_substs: &param_substs<'tcx>,
2048+
param_substs: &Substs<'tcx>,
20492049
llfndecl: ValueRef) {
20502050
let ctor_ty = ty::node_id_to_type(ccx.tcx(), ctor_id);
2051-
let ctor_ty = ctor_ty.substp(ccx.tcx(), param_substs);
2051+
let ctor_ty = ctor_ty.subst(ccx.tcx(), param_substs);
20522052

20532053
let result_ty = match ty::get(ctor_ty).sty {
20542054
ty::ty_bare_fn(ref bft) => bft.sig.output,
@@ -2264,15 +2264,15 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
22642264
&**body,
22652265
item.attrs.as_slice(),
22662266
llfn,
2267-
&param_substs::empty(),
2267+
&Substs::trans_empty(),
22682268
item.id,
22692269
None);
22702270
} else {
22712271
trans_fn(ccx,
22722272
&**decl,
22732273
&**body,
22742274
llfn,
2275-
&param_substs::empty(),
2275+
&Substs::trans_empty(),
22762276
item.id,
22772277
item.attrs.as_slice());
22782278
}

src/librustc_trans/trans/callee.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use llvm;
2929
use metadata::csearch;
3030
use middle::def;
3131
use middle::subst;
32-
use middle::subst::{Subst};
32+
use middle::subst::{Subst, Substs};
3333
use trans::adt;
3434
use trans::base;
3535
use trans::base::*;
@@ -319,7 +319,7 @@ pub fn trans_unboxing_shim<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
319319
function_name.as_slice());
320320

321321
let block_arena = TypedArena::new();
322-
let empty_param_substs = param_substs::empty();
322+
let empty_param_substs = Substs::trans_empty();
323323
let return_type = ty::ty_fn_ret(boxed_function_type);
324324
let fcx = new_fn_ctxt(ccx,
325325
llfn,

src/librustc_trans/trans/closure.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use back::link::mangle_internal_name_by_path_and_seq;
1515
use llvm::ValueRef;
1616
use middle::def;
1717
use middle::mem_categorization::Typer;
18+
use middle::subst::Substs;
1819
use trans::adt;
1920
use trans::base::*;
2021
use trans::build::*;
@@ -520,7 +521,7 @@ pub fn trans_unboxed_closure<'blk, 'tcx>(
520521
let llfn = get_or_create_declaration_if_unboxed_closure(
521522
bcx,
522523
closure_id,
523-
bcx.fcx.param_substs.substs()).unwrap();
524+
bcx.fcx.param_substs).unwrap();
524525

525526
let function_type = (*bcx.tcx().unboxed_closures.borrow())[closure_id]
526527
.closure_type
@@ -633,7 +634,7 @@ pub fn get_wrapper_for_bare_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
633634
let _icx = push_ctxt("closure::get_wrapper_for_bare_fn");
634635

635636
let arena = TypedArena::new();
636-
let empty_param_substs = param_substs::empty();
637+
let empty_param_substs = Substs::trans_empty();
637638
let fcx = new_fn_ctxt(ccx, llfn, ast::DUMMY_NODE_ID, true, f.sig.output,
638639
&empty_param_substs, None, &arena);
639640
let bcx = init_function(&fcx, true, f.sig.output);

src/librustc_trans/trans/common.rs

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use middle::def;
2222
use middle::lang_items::LangItem;
2323
use middle::mem_categorization as mc;
2424
use middle::subst;
25-
use middle::subst::Subst;
25+
use middle::subst::{Subst, Substs};
2626
use trans::base;
2727
use trans::build;
2828
use trans::cleanup;
@@ -189,50 +189,8 @@ pub fn BuilderRef_res(b: BuilderRef) -> BuilderRef_res {
189189

190190
pub type ExternMap = FnvHashMap<String, ValueRef>;
191191

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

238196
// work around bizarre resolve errors
@@ -292,7 +250,7 @@ pub struct FunctionContext<'a, 'tcx: 'a> {
292250

293251
// If this function is being monomorphized, this contains the type
294252
// substitutions used.
295-
pub param_substs: &'a param_substs<'tcx>,
253+
pub param_substs: &'a Substs<'tcx>,
296254

297255
// The source span and nesting context where this function comes from, for
298256
// error reporting and symbol generation.
@@ -792,7 +750,7 @@ pub fn is_null(val: ValueRef) -> bool {
792750
}
793751

794752
pub fn monomorphize_type<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, t: Ty<'tcx>) -> Ty<'tcx> {
795-
t.subst(bcx.tcx(), &bcx.fcx.param_substs.substs)
753+
t.subst(bcx.tcx(), bcx.fcx.param_substs)
796754
}
797755

798756
pub fn node_id_type<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, id: ast::NodeId) -> Ty<'tcx> {
@@ -950,7 +908,7 @@ pub fn node_id_substs<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
950908
}
951909

952910
let substs = substs.erase_regions();
953-
substs.substp(tcx, bcx.fcx.param_substs)
911+
substs.subst(tcx, bcx.fcx.param_substs)
954912
}
955913

956914
pub fn langcall(bcx: Block,

src/librustc_trans/trans/debuginfo.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ use llvm;
196196
use llvm::{ModuleRef, ContextRef, ValueRef};
197197
use llvm::debuginfo::*;
198198
use metadata::csearch;
199-
use middle::subst::{mod, Subst};
199+
use middle::subst::{mod, Subst, Substs};
200200
use trans::adt;
201201
use trans::common::*;
202202
use trans::machine;
@@ -1171,7 +1171,7 @@ pub fn start_emitting_source_locations(fcx: &FunctionContext) {
11711171
/// for the function.
11721172
pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
11731173
fn_ast_id: ast::NodeId,
1174-
param_substs: &param_substs<'tcx>,
1174+
param_substs: &Substs<'tcx>,
11751175
llfn: ValueRef) -> FunctionDebugContext {
11761176
if cx.sess().opts.debuginfo == NoDebugInfo {
11771177
return FunctionDebugContext { repr: DebugInfoDisabled };
@@ -1373,7 +1373,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
13731373
fn get_function_signature<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
13741374
fn_ast_id: ast::NodeId,
13751375
fn_decl: &ast::FnDecl,
1376-
param_substs: &param_substs<'tcx>,
1376+
param_substs: &Substs<'tcx>,
13771377
error_reporting_span: Span) -> DIArray {
13781378
if cx.sess().opts.debuginfo == LimitedDebugInfo {
13791379
return create_DIArray(DIB(cx), &[]);
@@ -1389,7 +1389,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
13891389
assert_type_for_node_id(cx, fn_ast_id, error_reporting_span);
13901390

13911391
let return_type = ty::node_id_to_type(cx.tcx(), fn_ast_id);
1392-
let return_type = return_type.substp(cx.tcx(), param_substs);
1392+
let return_type = return_type.subst(cx.tcx(), param_substs);
13931393
signature.push(type_metadata(cx, return_type, codemap::DUMMY_SP));
13941394
}
13951395
}
@@ -1398,7 +1398,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
13981398
for arg in fn_decl.inputs.iter() {
13991399
assert_type_for_node_id(cx, arg.pat.id, arg.pat.span);
14001400
let arg_type = ty::node_id_to_type(cx.tcx(), arg.pat.id);
1401-
let arg_type = arg_type.substp(cx.tcx(), param_substs);
1401+
let arg_type = arg_type.subst(cx.tcx(), param_substs);
14021402
signature.push(type_metadata(cx, arg_type, codemap::DUMMY_SP));
14031403
}
14041404

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

14081408
fn get_template_parameters<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
14091409
generics: &ast::Generics,
1410-
param_substs: &param_substs<'tcx>,
1410+
param_substs: &Substs<'tcx>,
14111411
file_metadata: DIFile,
14121412
name_to_append_suffix_to: &mut String)
14131413
-> DIArray {
1414-
let self_type = param_substs.substs().self_ty();
1414+
let self_type = param_substs.self_ty();
14151415

14161416
// Only true for static default methods:
14171417
let has_self_type = self_type.is_some();
@@ -1468,7 +1468,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
14681468
}
14691469

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

src/librustc_trans/trans/expr.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
333333
let trait_ref =
334334
Rc::new(ty::TraitRef { def_id: principal.def_id,
335335
substs: substs });
336-
let trait_ref =
337-
trait_ref.subst(bcx.tcx(), bcx.fcx.param_substs.substs());
336+
let trait_ref = trait_ref.subst(bcx.tcx(), bcx.fcx.param_substs);
338337
let box_ty = mk_ty(unsized_ty);
339338
PointerCast(bcx,
340339
meth::get_vtable(bcx, box_ty, trait_ref),
@@ -1121,8 +1120,7 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
11211120
.get(&expr.id)
11221121
.map(|t| (*t).clone())
11231122
.unwrap();
1124-
let trait_ref =
1125-
trait_ref.subst(bcx.tcx(), bcx.fcx.param_substs.substs());
1123+
let trait_ref = trait_ref.subst(bcx.tcx(), bcx.fcx.param_substs);
11261124
let datum = unpack_datum!(bcx, trans(bcx, &**val));
11271125
meth::trans_trait_cast(bcx, datum, expr.id,
11281126
trait_ref, dest)

src/librustc_trans/trans/foreign.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use trans::type_of::*;
2424
use 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};
@@ -531,13 +531,13 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
531531
body: &ast::Block,
532532
attrs: &[ast::Attribute],
533533
llwrapfn: ValueRef,
534-
param_substs: &param_substs<'tcx>,
534+
param_substs: &Substs<'tcx>,
535535
id: ast::NodeId,
536536
hash: Option<&str>) {
537537
let _icx = push_ctxt("foreign::build_foreign_fn");
538538

539539
let fnty = ty::node_id_to_type(ccx.tcx(), id);
540-
let mty = fnty.subst(ccx.tcx(), param_substs.substs());
540+
let mty = fnty.subst(ccx.tcx(), param_substs);
541541
let tys = foreign_types_for_fn_ty(ccx, mty);
542542

543543
unsafe { // unsafe because we call LLVM operations
@@ -551,15 +551,14 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
551551
fn build_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
552552
decl: &ast::FnDecl,
553553
body: &ast::Block,
554-
param_substs: &param_substs<'tcx>,
554+
param_substs: &Substs<'tcx>,
555555
attrs: &[ast::Attribute],
556556
id: ast::NodeId,
557557
hash: Option<&str>)
558558
-> ValueRef {
559559
let _icx = push_ctxt("foreign::foreign::build_rust_fn");
560560
let tcx = ccx.tcx();
561-
let t = ty::node_id_to_type(tcx, id).subst(
562-
ccx.tcx(), param_substs.substs());
561+
let t = ty::node_id_to_type(tcx, id).subst(ccx.tcx(), param_substs);
563562

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

0 commit comments

Comments
 (0)