rustc: fix fallout of making Ty
an alias for &TyS
instead of a wrapper.
This commit is contained in:
parent
5bc98954d5
commit
4c3ad48c45
@ -39,7 +39,7 @@ use middle::astencode;
|
||||
use middle::lang_items::{LangItem, ExchangeMallocFnLangItem, StartFnLangItem};
|
||||
use middle::subst;
|
||||
use middle::weak_lang_items;
|
||||
use middle::subst::Subst;
|
||||
use middle::subst::{Subst, Substs};
|
||||
use middle::ty::{mod, Ty};
|
||||
use session::config::{mod, NoDebugInfo, FullDebugInfo};
|
||||
use session::Session;
|
||||
@ -54,8 +54,8 @@ use trans::closure;
|
||||
use trans::common::{Block, C_bool, C_bytes_in_context, C_i32, C_integral};
|
||||
use trans::common::{C_null, C_struct_in_context, C_u64, C_u8, C_uint, C_undef};
|
||||
use trans::common::{CrateContext, ExternMap, FunctionContext};
|
||||
use trans::common::{NodeInfo, Result, SubstP};
|
||||
use trans::common::{node_id_type, param_substs, return_type_is_void};
|
||||
use trans::common::{NodeInfo, Result};
|
||||
use trans::common::{node_id_type, return_type_is_void};
|
||||
use trans::common::{tydesc_info, type_is_immediate};
|
||||
use trans::common::{type_is_zero_size, val_ty};
|
||||
use trans::common;
|
||||
@ -1422,11 +1422,11 @@ pub fn new_fn_ctxt<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>,
|
||||
id: ast::NodeId,
|
||||
has_env: bool,
|
||||
output_type: ty::FnOutput<'tcx>,
|
||||
param_substs: &'a param_substs<'tcx>,
|
||||
param_substs: &'a Substs<'tcx>,
|
||||
sp: Option<Span>,
|
||||
block_arena: &'a TypedArena<common::BlockS<'a, 'tcx>>)
|
||||
-> FunctionContext<'a, 'tcx> {
|
||||
param_substs.validate();
|
||||
common::validate_substs(param_substs);
|
||||
|
||||
debug!("new_fn_ctxt(path={}, id={}, param_substs={})",
|
||||
if id == -1 {
|
||||
@ -1438,7 +1438,7 @@ pub fn new_fn_ctxt<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>,
|
||||
|
||||
let uses_outptr = match output_type {
|
||||
ty::FnConverging(output_type) => {
|
||||
let substd_output_type = output_type.substp(ccx.tcx(), param_substs);
|
||||
let substd_output_type = output_type.subst(ccx.tcx(), param_substs);
|
||||
type_of::return_uses_outptr(ccx, substd_output_type)
|
||||
}
|
||||
ty::FnDiverging => false
|
||||
@ -1491,7 +1491,7 @@ pub fn init_function<'a, 'tcx>(fcx: &'a FunctionContext<'a, 'tcx>,
|
||||
if let ty::FnConverging(output_type) = output {
|
||||
// This shouldn't need to recompute the return type,
|
||||
// as new_fn_ctxt did it already.
|
||||
let substd_output_type = output_type.substp(fcx.ccx.tcx(), fcx.param_substs);
|
||||
let substd_output_type = output_type.subst(fcx.ccx.tcx(), fcx.param_substs);
|
||||
if !return_type_is_void(fcx.ccx, substd_output_type) {
|
||||
// If the function returns nil/bot, there is no real return
|
||||
// value, so do not set `llretslotptr`.
|
||||
@ -1712,7 +1712,7 @@ pub fn finish_fn<'blk, 'tcx>(fcx: &'blk FunctionContext<'blk, 'tcx>,
|
||||
|
||||
// This shouldn't need to recompute the return type,
|
||||
// as new_fn_ctxt did it already.
|
||||
let substd_retty = retty.substp(fcx.ccx.tcx(), fcx.param_substs);
|
||||
let substd_retty = retty.subst(fcx.ccx.tcx(), fcx.param_substs);
|
||||
build_return_block(fcx, ret_cx, substd_retty);
|
||||
|
||||
debuginfo::clear_source_location(fcx);
|
||||
@ -1788,7 +1788,7 @@ pub fn trans_closure<'a, 'b, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
decl: &ast::FnDecl,
|
||||
body: &ast::Block,
|
||||
llfndecl: ValueRef,
|
||||
param_substs: ¶m_substs<'tcx>,
|
||||
param_substs: &Substs<'tcx>,
|
||||
fn_ast_id: ast::NodeId,
|
||||
_attributes: &[ast::Attribute],
|
||||
output_type: ty::FnOutput<'tcx>,
|
||||
@ -1929,7 +1929,7 @@ pub fn trans_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
decl: &ast::FnDecl,
|
||||
body: &ast::Block,
|
||||
llfndecl: ValueRef,
|
||||
param_substs: ¶m_substs<'tcx>,
|
||||
param_substs: &Substs<'tcx>,
|
||||
id: ast::NodeId,
|
||||
attrs: &[ast::Attribute]) {
|
||||
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>,
|
||||
variant: &ast::Variant,
|
||||
_args: &[ast::VariantArg],
|
||||
disr: ty::Disr,
|
||||
param_substs: ¶m_substs<'tcx>,
|
||||
param_substs: &Substs<'tcx>,
|
||||
llfndecl: ValueRef) {
|
||||
let _icx = push_ctxt("trans_enum_variant");
|
||||
|
||||
@ -2030,7 +2030,7 @@ pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
pub fn trans_tuple_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
_fields: &[ast::StructField],
|
||||
ctor_id: ast::NodeId,
|
||||
param_substs: ¶m_substs<'tcx>,
|
||||
param_substs: &Substs<'tcx>,
|
||||
llfndecl: ValueRef) {
|
||||
let _icx = push_ctxt("trans_tuple_struct");
|
||||
|
||||
@ -2045,10 +2045,10 @@ pub fn trans_tuple_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
ctor_id: ast::NodeId,
|
||||
disr: ty::Disr,
|
||||
param_substs: ¶m_substs<'tcx>,
|
||||
param_substs: &Substs<'tcx>,
|
||||
llfndecl: ValueRef) {
|
||||
let ctor_ty = ty::node_id_to_type(ccx.tcx(), ctor_id);
|
||||
let ctor_ty = ctor_ty.substp(ccx.tcx(), param_substs);
|
||||
let ctor_ty = ctor_ty.subst(ccx.tcx(), param_substs);
|
||||
|
||||
let result_ty = match ty::get(ctor_ty).sty {
|
||||
ty::ty_bare_fn(ref bft) => bft.sig.output,
|
||||
@ -2264,7 +2264,7 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
|
||||
&**body,
|
||||
item.attrs.as_slice(),
|
||||
llfn,
|
||||
¶m_substs::empty(),
|
||||
&Substs::trans_empty(),
|
||||
item.id,
|
||||
None);
|
||||
} else {
|
||||
@ -2272,7 +2272,7 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
|
||||
&**decl,
|
||||
&**body,
|
||||
llfn,
|
||||
¶m_substs::empty(),
|
||||
&Substs::trans_empty(),
|
||||
item.id,
|
||||
item.attrs.as_slice());
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ use llvm;
|
||||
use metadata::csearch;
|
||||
use middle::def;
|
||||
use middle::subst;
|
||||
use middle::subst::{Subst};
|
||||
use middle::subst::{Subst, Substs};
|
||||
use trans::adt;
|
||||
use trans::base;
|
||||
use trans::base::*;
|
||||
@ -319,7 +319,7 @@ pub fn trans_unboxing_shim<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
function_name.as_slice());
|
||||
|
||||
let block_arena = TypedArena::new();
|
||||
let empty_param_substs = param_substs::empty();
|
||||
let empty_param_substs = Substs::trans_empty();
|
||||
let return_type = ty::ty_fn_ret(boxed_function_type);
|
||||
let fcx = new_fn_ctxt(ccx,
|
||||
llfn,
|
||||
|
@ -15,6 +15,7 @@ use back::link::mangle_internal_name_by_path_and_seq;
|
||||
use llvm::ValueRef;
|
||||
use middle::def;
|
||||
use middle::mem_categorization::Typer;
|
||||
use middle::subst::Substs;
|
||||
use trans::adt;
|
||||
use trans::base::*;
|
||||
use trans::build::*;
|
||||
@ -520,7 +521,7 @@ pub fn trans_unboxed_closure<'blk, 'tcx>(
|
||||
let llfn = get_or_create_declaration_if_unboxed_closure(
|
||||
bcx,
|
||||
closure_id,
|
||||
bcx.fcx.param_substs.substs()).unwrap();
|
||||
bcx.fcx.param_substs).unwrap();
|
||||
|
||||
let function_type = (*bcx.tcx().unboxed_closures.borrow())[closure_id]
|
||||
.closure_type
|
||||
@ -633,7 +634,7 @@ pub fn get_wrapper_for_bare_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
let _icx = push_ctxt("closure::get_wrapper_for_bare_fn");
|
||||
|
||||
let arena = TypedArena::new();
|
||||
let empty_param_substs = param_substs::empty();
|
||||
let empty_param_substs = Substs::trans_empty();
|
||||
let fcx = new_fn_ctxt(ccx, llfn, ast::DUMMY_NODE_ID, true, f.sig.output,
|
||||
&empty_param_substs, None, &arena);
|
||||
let bcx = init_function(&fcx, true, f.sig.output);
|
||||
|
@ -22,7 +22,7 @@ use middle::def;
|
||||
use middle::lang_items::LangItem;
|
||||
use middle::mem_categorization as mc;
|
||||
use middle::subst;
|
||||
use middle::subst::Subst;
|
||||
use middle::subst::{Subst, Substs};
|
||||
use trans::base;
|
||||
use trans::build;
|
||||
use trans::cleanup;
|
||||
@ -189,50 +189,8 @@ pub fn BuilderRef_res(b: BuilderRef) -> BuilderRef_res {
|
||||
|
||||
pub type ExternMap = FnvHashMap<String, ValueRef>;
|
||||
|
||||
// Here `self_ty` is the real type of the self parameter to this method. It
|
||||
// will only be set in the case of default methods.
|
||||
pub struct param_substs<'tcx> {
|
||||
substs: subst::Substs<'tcx>,
|
||||
}
|
||||
|
||||
impl<'tcx> param_substs<'tcx> {
|
||||
pub fn new(substs: subst::Substs<'tcx>) -> param_substs<'tcx> {
|
||||
assert!(substs.types.all(|t| !ty::type_needs_infer(*t)));
|
||||
assert!(substs.types.all(|t| !ty::type_has_params(*t)));
|
||||
assert!(substs.types.all(|t| !ty::type_has_escaping_regions(*t)));
|
||||
param_substs { substs: substs.erase_regions() }
|
||||
}
|
||||
|
||||
pub fn substs(&self) -> &subst::Substs<'tcx> {
|
||||
&self.substs
|
||||
}
|
||||
|
||||
pub fn empty() -> param_substs<'tcx> {
|
||||
param_substs {
|
||||
substs: subst::Substs::trans_empty(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn validate(&self) {
|
||||
assert!(self.substs.types.all(|t| !ty::type_needs_infer(*t)));
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for param_substs<'tcx> {
|
||||
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
|
||||
self.substs.repr(tcx)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait SubstP<'tcx> {
|
||||
fn substp(&self, tcx: &ty::ctxt<'tcx>, param_substs: ¶m_substs<'tcx>)
|
||||
-> Self;
|
||||
}
|
||||
|
||||
impl<'tcx, T: Subst<'tcx> + Clone> SubstP<'tcx> for T {
|
||||
fn substp(&self, tcx: &ty::ctxt<'tcx>, substs: ¶m_substs<'tcx>) -> T {
|
||||
self.subst(tcx, &substs.substs)
|
||||
}
|
||||
pub fn validate_substs(substs: &Substs) {
|
||||
assert!(substs.types.all(|t| !ty::type_needs_infer(*t)));
|
||||
}
|
||||
|
||||
// work around bizarre resolve errors
|
||||
@ -292,7 +250,7 @@ pub struct FunctionContext<'a, 'tcx: 'a> {
|
||||
|
||||
// If this function is being monomorphized, this contains the type
|
||||
// substitutions used.
|
||||
pub param_substs: &'a param_substs<'tcx>,
|
||||
pub param_substs: &'a Substs<'tcx>,
|
||||
|
||||
// The source span and nesting context where this function comes from, for
|
||||
// error reporting and symbol generation.
|
||||
@ -792,7 +750,7 @@ pub fn is_null(val: ValueRef) -> bool {
|
||||
}
|
||||
|
||||
pub fn monomorphize_type<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, t: Ty<'tcx>) -> Ty<'tcx> {
|
||||
t.subst(bcx.tcx(), &bcx.fcx.param_substs.substs)
|
||||
t.subst(bcx.tcx(), bcx.fcx.param_substs)
|
||||
}
|
||||
|
||||
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>,
|
||||
}
|
||||
|
||||
let substs = substs.erase_regions();
|
||||
substs.substp(tcx, bcx.fcx.param_substs)
|
||||
substs.subst(tcx, bcx.fcx.param_substs)
|
||||
}
|
||||
|
||||
pub fn langcall(bcx: Block,
|
||||
|
@ -196,7 +196,7 @@ use llvm;
|
||||
use llvm::{ModuleRef, ContextRef, ValueRef};
|
||||
use llvm::debuginfo::*;
|
||||
use metadata::csearch;
|
||||
use middle::subst::{mod, Subst};
|
||||
use middle::subst::{mod, Subst, Substs};
|
||||
use trans::adt;
|
||||
use trans::common::*;
|
||||
use trans::machine;
|
||||
@ -1171,7 +1171,7 @@ pub fn start_emitting_source_locations(fcx: &FunctionContext) {
|
||||
/// for the function.
|
||||
pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
fn_ast_id: ast::NodeId,
|
||||
param_substs: ¶m_substs<'tcx>,
|
||||
param_substs: &Substs<'tcx>,
|
||||
llfn: ValueRef) -> FunctionDebugContext {
|
||||
if cx.sess().opts.debuginfo == NoDebugInfo {
|
||||
return FunctionDebugContext { repr: DebugInfoDisabled };
|
||||
@ -1373,7 +1373,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
fn get_function_signature<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
fn_ast_id: ast::NodeId,
|
||||
fn_decl: &ast::FnDecl,
|
||||
param_substs: ¶m_substs<'tcx>,
|
||||
param_substs: &Substs<'tcx>,
|
||||
error_reporting_span: Span) -> DIArray {
|
||||
if cx.sess().opts.debuginfo == LimitedDebugInfo {
|
||||
return create_DIArray(DIB(cx), &[]);
|
||||
@ -1389,7 +1389,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
assert_type_for_node_id(cx, fn_ast_id, error_reporting_span);
|
||||
|
||||
let return_type = ty::node_id_to_type(cx.tcx(), fn_ast_id);
|
||||
let return_type = return_type.substp(cx.tcx(), param_substs);
|
||||
let return_type = return_type.subst(cx.tcx(), param_substs);
|
||||
signature.push(type_metadata(cx, return_type, codemap::DUMMY_SP));
|
||||
}
|
||||
}
|
||||
@ -1398,7 +1398,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
for arg in fn_decl.inputs.iter() {
|
||||
assert_type_for_node_id(cx, arg.pat.id, arg.pat.span);
|
||||
let arg_type = ty::node_id_to_type(cx.tcx(), arg.pat.id);
|
||||
let arg_type = arg_type.substp(cx.tcx(), param_substs);
|
||||
let arg_type = arg_type.subst(cx.tcx(), param_substs);
|
||||
signature.push(type_metadata(cx, arg_type, codemap::DUMMY_SP));
|
||||
}
|
||||
|
||||
@ -1407,11 +1407,11 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
|
||||
fn get_template_parameters<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
generics: &ast::Generics,
|
||||
param_substs: ¶m_substs<'tcx>,
|
||||
param_substs: &Substs<'tcx>,
|
||||
file_metadata: DIFile,
|
||||
name_to_append_suffix_to: &mut String)
|
||||
-> DIArray {
|
||||
let self_type = param_substs.substs().self_ty();
|
||||
let self_type = param_substs.self_ty();
|
||||
|
||||
// Only true for static default methods:
|
||||
let has_self_type = self_type.is_some();
|
||||
@ -1468,7 +1468,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
}
|
||||
|
||||
// Handle other generic parameters
|
||||
let actual_types = param_substs.substs().types.get_slice(subst::FnSpace);
|
||||
let actual_types = param_substs.types.get_slice(subst::FnSpace);
|
||||
for (index, &ast::TyParam{ ident, .. }) in generics.ty_params.iter().enumerate() {
|
||||
let actual_type = actual_types[index];
|
||||
// Add actual type name to <...> clause of function name
|
||||
|
@ -333,8 +333,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
let trait_ref =
|
||||
Rc::new(ty::TraitRef { def_id: principal.def_id,
|
||||
substs: substs });
|
||||
let trait_ref =
|
||||
trait_ref.subst(bcx.tcx(), bcx.fcx.param_substs.substs());
|
||||
let trait_ref = trait_ref.subst(bcx.tcx(), bcx.fcx.param_substs);
|
||||
let box_ty = mk_ty(unsized_ty);
|
||||
PointerCast(bcx,
|
||||
meth::get_vtable(bcx, box_ty, trait_ref),
|
||||
@ -1121,8 +1120,7 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
.get(&expr.id)
|
||||
.map(|t| (*t).clone())
|
||||
.unwrap();
|
||||
let trait_ref =
|
||||
trait_ref.subst(bcx.tcx(), bcx.fcx.param_substs.substs());
|
||||
let trait_ref = trait_ref.subst(bcx.tcx(), bcx.fcx.param_substs);
|
||||
let datum = unpack_datum!(bcx, trans(bcx, &**val));
|
||||
meth::trans_trait_cast(bcx, datum, expr.id,
|
||||
trait_ref, dest)
|
||||
|
@ -24,7 +24,7 @@ use trans::type_of::*;
|
||||
use trans::type_of;
|
||||
use middle::ty::FnSig;
|
||||
use middle::ty::{mod, Ty};
|
||||
use middle::subst::Subst;
|
||||
use middle::subst::{Subst, Substs};
|
||||
use std::cmp;
|
||||
use libc::c_uint;
|
||||
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>,
|
||||
body: &ast::Block,
|
||||
attrs: &[ast::Attribute],
|
||||
llwrapfn: ValueRef,
|
||||
param_substs: ¶m_substs<'tcx>,
|
||||
param_substs: &Substs<'tcx>,
|
||||
id: ast::NodeId,
|
||||
hash: Option<&str>) {
|
||||
let _icx = push_ctxt("foreign::build_foreign_fn");
|
||||
|
||||
let fnty = ty::node_id_to_type(ccx.tcx(), id);
|
||||
let mty = fnty.subst(ccx.tcx(), param_substs.substs());
|
||||
let mty = fnty.subst(ccx.tcx(), param_substs);
|
||||
let tys = foreign_types_for_fn_ty(ccx, mty);
|
||||
|
||||
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>,
|
||||
fn build_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
decl: &ast::FnDecl,
|
||||
body: &ast::Block,
|
||||
param_substs: ¶m_substs<'tcx>,
|
||||
param_substs: &Substs<'tcx>,
|
||||
attrs: &[ast::Attribute],
|
||||
id: ast::NodeId,
|
||||
hash: Option<&str>)
|
||||
-> ValueRef {
|
||||
let _icx = push_ctxt("foreign::foreign::build_rust_fn");
|
||||
let tcx = ccx.tcx();
|
||||
let t = ty::node_id_to_type(tcx, id).subst(
|
||||
ccx.tcx(), param_substs.substs());
|
||||
let t = ty::node_id_to_type(tcx, id).subst(ccx.tcx(), param_substs);
|
||||
|
||||
let ps = ccx.tcx().map.with_path(id, |path| {
|
||||
let abi = Some(ast_map::PathName(special_idents::clownshoe_abi.name));
|
||||
|
@ -19,7 +19,7 @@ use llvm::{ValueRef, True, get_param};
|
||||
use llvm;
|
||||
use middle::lang_items::ExchangeFreeFnLangItem;
|
||||
use middle::subst;
|
||||
use middle::subst::Subst;
|
||||
use middle::subst::{Subst, Substs};
|
||||
use trans::adt;
|
||||
use trans::base::*;
|
||||
use trans::build::*;
|
||||
@ -541,7 +541,7 @@ fn make_generic_glue<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
let _s = StatRecorder::new(ccx, glue_name);
|
||||
|
||||
let arena = TypedArena::new();
|
||||
let empty_param_substs = param_substs::empty();
|
||||
let empty_param_substs = Substs::trans_empty();
|
||||
let fcx = new_fn_ctxt(ccx, llfn, ast::DUMMY_NODE_ID, false,
|
||||
ty::FnConverging(ty::mk_nil(ccx.tcx())),
|
||||
&empty_param_substs, None, &arena);
|
||||
|
@ -11,6 +11,7 @@
|
||||
use llvm::{AvailableExternallyLinkage, InternalLinkage, SetLinkage};
|
||||
use metadata::csearch;
|
||||
use middle::astencode;
|
||||
use middle::subst::Substs;
|
||||
use trans::base::{push_ctxt, trans_item, get_item_val, trans_fn};
|
||||
use trans::common::*;
|
||||
use middle::ty;
|
||||
@ -164,7 +165,7 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId)
|
||||
&*mth.pe_fn_decl(),
|
||||
&*mth.pe_body(),
|
||||
llfn,
|
||||
¶m_substs::empty(),
|
||||
&Substs::trans_empty(),
|
||||
mth.id,
|
||||
&[]);
|
||||
// Use InternalLinkage so LLVM can optimize more
|
||||
|
@ -87,7 +87,7 @@ pub fn trans_impl(ccx: &CrateContext,
|
||||
method.pe_fn_decl(),
|
||||
method.pe_body(),
|
||||
llfn,
|
||||
¶m_substs::empty(),
|
||||
&Substs::trans_empty(),
|
||||
method.id,
|
||||
&[]);
|
||||
update_linkage(ccx,
|
||||
@ -136,8 +136,7 @@ pub fn trans_method_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
method_num
|
||||
}) => {
|
||||
let trait_ref =
|
||||
Rc::new(trait_ref.subst(bcx.tcx(),
|
||||
bcx.fcx.param_substs.substs()));
|
||||
Rc::new(trait_ref.subst(bcx.tcx(), bcx.fcx.param_substs));
|
||||
let span = bcx.tcx().map.span(method_call.expr_id);
|
||||
debug!("method_call={} trait_ref={}",
|
||||
method_call,
|
||||
|
@ -32,7 +32,7 @@ use std::hash::{sip, Hash};
|
||||
|
||||
pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
fn_id: ast::DefId,
|
||||
real_substs: &subst::Substs<'tcx>,
|
||||
psubsts: &subst::Substs<'tcx>,
|
||||
ref_id: Option<ast::NodeId>)
|
||||
-> (ValueRef, bool) {
|
||||
debug!("monomorphic_fn(\
|
||||
@ -40,10 +40,10 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
real_substs={}, \
|
||||
ref_id={})",
|
||||
fn_id.repr(ccx.tcx()),
|
||||
real_substs.repr(ccx.tcx()),
|
||||
psubsts.repr(ccx.tcx()),
|
||||
ref_id);
|
||||
|
||||
assert!(real_substs.types.all(|t| {
|
||||
assert!(psubsts.types.all(|t| {
|
||||
!ty::type_needs_infer(*t) && !ty::type_has_params(*t)
|
||||
}));
|
||||
|
||||
@ -51,7 +51,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
|
||||
let hash_id = MonoId {
|
||||
def: fn_id,
|
||||
params: real_substs.types.clone()
|
||||
params: psubsts.types.clone()
|
||||
};
|
||||
|
||||
match ccx.monomorphized().borrow().get(&hash_id) {
|
||||
@ -63,9 +63,6 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
None => ()
|
||||
}
|
||||
|
||||
debug!("creating param_substs with real_substs={}", real_substs.repr(ccx.tcx()));
|
||||
let psubsts = param_substs::new((*real_substs).clone());
|
||||
|
||||
debug!("monomorphic_fn(\
|
||||
fn_id={}, \
|
||||
psubsts={}, \
|
||||
@ -98,7 +95,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
}
|
||||
|
||||
debug!("monomorphic_fn about to subst into {}", llitem_ty.repr(ccx.tcx()));
|
||||
let mono_ty = llitem_ty.subst(ccx.tcx(), real_substs);
|
||||
let mono_ty = llitem_ty.subst(ccx.tcx(), psubsts);
|
||||
|
||||
ccx.stats().n_monos.set(ccx.stats().n_monos.get() + 1);
|
||||
|
||||
@ -178,10 +175,10 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
if needs_body {
|
||||
if abi != abi::Rust {
|
||||
foreign::trans_rust_fn_with_foreign_abi(
|
||||
ccx, &**decl, &**body, &[], d, &psubsts, fn_id.node,
|
||||
ccx, &**decl, &**body, &[], d, psubsts, fn_id.node,
|
||||
Some(hash.as_slice()));
|
||||
} else {
|
||||
trans_fn(ccx, &**decl, &**body, d, &psubsts, fn_id.node, &[]);
|
||||
trans_fn(ccx, &**decl, &**body, d, psubsts, fn_id.node, &[]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -205,7 +202,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
&*v,
|
||||
args.as_slice(),
|
||||
this_tv.disr_val,
|
||||
&psubsts,
|
||||
psubsts,
|
||||
d);
|
||||
}
|
||||
ast::StructVariantKind(_) =>
|
||||
@ -223,7 +220,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
mth.pe_fn_decl(),
|
||||
mth.pe_body(),
|
||||
d,
|
||||
&psubsts,
|
||||
psubsts,
|
||||
mth.id,
|
||||
&[]);
|
||||
}
|
||||
@ -241,7 +238,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
let needs_body = setup_lldecl(d, mth.attrs.as_slice());
|
||||
if needs_body {
|
||||
trans_fn(ccx, mth.pe_fn_decl(), mth.pe_body(), d,
|
||||
&psubsts, mth.id, &[]);
|
||||
psubsts, mth.id, &[]);
|
||||
}
|
||||
d
|
||||
}
|
||||
@ -258,7 +255,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
struct_def.fields.as_slice(),
|
||||
struct_def.ctor_id.expect("ast-mapped tuple struct \
|
||||
didn't have a ctor id"),
|
||||
&psubsts,
|
||||
psubsts,
|
||||
d);
|
||||
d
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user