]> git.lizzy.rs Git - rust.git/commitdiff
DecodeInlinedItem: convert to "unboxed" closures
authorJorge Aparicio <japaricious@gmail.com>
Sun, 4 Jan 2015 14:07:13 +0000 (09:07 -0500)
committerJorge Aparicio <japaricious@gmail.com>
Mon, 5 Jan 2015 22:22:13 +0000 (17:22 -0500)
src/librustc/metadata/decoder.rs
src/librustc/middle/const_eval.rs
src/librustc_trans/trans/inline.rs

index 97f5228f0330b5ca98a988d15215ff433e47052d..ac8dfc1675942c37055147762cb438bb94a20568 100644 (file)
@@ -662,27 +662,27 @@ pub fn get_item_path(cdata: Cmd, id: ast::NodeId) -> Vec<ast_map::PathElem> {
     item_path(lookup_item(id, cdata.data()))
 }
 
-pub type DecodeInlinedItem<'a> = for<'tcx> |cdata: Cmd,
-                                            tcx: &ty::ctxt<'tcx>,
-                                            path: Vec<ast_map::PathElem>,
-                                            par_doc: rbml::Doc|: 'a
-                                            -> Result<&'tcx ast::InlinedItem,
-                                                      Vec<ast_map::PathElem>>;
+pub type DecodeInlinedItem<'a> =
+    Box<for<'tcx> FnMut(Cmd,
+                        &ty::ctxt<'tcx>,
+                        Vec<ast_map::PathElem>,
+                        rbml::Doc)
+                        -> Result<&'tcx ast::InlinedItem, Vec<ast_map::PathElem>> + '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
                     }
index 6671f0f72f674f44717707f3846eb640428d1bf7..a95523f2e06005f3f72af857d4a8bd0dc1e6e788 100644 (file)
@@ -132,7 +132,7 @@ fn variant_expr<'a>(variants: &'a [P<ast::Variant>], 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
index bde9051ec74d6a65c5a95aaa07f81445a688fc87..dd1cfc5ad6d823db5c4643adefed5e512d990712 100644 (file)
@@ -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 => {