metadata -- remove tiny convenience closure that was causing conflicting mutable borrows

This commit is contained in:
Niko Matsakis 2014-02-07 14:44:56 -05:00
parent 7286e35c6b
commit 949e1c7935
2 changed files with 11 additions and 11 deletions

View File

@ -924,7 +924,6 @@ fn encode_info_for_item(ecx: &EncodeContext,
pos: ebml_w.writer.tell().unwrap(),
});
}
let add_to_index: || = || add_to_index(item, ebml_w, index);
debug!("encoding info for item at {}",
ecx.tcx.sess.codemap.span_to_str(item.span));
@ -932,7 +931,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
let def_id = local_def(item.id);
match item.node {
ItemStatic(_, m, _) => {
add_to_index();
add_to_index(item, ebml_w, index);
ebml_w.start_tag(tag_items_data_item);
encode_def_id(ebml_w, def_id);
if m == ast::MutMutable {
@ -959,7 +958,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
ebml_w.end_tag();
}
ItemFn(_, purity, _, ref generics, _) => {
add_to_index();
add_to_index(item, ebml_w, index);
ebml_w.start_tag(tag_items_data_item);
encode_def_id(ebml_w, def_id);
encode_family(ebml_w, purity_fn_family(purity));
@ -977,7 +976,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
ebml_w.end_tag();
}
ItemMod(ref m) => {
add_to_index();
add_to_index(item, ebml_w, index);
encode_info_for_mod(ecx,
ebml_w,
m,
@ -987,7 +986,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
item.vis);
}
ItemForeignMod(ref fm) => {
add_to_index();
add_to_index(item, ebml_w, index);
ebml_w.start_tag(tag_items_data_item);
encode_def_id(ebml_w, def_id);
encode_family(ebml_w, 'n');
@ -1004,7 +1003,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
ebml_w.end_tag();
}
ItemTy(..) => {
add_to_index();
add_to_index(item, ebml_w, index);
ebml_w.start_tag(tag_items_data_item);
encode_def_id(ebml_w, def_id);
encode_family(ebml_w, 'y');
@ -1015,7 +1014,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
ebml_w.end_tag();
}
ItemEnum(ref enum_definition, ref generics) => {
add_to_index();
add_to_index(item, ebml_w, index);
ebml_w.start_tag(tag_items_data_item);
encode_def_id(ebml_w, def_id);
@ -1053,7 +1052,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
struct_def.fields, index);
/* Index the class*/
add_to_index();
add_to_index(item, ebml_w, index);
/* Now, make an item for the class itself */
ebml_w.start_tag(tag_items_data_item);
@ -1106,7 +1105,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
let impls = tcx.impls.borrow();
let imp = impls.get().get(&def_id);
add_to_index();
add_to_index(item, ebml_w, index);
ebml_w.start_tag(tag_items_data_item);
encode_def_id(ebml_w, def_id);
encode_family(ebml_w, 'i');
@ -1170,7 +1169,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
}
}
ItemTrait(_, ref super_traits, ref ms) => {
add_to_index();
add_to_index(item, ebml_w, index);
ebml_w.start_tag(tag_items_data_item);
encode_def_id(ebml_w, def_id);
encode_family(ebml_w, 'I');

View File

@ -96,8 +96,9 @@ pub fn parse_ident(st: &mut PState, last: char) -> ast::Ident {
}
fn parse_ident_(st: &mut PState, is_last: |char| -> bool) -> ast::Ident {
let tcx = st.tcx;
scan(st, is_last, |bytes| {
st.tcx.sess.ident_of(str::from_utf8(bytes).unwrap())
tcx.sess.ident_of(str::from_utf8(bytes).unwrap())
})
}