Intern BareFnTys to make sty slightly smaller.
This cuts the ty_bare_fn variant to 48 bytes rather than 56. There doesn't seem to be a noticable memory usage decrease from this.
This commit is contained in:
parent
a33a7d20de
commit
ce3c949115
21 changed files with 91 additions and 64 deletions
|
|
@ -454,10 +454,12 @@ fn parse_ty<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did) -> Ty<'tcx> {
|
|||
}
|
||||
'F' => {
|
||||
let def_id = parse_def(st, NominalType, |x,y| conv(x,y));
|
||||
return ty::mk_bare_fn(st.tcx, Some(def_id), parse_bare_fn_ty(st, |x,y| conv(x,y)));
|
||||
return ty::mk_bare_fn(st.tcx, Some(def_id),
|
||||
st.tcx.mk_bare_fn(parse_bare_fn_ty(st, |x,y| conv(x,y))));
|
||||
}
|
||||
'G' => {
|
||||
return ty::mk_bare_fn(st.tcx, None, parse_bare_fn_ty(st, |x,y| conv(x,y)));
|
||||
return ty::mk_bare_fn(st.tcx, None,
|
||||
st.tcx.mk_bare_fn(parse_bare_fn_ty(st, |x,y| conv(x,y))));
|
||||
}
|
||||
'#' => {
|
||||
let pos = parse_hex(st);
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
|
||||
self.unpack_actual_value(a, |a| {
|
||||
match a.sty {
|
||||
ty::ty_bare_fn(Some(a_def_id), ref a_f) => {
|
||||
ty::ty_bare_fn(Some(a_def_id), a_f) => {
|
||||
// Function items are coercible to any closure
|
||||
// type; function pointers are not (that would
|
||||
// require double indirection).
|
||||
|
|
@ -486,7 +486,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
b.repr(self.tcx()));
|
||||
|
||||
match a.sty {
|
||||
ty::ty_bare_fn(Some(a_def_id), ref f) => {
|
||||
ty::ty_bare_fn(Some(a_def_id), f) => {
|
||||
self.coerce_from_fn_item(a, a_def_id, f, b)
|
||||
}
|
||||
_ => {
|
||||
|
|
|
|||
|
|
@ -568,7 +568,7 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C,
|
|||
}
|
||||
}
|
||||
|
||||
(&ty::ty_bare_fn(a_opt_def_id, ref a_fty), &ty::ty_bare_fn(b_opt_def_id, ref b_fty))
|
||||
(&ty::ty_bare_fn(a_opt_def_id, a_fty), &ty::ty_bare_fn(b_opt_def_id, b_fty))
|
||||
if a_opt_def_id == b_opt_def_id =>
|
||||
{
|
||||
let fty = try!(this.bare_fn_tys(a_fty, b_fty));
|
||||
|
|
|
|||
|
|
@ -806,7 +806,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
}
|
||||
|
||||
// provide an impl, but only for suitable `fn` pointers
|
||||
ty::ty_bare_fn(_, ty::BareFnTy {
|
||||
ty::ty_bare_fn(_, &ty::BareFnTy {
|
||||
unsafety: ast::Unsafety::Normal,
|
||||
abi: abi::Rust,
|
||||
sig: ty::Binder(ty::FnSig {
|
||||
|
|
@ -1549,7 +1549,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
|
||||
let self_ty = self.infcx.shallow_resolve(obligation.self_ty());
|
||||
let sig = match self_ty.sty {
|
||||
ty::ty_bare_fn(_, ty::BareFnTy {
|
||||
ty::ty_bare_fn(_, &ty::BareFnTy {
|
||||
unsafety: ast::Unsafety::Normal,
|
||||
abi: abi::Rust,
|
||||
ref sig
|
||||
|
|
|
|||
|
|
@ -611,6 +611,7 @@ pub struct ctxt<'tcx> {
|
|||
/// The arena that types are allocated from.
|
||||
type_arena: &'tcx TypedArena<TyS<'tcx>>,
|
||||
substs_arena: &'tcx TypedArena<Substs<'tcx>>,
|
||||
bare_fn_arena: &'tcx TypedArena<BareFnTy<'tcx>>,
|
||||
|
||||
/// Specifically use a speedy hash algorithm for this hash map, it's used
|
||||
/// quite often.
|
||||
|
|
@ -619,6 +620,7 @@ pub struct ctxt<'tcx> {
|
|||
interner: RefCell<FnvHashMap<InternedTy<'tcx>, Ty<'tcx>>>,
|
||||
// FIXME as above, use a hashset if equivalent elements can be queried.
|
||||
substs_interner: RefCell<FnvHashMap<&'tcx Substs<'tcx>, &'tcx Substs<'tcx>>>,
|
||||
bare_fn_interner: RefCell<FnvHashMap<&'tcx BareFnTy<'tcx>, &'tcx BareFnTy<'tcx>>>,
|
||||
|
||||
pub sess: Session,
|
||||
pub def_map: DefMap,
|
||||
|
|
@ -1327,7 +1329,7 @@ pub enum sty<'tcx> {
|
|||
|
||||
// If the def-id is Some(_), then this is the type of a specific
|
||||
// fn item. Otherwise, if None(_), it a fn pointer type.
|
||||
ty_bare_fn(Option<DefId>, BareFnTy<'tcx>),
|
||||
ty_bare_fn(Option<DefId>, &'tcx BareFnTy<'tcx>),
|
||||
|
||||
ty_closure(Box<ClosureTy<'tcx>>),
|
||||
ty_trait(Box<TyTrait<'tcx>>),
|
||||
|
|
@ -2056,6 +2058,7 @@ impl UnboxedClosureKind {
|
|||
pub fn mk_ctxt<'tcx>(s: Session,
|
||||
type_arena: &'tcx TypedArena<TyS<'tcx>>,
|
||||
substs_arena: &'tcx TypedArena<Substs<'tcx>>,
|
||||
bare_fn_arena: &'tcx TypedArena<BareFnTy<'tcx>>,
|
||||
dm: DefMap,
|
||||
named_region_map: resolve_lifetime::NamedRegionMap,
|
||||
map: ast_map::Map<'tcx>,
|
||||
|
|
@ -2067,8 +2070,10 @@ pub fn mk_ctxt<'tcx>(s: Session,
|
|||
ctxt {
|
||||
type_arena: type_arena,
|
||||
substs_arena: substs_arena,
|
||||
bare_fn_arena: bare_fn_arena,
|
||||
interner: RefCell::new(FnvHashMap::new()),
|
||||
substs_interner: RefCell::new(FnvHashMap::new()),
|
||||
bare_fn_interner: RefCell::new(FnvHashMap::new()),
|
||||
named_region_map: named_region_map,
|
||||
item_variance_map: RefCell::new(DefIdMap::new()),
|
||||
variance_computed: Cell::new(false),
|
||||
|
|
@ -2138,6 +2143,16 @@ impl<'tcx> ctxt<'tcx> {
|
|||
self.substs_interner.borrow_mut().insert(substs, substs);
|
||||
substs
|
||||
}
|
||||
|
||||
pub fn mk_bare_fn(&self, bare_fn: BareFnTy<'tcx>) -> &'tcx BareFnTy<'tcx> {
|
||||
if let Some(bare_fn) = self.bare_fn_interner.borrow().get(&bare_fn) {
|
||||
return *bare_fn;
|
||||
}
|
||||
|
||||
let bare_fn = self.bare_fn_arena.alloc(bare_fn);
|
||||
self.bare_fn_interner.borrow_mut().insert(bare_fn, bare_fn);
|
||||
bare_fn
|
||||
}
|
||||
}
|
||||
|
||||
// Interns a type/name combination, stores the resulting box in cx.interner,
|
||||
|
|
@ -2444,7 +2459,7 @@ pub fn mk_closure<'tcx>(cx: &ctxt<'tcx>, fty: ClosureTy<'tcx>) -> Ty<'tcx> {
|
|||
|
||||
pub fn mk_bare_fn<'tcx>(cx: &ctxt<'tcx>,
|
||||
opt_def_id: Option<ast::DefId>,
|
||||
fty: BareFnTy<'tcx>) -> Ty<'tcx> {
|
||||
fty: &'tcx BareFnTy<'tcx>) -> Ty<'tcx> {
|
||||
mk_t(cx, ty_bare_fn(opt_def_id, fty))
|
||||
}
|
||||
|
||||
|
|
@ -2455,7 +2470,7 @@ pub fn mk_ctor_fn<'tcx>(cx: &ctxt<'tcx>,
|
|||
let input_args = input_tys.iter().map(|ty| *ty).collect();
|
||||
mk_bare_fn(cx,
|
||||
Some(def_id),
|
||||
BareFnTy {
|
||||
cx.mk_bare_fn(BareFnTy {
|
||||
unsafety: ast::Unsafety::Normal,
|
||||
abi: abi::Rust,
|
||||
sig: ty::Binder(FnSig {
|
||||
|
|
@ -2463,7 +2478,7 @@ pub fn mk_ctor_fn<'tcx>(cx: &ctxt<'tcx>,
|
|||
output: ty::FnConverging(output),
|
||||
variadic: false
|
||||
})
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,10 @@ pub fn compile_input(sess: Session,
|
|||
|
||||
let type_arena = TypedArena::new();
|
||||
let substs_arena = TypedArena::new();
|
||||
let analysis = phase_3_run_analysis_passes(sess, ast_map, &type_arena, &substs_arena, id);
|
||||
let bare_fn_arena = TypedArena::new();
|
||||
let analysis = phase_3_run_analysis_passes(sess, ast_map,
|
||||
&type_arena, &substs_arena, &bare_fn_arena,
|
||||
id);
|
||||
phase_save_analysis(&analysis.ty_cx.sess, analysis.ty_cx.map.krate(), &analysis, outdir);
|
||||
|
||||
if log_enabled!(::log::INFO) {
|
||||
|
|
@ -345,6 +348,7 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
|
|||
ast_map: ast_map::Map<'tcx>,
|
||||
type_arena: &'tcx TypedArena<ty::TyS<'tcx>>,
|
||||
substs_arena: &'tcx TypedArena<subst::Substs<'tcx>>,
|
||||
bare_fn_arena: &'tcx TypedArena<ty::BareFnTy<'tcx>>,
|
||||
name: String) -> ty::CrateAnalysis<'tcx> {
|
||||
let time_passes = sess.time_passes();
|
||||
let krate = ast_map.krate();
|
||||
|
|
@ -406,6 +410,7 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
|
|||
let ty_cx = ty::mk_ctxt(sess,
|
||||
type_arena,
|
||||
substs_arena,
|
||||
bare_fn_arena,
|
||||
def_map,
|
||||
named_region_map,
|
||||
ast_map,
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ impl PpSourceMode {
|
|||
ast_map: Option<ast_map::Map<'tcx>>,
|
||||
type_arena: &'tcx TypedArena<ty::TyS<'tcx>>,
|
||||
substs_arena: &'tcx TypedArena<subst::Substs<'tcx>>,
|
||||
bare_fn_arena: &'tcx TypedArena<ty::BareFnTy<'tcx>>,
|
||||
id: String,
|
||||
payload: B,
|
||||
f: F) -> A where
|
||||
|
|
@ -136,7 +137,9 @@ impl PpSourceMode {
|
|||
PpmTyped => {
|
||||
let ast_map = ast_map.expect("--pretty=typed missing ast_map");
|
||||
let analysis = driver::phase_3_run_analysis_passes(sess, ast_map,
|
||||
type_arena, substs_arena, id);
|
||||
type_arena, substs_arena,
|
||||
bare_fn_arena,
|
||||
id);
|
||||
let annotation = TypedAnnotation { analysis: analysis };
|
||||
f(&annotation, payload)
|
||||
}
|
||||
|
|
@ -513,6 +516,7 @@ pub fn pretty_print_input(sess: Session,
|
|||
let mut forest = ast_map::Forest::new(krate);
|
||||
let type_arena = TypedArena::new();
|
||||
let substs_arena = TypedArena::new();
|
||||
let bare_fn_arena = TypedArena::new();
|
||||
|
||||
let (krate, ast_map) = if compute_ast_map {
|
||||
let map = driver::assign_node_ids_and_map(&sess, &mut forest);
|
||||
|
|
@ -541,7 +545,8 @@ pub fn pretty_print_input(sess: Session,
|
|||
match (ppm, opt_uii) {
|
||||
(PpmSource(s), None) =>
|
||||
s.call_with_pp_support(
|
||||
sess, ast_map, &type_arena, &substs_arena, id, out, |annotation, out| {
|
||||
sess, ast_map, &type_arena, &substs_arena, &bare_fn_arena,
|
||||
id, out, |annotation, out| {
|
||||
debug!("pretty printing source code {}", s);
|
||||
let sess = annotation.sess();
|
||||
pprust::print_crate(sess.codemap(),
|
||||
|
|
@ -556,7 +561,8 @@ pub fn pretty_print_input(sess: Session,
|
|||
|
||||
(PpmSource(s), Some(uii)) =>
|
||||
s.call_with_pp_support(
|
||||
sess, ast_map, &type_arena, &substs_arena, id, (out,uii), |annotation, (out,uii)| {
|
||||
sess, ast_map, &type_arena, &substs_arena, &bare_fn_arena,
|
||||
id, (out,uii), |annotation, (out,uii)| {
|
||||
debug!("pretty printing source code {}", s);
|
||||
let sess = annotation.sess();
|
||||
let ast_map = annotation.ast_map()
|
||||
|
|
@ -600,6 +606,7 @@ pub fn pretty_print_input(sess: Session,
|
|||
let variants = gather_flowgraph_variants(&sess);
|
||||
let analysis = driver::phase_3_run_analysis_passes(sess, ast_map,
|
||||
&type_arena, &substs_arena,
|
||||
&bare_fn_arena,
|
||||
id);
|
||||
print_flowgraph(variants, analysis, code, out)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,8 +128,12 @@ fn test_env<F>(source_string: &str,
|
|||
let region_map = region::resolve_crate(&sess, krate);
|
||||
let stability_index = stability::Index::build(krate);
|
||||
let type_arena = TypedArena::new();
|
||||
let substs_arena = TypedArena::new();
|
||||
let bare_fn_arena = TypedArena::new();
|
||||
let tcx = ty::mk_ctxt(sess,
|
||||
&type_arena,
|
||||
&substs_arena,
|
||||
&bare_fn_arena,
|
||||
def_map,
|
||||
named_region_map,
|
||||
ast_map,
|
||||
|
|
@ -816,4 +820,3 @@ fn subst_region_renumber_region() {
|
|||
assert_eq!(t_substituted, t_expected);
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -279,7 +279,7 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>(
|
|||
let (opt_def_id, input_tys, output_ty) =
|
||||
match bare_fn_ty.sty {
|
||||
ty::ty_bare_fn(opt_def_id,
|
||||
ty::BareFnTy { unsafety: ast::Unsafety::Normal,
|
||||
&ty::BareFnTy { unsafety: ast::Unsafety::Normal,
|
||||
abi: synabi::Rust,
|
||||
sig: ty::Binder(ty::FnSig { inputs: ref input_tys,
|
||||
output: output_ty,
|
||||
|
|
@ -296,14 +296,15 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>(
|
|||
let tuple_input_ty = ty::mk_tup(tcx, input_tys.to_vec());
|
||||
let tuple_fn_ty = ty::mk_bare_fn(tcx,
|
||||
opt_def_id,
|
||||
ty::BareFnTy { unsafety: ast::Unsafety::Normal,
|
||||
abi: synabi::RustCall,
|
||||
sig: ty::Binder(ty::FnSig {
|
||||
inputs: vec![bare_fn_ty_ref,
|
||||
tuple_input_ty],
|
||||
output: output_ty,
|
||||
variadic: false
|
||||
})});
|
||||
tcx.mk_bare_fn(ty::BareFnTy {
|
||||
unsafety: ast::Unsafety::Normal,
|
||||
abi: synabi::RustCall,
|
||||
sig: ty::FnSig {
|
||||
inputs: vec![bare_fn_ty_ref,
|
||||
tuple_input_ty],
|
||||
output: output_ty,
|
||||
variadic: false
|
||||
}}));
|
||||
debug!("tuple_fn_ty: {}", tuple_fn_ty.repr(tcx));
|
||||
|
||||
//
|
||||
|
|
|
|||
|
|
@ -430,7 +430,7 @@ impl<'tcx> TypeMap<'tcx> {
|
|||
trait_data.principal.substs(),
|
||||
&mut unique_type_id);
|
||||
},
|
||||
ty::ty_bare_fn(_, ty::BareFnTy{ unsafety, abi, ref sig } ) => {
|
||||
ty::ty_bare_fn(_, &ty::BareFnTy{ unsafety, abi, ref sig } ) => {
|
||||
if unsafety == ast::Unsafety::Unsafe {
|
||||
unique_type_id.push_str("unsafe ");
|
||||
}
|
||||
|
|
@ -3819,7 +3819,7 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
push_item_name(cx, trait_data.principal.def_id(), false, output);
|
||||
push_type_params(cx, trait_data.principal.substs(), output);
|
||||
},
|
||||
ty::ty_bare_fn(_, ty::BareFnTy{ unsafety, abi, ref sig } ) => {
|
||||
ty::ty_bare_fn(_, &ty::BareFnTy{ unsafety, abi, ref sig } ) => {
|
||||
if unsafety == ast::Unsafety::Unsafe {
|
||||
output.push_str("unsafe ");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -639,7 +639,7 @@ fn emit_vtable_methods<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
m.repr(tcx),
|
||||
substs.repr(tcx));
|
||||
if m.generics.has_type_params(subst::FnSpace) ||
|
||||
ty::type_has_self(ty::mk_bare_fn(tcx, None, m.fty.clone()))
|
||||
ty::type_has_self(ty::mk_bare_fn(tcx, None, tcx.mk_bare_fn(m.fty.clone())))
|
||||
{
|
||||
debug!("(making impl vtable) method has self or type \
|
||||
params: {}",
|
||||
|
|
|
|||
|
|
@ -954,7 +954,8 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
|
|||
tcx.sess.span_err(ast_ty.span,
|
||||
"variadic function must have C calling convention");
|
||||
}
|
||||
ty::mk_bare_fn(tcx, None, ty_of_bare_fn(this, bf.unsafety, bf.abi, &*bf.decl))
|
||||
let bare_fn = ty_of_bare_fn(this, bf.unsafety, bf.abi, &*bf.decl);
|
||||
ty::mk_bare_fn(tcx, None, tcx.mk_bare_fn(bare_fn))
|
||||
}
|
||||
ast::TyClosure(ref f) => {
|
||||
// Use corresponding trait store to figure out default bounds
|
||||
|
|
|
|||
|
|
@ -113,11 +113,11 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> {
|
|||
self.add_obligations(&pick, &method_bounds_substs, &method_bounds);
|
||||
|
||||
// Create the final `MethodCallee`.
|
||||
let fty = ty::mk_bare_fn(self.tcx(), None, ty::BareFnTy {
|
||||
let fty = ty::mk_bare_fn(self.tcx(), None, self.tcx().mk_bare_fn(ty::BareFnTy {
|
||||
sig: ty::Binder(method_sig),
|
||||
unsafety: pick.method_ty.fty.unsafety,
|
||||
abi: pick.method_ty.fty.abi.clone(),
|
||||
});
|
||||
}));
|
||||
let callee = MethodCallee {
|
||||
origin: method_origin,
|
||||
ty: fty,
|
||||
|
|
|
|||
|
|
@ -199,11 +199,10 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &'a FnCtxt<'a, 'tcx>,
|
|||
infer::FnCall,
|
||||
&fn_sig).0;
|
||||
let transformed_self_ty = fn_sig.inputs[0];
|
||||
let fty = ty::mk_bare_fn(tcx, None, ty::BareFnTy {
|
||||
sig: ty::Binder(fn_sig),
|
||||
let fty = ty::mk_bare_fn(tcx, None, tcx.mk_bare_fn(ty::BareFnTy {
|
||||
unsafety: bare_fn_ty.unsafety,
|
||||
abi: bare_fn_ty.abi.clone(),
|
||||
});
|
||||
}));
|
||||
|
||||
debug!("lookup_in_trait_adjusted: matched method fty={} obligation={}",
|
||||
fty.repr(fcx.tcx()),
|
||||
|
|
|
|||
|
|
@ -1154,9 +1154,9 @@ fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
}
|
||||
|
||||
// Compute skolemized form of impl and trait method tys.
|
||||
let impl_fty = ty::mk_bare_fn(tcx, None, impl_m.fty.clone());
|
||||
let impl_fty = ty::mk_bare_fn(tcx, None, tcx.mk_bare_fn(impl_m.fty.clone()));
|
||||
let impl_fty = impl_fty.subst(tcx, &impl_to_skol_substs);
|
||||
let trait_fty = ty::mk_bare_fn(tcx, None, trait_m.fty.clone());
|
||||
let trait_fty = ty::mk_bare_fn(tcx, None, tcx.mk_bare_fn(trait_m.fty.clone()));
|
||||
let trait_fty = trait_fty.subst(tcx, &trait_to_skol_substs);
|
||||
|
||||
// Check the impl method type IM is a subtype of the trait method
|
||||
|
|
@ -2949,7 +2949,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
});
|
||||
|
||||
let fn_sig = match fn_ty.sty {
|
||||
ty::ty_bare_fn(_, ty::BareFnTy {ref sig, ..}) |
|
||||
ty::ty_bare_fn(_, &ty::BareFnTy {ref sig, ..}) |
|
||||
ty::ty_closure(box ty::ClosureTy {ref sig, ..}) => sig,
|
||||
_ => {
|
||||
fcx.type_error_message(call_expr.span, |actual| {
|
||||
|
|
@ -5769,7 +5769,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
|
|||
};
|
||||
(n_tps, inputs, ty::FnConverging(output))
|
||||
};
|
||||
let fty = ty::mk_bare_fn(tcx, None, ty::BareFnTy {
|
||||
let fty = ty::mk_bare_fn(tcx, None, tcx.mk_bare_fn(ty::BareFnTy {
|
||||
unsafety: ast::Unsafety::Unsafe,
|
||||
abi: abi::RustIntrinsic,
|
||||
sig: ty::Binder(FnSig {
|
||||
|
|
@ -5777,7 +5777,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
|
|||
output: output,
|
||||
variadic: false,
|
||||
}),
|
||||
});
|
||||
}));
|
||||
let i_ty = ty::lookup_item_type(ccx.tcx, local_def(it.id));
|
||||
let i_n_tps = i_ty.generics.types.len(subst::FnSpace);
|
||||
if i_n_tps != n_tps {
|
||||
|
|
|
|||
|
|
@ -355,7 +355,7 @@ impl<'cx,'tcx> TypeFolder<'tcx> for BoundsChecker<'cx,'tcx> {
|
|||
|
||||
self.fold_substs(substs);
|
||||
}
|
||||
ty::ty_bare_fn(_, ty::BareFnTy{sig: ref fn_sig, ..}) |
|
||||
ty::ty_bare_fn(_, &ty::BareFnTy{sig: ref fn_sig, ..}) |
|
||||
ty::ty_closure(box ty::ClosureTy{sig: ref fn_sig, ..}) => {
|
||||
self.binding_count += 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -235,7 +235,8 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
|
|||
// impl, plus its own.
|
||||
let new_polytype = ty::Polytype {
|
||||
generics: new_method_ty.generics.clone(),
|
||||
ty: ty::mk_bare_fn(tcx, Some(new_did), new_method_ty.fty.clone())
|
||||
ty: ty::mk_bare_fn(tcx, Some(new_did),
|
||||
tcx.mk_bare_fn(new_method_ty.fty.clone()))
|
||||
};
|
||||
debug!("new_polytype={}", new_polytype.repr(tcx));
|
||||
|
||||
|
|
|
|||
|
|
@ -355,7 +355,7 @@ fn collect_trait_methods<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
m.def_id,
|
||||
Polytype {
|
||||
generics: m.generics.clone(),
|
||||
ty: ty::mk_bare_fn(ccx.tcx, Some(m.def_id), m.fty.clone()) });
|
||||
ty: ty::mk_bare_fn(ccx.tcx, Some(m.def_id), ccx.tcx.mk_bare_fn(m.fty.clone())) });
|
||||
}
|
||||
|
||||
fn ty_method_of_trait_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
|
|
@ -529,7 +529,7 @@ fn convert_methods<'a,'tcx,'i,I>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
untransformed_rcvr_ty,
|
||||
rcvr_ty_generics,
|
||||
rcvr_visibility));
|
||||
let fty = ty::mk_bare_fn(tcx, Some(m_def_id), mty.fty.clone());
|
||||
let fty = ty::mk_bare_fn(tcx, Some(m_def_id), tcx.mk_bare_fn(mty.fty.clone()));
|
||||
debug!("method {} (id {}) has type {}",
|
||||
m.pe_ident().repr(tcx),
|
||||
m.id,
|
||||
|
|
@ -1465,7 +1465,7 @@ pub fn ty_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, it: &ast::Item)
|
|||
};
|
||||
let pty = Polytype {
|
||||
generics: ty_generics,
|
||||
ty: ty::mk_bare_fn(ccx.tcx, Some(local_def(it.id)), tofd)
|
||||
ty: ty::mk_bare_fn(ccx.tcx, Some(local_def(it.id)), ccx.tcx.mk_bare_fn(tofd))
|
||||
};
|
||||
debug!("type of {} (id {}) is {}",
|
||||
token::get_ident(it.ident),
|
||||
|
|
@ -1775,12 +1775,7 @@ fn ty_generics<'tcx,AC>(this: &AC,
|
|||
let def = get_or_create_type_parameter_def(&gcx,
|
||||
space,
|
||||
param,
|
||||
<<<<<<< HEAD
|
||||
i,
|
||||
=======
|
||||
i as u32,
|
||||
where_clause,
|
||||
>>>>>>> Switch Region information from uint to u32.
|
||||
None);
|
||||
debug!("ty_generics: def for type param: {}, {}",
|
||||
def.repr(this.tcx()),
|
||||
|
|
@ -1968,12 +1963,7 @@ fn ty_generics<'tcx,AC>(this: &AC,
|
|||
fn get_or_create_type_parameter_def<'tcx,AC>(this: &AC,
|
||||
space: subst::ParamSpace,
|
||||
param: &ast::TyParam,
|
||||
<<<<<<< HEAD
|
||||
index: uint,
|
||||
=======
|
||||
index: u32,
|
||||
where_clause: &ast::WhereClause,
|
||||
>>>>>>> Switch Region information from uint to u32.
|
||||
associated_with: Option<ast::DefId>)
|
||||
-> ty::TypeParameterDef<'tcx>
|
||||
where AC: AstConv<'tcx>
|
||||
|
|
@ -2153,13 +2143,13 @@ pub fn ty_of_foreign_fn_decl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
let t_fn = ty::mk_bare_fn(
|
||||
ccx.tcx,
|
||||
None,
|
||||
ty::BareFnTy {
|
||||
ccx.tcx.mk_bare_fn(ty::BareFnTy {
|
||||
abi: abi,
|
||||
unsafety: ast::Unsafety::Unsafe,
|
||||
sig: ty::Binder(ty::FnSig {inputs: input_tys,
|
||||
output: output,
|
||||
variadic: decl.variadic}),
|
||||
});
|
||||
output: output,
|
||||
variadic: decl.variadic})
|
||||
}));
|
||||
let pty = Polytype {
|
||||
generics: ty_generics_for_fn_or_method,
|
||||
ty: t_fn
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ fn check_main_fn_ty(ccx: &CrateCtxt,
|
|||
}
|
||||
_ => ()
|
||||
}
|
||||
let se_ty = ty::mk_bare_fn(tcx, Some(local_def(main_id)), ty::BareFnTy {
|
||||
let se_ty = ty::mk_bare_fn(tcx, Some(local_def(main_id)), tcx.mk_bare_fn(ty::BareFnTy {
|
||||
unsafety: ast::Unsafety::Normal,
|
||||
abi: abi::Rust,
|
||||
sig: ty::Binder(ty::FnSig {
|
||||
|
|
@ -233,7 +233,7 @@ fn check_main_fn_ty(ccx: &CrateCtxt,
|
|||
output: ty::FnConverging(ty::mk_nil(tcx)),
|
||||
variadic: false
|
||||
})
|
||||
});
|
||||
}));
|
||||
|
||||
require_same_types(tcx, None, false, main_span, main_t, se_ty,
|
||||
|| {
|
||||
|
|
@ -273,7 +273,7 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
|
|||
_ => ()
|
||||
}
|
||||
|
||||
let se_ty = ty::mk_bare_fn(tcx, Some(local_def(start_id)), ty::BareFnTy {
|
||||
let se_ty = ty::mk_bare_fn(tcx, Some(local_def(start_id)), tcx.mk_bare_fn(ty::BareFnTy {
|
||||
unsafety: ast::Unsafety::Normal,
|
||||
abi: abi::Rust,
|
||||
sig: ty::Binder(ty::FnSig {
|
||||
|
|
@ -284,7 +284,7 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
|
|||
output: ty::FnConverging(ty::mk_int()),
|
||||
variadic: false
|
||||
}),
|
||||
});
|
||||
}));
|
||||
|
||||
require_same_types(tcx, None, false, start_span, start_t, se_ty,
|
||||
|| {
|
||||
|
|
|
|||
|
|
@ -814,7 +814,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
ty::ty_bare_fn(_, ty::BareFnTy { ref sig, .. }) |
|
||||
ty::ty_bare_fn(_, &ty::BareFnTy { ref sig, .. }) |
|
||||
ty::ty_closure(box ty::ClosureTy {
|
||||
ref sig,
|
||||
store: ty::UniqTraitStore,
|
||||
|
|
|
|||
|
|
@ -123,9 +123,12 @@ pub fn run_core(libs: Vec<Path>, cfgs: Vec<String>, externs: Externs,
|
|||
|
||||
let type_arena = TypedArena::new();
|
||||
let substs_arena = TypedArena::new();
|
||||
let bare_fn_arena = TypedArena::new();
|
||||
let ty::CrateAnalysis {
|
||||
exported_items, public_items, ty_cx, ..
|
||||
} = driver::phase_3_run_analysis_passes(sess, ast_map, &type_arena, &substs_arena, name);
|
||||
} = driver::phase_3_run_analysis_passes(sess, ast_map,
|
||||
&type_arena, &substs_arena, &bare_fn_arena,
|
||||
name);
|
||||
|
||||
let ctxt = DocContext {
|
||||
krate: ty_cx.map.krate(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue