diff options
Diffstat (limited to 'src/librustc/metadata/encoder.rs')
| -rw-r--r-- | src/librustc/metadata/encoder.rs | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index e4226ddde85..592fbe4d64e 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -95,7 +95,7 @@ fn encode_impl_type_basename(rbml_w: &mut Encoder, name: ast::Ident) { } pub fn encode_def_id(rbml_w: &mut Encoder, id: DefId) { - rbml_w.wr_tagged_str(tag_def_id, def_to_string(id)[]); + rbml_w.wr_tagged_str(tag_def_id, def_to_string(id).index(&FullRange)); } #[derive(Clone)] @@ -154,7 +154,7 @@ fn encode_variant_id(rbml_w: &mut Encoder, vid: DefId) { rbml_w.end_tag(); rbml_w.start_tag(tag_mod_child); - rbml_w.wr_str(s[]); + rbml_w.wr_str(s.index(&FullRange)); rbml_w.end_tag(); } @@ -264,7 +264,7 @@ fn encode_symbol(ecx: &EncodeContext, } None => { ecx.diag.handler().bug( - format!("encode_symbol: id not found {}", id)[]); + format!("encode_symbol: id not found {}", id).index(&FullRange)); } } rbml_w.end_tag(); @@ -332,8 +332,8 @@ fn encode_enum_variant_info(ecx: &EncodeContext, encode_name(rbml_w, variant.node.name.name); encode_parent_item(rbml_w, local_def(id)); encode_visibility(rbml_w, variant.node.vis); - encode_attributes(rbml_w, variant.node.attrs[]); - encode_repr_attrs(rbml_w, ecx, variant.node.attrs[]); + encode_attributes(rbml_w, variant.node.attrs.index(&FullRange)); + encode_repr_attrs(rbml_w, ecx, variant.node.attrs.index(&FullRange)); let stab = stability::lookup(ecx.tcx, ast_util::local_def(variant.node.id)); encode_stability(rbml_w, stab); @@ -344,9 +344,9 @@ fn encode_enum_variant_info(ecx: &EncodeContext, let fields = ty::lookup_struct_fields(ecx.tcx, def_id); let idx = encode_info_for_struct(ecx, rbml_w, - fields[], + fields.index(&FullRange), index); - encode_struct_fields(rbml_w, fields[], def_id); + encode_struct_fields(rbml_w, fields.index(&FullRange), def_id); encode_index(rbml_w, idx, write_i64); } } @@ -386,12 +386,12 @@ fn encode_reexported_static_method(rbml_w: &mut Encoder, exp.name, token::get_name(method_name)); rbml_w.start_tag(tag_items_data_item_reexport); rbml_w.start_tag(tag_items_data_item_reexport_def_id); - rbml_w.wr_str(def_to_string(method_def_id)[]); + rbml_w.wr_str(def_to_string(method_def_id).index(&FullRange)); rbml_w.end_tag(); rbml_w.start_tag(tag_items_data_item_reexport_name); rbml_w.wr_str(format!("{}::{}", exp.name, - token::get_name(method_name))[]); + token::get_name(method_name)).index(&FullRange)); rbml_w.end_tag(); rbml_w.end_tag(); } @@ -529,7 +529,7 @@ fn encode_reexports(ecx: &EncodeContext, id); rbml_w.start_tag(tag_items_data_item_reexport); rbml_w.start_tag(tag_items_data_item_reexport_def_id); - rbml_w.wr_str(def_to_string(exp.def_id)[]); + rbml_w.wr_str(def_to_string(exp.def_id).index(&FullRange)); rbml_w.end_tag(); rbml_w.start_tag(tag_items_data_item_reexport_name); rbml_w.wr_str(exp.name.as_str()); @@ -562,13 +562,13 @@ fn encode_info_for_mod(ecx: &EncodeContext, // Encode info about all the module children. for item in md.items.iter() { rbml_w.start_tag(tag_mod_child); - rbml_w.wr_str(def_to_string(local_def(item.id))[]); + rbml_w.wr_str(def_to_string(local_def(item.id)).index(&FullRange)); rbml_w.end_tag(); each_auxiliary_node_id(&**item, |auxiliary_node_id| { rbml_w.start_tag(tag_mod_child); rbml_w.wr_str(def_to_string(local_def( - auxiliary_node_id))[]); + auxiliary_node_id)).index(&FullRange)); rbml_w.end_tag(); true }); @@ -580,7 +580,7 @@ fn encode_info_for_mod(ecx: &EncodeContext, did, ecx.tcx.map.node_to_string(did)); rbml_w.start_tag(tag_mod_impl); - rbml_w.wr_str(def_to_string(local_def(did))[]); + rbml_w.wr_str(def_to_string(local_def(did)).index(&FullRange)); rbml_w.end_tag(); } } @@ -615,7 +615,7 @@ fn encode_visibility(rbml_w: &mut Encoder, visibility: ast::Visibility) { ast::Public => 'y', ast::Inherited => 'i', }; - rbml_w.wr_str(ch.to_string()[]); + rbml_w.wr_str(ch.to_string().index(&FullRange)); rbml_w.end_tag(); } @@ -627,7 +627,7 @@ fn encode_unboxed_closure_kind(rbml_w: &mut Encoder, ty::FnMutUnboxedClosureKind => 'm', ty::FnOnceUnboxedClosureKind => 'o', }; - rbml_w.wr_str(ch.to_string()[]); + rbml_w.wr_str(ch.to_string().index(&FullRange)); rbml_w.end_tag(); } @@ -788,7 +788,7 @@ fn encode_generics<'a, 'tcx>(rbml_w: &mut Encoder, rbml_w.end_tag(); rbml_w.wr_tagged_str(tag_region_param_def_def_id, - def_to_string(param.def_id)[]); + def_to_string(param.def_id).index(&FullRange)); rbml_w.wr_tagged_u64(tag_region_param_def_space, param.space.to_uint() as u64); @@ -864,9 +864,9 @@ fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, encode_path(rbml_w, impl_path.chain(Some(elem).into_iter())); match ast_item_opt { Some(&ast::MethodImplItem(ref ast_method)) => { - encode_attributes(rbml_w, ast_method.attrs[]); + encode_attributes(rbml_w, ast_method.attrs.index(&FullRange)); let any_types = !pty.generics.types.is_empty(); - if any_types || is_default_impl || should_inline(ast_method.attrs[]) { + if any_types || is_default_impl || should_inline(ast_method.attrs.index(&FullRange)) { encode_inlined_item(ecx, rbml_w, IIImplItemRef(local_def(parent_id), ast_item_opt.unwrap())); } @@ -912,7 +912,7 @@ fn encode_info_for_associated_type(ecx: &EncodeContext, match typedef_opt { None => {} Some(typedef) => { - encode_attributes(rbml_w, typedef.attrs[]); + encode_attributes(rbml_w, typedef.attrs.index(&FullRange)); encode_type(ecx, rbml_w, ty::node_id_to_type(ecx.tcx, typedef.id)); } @@ -1046,7 +1046,7 @@ fn encode_info_for_item(ecx: &EncodeContext, encode_path(rbml_w, path); encode_visibility(rbml_w, vis); encode_stability(rbml_w, stab); - encode_attributes(rbml_w, item.attrs[]); + encode_attributes(rbml_w, item.attrs.index(&FullRange)); rbml_w.end_tag(); } ast::ItemConst(_, _) => { @@ -1072,8 +1072,8 @@ fn encode_info_for_item(ecx: &EncodeContext, encode_bounds_and_type(rbml_w, ecx, &lookup_item_type(tcx, def_id)); encode_name(rbml_w, item.ident.name); encode_path(rbml_w, path); - encode_attributes(rbml_w, item.attrs[]); - if tps_len > 0u || should_inline(item.attrs[]) { + encode_attributes(rbml_w, item.attrs.index(&FullRange)); + if tps_len > 0u || should_inline(item.attrs.index(&FullRange)) { encode_inlined_item(ecx, rbml_w, IIItemRef(item)); } if tps_len == 0 { @@ -1089,7 +1089,7 @@ fn encode_info_for_item(ecx: &EncodeContext, encode_info_for_mod(ecx, rbml_w, m, - item.attrs[], + item.attrs.index(&FullRange), item.id, path, item.ident, @@ -1106,7 +1106,7 @@ fn encode_info_for_item(ecx: &EncodeContext, // Encode all the items in this module. for foreign_item in fm.items.iter() { rbml_w.start_tag(tag_mod_child); - rbml_w.wr_str(def_to_string(local_def(foreign_item.id))[]); + rbml_w.wr_str(def_to_string(local_def(foreign_item.id)).index(&FullRange)); rbml_w.end_tag(); } encode_visibility(rbml_w, vis); @@ -1134,8 +1134,8 @@ fn encode_info_for_item(ecx: &EncodeContext, encode_item_variances(rbml_w, ecx, item.id); encode_bounds_and_type(rbml_w, ecx, &lookup_item_type(tcx, def_id)); encode_name(rbml_w, item.ident.name); - encode_attributes(rbml_w, item.attrs[]); - encode_repr_attrs(rbml_w, ecx, item.attrs[]); + encode_attributes(rbml_w, item.attrs.index(&FullRange)); + encode_repr_attrs(rbml_w, ecx, item.attrs.index(&FullRange)); for v in (*enum_definition).variants.iter() { encode_variant_id(rbml_w, local_def(v.node.id)); } @@ -1152,7 +1152,7 @@ fn encode_info_for_item(ecx: &EncodeContext, encode_enum_variant_info(ecx, rbml_w, item.id, - (*enum_definition).variants[], + (*enum_definition).variants.index(&FullRange), index); } ast::ItemStruct(ref struct_def, _) => { @@ -1164,7 +1164,7 @@ fn encode_info_for_item(ecx: &EncodeContext, class itself */ let idx = encode_info_for_struct(ecx, rbml_w, - fields[], + fields.index(&FullRange), index); /* Index the class*/ @@ -1178,16 +1178,16 @@ fn encode_info_for_item(ecx: &EncodeContext, encode_item_variances(rbml_w, ecx, item.id); encode_name(rbml_w, item.ident.name); - encode_attributes(rbml_w, item.attrs[]); + encode_attributes(rbml_w, item.attrs.index(&FullRange)); encode_path(rbml_w, path.clone()); encode_stability(rbml_w, stab); encode_visibility(rbml_w, vis); - encode_repr_attrs(rbml_w, ecx, item.attrs[]); + encode_repr_attrs(rbml_w, ecx, item.attrs.index(&FullRange)); /* Encode def_ids for each field and method for methods, write all the stuff get_trait_method needs to know*/ - encode_struct_fields(rbml_w, fields[], def_id); + encode_struct_fields(rbml_w, fields.index(&FullRange), def_id); encode_inlined_item(ecx, rbml_w, IIItemRef(item)); @@ -1219,7 +1219,7 @@ fn encode_info_for_item(ecx: &EncodeContext, encode_family(rbml_w, 'i'); encode_bounds_and_type(rbml_w, ecx, &lookup_item_type(tcx, def_id)); encode_name(rbml_w, item.ident.name); - encode_attributes(rbml_w, item.attrs[]); + encode_attributes(rbml_w, item.attrs.index(&FullRange)); encode_unsafety(rbml_w, unsafety); encode_polarity(rbml_w, polarity); match ty.node { @@ -1323,7 +1323,7 @@ fn encode_info_for_item(ecx: &EncodeContext, encode_generics(rbml_w, ecx, &trait_def.generics, tag_item_generics); encode_trait_ref(rbml_w, ecx, &*trait_def.trait_ref, tag_item_trait_ref); encode_name(rbml_w, item.ident.name); - encode_attributes(rbml_w, item.attrs[]); + encode_attributes(rbml_w, item.attrs.index(&FullRange)); encode_visibility(rbml_w, vis); encode_stability(rbml_w, stab); for &method_def_id in ty::trait_item_def_ids(tcx, def_id).iter() { @@ -1341,7 +1341,7 @@ fn encode_info_for_item(ecx: &EncodeContext, rbml_w.end_tag(); rbml_w.start_tag(tag_mod_child); - rbml_w.wr_str(def_to_string(method_def_id.def_id())[]); + rbml_w.wr_str(def_to_string(method_def_id.def_id()).index(&FullRange)); rbml_w.end_tag(); } encode_path(rbml_w, path.clone()); @@ -1433,14 +1433,14 @@ fn encode_info_for_item(ecx: &EncodeContext, }; match trait_item { &ast::RequiredMethod(ref m) => { - encode_attributes(rbml_w, m.attrs[]); + encode_attributes(rbml_w, m.attrs.index(&FullRange)); encode_trait_item(rbml_w); encode_item_sort(rbml_w, 'r'); encode_method_argument_names(rbml_w, &*m.decl); } &ast::ProvidedMethod(ref m) => { - encode_attributes(rbml_w, m.attrs[]); + encode_attributes(rbml_w, m.attrs.index(&FullRange)); encode_trait_item(rbml_w); encode_item_sort(rbml_w, 'p'); encode_inlined_item(ecx, rbml_w, IITraitItemRef(def_id, trait_item)); @@ -1449,7 +1449,7 @@ fn encode_info_for_item(ecx: &EncodeContext, &ast::TypeTraitItem(ref associated_type) => { encode_attributes(rbml_w, - associated_type.attrs[]); + associated_type.attrs.index(&FullRange)); encode_item_sort(rbml_w, 't'); } } @@ -1603,7 +1603,7 @@ fn encode_index<T, F>(rbml_w: &mut Encoder, index: Vec<entry<T>>, mut write_fn: let mut buckets: Vec<Vec<entry<T>>> = range(0, 256u16).map(|_| Vec::new()).collect(); for elt in index.into_iter() { let h = hash::hash(&elt.val) as uint; - buckets[h % 256].push(elt); + (&mut buckets[h % 256]).push(elt); } rbml_w.start_tag(tag_index); @@ -1869,7 +1869,7 @@ fn encode_struct_field_attrs(rbml_w: &mut Encoder, krate: &ast::Crate) { fn visit_struct_field(&mut self, field: &ast::StructField) { self.rbml_w.start_tag(tag_struct_field); self.rbml_w.wr_tagged_u32(tag_struct_field_id, field.node.id); - encode_attributes(self.rbml_w, field.node.attrs[]); + encode_attributes(self.rbml_w, field.node.attrs.index(&FullRange)); self.rbml_w.end_tag(); } } @@ -1941,13 +1941,13 @@ fn encode_misc_info(ecx: &EncodeContext, rbml_w.start_tag(tag_misc_info_crate_items); for item in krate.module.items.iter() { rbml_w.start_tag(tag_mod_child); - rbml_w.wr_str(def_to_string(local_def(item.id))[]); + rbml_w.wr_str(def_to_string(local_def(item.id)).index(&FullRange)); rbml_w.end_tag(); each_auxiliary_node_id(&**item, |auxiliary_node_id| { rbml_w.start_tag(tag_mod_child); rbml_w.wr_str(def_to_string(local_def( - auxiliary_node_id))[]); + auxiliary_node_id)).index(&FullRange)); rbml_w.end_tag(); true }); @@ -2116,17 +2116,17 @@ fn encode_metadata_inner(wr: &mut SeekableMemWriter, let mut rbml_w = writer::Encoder::new(wr); - encode_crate_name(&mut rbml_w, ecx.link_meta.crate_name[]); + encode_crate_name(&mut rbml_w, ecx.link_meta.crate_name.index(&FullRange)); encode_crate_triple(&mut rbml_w, tcx.sess .opts .target_triple - []); + .index(&FullRange)); encode_hash(&mut rbml_w, &ecx.link_meta.crate_hash); encode_dylib_dependency_formats(&mut rbml_w, &ecx); let mut i = rbml_w.writer.tell().unwrap(); - encode_attributes(&mut rbml_w, krate.attrs[]); + encode_attributes(&mut rbml_w, krate.attrs.index(&FullRange)); stats.attr_bytes = rbml_w.writer.tell().unwrap() - i; i = rbml_w.writer.tell().unwrap(); |
