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