mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 07:44:10 +00:00
rustc: de-@ param_substs.
This commit is contained in:
parent
7b3d6afe0a
commit
3fbc57894a
@ -1112,7 +1112,7 @@ pub fn new_fn_ctxt<'a>(ccx: &'a CrateContext,
|
||||
id: ast::NodeId,
|
||||
has_env: bool,
|
||||
output_type: ty::t,
|
||||
param_substs: Option<@param_substs>,
|
||||
param_substs: Option<&'a param_substs>,
|
||||
sp: Option<Span>,
|
||||
block_arena: &'a TypedArena<Block<'a>>)
|
||||
-> FunctionContext<'a> {
|
||||
@ -1120,7 +1120,7 @@ pub fn new_fn_ctxt<'a>(ccx: &'a CrateContext,
|
||||
|
||||
debug!("new_fn_ctxt(path={}, id={}, param_substs={})",
|
||||
if id == -1 { "".to_owned() } else { ccx.tcx.map.path_to_str(id) },
|
||||
id, param_substs.repr(ccx.tcx()));
|
||||
id, param_substs.map(|s| s.repr(ccx.tcx())));
|
||||
|
||||
let substd_output_type = match param_substs {
|
||||
None => output_type,
|
||||
@ -1166,11 +1166,9 @@ pub fn new_fn_ctxt<'a>(ccx: &'a CrateContext,
|
||||
|
||||
/// Performs setup on a newly created function, creating the entry scope block
|
||||
/// and allocating space for the return pointer.
|
||||
pub fn init_function<'a>(
|
||||
fcx: &'a FunctionContext<'a>,
|
||||
skip_retptr: bool,
|
||||
output_type: ty::t,
|
||||
param_substs: Option<@param_substs>) {
|
||||
pub fn init_function<'a>(fcx: &'a FunctionContext<'a>,
|
||||
skip_retptr: bool,
|
||||
output_type: ty::t) {
|
||||
let entry_bcx = fcx.new_temp_block("entry-block");
|
||||
|
||||
*fcx.entry_bcx.borrow_mut() = Some(entry_bcx);
|
||||
@ -1182,7 +1180,9 @@ pub fn init_function<'a>(
|
||||
llvm::LLVMGetFirstInstruction(entry_bcx.llbb)
|
||||
}));
|
||||
|
||||
let substd_output_type = match param_substs {
|
||||
// This shouldn't need to recompute the return type,
|
||||
// as new_fn_ctxt did it already.
|
||||
let substd_output_type = match fcx.param_substs {
|
||||
None => output_type,
|
||||
Some(substs) => {
|
||||
ty::subst_tps(fcx.ccx.tcx(),
|
||||
@ -1329,7 +1329,7 @@ pub fn trans_closure(ccx: &CrateContext,
|
||||
decl: &ast::FnDecl,
|
||||
body: &ast::Block,
|
||||
llfndecl: ValueRef,
|
||||
param_substs: Option<@param_substs>,
|
||||
param_substs: Option<¶m_substs>,
|
||||
id: ast::NodeId,
|
||||
_attributes: &[ast::Attribute],
|
||||
output_type: ty::t,
|
||||
@ -1340,7 +1340,7 @@ pub fn trans_closure(ccx: &CrateContext,
|
||||
set_uwtable(llfndecl);
|
||||
|
||||
debug!("trans_closure(..., param_substs={})",
|
||||
param_substs.repr(ccx.tcx()));
|
||||
param_substs.map(|s| s.repr(ccx.tcx())));
|
||||
|
||||
let has_env = match ty::get(ty::node_id_to_type(ccx.tcx(), id)).sty {
|
||||
ty::ty_closure(_) => true,
|
||||
@ -1353,10 +1353,10 @@ pub fn trans_closure(ccx: &CrateContext,
|
||||
id,
|
||||
has_env,
|
||||
output_type,
|
||||
param_substs,
|
||||
param_substs.map(|s| &*s),
|
||||
Some(body.span),
|
||||
&arena);
|
||||
init_function(&fcx, false, output_type, param_substs);
|
||||
init_function(&fcx, false, output_type);
|
||||
|
||||
// cleanup scope for the incoming arguments
|
||||
let arg_scope = fcx.push_custom_cleanup_scope();
|
||||
@ -1429,11 +1429,11 @@ pub fn trans_fn(ccx: &CrateContext,
|
||||
decl: &ast::FnDecl,
|
||||
body: &ast::Block,
|
||||
llfndecl: ValueRef,
|
||||
param_substs: Option<@param_substs>,
|
||||
param_substs: Option<¶m_substs>,
|
||||
id: ast::NodeId,
|
||||
attrs: &[ast::Attribute]) {
|
||||
let _s = StatRecorder::new(ccx, ccx.tcx.map.path_to_str(id));
|
||||
debug!("trans_fn(param_substs={})", param_substs.repr(ccx.tcx()));
|
||||
debug!("trans_fn(param_substs={})", param_substs.map(|s| s.repr(ccx.tcx())));
|
||||
let _icx = push_ctxt("trans_fn");
|
||||
let output_type = ty::ty_fn_ret(ty::node_id_to_type(ccx.tcx(), id));
|
||||
trans_closure(ccx, decl, body, llfndecl,
|
||||
@ -1445,7 +1445,7 @@ pub fn trans_enum_variant(ccx: &CrateContext,
|
||||
variant: &ast::Variant,
|
||||
_args: &[ast::VariantArg],
|
||||
disr: ty::Disr,
|
||||
param_substs: Option<@param_substs>,
|
||||
param_substs: Option<¶m_substs>,
|
||||
llfndecl: ValueRef) {
|
||||
let _icx = push_ctxt("trans_enum_variant");
|
||||
|
||||
@ -1460,7 +1460,7 @@ pub fn trans_enum_variant(ccx: &CrateContext,
|
||||
pub fn trans_tuple_struct(ccx: &CrateContext,
|
||||
_fields: &[ast::StructField],
|
||||
ctor_id: ast::NodeId,
|
||||
param_substs: Option<@param_substs>,
|
||||
param_substs: Option<¶m_substs>,
|
||||
llfndecl: ValueRef) {
|
||||
let _icx = push_ctxt("trans_tuple_struct");
|
||||
|
||||
@ -1475,24 +1475,20 @@ pub fn trans_tuple_struct(ccx: &CrateContext,
|
||||
fn trans_enum_variant_or_tuple_like_struct(ccx: &CrateContext,
|
||||
ctor_id: ast::NodeId,
|
||||
disr: ty::Disr,
|
||||
param_substs: Option<@param_substs>,
|
||||
param_substs: Option<¶m_substs>,
|
||||
llfndecl: ValueRef) {
|
||||
let no_substs: &[ty::t] = [];
|
||||
let ty_param_substs = match param_substs {
|
||||
Some(ref substs) => {
|
||||
let v: &[ty::t] = substs.tys.as_slice();
|
||||
v
|
||||
}
|
||||
None => {
|
||||
let v: &[ty::t] = no_substs;
|
||||
v
|
||||
}
|
||||
};
|
||||
let ctor_ty = {
|
||||
let no_substs: &[ty::t] = [];
|
||||
let ty_param_substs: &[ty::t] = match param_substs {
|
||||
Some(substs) => substs.tys.as_slice(),
|
||||
None => no_substs
|
||||
};
|
||||
|
||||
let ctor_ty = ty::subst_tps(ccx.tcx(),
|
||||
ty_param_substs,
|
||||
None,
|
||||
ty::node_id_to_type(ccx.tcx(), ctor_id));
|
||||
ty::subst_tps(ccx.tcx(),
|
||||
ty_param_substs,
|
||||
None,
|
||||
ty::node_id_to_type(ccx.tcx(), ctor_id))
|
||||
};
|
||||
|
||||
let result_ty = match ty::get(ctor_ty).sty {
|
||||
ty::ty_bare_fn(ref bft) => bft.sig.output,
|
||||
@ -1504,8 +1500,8 @@ fn trans_enum_variant_or_tuple_like_struct(ccx: &CrateContext,
|
||||
|
||||
let arena = TypedArena::new();
|
||||
let fcx = new_fn_ctxt(ccx, llfndecl, ctor_id, false, result_ty,
|
||||
param_substs, None, &arena);
|
||||
init_function(&fcx, false, result_ty, param_substs);
|
||||
param_substs.map(|s| &*s), None, &arena);
|
||||
init_function(&fcx, false, result_ty);
|
||||
|
||||
let arg_tys = ty::ty_fn_args(ctor_ty);
|
||||
|
||||
|
@ -203,15 +203,15 @@ fn resolve_default_method_vtables(bcx: &Block,
|
||||
|
||||
// Build up a param_substs that we are going to resolve the
|
||||
// trait_vtables under.
|
||||
let param_substs = Some(@param_substs {
|
||||
let param_substs = param_substs {
|
||||
tys: substs.tps.clone(),
|
||||
self_ty: substs.self_ty,
|
||||
vtables: impl_vtables.clone(),
|
||||
self_vtables: None
|
||||
});
|
||||
};
|
||||
|
||||
let mut param_vtables = resolve_vtables_under_param_substs(
|
||||
bcx.tcx(), param_substs, impl_res.trait_vtables.as_slice());
|
||||
bcx.tcx(), Some(¶m_substs), impl_res.trait_vtables.as_slice());
|
||||
|
||||
// Now we pull any vtables for parameters on the actual method.
|
||||
let num_method_vtables = method.generics.type_param_defs().len();
|
||||
@ -231,7 +231,7 @@ fn resolve_default_method_vtables(bcx: &Block,
|
||||
}
|
||||
|
||||
let self_vtables = resolve_param_vtables_under_param_substs(
|
||||
bcx.tcx(), param_substs, impl_res.self_vtables.as_slice());
|
||||
bcx.tcx(), Some(¶m_substs), impl_res.self_vtables.as_slice());
|
||||
|
||||
(param_vtables, self_vtables)
|
||||
}
|
||||
|
@ -466,7 +466,7 @@ pub fn get_wrapper_for_bare_fn(ccx: &CrateContext,
|
||||
|
||||
let arena = TypedArena::new();
|
||||
let fcx = new_fn_ctxt(ccx, llfn, -1, true, f.sig.output, None, None, &arena);
|
||||
init_function(&fcx, true, f.sig.output, None);
|
||||
init_function(&fcx, true, f.sig.output);
|
||||
let bcx = fcx.entry_bcx.borrow().clone().unwrap();
|
||||
|
||||
let args = create_datums_for_fn_args(&fcx,
|
||||
|
@ -274,7 +274,7 @@ pub struct FunctionContext<'a> {
|
||||
|
||||
// If this function is being monomorphized, this contains the type
|
||||
// substitutions used.
|
||||
pub param_substs: Option<@param_substs>,
|
||||
pub param_substs: Option<&'a param_substs>,
|
||||
|
||||
// The source span and nesting context where this function comes from, for
|
||||
// error reporting and symbol generation.
|
||||
@ -688,7 +688,7 @@ pub fn is_null(val: ValueRef) -> bool {
|
||||
|
||||
pub fn monomorphize_type(bcx: &Block, t: ty::t) -> ty::t {
|
||||
match bcx.fcx.param_substs {
|
||||
Some(substs) => {
|
||||
Some(ref substs) => {
|
||||
ty::subst_tps(bcx.tcx(), substs.tys.as_slice(), substs.self_ty, t)
|
||||
}
|
||||
_ => {
|
||||
@ -742,12 +742,12 @@ pub fn node_id_type_params(bcx: &Block, node: ExprOrMethodCall) -> Vec<ty::t> {
|
||||
}
|
||||
|
||||
match bcx.fcx.param_substs {
|
||||
Some(substs) => {
|
||||
params.iter().map(|t| {
|
||||
ty::subst_tps(tcx, substs.tys.as_slice(), substs.self_ty, *t)
|
||||
}).collect()
|
||||
}
|
||||
_ => params
|
||||
Some(ref substs) => {
|
||||
params.iter().map(|t| {
|
||||
ty::subst_tps(tcx, substs.tys.as_slice(), substs.self_ty, *t)
|
||||
}).collect()
|
||||
}
|
||||
_ => params
|
||||
}
|
||||
}
|
||||
|
||||
@ -769,7 +769,7 @@ pub fn resolve_vtables_in_fn_ctxt(fcx: &FunctionContext,
|
||||
}
|
||||
|
||||
pub fn resolve_vtables_under_param_substs(tcx: &ty::ctxt,
|
||||
param_substs: Option<@param_substs>,
|
||||
param_substs: Option<¶m_substs>,
|
||||
vts: &[typeck::vtable_param_res])
|
||||
-> typeck::vtable_res {
|
||||
vts.iter().map(|ds| {
|
||||
@ -781,7 +781,7 @@ pub fn resolve_vtables_under_param_substs(tcx: &ty::ctxt,
|
||||
|
||||
pub fn resolve_param_vtables_under_param_substs(
|
||||
tcx: &ty::ctxt,
|
||||
param_substs: Option<@param_substs>,
|
||||
param_substs: Option<¶m_substs>,
|
||||
ds: &[typeck::vtable_origin])
|
||||
-> typeck::vtable_param_res {
|
||||
ds.iter().map(|d| {
|
||||
@ -794,7 +794,7 @@ pub fn resolve_param_vtables_under_param_substs(
|
||||
|
||||
|
||||
pub fn resolve_vtable_under_param_substs(tcx: &ty::ctxt,
|
||||
param_substs: Option<@param_substs>,
|
||||
param_substs: Option<¶m_substs>,
|
||||
vt: &typeck::vtable_origin)
|
||||
-> typeck::vtable_origin {
|
||||
match *vt {
|
||||
|
@ -609,7 +609,7 @@ pub fn start_emitting_source_locations(fcx: &FunctionContext) {
|
||||
/// indicates why no debuginfo should be created for the function.
|
||||
pub fn create_function_debug_context(cx: &CrateContext,
|
||||
fn_ast_id: ast::NodeId,
|
||||
param_substs: Option<@param_substs>,
|
||||
param_substs: Option<¶m_substs>,
|
||||
llfn: ValueRef) -> FunctionDebugContext {
|
||||
if cx.sess().opts.debuginfo == NoDebugInfo {
|
||||
return FunctionDebugContext { repr: DebugInfoDisabled };
|
||||
@ -775,7 +775,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
|
||||
fn get_function_signature(cx: &CrateContext,
|
||||
fn_ast_id: ast::NodeId,
|
||||
fn_decl: &ast::FnDecl,
|
||||
param_substs: Option<@param_substs>,
|
||||
param_substs: Option<¶m_substs>,
|
||||
error_span: Span) -> DIArray {
|
||||
if cx.sess().opts.debuginfo == LimitedDebugInfo {
|
||||
return create_DIArray(DIB(cx), []);
|
||||
@ -828,7 +828,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
|
||||
|
||||
fn get_template_parameters(cx: &CrateContext,
|
||||
generics: &ast::Generics,
|
||||
param_substs: Option<@param_substs>,
|
||||
param_substs: Option<¶m_substs>,
|
||||
file_metadata: DIFile,
|
||||
name_to_append_suffix_to: &mut StrBuf)
|
||||
-> DIArray {
|
||||
|
@ -466,7 +466,7 @@ fn make_generic_glue(ccx: &CrateContext,
|
||||
let arena = TypedArena::new();
|
||||
let fcx = new_fn_ctxt(ccx, llfn, -1, false, ty::mk_nil(), None, None, &arena);
|
||||
|
||||
init_function(&fcx, false, ty::mk_nil(), None);
|
||||
init_function(&fcx, false, ty::mk_nil());
|
||||
|
||||
lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage);
|
||||
ccx.stats.n_glues_created.set(ccx.stats.n_glues_created.get() + 1u);
|
||||
|
@ -85,7 +85,7 @@ pub fn get_simple_intrinsic(ccx: &CrateContext, item: &ast::ForeignItem) -> Opti
|
||||
pub fn trans_intrinsic(ccx: &CrateContext,
|
||||
decl: ValueRef,
|
||||
item: &ast::ForeignItem,
|
||||
substs: @param_substs,
|
||||
substs: ¶m_substs,
|
||||
ref_id: Option<ast::NodeId>) {
|
||||
debug!("trans_intrinsic(item.ident={})", token::get_ident(item.ident));
|
||||
|
||||
@ -194,8 +194,8 @@ pub fn trans_intrinsic(ccx: &CrateContext,
|
||||
|
||||
let arena = TypedArena::new();
|
||||
let fcx = new_fn_ctxt(ccx, decl, item.id, false, output_type,
|
||||
Some(substs), Some(item.span), &arena);
|
||||
init_function(&fcx, true, output_type, Some(substs));
|
||||
Some(&*substs), Some(item.span), &arena);
|
||||
init_function(&fcx, true, output_type);
|
||||
|
||||
set_always_inline(fcx.llfn);
|
||||
|
||||
|
@ -84,7 +84,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
|
||||
None => ()
|
||||
}
|
||||
|
||||
let psubsts = @param_substs {
|
||||
let psubsts = param_substs {
|
||||
tys: real_substs.tps.clone(),
|
||||
vtables: vtables,
|
||||
self_ty: real_substs.self_ty.clone(),
|
||||
@ -221,7 +221,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
|
||||
} => {
|
||||
let d = mk_lldecl();
|
||||
set_llvm_fn_attrs(i.attrs.as_slice(), d);
|
||||
trans_fn(ccx, decl, body, d, Some(psubsts), fn_id.node, []);
|
||||
trans_fn(ccx, decl, body, d, Some(&psubsts), fn_id.node, []);
|
||||
d
|
||||
}
|
||||
_ => {
|
||||
@ -235,7 +235,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
|
||||
Some(decl) => decl,
|
||||
None => {
|
||||
let d = mk_lldecl();
|
||||
intrinsic::trans_intrinsic(ccx, d, i, psubsts, ref_id);
|
||||
intrinsic::trans_intrinsic(ccx, d, i, &psubsts, ref_id);
|
||||
d
|
||||
}
|
||||
}
|
||||
@ -253,7 +253,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
|
||||
v,
|
||||
args.as_slice(),
|
||||
this_tv.disr_val,
|
||||
Some(psubsts),
|
||||
Some(&psubsts),
|
||||
d);
|
||||
}
|
||||
ast::StructVariantKind(_) =>
|
||||
@ -264,7 +264,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
|
||||
ast_map::NodeMethod(mth) => {
|
||||
let d = mk_lldecl();
|
||||
set_llvm_fn_attrs(mth.attrs.as_slice(), d);
|
||||
trans_fn(ccx, mth.decl, mth.body, d, Some(psubsts), mth.id, []);
|
||||
trans_fn(ccx, mth.decl, mth.body, d, Some(&psubsts), mth.id, []);
|
||||
d
|
||||
}
|
||||
ast_map::NodeTraitMethod(method) => {
|
||||
@ -272,7 +272,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
|
||||
ast::Provided(mth) => {
|
||||
let d = mk_lldecl();
|
||||
set_llvm_fn_attrs(mth.attrs.as_slice(), d);
|
||||
trans_fn(ccx, mth.decl, mth.body, d, Some(psubsts), mth.id, []);
|
||||
trans_fn(ccx, mth.decl, mth.body, d, Some(&psubsts), mth.id, []);
|
||||
d
|
||||
}
|
||||
_ => {
|
||||
@ -288,7 +288,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
|
||||
struct_def.fields.as_slice(),
|
||||
struct_def.ctor_id.expect("ast-mapped tuple struct \
|
||||
didn't have a ctor id"),
|
||||
Some(psubsts),
|
||||
Some(&psubsts),
|
||||
d);
|
||||
d
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ impl<'a> Reflector<'a> {
|
||||
let arena = TypedArena::new();
|
||||
let fcx = new_fn_ctxt(ccx, llfdecl, -1, false,
|
||||
ty::mk_u64(), None, None, &arena);
|
||||
init_function(&fcx, false, ty::mk_u64(), None);
|
||||
init_function(&fcx, false, ty::mk_u64());
|
||||
|
||||
let arg = unsafe {
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user