From ce3c9491156f5f475bcfcfc1ec2e2352fa4a6567 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Thu, 4 Dec 2014 14:52:20 -0800 Subject: [PATCH] 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. --- src/librustc/metadata/tydecode.rs | 6 ++++-- src/librustc/middle/infer/coercion.rs | 4 ++-- src/librustc/middle/infer/combine.rs | 2 +- src/librustc/middle/traits/select.rs | 4 ++-- src/librustc/middle/ty.rs | 23 ++++++++++++++++---- src/librustc_driver/driver.rs | 7 +++++- src/librustc_driver/pretty.rs | 13 ++++++++--- src/librustc_driver/test.rs | 5 ++++- src/librustc_trans/trans/callee.rs | 19 ++++++++-------- src/librustc_trans/trans/debuginfo.rs | 4 ++-- src/librustc_trans/trans/meth.rs | 2 +- src/librustc_typeck/astconv.rs | 3 ++- src/librustc_typeck/check/method/confirm.rs | 4 ++-- src/librustc_typeck/check/method/mod.rs | 5 ++--- src/librustc_typeck/check/mod.rs | 10 ++++----- src/librustc_typeck/check/wf.rs | 2 +- src/librustc_typeck/coherence/mod.rs | 3 ++- src/librustc_typeck/collect.rs | 24 ++++++--------------- src/librustc_typeck/lib.rs | 8 +++---- src/librustc_typeck/variance.rs | 2 +- src/librustdoc/core.rs | 5 ++++- 21 files changed, 91 insertions(+), 64 deletions(-) diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index b623fa210234..5dd1ee2882f2 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -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); diff --git a/src/librustc/middle/infer/coercion.rs b/src/librustc/middle/infer/coercion.rs index 9dc09d9032a1..d64bdf8af898 100644 --- a/src/librustc/middle/infer/coercion.rs +++ b/src/librustc/middle/infer/coercion.rs @@ -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) } _ => { diff --git a/src/librustc/middle/infer/combine.rs b/src/librustc/middle/infer/combine.rs index e0aa010a6a0c..220f2f369c23 100644 --- a/src/librustc/middle/infer/combine.rs +++ b/src/librustc/middle/infer/combine.rs @@ -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)); diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs index 4199e19a9d49..a32830bf92ee 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/middle/traits/select.rs @@ -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 diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 670603cf311d..473c3b49cd2f 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -611,6 +611,7 @@ pub struct ctxt<'tcx> { /// The arena that types are allocated from. type_arena: &'tcx TypedArena>, substs_arena: &'tcx TypedArena>, + bare_fn_arena: &'tcx TypedArena>, /// 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, Ty<'tcx>>>, // FIXME as above, use a hashset if equivalent elements can be queried. substs_interner: RefCell, &'tcx Substs<'tcx>>>, + bare_fn_interner: RefCell, &'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, BareFnTy<'tcx>), + ty_bare_fn(Option, &'tcx BareFnTy<'tcx>), ty_closure(Box>), ty_trait(Box>), @@ -2056,6 +2058,7 @@ impl UnboxedClosureKind { pub fn mk_ctxt<'tcx>(s: Session, type_arena: &'tcx TypedArena>, substs_arena: &'tcx TypedArena>, + bare_fn_arena: &'tcx TypedArena>, 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, - 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 }) - }) + })) } diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 4208b2908fa5..e2323127aecb 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -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>, substs_arena: &'tcx TypedArena>, + bare_fn_arena: &'tcx TypedArena>, 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, diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index d9d52d59b0cf..c60e0ba4fc8c 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -114,6 +114,7 @@ impl PpSourceMode { ast_map: Option>, type_arena: &'tcx TypedArena>, substs_arena: &'tcx TypedArena>, + bare_fn_arena: &'tcx TypedArena>, 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) } diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 1ef1486dd54d..2201d90a265c 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -128,8 +128,12 @@ fn test_env(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); }) } - diff --git a/src/librustc_trans/trans/callee.rs b/src/librustc_trans/trans/callee.rs index 7f22faf050da..8450e99bc28e 100644 --- a/src/librustc_trans/trans/callee.rs +++ b/src/librustc_trans/trans/callee.rs @@ -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)); // diff --git a/src/librustc_trans/trans/debuginfo.rs b/src/librustc_trans/trans/debuginfo.rs index d8c465d17aff..ea2d42bebdfc 100644 --- a/src/librustc_trans/trans/debuginfo.rs +++ b/src/librustc_trans/trans/debuginfo.rs @@ -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 "); } diff --git a/src/librustc_trans/trans/meth.rs b/src/librustc_trans/trans/meth.rs index 002590c4db35..553613a8eac0 100644 --- a/src/librustc_trans/trans/meth.rs +++ b/src/librustc_trans/trans/meth.rs @@ -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: {}", diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index b29ac70ca154..abb0d1951c49 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -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 diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index 461e2c67f1fd..abd99f6b3245 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -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, diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index d2d2e108b33c..d38bd7c2a1d7 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -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()), diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 4ffbd4df6e78..0bf8d4d3982b 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -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 { diff --git a/src/librustc_typeck/check/wf.rs b/src/librustc_typeck/check/wf.rs index ac65e5702059..258177bb7209 100644 --- a/src/librustc_typeck/check/wf.rs +++ b/src/librustc_typeck/check/wf.rs @@ -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; diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index b08db39c1898..f92c7764a69b 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -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)); diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index fc21dce18996..9252e5a82034 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -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) -> 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 diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 65dff774528a..3418cded022c 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -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, || { diff --git a/src/librustc_typeck/variance.rs b/src/librustc_typeck/variance.rs index b4409a61ece5..8bbc4d21739a 100644 --- a/src/librustc_typeck/variance.rs +++ b/src/librustc_typeck/variance.rs @@ -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, diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 5603f728d2fa..9456d8847b67 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -123,9 +123,12 @@ pub fn run_core(libs: Vec, cfgs: Vec, 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(),