From: Jorge Aparicio Date: Sun, 4 Jan 2015 14:07:13 +0000 (-0500) Subject: DecodeInlinedItem: convert to "unboxed" closures X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=bd9eef7ac64b4263c9db25d74b7cc57958909ddc;p=rust.git DecodeInlinedItem: convert to "unboxed" closures --- diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 97f5228f033..ac8dfc16759 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -662,27 +662,27 @@ pub fn get_item_path(cdata: Cmd, id: ast::NodeId) -> Vec { item_path(lookup_item(id, cdata.data())) } -pub type DecodeInlinedItem<'a> = for<'tcx> |cdata: Cmd, - tcx: &ty::ctxt<'tcx>, - path: Vec, - par_doc: rbml::Doc|: 'a - -> Result<&'tcx ast::InlinedItem, - Vec>; +pub type DecodeInlinedItem<'a> = + Box FnMut(Cmd, + &ty::ctxt<'tcx>, + Vec, + rbml::Doc) + -> Result<&'tcx ast::InlinedItem, Vec> + 'a>; pub fn maybe_get_item_ast<'tcx>(cdata: Cmd, tcx: &ty::ctxt<'tcx>, id: ast::NodeId, - decode_inlined_item: DecodeInlinedItem) + mut decode_inlined_item: DecodeInlinedItem) -> csearch::found_ast<'tcx> { debug!("Looking up item: {}", id); let item_doc = lookup_item(id, cdata.data()); let path = item_path(item_doc).init().to_vec(); - match decode_inlined_item(cdata, tcx, path, item_doc) { + match decode_inlined_item.call_mut((cdata, tcx, path, item_doc)) { Ok(ii) => csearch::found(ii), Err(path) => { match item_parent_item(item_doc) { Some(did) => { let did = translate_def_id(cdata, did); let parent_item = lookup_item(did.node, cdata.data()); - match decode_inlined_item(cdata, tcx, path, parent_item) { + match decode_inlined_item.call_mut((cdata, tcx, path, parent_item)) { Ok(ii) => csearch::found_parent(did, ii), Err(_) => csearch::not_found } diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index 6671f0f72f6..a95523f2e06 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -132,7 +132,7 @@ fn variant_expr<'a>(variants: &'a [P], id: ast::NodeId) None => {} } let expr_id = match csearch::maybe_get_item_ast(tcx, enum_def, - |a, b, c, d| astencode::decode_inlined_item(a, b, c, d)) { + box |a, b, c, d| astencode::decode_inlined_item(a, b, c, d)) { csearch::found(&ast::IIItem(ref item)) => match item.node { ast::ItemEnum(ast::EnumDef { ref variants }, _) => { // NOTE this doesn't do the right thing, it compares inlined @@ -172,7 +172,7 @@ pub fn lookup_const_by_id<'a>(tcx: &'a ty::ctxt, def_id: ast::DefId) None => {} } let expr_id = match csearch::maybe_get_item_ast(tcx, def_id, - |a, b, c, d| astencode::decode_inlined_item(a, b, c, d)) { + box |a, b, c, d| astencode::decode_inlined_item(a, b, c, d)) { csearch::found(&ast::IIItem(ref item)) => match item.node { ast::ItemConst(_, ref const_expr) => Some(const_expr.id), _ => None diff --git a/src/librustc_trans/trans/inline.rs b/src/librustc_trans/trans/inline.rs index bde9051ec74..dd1cfc5ad6d 100644 --- a/src/librustc_trans/trans/inline.rs +++ b/src/librustc_trans/trans/inline.rs @@ -40,7 +40,7 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId) let csearch_result = csearch::maybe_get_item_ast( ccx.tcx(), fn_id, - |a,b,c,d| astencode::decode_inlined_item(a, b, c, d)); + box |a,b,c,d| astencode::decode_inlined_item(a, b, c, d)); let inline_def = match csearch_result { csearch::not_found => {