From fe13b865192028645b50c17d2cb1a6d44481f338 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 22 Apr 2013 14:43:02 -0700 Subject: Make conditions public. #6009 --- src/libsyntax/ext/expand.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 430402a8982..5c5817d480d 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -475,7 +475,7 @@ pub fn core_macros() -> ~str { { $c:ident: $in:ty -> $out:ty; } => { - mod $c { + pub mod $c { fn key(_x: @::core::condition::Handler<$in,$out>) { } pub static cond : -- cgit 1.4.1-3-g733a5 From c2e1f47955571fab24fc731c0af97e4c71f4ada9 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Tue, 30 Apr 2013 21:00:45 -0700 Subject: rustc: remove the rest of drop Removes: ast::struct_def::dtor syntax::ast::ii_dtor syntax::visit::fk_dtor syntax::ast_map::node_dtor syntax:struct_dtor --- src/librustc/metadata/common.rs | 1 - src/librustc/metadata/csearch.rs | 7 -- src/librustc/metadata/decoder.rs | 16 ---- src/librustc/metadata/encoder.rs | 27 ------ src/librustc/middle/astencode.rs | 26 ------ src/librustc/middle/borrowck/check_loans.rs | 6 +- src/librustc/middle/borrowck/gather_loans.rs | 3 +- src/librustc/middle/kind.rs | 11 --- src/librustc/middle/lint.rs | 29 ------- src/librustc/middle/liveness.rs | 5 +- src/librustc/middle/region.rs | 3 +- src/librustc/middle/resolve.rs | 21 +---- src/librustc/middle/trans/base.rs | 124 +-------------------------- src/librustc/middle/trans/debuginfo.rs | 3 - src/librustc/middle/trans/inline.rs | 4 - src/librustc/middle/trans/monomorphize.rs | 15 +--- src/librustc/middle/trans/reachable.rs | 13 +-- src/librustc/middle/trans/type_use.rs | 3 - src/librustc/middle/ty.rs | 27 +----- src/librustc/middle/typeck/check/mod.rs | 29 +------ src/librustc/middle/typeck/collect.rs | 25 ------ src/librustdoc/tystr_pass.rs | 8 +- src/libsyntax/ast.rs | 18 +--- src/libsyntax/ast_map.rs | 29 +------ src/libsyntax/ast_util.rs | 26 ------ src/libsyntax/ext/pipes/pipec.rs | 1 - src/libsyntax/fold.rs | 26 ------ src/libsyntax/parse/parser.rs | 2 - src/libsyntax/print/pprust.rs | 7 -- src/libsyntax/visit.rs | 44 +--------- 30 files changed, 21 insertions(+), 538 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/librustc/metadata/common.rs b/src/librustc/metadata/common.rs index 8e689f3147b..111c201d502 100644 --- a/src/librustc/metadata/common.rs +++ b/src/librustc/metadata/common.rs @@ -100,7 +100,6 @@ pub static tag_mod_impl_trait: uint = 0x47u; different tags. */ pub static tag_item_impl_method: uint = 0x48u; -pub static tag_item_dtor: uint = 0x49u; pub static tag_item_trait_method_self_ty: uint = 0x4b; pub static tag_item_trait_method_self_ty_region: uint = 0x4c; diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index 5626714260b..f8dc34f9cee 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -230,13 +230,6 @@ pub fn get_impl_method(cstore: @mut cstore::CStore, decoder::get_impl_method(cstore.intr, cdata, def.node, mname) } -/* If def names a class with a dtor, return it. Otherwise, return none. */ -pub fn struct_dtor(cstore: @mut cstore::CStore, def: ast::def_id) - -> Option { - let cdata = cstore::get_crate_data(cstore, def.crate); - decoder::struct_dtor(cdata, def.node) -} - pub fn get_item_visibility(cstore: @mut cstore::CStore, def_id: ast::def_id) -> ast::visibility { diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index cfe31360d32..fb7b3f9c8b1 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -445,22 +445,6 @@ pub fn get_impl_method(intr: @ident_interner, cdata: cmd, id: ast::node_id, found.get() } -pub fn struct_dtor(cdata: cmd, id: ast::node_id) -> Option { - let items = reader::get_doc(reader::Doc(cdata.data), tag_items); - let mut found = None; - let cls_items = match maybe_find_item(id, items) { - Some(it) => it, - None => fail!(fmt!("struct_dtor: class id not found \ - when looking up dtor for %d", id)) - }; - for reader::tagged_docs(cls_items, tag_item_dtor) |doc| { - let doc1 = reader::get_doc(doc, tag_def_id); - let did = reader::with_doc_data(doc1, |d| parse_def_id(d)); - found = Some(translate_def_id(cdata, did)); - }; - found -} - pub fn get_symbol(data: @~[u8], id: ast::node_id) -> ~str { return item_symbol(lookup_item(id, data)); } diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index dd4ef0d2e68..ba6a4f30857 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -765,26 +765,6 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: &writer::Encoder, class itself */ let idx = encode_info_for_struct(ecx, ebml_w, path, struct_def.fields, index); - /* Encode the dtor */ - for struct_def.dtor.each |dtor| { - index.push(entry {val: dtor.node.id, pos: ebml_w.writer.tell()}); - encode_info_for_ctor(ecx, - ebml_w, - dtor.node.id, - ecx.tcx.sess.ident_of( - *ecx.tcx.sess.str_of(item.ident) + - ~"_dtor"), - path, - if generics.ty_params.len() > 0u { - Some(ii_dtor(copy *dtor, - item.ident, - copy *generics, - local_def(item.id))) } - else { - None - }, - generics); - } /* Index the class*/ add_to_index(); @@ -816,13 +796,6 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: &writer::Encoder, encode_name(ecx, ebml_w, item.ident); encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); encode_region_param(ecx, ebml_w, item); - /* Encode the dtor */ - /* Encode id for dtor */ - for struct_def.dtor.each |dtor| { - do ebml_w.wr_tag(tag_item_dtor) { - encode_def_id(ebml_w, local_def(dtor.node.id)); - } - }; /* Encode def_ids for each field and method for methods, write all the stuff get_trait_method diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index c7c9c110586..2f753523a7b 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -327,15 +327,6 @@ fn simplify_ast(ii: &ast::inlined_item) -> ast::inlined_item { ast::ii_foreign(i) => { ast::ii_foreign(fld.fold_foreign_item(i)) } - ast::ii_dtor(ref dtor, nm, ref tps, parent_id) => { - let dtor_body = fld.fold_block(&dtor.node.body); - ast::ii_dtor( - codemap::spanned { - node: ast::struct_dtor_ { body: dtor_body, - .. /*bad*/copy (*dtor).node }, - .. (/*bad*/copy *dtor) }, - nm, /*bad*/copy *tps, parent_id) - } } } @@ -363,23 +354,6 @@ fn renumber_ast(xcx: @ExtendedDecodeContext, ii: ast::inlined_item) ast::ii_foreign(i) => { ast::ii_foreign(fld.fold_foreign_item(i)) } - ast::ii_dtor(ref dtor, nm, ref generics, parent_id) => { - let dtor_body = fld.fold_block(&dtor.node.body); - let dtor_attrs = fld.fold_attributes(/*bad*/copy (*dtor).node.attrs); - let new_generics = fold::fold_generics(generics, fld); - let dtor_id = fld.new_id((*dtor).node.id); - let new_parent = xcx.tr_def_id(parent_id); - let new_self = fld.new_id((*dtor).node.self_id); - ast::ii_dtor( - codemap::spanned { - node: ast::struct_dtor_ { id: dtor_id, - attrs: dtor_attrs, - self_id: new_self, - body: dtor_body }, - .. (/*bad*/copy *dtor) - }, - nm, new_generics, new_parent) - } } } diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index 07b6c80d420..526a5a3a9dd 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -629,8 +629,7 @@ fn check_loans_in_fn(fk: &visit::fn_kind, let declared_purity, src; match *fk { - visit::fk_item_fn(*) | visit::fk_method(*) | - visit::fk_dtor(*) => { + visit::fk_item_fn(*) | visit::fk_method(*) => { declared_purity = ty::ty_fn_purity(fty); src = id; } @@ -658,8 +657,7 @@ fn check_loans_in_fn(fk: &visit::fn_kind, // inherits the fn_args from enclosing ctxt } visit::fk_anon(*) | visit::fk_fn_block(*) | - visit::fk_method(*) | visit::fk_item_fn(*) | - visit::fk_dtor(*) => { + visit::fk_method(*) | visit::fk_item_fn(*) => { let mut fn_args = ~[]; for decl.inputs.each |input| { // For the purposes of purity, only consider function- diff --git a/src/librustc/middle/borrowck/gather_loans.rs b/src/librustc/middle/borrowck/gather_loans.rs index e40d0e63eb3..da048534118 100644 --- a/src/librustc/middle/borrowck/gather_loans.rs +++ b/src/librustc/middle/borrowck/gather_loans.rs @@ -104,8 +104,7 @@ fn req_loans_in_fn(fk: &visit::fn_kind, match *fk { visit::fk_anon(*) | visit::fk_fn_block(*) => {} - visit::fk_item_fn(*) | visit::fk_method(*) | - visit::fk_dtor(*) => { + visit::fk_item_fn(*) | visit::fk_method(*) => { self.item_ub = body.node.id; } } diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index cf488b0ac89..0925e8cdd63 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -153,17 +153,6 @@ fn check_item(item: @item, cx: Context, visitor: visit::vt) { } } } - item_struct(struct_def, _) => { - match struct_def.dtor { - None => {} - Some(ref dtor) => { - let struct_did = def_id { crate: 0, node: item.id }; - check_struct_safe_for_destructor(cx, - dtor.span, - struct_did); - } - } - } _ => {} } } diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index faf4b1c3106..b67d74bc272 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -57,7 +57,6 @@ pub enum lint { type_limits, default_methods, deprecated_mutable_fields, - deprecated_drop, unused_unsafe, managed_heap_memory, @@ -210,13 +209,6 @@ pub fn get_lint_dict() -> LintDict { default: deny }), - (~"deprecated_drop", - LintSpec { - lint: deprecated_drop, - desc: "deprecated \"drop\" notation for the destructor", - default: deny - }), - (~"unused_unsafe", LintSpec { lint: unused_unsafe, @@ -463,7 +455,6 @@ fn check_item(i: @ast::item, cx: ty::ctxt) { check_item_type_limits(cx, i); check_item_default_methods(cx, i); check_item_deprecated_mutable_fields(cx, i); - check_item_deprecated_drop(cx, i); check_item_unused_unsafe(cx, i); check_item_unused_mut(cx, i); } @@ -668,26 +659,6 @@ fn check_item_deprecated_mutable_fields(cx: ty::ctxt, item: @ast::item) { } } -fn check_item_deprecated_drop(cx: ty::ctxt, item: @ast::item) { - match item.node { - ast::item_struct(struct_def, _) => { - match struct_def.dtor { - None => {} - Some(ref dtor) => { - cx.sess.span_lint(deprecated_drop, - item.id, - item.id, - dtor.span, - ~"`drop` notation for destructors is \ - deprecated; implement the `Drop` \ - trait instead"); - } - } - } - _ => {} - } -} - fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) { fn check_foreign_fn(cx: ty::ctxt, fn_id: ast::node_id, diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 94d82d0acb8..0df10c59a8a 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -117,7 +117,7 @@ use syntax::ast::*; use syntax::codemap::span; use syntax::parse::token::special_idents; use syntax::print::pprust::{expr_to_str, block_to_str}; -use syntax::visit::{fk_anon, fk_dtor, fk_fn_block, fk_item_fn, fk_method}; +use syntax::visit::{fk_anon, fk_fn_block, fk_item_fn, fk_method}; use syntax::visit::{vt}; use syntax::{visit, ast_util}; @@ -440,9 +440,6 @@ fn visit_fn(fk: &visit::fn_kind, sty_static => {} } } - fk_dtor(_, _, self_id, _) => { - fn_maps.add_variable(Arg(self_id, special_idents::self_)); - } fk_item_fn(*) | fk_anon(*) | fk_fn_block(*) => {} } diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index f3299828171..88e201fb5f4 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -438,8 +438,7 @@ pub fn resolve_fn(fk: &visit::fn_kind, cx: ctxt, visitor: visit::vt) { let fn_cx = match *fk { - visit::fk_item_fn(*) | visit::fk_method(*) | - visit::fk_dtor(*) => { + visit::fk_item_fn(*) | visit::fk_method(*) => { // Top-level functions are a root scope. ctxt {parent: Some(id),.. cx} } diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 294a21fac2c..1d2ca59b8aa 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -47,7 +47,7 @@ use syntax::ast::{named_field, ne, neg, node_id, pat, pat_enum, pat_ident}; use syntax::ast::{Path, pat_lit, pat_range, pat_struct}; use syntax::ast::{prim_ty, private, provided}; use syntax::ast::{public, required, rem, self_ty_, shl, shr, stmt_decl}; -use syntax::ast::{struct_dtor, struct_field, struct_variant_kind}; +use syntax::ast::{struct_field, struct_variant_kind}; use syntax::ast::{sty_static, subtract, trait_ref, tuple_variant_kind, Ty}; use syntax::ast::{ty_bool, ty_char, ty_f, ty_f32, ty_f64, ty_float, ty_i}; use syntax::ast::{ty_i16, ty_i32, ty_i64, ty_i8, ty_int, TyParam, ty_path}; @@ -3512,7 +3512,6 @@ pub impl Resolver { self.resolve_struct(item.id, generics, struct_def.fields, - &struct_def.dtor, visitor); } @@ -3770,7 +3769,6 @@ pub impl Resolver { id: node_id, generics: &Generics, fields: &[@struct_field], - optional_destructor: &Option, visitor: ResolveVisitor) { // If applicable, create a rib for the type parameters. do self.with_type_parameter_rib(HasTypeParameters @@ -3784,23 +3782,6 @@ pub impl Resolver { for fields.each |field| { self.resolve_type(field.node.ty, visitor); } - - // Resolve the destructor, if applicable. - match *optional_destructor { - None => { - // Nothing to do. - } - Some(ref destructor) => { - self.resolve_function(NormalRibKind, - None, - NoTypeParameters, - &destructor.node.body, - HasSelfBinding - ((*destructor).node.self_id, - true), - visitor); - } - } } } diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index efa10dfc2aa..b3f7ab8b00a 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -2093,53 +2093,6 @@ pub fn trans_tuple_struct(ccx: @CrateContext, finish_fn(fcx, lltop); } -pub fn trans_struct_dtor(ccx: @CrateContext, - path: path, - body: &ast::blk, - dtor_id: ast::node_id, - psubsts: Option<@param_substs>, - hash_id: Option, - parent_id: ast::def_id) - -> ValueRef { - let tcx = ccx.tcx; - /* Look up the parent class's def_id */ - let mut class_ty = ty::lookup_item_type(tcx, parent_id).ty; - /* Substitute in the class type if necessary */ - for psubsts.each |ss| { - class_ty = ty::subst_tps(tcx, ss.tys, ss.self_ty, class_ty); - } - - /* The dtor takes a (null) output pointer, and a self argument, - and returns () */ - let lldty = type_of_dtor(ccx, class_ty); - - // XXX: Bad copies. - let s = get_dtor_symbol(ccx, copy path, dtor_id, psubsts); - - /* Register the dtor as a function. It has external linkage */ - let lldecl = decl_internal_cdecl_fn(ccx.llmod, s, lldty); - lib::llvm::SetLinkage(lldecl, lib::llvm::ExternalLinkage); - - /* If we're monomorphizing, register the monomorphized decl - for the dtor */ - for hash_id.each |h_id| { - ccx.monomorphized.insert(*h_id, lldecl); - } - /* Translate the dtor body */ - let decl = ast_util::dtor_dec(); - trans_fn(ccx, - path, - &decl, - body, - lldecl, - impl_self(class_ty), - psubsts, - dtor_id, - None, - []); - lldecl -} - pub fn trans_enum_def(ccx: @CrateContext, enum_definition: &ast::enum_def, id: ast::node_id, path: @ast_map::path, vi: @~[ty::VariantInfo], @@ -2158,8 +2111,7 @@ pub fn trans_enum_def(ccx: @CrateContext, enum_definition: &ast::enum_def, // Nothing to do. } ast::struct_variant_kind(struct_def) => { - trans_struct_def(ccx, struct_def, path, - variant.node.id); + trans_struct_def(ccx, struct_def); } } } @@ -2228,22 +2180,14 @@ pub fn trans_item(ccx: @CrateContext, item: &ast::item) { } ast::item_struct(struct_def, ref generics) => { if !generics.is_type_parameterized() { - trans_struct_def(ccx, struct_def, path, item.id); + trans_struct_def(ccx, struct_def); } } _ => {/* fall through */ } } } -pub fn trans_struct_def(ccx: @CrateContext, struct_def: @ast::struct_def, - path: @ast_map::path, - id: ast::node_id) { - // Translate the destructor. - for struct_def.dtor.each |dtor| { - trans_struct_dtor(ccx, /*bad*/copy *path, &dtor.node.body, - dtor.node.id, None, None, local_def(id)); - }; - +pub fn trans_struct_def(ccx: @CrateContext, struct_def: @ast::struct_def) { // If this is a tuple-like struct, translate the constructor. match struct_def.ctor_id { // We only need to translate a constructor if there are fields; @@ -2477,46 +2421,6 @@ pub fn item_path(ccx: @CrateContext, i: @ast::item) -> path { vec::append(/*bad*/copy *base, ~[path_name(i.ident)]) } -/* If there's already a symbol for the dtor with and substs , - return it; otherwise, create one and register it, returning it as well */ -pub fn get_dtor_symbol(ccx: @CrateContext, - path: path, - id: ast::node_id, - substs: Option<@param_substs>) - -> ~str { - let t = ty::node_id_to_type(ccx.tcx, id); - match ccx.item_symbols.find(&id) { - Some(s) => (/*bad*/copy *s), - None if substs.is_none() => { - let s = mangle_exported_name( - ccx, - vec::append(path, ~[path_name((ccx.names)(~"dtor"))]), - t); - // XXX: Bad copy, use `@str`? - ccx.item_symbols.insert(id, copy s); - s - } - None => { - // Monomorphizing, so just make a symbol, don't add - // this to item_symbols - match substs { - Some(ss) => { - let mono_ty = ty::subst_tps(ccx.tcx, ss.tys, ss.self_ty, t); - mangle_exported_name( - ccx, - vec::append(path, - ~[path_name((ccx.names)(~"dtor"))]), - mono_ty) - } - None => { - ccx.sess.bug(fmt!("get_dtor_symbol: not monomorphizing and \ - couldn't find a symbol for dtor %?", path)); - } - } - } - } -} - pub fn get_item_val(ccx: @CrateContext, id: ast::node_id) -> ValueRef { debug!("get_item_val(id=`%?`)", id); let tcx = ccx.tcx; @@ -2602,28 +2506,6 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::node_id) -> ValueRef { } } } - ast_map::node_dtor(_, dt, parent_id, pt) => { - /* - Don't just call register_fn, since we don't want to add - the implicit self argument automatically (we want to make sure - it has the right type) - */ - // Want parent_id and not id, because id is the dtor's type - let class_ty = ty::lookup_item_type(tcx, parent_id).ty; - // This code shouldn't be reached if the class is generic - assert!(!ty::type_has_params(class_ty)); - let lldty = T_fn(~[ - T_ptr(T_i8()), - T_ptr(type_of(ccx, class_ty)) - ], - T_nil()); - let s = get_dtor_symbol(ccx, /*bad*/copy *pt, dt.node.id, None); - - /* Make the declaration for the dtor */ - let llfn = decl_internal_cdecl_fn(ccx.llmod, s, lldty); - lib::llvm::SetLinkage(llfn, lib::llvm::ExternalLinkage); - llfn - } ast_map::node_variant(ref v, enm, pth) => { let llfn; diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index 2a2bf7ba4ad..58fc5ea3be6 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -983,9 +983,6 @@ pub fn create_function(fcx: fn_ctxt) -> @Metadata { expected an expr_fn_block here") } } - ast_map::node_dtor(_, _, did, _) => { - ((dbg_cx.names)(~"dtor"), ast_util::dtor_ty(), did.node) - } _ => fcx.ccx.sess.bug(~"create_function: unexpected \ sort of node") }; diff --git a/src/librustc/middle/trans/inline.rs b/src/librustc/middle/trans/inline.rs index 7a7f03c2273..ad06a9715b4 100644 --- a/src/librustc/middle/trans/inline.rs +++ b/src/librustc/middle/trans/inline.rs @@ -118,10 +118,6 @@ pub fn maybe_instantiate_inline(ccx: @CrateContext, fn_id: ast::def_id, } local_def(mth.id) } - csearch::found(ast::ii_dtor(ref dtor, _, _, _)) => { - ccx.external.insert(fn_id, Some((*dtor).node.id)); - local_def((*dtor).node.id) - } } } } diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs index 72ad6dde4f1..aa49915d175 100644 --- a/src/librustc/middle/trans/monomorphize.rs +++ b/src/librustc/middle/trans/monomorphize.rs @@ -13,7 +13,7 @@ use driver::session; use lib::llvm::ValueRef; use middle::trans::base::{get_insn_ctxt}; use middle::trans::base::{set_inline_hint_if_appr, set_inline_hint}; -use middle::trans::base::{trans_enum_variant, trans_struct_dtor}; +use middle::trans::base::{trans_enum_variant}; use middle::trans::base::{trans_fn, decl_internal_cdecl_fn}; use middle::trans::base::{get_item_val, no_self}; use middle::trans::base; @@ -35,7 +35,6 @@ use syntax::ast_map; use syntax::ast_map::path_name; use syntax::ast_util::local_def; use syntax::opt_vec; -use syntax::parse::token::special_idents; use syntax::abi::AbiSet; pub fn monomorphic_fn(ccx: @CrateContext, @@ -116,8 +115,6 @@ pub fn monomorphic_fn(ccx: @CrateContext, // Foreign externs don't have to be monomorphized. return (get_item_val(ccx, fn_id.node), true); } - ast_map::node_dtor(_, dtor, _, pt) => - (pt, special_idents::dtor, dtor.span), ast_map::node_trait_method(@ast::provided(m), _, pt) => { (pt, m.ident, m.span) } @@ -243,16 +240,6 @@ pub fn monomorphic_fn(ccx: @CrateContext, meth::trans_method(ccx, pt, mth, psubsts, None, d, impl_did); d } - ast_map::node_dtor(_, dtor, _, pt) => { - let parent_id = match ty::ty_to_def_id(ty::node_id_to_type(ccx.tcx, - dtor.node.self_id)) { - Some(did) => did, - None => ccx.sess.span_bug(dtor.span, ~"Bad self ty in \ - dtor") - }; - trans_struct_dtor(ccx, /*bad*/copy *pt, &dtor.node.body, - dtor.node.id, psubsts, Some(hash_id), parent_id) - } ast_map::node_trait_method(@ast::provided(mth), _, pt) => { let d = mk_lldecl(); set_inline_hint_if_appr(/*bad*/copy mth.attrs, d); diff --git a/src/librustc/middle/trans/reachable.rs b/src/librustc/middle/trans/reachable.rs index 3ccef0dbc4a..234473dd35b 100644 --- a/src/librustc/middle/trans/reachable.rs +++ b/src/librustc/middle/trans/reachable.rs @@ -124,18 +124,10 @@ fn traverse_public_item(cx: &ctx, item: @item) { } } } - item_struct(ref struct_def, ref generics) => { + item_struct(ref struct_def, _) => { for struct_def.ctor_id.each |&ctor_id| { cx.rmap.insert(ctor_id); } - for struct_def.dtor.each |dtor| { - cx.rmap.insert(dtor.node.id); - if generics.ty_params.len() > 0u || - attr::find_inline_attr(dtor.node.attrs) != attr::ia_none - { - traverse_inline_body(cx, &dtor.node.body); - } - } } item_ty(t, _) => { traverse_ty(t, cx, @@ -239,9 +231,6 @@ fn traverse_all_resources_and_impls(cx: &ctx, crate_mod: &_mod) { visit_item: |i, cx, v| { visit::visit_item(i, cx, v); match i.node { - item_struct(sdef, _) if sdef.dtor.is_some() => { - traverse_public_item(cx, i); - } item_impl(*) => { traverse_public_item(cx, i); } diff --git a/src/librustc/middle/trans/type_use.rs b/src/librustc/middle/trans/type_use.rs index 33145dd4334..e19eba6ca98 100644 --- a/src/librustc/middle/trans/type_use.rs +++ b/src/librustc/middle/trans/type_use.rs @@ -157,9 +157,6 @@ pub fn type_uses_for(ccx: @CrateContext, fn_id: def_id, n_tps: uint) for uint::range(0u, n_tps) |n| { cx.uses[n] |= flags;} } } - ast_map::node_dtor(_, ref dtor, _, _) => { - handle_body(cx, &dtor.node.body); - } ast_map::node_struct_ctor(*) => { // Similarly to node_variant, this monomorphized function just uses // the representations of all of its type parameters. diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index c7fb1e94adf..5b8e0e03b62 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -3748,28 +3748,8 @@ pub impl DtorKind { Otherwise return none. */ pub fn ty_dtor(cx: ctxt, struct_id: def_id) -> DtorKind { match cx.destructor_for_type.find(&struct_id) { - Some(&method_def_id) => return TraitDtor(method_def_id), - None => {} // Continue. - } - - if is_local(struct_id) { - match cx.items.find(&struct_id.node) { - Some(&ast_map::node_item(@ast::item { - node: ast::item_struct(@ast::struct_def { dtor: Some(ref dtor), - _ }, - _), - _ - }, _)) => - LegacyDtor(local_def((*dtor).node.id)), - _ => - NoDtor - } - } - else { - match csearch::struct_dtor(cx.sess.cstore, struct_id) { + Some(&method_def_id) => TraitDtor(method_def_id), None => NoDtor, - Some(did) => LegacyDtor(did), - } } } @@ -3819,11 +3799,6 @@ pub fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path { ast_map::path_name((*variant).node.name)) } - ast_map::node_dtor(_, _, _, path) => { - vec::append_one(/*bad*/copy *path, ast_map::path_name( - syntax::parse::token::special_idents::literally_dtor)) - } - ast_map::node_struct_ctor(_, item, path) => { vec::append_one(/*bad*/copy *path, ast_map::path_name(item.ident)) } diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index b9f3de873cf..d1c5ae18bc3 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -557,30 +557,7 @@ pub fn check_no_duplicate_fields(tcx: ty::ctxt, } } -pub fn check_struct(ccx: @mut CrateCtxt, - struct_def: @ast::struct_def, - id: ast::node_id, - span: span) { - let tcx = ccx.tcx; - let self_ty = ty::node_id_to_type(tcx, id); - - for struct_def.dtor.each |dtor| { - let class_t = SelfInfo { - self_ty: self_ty, - self_id: dtor.node.self_id, - span: dtor.span, - }; - // typecheck the dtor - let dtor_dec = ast_util::dtor_dec(); - check_bare_fn( - ccx, - &dtor_dec, - &dtor.node.body, - dtor.node.id, - Some(class_t) - ); - }; - +pub fn check_struct(ccx: @mut CrateCtxt, id: ast::node_id, span: span) { // Check that the class is instantiable check_instantiable(ccx.tcx, span, id); } @@ -623,8 +600,8 @@ pub fn check_item(ccx: @mut CrateCtxt, it: @ast::item) { } } } - ast::item_struct(struct_def, _) => { - check_struct(ccx, struct_def, it.id, it.span); + ast::item_struct(*) => { + check_struct(ccx, it.id, it.span); } ast::item_ty(t, ref generics) => { let tpt_ty = ty::node_id_to_type(ccx.tcx, it.id); diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 0ffd398d03c..10537711b32 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -49,7 +49,6 @@ use syntax::ast::{RegionTyParamBound, TraitTyParamBound}; use syntax::ast; use syntax::ast_map; use syntax::ast_util::{local_def, split_trait_methods}; -use syntax::ast_util; use syntax::codemap::span; use syntax::codemap; use syntax::print::pprust::{path_to_str, self_ty_to_str}; @@ -897,30 +896,6 @@ pub fn convert_struct(ccx: &CrateCtxt, id: ast::node_id) { let tcx = ccx.tcx; - for struct_def.dtor.each |dtor| { - let region_parameterization = - RegionParameterization::from_variance_and_generics(rp, generics); - - // Write the dtor type - let t_dtor = ty::mk_bare_fn( - tcx, - astconv::ty_of_bare_fn( - ccx, - &type_rscope(region_parameterization), - ast::impure_fn, - AbiSet::Rust(), - &opt_vec::Empty, - &ast_util::dtor_dec())); - write_ty_to_tcx(tcx, dtor.node.id, t_dtor); - tcx.tcache.insert(local_def(dtor.node.id), - ty_param_bounds_and_ty { - generics: ty::Generics { - type_param_defs: tpt.generics.type_param_defs, - region_param: rp - }, - ty: t_dtor}); - }; - // Write the type of each of the members for struct_def.fields.each |f| { convert_field(ccx, rp, tpt.generics.type_param_defs, *f, generics); diff --git a/src/librustdoc/tystr_pass.rs b/src/librustdoc/tystr_pass.rs index 303bdc53b69..a6fbee81bc8 100644 --- a/src/librustdoc/tystr_pass.rs +++ b/src/librustdoc/tystr_pass.rs @@ -332,13 +332,7 @@ fn fold_struct( /// what I actually want fn strip_struct_extra_stuff(item: @ast::item) -> @ast::item { let node = match copy item.node { - ast::item_struct(def, tys) => { - let def = @ast::struct_def { - dtor: None, // Remove the drop { } block - .. copy *def - }; - ast::item_struct(def, tys) - } + ast::item_struct(def, tys) => ast::item_struct(def, tys), _ => fail!(~"not a struct") }; diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index ba6fe1cda4f..71fd506ebed 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1174,10 +1174,7 @@ pub enum struct_field_kind { #[auto_decode] #[deriving(Eq)] pub struct struct_def { - fields: ~[@struct_field], /* fields */ - /* (not including ctor or dtor) */ - /* dtor is optional */ - dtor: Option, + fields: ~[@struct_field], /* fields, not including ctor */ /* ID of the constructor. This is only used for tuple- or enum-like * structs. */ ctor_id: Option @@ -1230,18 +1227,6 @@ impl to_bytes::IterBytes for struct_mutability { } } -pub type struct_dtor = spanned; - -#[auto_encode] -#[auto_decode] -#[deriving(Eq)] -pub struct struct_dtor_ { - id: node_id, - attrs: ~[attribute], - self_id: node_id, - body: blk, -} - #[auto_encode] #[auto_decode] #[deriving(Eq)] @@ -1272,7 +1257,6 @@ pub enum inlined_item { ii_item(@item), ii_method(def_id /* impl id */, @method), ii_foreign(@foreign_item), - ii_dtor(struct_dtor, ident, Generics, def_id /* parent id */) } /* hold off on tests ... they appear in a later merge. diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index f9828ad2b9e..d2125cebb5e 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -14,7 +14,6 @@ use ast; use ast_util::{inlined_item_utils, stmt_id}; use ast_util; use codemap; -use codemap::spanned; use diagnostic::span_handler; use parse::token::ident_interner; use print::pprust; @@ -93,8 +92,6 @@ pub enum ast_node { // order they are introduced. node_arg(arg, uint), node_local(uint), - // Destructor for a struct - node_dtor(Generics, @struct_dtor, def_id, @path), node_block(blk), node_struct_ctor(@struct_def, @item, @path), } @@ -163,7 +160,7 @@ pub fn map_decoded_item(diag: @span_handler, // don't decode and instantiate the impl, but just the method, we have to // add it to the table now: match *ii { - ii_item(*) | ii_dtor(*) => { /* fallthrough */ } + ii_item(*) => { /* fallthrough */ } ii_foreign(i) => { cx.map.insert(i.id, node_foreign_item(i, AbiSet::Intrinsic(), @@ -193,27 +190,6 @@ pub fn map_fn( node_arg(/* FIXME (#2543) */ copy *a, cx.local_id)); cx.local_id += 1u; } - match *fk { - visit::fk_dtor(generics, ref attrs, self_id, parent_id) => { - let dt = @spanned { - node: ast::struct_dtor_ { - id: id, - attrs: /* FIXME (#2543) */ vec::from_slice(*attrs), - self_id: self_id, - body: /* FIXME (#2543) */ copy *body, - }, - span: sp, - }; - cx.map.insert( - id, - node_dtor( - /* FIXME (#2543) */ copy *generics, - dt, - parent_id, - @/* FIXME (#2543) */ copy cx.path)); - } - _ => () - } visit::visit_fn(fk, decl, body, sp, id, cx, v); } @@ -411,9 +387,6 @@ pub fn node_id_to_str(map: map, id: node_id, itr: @ident_interner) -> ~str { Some(&node_local(_)) => { // add more info here fmt!("local (id=%?)", id) } - Some(&node_dtor(*)) => { // add more info here - fmt!("node_dtor (id=%?)", id) - } Some(&node_block(_)) => { fmt!("block") } diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 148b713a4f5..bf5381831d0 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -302,7 +302,6 @@ impl inlined_item_utils for inlined_item { ii_item(i) => /* FIXME (#2543) */ copy i.ident, ii_foreign(i) => /* FIXME (#2543) */ copy i.ident, ii_method(_, m) => /* FIXME (#2543) */ copy m.ident, - ii_dtor(_, nm, _, _) => /* FIXME (#2543) */ copy nm } } @@ -311,7 +310,6 @@ impl inlined_item_utils for inlined_item { ii_item(i) => i.id, ii_foreign(i) => i.id, ii_method(_, m) => m.id, - ii_dtor(ref dtor, _, _, _) => (*dtor).node.id } } @@ -320,10 +318,6 @@ impl inlined_item_utils for inlined_item { ii_item(i) => (v.visit_item)(i, e, v), ii_foreign(i) => (v.visit_foreign_item)(i, e, v), ii_method(_, m) => visit::visit_method_helper(m, e, v), - ii_dtor(/*bad*/ copy dtor, _, ref generics, parent_id) => { - visit::visit_struct_dtor_helper(dtor, generics, - parent_id, e, v); - } } } } @@ -359,20 +353,6 @@ pub fn operator_prec(op: ast::binop) -> uint { /// not appearing in the prior table. pub static as_prec: uint = 11u; -pub fn dtor_ty() -> @ast::Ty { - @ast::Ty {id: 0, node: ty_nil, span: dummy_sp()} -} - -pub fn dtor_dec() -> fn_decl { - let nil_t = dtor_ty(); - // dtor has no args - ast::fn_decl { - inputs: ~[], - output: nil_t, - cf: return_val, - } -} - pub fn empty_generics() -> Generics { Generics {lifetimes: opt_vec::Empty, ty_params: opt_vec::Empty} @@ -457,12 +437,6 @@ pub fn id_visitor(vfn: @fn(node_id)) -> visit::vt<()> { vfn(id); match *fk { - visit::fk_dtor(generics, _, self_id, parent_id) => { - visit_generics(generics); - vfn(id); - vfn(self_id); - vfn(parent_id.node); - } visit::fk_item_fn(_, generics, _, _) => { visit_generics(generics); } diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index 3311c61de8b..3ad94905f7f 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -431,7 +431,6 @@ impl gen_init for protocol { dummy_sp(), ast::struct_def { fields: fields, - dtor: None, ctor_id: None }, cx.strip_bounds(&generics)) diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index d82608846ab..adfc95f3e94 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -290,21 +290,8 @@ pub fn noop_fold_item_underscore(i: &item_, fld: @ast_fold) -> item_ { fn fold_struct_def(struct_def: @ast::struct_def, fld: @ast_fold) -> @ast::struct_def { - let dtor = do struct_def.dtor.map |dtor| { - let dtor_body = fld.fold_block(&dtor.node.body); - let dtor_id = fld.new_id(dtor.node.id); - spanned { - node: ast::struct_dtor_ { - body: dtor_body, - id: dtor_id, - .. copy dtor.node - }, - span: copy dtor.span - } - }; @ast::struct_def { fields: struct_def.fields.map(|f| fold_struct_field(*f, fld)), - dtor: dtor, ctor_id: struct_def.ctor_id.map(|cid| fld.new_id(*cid)), } } @@ -655,22 +642,9 @@ fn noop_fold_variant(v: &variant_, fld: @ast_fold) -> variant_ { }) } struct_variant_kind(struct_def) => { - let dtor = do struct_def.dtor.map |dtor| { - let dtor_body = fld.fold_block(&dtor.node.body); - let dtor_id = fld.new_id(dtor.node.id); - spanned { - node: ast::struct_dtor_ { - body: dtor_body, - id: dtor_id, - .. copy dtor.node - }, - .. copy *dtor - } - }; kind = struct_variant_kind(@ast::struct_def { fields: vec::map(struct_def.fields, |f| fld.fold_struct_field(*f)), - dtor: dtor, ctor_id: struct_def.ctor_id.map(|c| fld.new_id(*c)) }) } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 1a4a15b3bf5..27a1cde2f96 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3346,7 +3346,6 @@ pub impl Parser { (class_name, item_struct(@ast::struct_def { fields: fields, - dtor: None, ctor_id: if is_tuple_like { Some(new_id) } else { None } }, generics), None) @@ -3803,7 +3802,6 @@ pub impl Parser { return @ast::struct_def { fields: fields, - dtor: None, ctor_id: None }; } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index d5645ada929..f23badd0462 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -693,13 +693,6 @@ pub fn print_struct(s: @ps, nbsp(s); bopen(s); hardbreak_if_not_bol(s); - for struct_def.dtor.each |dtor| { - hardbreak_if_not_bol(s); - maybe_print_comment(s, dtor.span.lo); - print_outer_attributes(s, dtor.node.attrs); - head(s, ~"drop"); - print_block(s, &dtor.node.body); - } for struct_def.fields.each |field| { match field.node.kind { diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 80df8fb91a5..71cfbab9108 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -11,7 +11,6 @@ use abi::AbiSet; use ast::*; use ast; -use ast_util; use codemap::span; use parse; use opt_vec; @@ -39,13 +38,6 @@ pub enum fn_kind<'self> { // |x, y| ... fk_fn_block, - - fk_dtor( // class destructor - &'self Generics, - &'self [attribute], - node_id /* self id */, - def_id /* parent class id */ - ) } pub fn name_of_fn(fk: &fn_kind) -> ident { @@ -54,15 +46,13 @@ pub fn name_of_fn(fk: &fn_kind) -> ident { name } fk_anon(*) | fk_fn_block(*) => parse::token::special_idents::anon, - fk_dtor(*) => parse::token::special_idents::dtor } } pub fn generics_of_fn(fk: &fn_kind) -> Generics { match *fk { fk_item_fn(_, generics, _, _) | - fk_method(_, generics, _) | - fk_dtor(generics, _, _, _) => { + fk_method(_, generics, _) => { copy *generics } fk_anon(*) | fk_fn_block(*) => { @@ -369,25 +359,6 @@ pub fn visit_method_helper(m: &method, e: E, v: vt) { ); } -pub fn visit_struct_dtor_helper(dtor: struct_dtor, generics: &Generics, - parent_id: def_id, e: E, v: vt) { - (v.visit_fn)( - &fk_dtor( - generics, - dtor.node.attrs, - dtor.node.self_id, - parent_id - ), - &ast_util::dtor_dec(), - &dtor.node.body, - dtor.span, - dtor.node.id, - e, - v - ) - -} - pub fn visit_fn(fk: &fn_kind, decl: &fn_decl, body: &blk, _sp: span, _id: node_id, e: E, v: vt) { visit_fn_decl(decl, e, v); @@ -412,23 +383,14 @@ pub fn visit_trait_method(m: &trait_method, e: E, v: vt) { pub fn visit_struct_def( sd: @struct_def, _nm: ast::ident, - generics: &Generics, - id: node_id, + _generics: &Generics, + _id: node_id, e: E, v: vt ) { for sd.fields.each |f| { (v.visit_struct_field)(*f, e, v); } - for sd.dtor.each |dtor| { - visit_struct_dtor_helper( - *dtor, - generics, - ast_util::local_def(id), - e, - v - ) - } } pub fn visit_struct_field(sf: @struct_field, e: E, v: vt) { -- cgit 1.4.1-3-g733a5 From 3e3e2f00250d77719598ad052bb2016d46e6a148 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Tue, 30 Apr 2013 20:20:08 -0700 Subject: allow parsing attributes on struct fields --- src/libsyntax/ast.rs | 1 + src/libsyntax/ext/pipes/pipec.rs | 3 ++- src/libsyntax/fold.rs | 7 ++++++- src/libsyntax/parse/obsolete.rs | 6 +++--- src/libsyntax/parse/parser.rs | 30 ++++++++++++++++++------------ src/libsyntax/print/pprust.rs | 1 + 6 files changed, 31 insertions(+), 17 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 71fd506ebed..a853dbed2f1 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1158,6 +1158,7 @@ pub struct struct_field_ { kind: struct_field_kind, id: node_id, ty: @Ty, + attrs: ~[attribute], } pub type struct_field = spanned; diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index 3ad94905f7f..e876972fe68 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -415,7 +415,8 @@ impl gen_init for protocol { ast::struct_immutable, ast::inherited), id: cx.next_id(), - ty: fty + ty: fty, + attrs: ~[], }, span: dummy_sp() } diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index adfc95f3e94..36565395e59 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -222,9 +222,12 @@ pub fn noop_fold_item(i: @item, fld: @ast_fold) -> Option<@item> { fn noop_fold_struct_field(sf: @struct_field, fld: @ast_fold) -> @struct_field { + let fold_attribute = |x| fold_attribute_(x, fld); + @spanned { node: ast::struct_field_ { kind: copy sf.node.kind, id: sf.node.id, - ty: fld.fold_ty(sf.node.ty) }, + ty: fld.fold_ty(sf.node.ty), + attrs: sf.node.attrs.map(|e| fold_attribute(*e)) }, span: sf.span } } @@ -309,6 +312,7 @@ fn fold_struct_field(f: @struct_field, fld: @ast_fold) -> @struct_field { kind: copy f.node.kind, id: fld.new_id(f.node.id), ty: fld.fold_ty(f.node.ty), + attrs: /* FIXME (#2543) */ copy f.node.attrs, }, span: fld.new_span(f.span), } @@ -757,6 +761,7 @@ impl ast_fold for AstFoldFns { kind: copy sf.node.kind, id: sf.node.id, ty: (self as @ast_fold).fold_ty(sf.node.ty), + attrs: copy sf.node.attrs, }, span: (self.new_span)(sf.span), } diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index ce21e0f672d..c1afc53def0 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -18,7 +18,7 @@ removed. */ -use ast::{expr, expr_lit, lit_nil}; +use ast::{expr, expr_lit, lit_nil, attribute}; use ast; use codemap::{span, respan}; use parse::parser::Parser; @@ -282,13 +282,13 @@ pub impl Parser { } } - fn try_parse_obsolete_priv_section(&self) -> bool { + fn try_parse_obsolete_priv_section(&self, attrs: ~[attribute]) -> bool { if self.is_keyword(&~"priv") && self.look_ahead(1) == token::LBRACE { self.obsolete(copy *self.span, ObsoletePrivSection); self.eat_keyword(&~"priv"); self.bump(); while *self.token != token::RBRACE { - self.parse_single_struct_field(ast::private); + self.parse_single_struct_field(ast::private, attrs); } self.bump(); true diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 27a1cde2f96..74af7458408 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2520,7 +2520,9 @@ pub impl Parser { } // parse a structure field - fn parse_name_and_ty(&self, pr: visibility) -> @struct_field { + fn parse_name_and_ty(&self, + pr: visibility, + attrs: ~[attribute]) -> @struct_field { let mut is_mutbl = struct_immutable; let lo = self.span.lo; if self.eat_keyword(&~"mut") { @@ -2535,7 +2537,8 @@ pub impl Parser { @spanned(lo, self.last_span.hi, ast::struct_field_ { kind: named_field(name, is_mutbl, pr), id: self.get_id(), - ty: ty + ty: ty, + attrs: attrs, }) } @@ -3318,11 +3321,13 @@ pub impl Parser { &token::RPAREN, seq_sep_trailing_allowed(token::COMMA) ) |p| { + let attrs = self.parse_outer_attributes(); let lo = p.span.lo; let struct_field_ = ast::struct_field_ { kind: unnamed_field, id: self.get_id(), - ty: p.parse_ty(false) + ty: p.parse_ty(false), + attrs: attrs, }; @spanned(lo, p.span.hi, struct_field_) }; @@ -3359,12 +3364,14 @@ pub impl Parser { } // parse a structure field declaration - fn parse_single_struct_field(&self, vis: visibility) -> @struct_field { + fn parse_single_struct_field(&self, + vis: visibility, + attrs: ~[attribute]) -> @struct_field { if self.eat_obsolete_ident("let") { self.obsolete(*self.last_span, ObsoleteLet); } - let a_var = self.parse_name_and_ty(vis); + let a_var = self.parse_name_and_ty(vis, attrs); match *self.token { token::SEMI => { self.obsolete(copy *self.span, ObsoleteFieldTerminator); @@ -3390,26 +3397,25 @@ pub impl Parser { // parse an element of a struct definition fn parse_struct_decl_field(&self) -> ~[@struct_field] { - if self.try_parse_obsolete_priv_section() { + let attrs = self.parse_outer_attributes(); + + if self.try_parse_obsolete_priv_section(attrs) { return ~[]; } - // Need this to parse comments on fields. - let _attrs = self.parse_outer_attributes(); - if self.eat_keyword(&~"priv") { - return ~[self.parse_single_struct_field(private)] + return ~[self.parse_single_struct_field(private, attrs)] } if self.eat_keyword(&~"pub") { - return ~[self.parse_single_struct_field(public)]; + return ~[self.parse_single_struct_field(public, attrs)]; } if self.try_parse_obsolete_struct_ctor() { return ~[]; } - return ~[self.parse_single_struct_field(inherited)]; + return ~[self.parse_single_struct_field(inherited, attrs)]; } // parse visiility: PUB, PRIV, or nothing diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index f23badd0462..ab958d8b5ce 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -700,6 +700,7 @@ pub fn print_struct(s: @ps, ast::named_field(ident, mutability, visibility) => { hardbreak_if_not_bol(s); maybe_print_comment(s, field.span.lo); + print_outer_attributes(s, field.node.attrs); print_visibility(s, visibility); if mutability == ast::struct_mutable { word_nbsp(s, ~"mut"); -- cgit 1.4.1-3-g733a5 From e596128bd87b978fb163235bcf5eb0ef7d446218 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Wed, 1 May 2013 20:52:09 +1000 Subject: Remove 'Local Variable' comments --- src/compiletest/compiletest.rc | 7 ------- src/libcore/core.rc | 9 --------- src/libcore/either.rs | 10 ---------- src/libcore/io.rs | 10 ---------- src/libcore/libc.rs | 9 --------- src/libcore/num/cmath.rs | 11 ----------- src/libcore/num/f32.rs | 10 ---------- src/libcore/num/f64.rs | 10 ---------- src/libcore/num/float.rs | 10 ---------- src/libcore/option.rs | 8 -------- src/libcore/rand.rs | 9 --------- src/libcore/run.rs | 8 -------- src/libcore/sys.rs | 8 -------- src/libcore/unstable/extfmt.rs | 8 -------- src/libcore/unstable/lang.rs | 8 -------- src/libfuzzer/fuzzer.rc | 7 ------- src/librustc/back/abi.rs | 9 --------- src/librustc/back/arm.rs | 11 ----------- src/librustc/back/link.rs | 10 ---------- src/librustc/back/mips.rs | 11 ----------- src/librustc/back/upcall.rs | 9 --------- src/librustc/back/x86.rs | 10 ---------- src/librustc/back/x86_64.rs | 10 ---------- src/librustc/driver/driver.rs | 8 -------- src/librustc/driver/session.rs | 7 ------- src/librustc/front/config.rs | 8 -------- src/librustc/front/test.rs | 8 -------- src/librustc/lib/llvm.rs | 10 ---------- src/librustc/metadata/creader.rs | 8 -------- src/librustc/metadata/csearch.rs | 8 -------- src/librustc/metadata/cstore.rs | 8 -------- src/librustc/metadata/decoder.rs | 8 -------- src/librustc/metadata/encoder.rs | 9 --------- src/librustc/metadata/tydecode.rs | 10 ---------- src/librustc/metadata/tyencode.rs | 10 ---------- src/librustc/middle/check_const.rs | 8 -------- src/librustc/middle/check_match.rs | 8 -------- src/librustc/middle/const_eval.rs | 9 --------- src/librustc/middle/freevars.rs | 8 -------- src/librustc/middle/kind.rs | 10 ---------- src/librustc/middle/lint.rs | 10 ---------- src/librustc/middle/trans/_match.rs | 8 -------- src/librustc/middle/trans/base.rs | 9 --------- src/librustc/middle/trans/build.rs | 10 ---------- src/librustc/middle/trans/common.rs | 10 ---------- src/librustc/middle/trans/tvec.rs | 10 ---------- src/librustc/middle/ty.rs | 8 -------- src/librustc/middle/typeck/mod.rs | 9 --------- src/librustc/rustc.rc | 8 -------- src/librustc/util/common.rs | 10 ---------- src/librustc/util/ppaux.rs | 8 -------- src/libstd/bitv.rs | 10 ---------- src/libstd/dbg.rs | 8 -------- src/libstd/getopts.rs | 8 -------- src/libstd/list.rs | 8 -------- src/libstd/sha1.rs | 8 -------- src/libstd/sort.rs | 8 -------- src/libstd/std.rc | 8 -------- src/libstd/term.rs | 7 ------- src/libstd/test.rs | 9 --------- src/libsyntax/ast.rs | 9 --------- src/libsyntax/ast_map.rs | 8 -------- src/libsyntax/ast_util.rs | 8 -------- src/libsyntax/attr.rs | 10 ---------- src/libsyntax/codemap.rs | 12 ------------ src/libsyntax/ext/asm.rs | 12 ------------ src/libsyntax/ext/base.rs | 10 ---------- src/libsyntax/ext/env.rs | 10 ---------- src/libsyntax/ext/expand.rs | 8 -------- src/libsyntax/ext/fmt.rs | 9 --------- src/libsyntax/ext/source_util.rs | 10 ---------- src/libsyntax/ext/tt/macro_parser.rs | 8 -------- src/libsyntax/fold.rs | 10 ---------- src/libsyntax/parse/attr.rs | 10 ---------- src/libsyntax/parse/lexer.rs | 10 ---------- src/libsyntax/parse/mod.rs | 10 ---------- src/libsyntax/parse/parser.rs | 11 ----------- src/libsyntax/parse/token.rs | 8 -------- src/libsyntax/print/pp.rs | 11 ----------- src/libsyntax/print/pprust.rs | 10 ---------- src/libsyntax/visit.rs | 8 -------- src/test/run-pass/item-attributes.rs | 10 ---------- src/test/run-pass/spawn.rs | 8 -------- src/test/run-pass/spawn2.rs | 8 -------- src/test/run-pass/task-killjoin-rsrc.rs | 8 -------- src/test/run-pass/task-killjoin.rs | 8 -------- 86 files changed, 775 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/compiletest/compiletest.rc b/src/compiletest/compiletest.rc index 4392ce7ba28..b6d690f8307 100644 --- a/src/compiletest/compiletest.rc +++ b/src/compiletest/compiletest.rc @@ -223,10 +223,3 @@ pub fn make_test_closure(config: config, testfile: &Path) -> test::TestFn { let testfile = testfile.to_str(); test::DynTestFn(|| runtest::run(config, testfile)) } - -// Local Variables: -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libcore/core.rc b/src/libcore/core.rc index 9a0419ebfc6..f410591fdc7 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -263,12 +263,3 @@ mod core { pub use sys; pub use pipes; } - - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libcore/either.rs b/src/libcore/either.rs index 92f850cddd6..33b7e81ee85 100644 --- a/src/libcore/either.rs +++ b/src/libcore/either.rs @@ -263,13 +263,3 @@ fn test_partition_empty() { assert_eq!(vec::len(lefts), 0u); assert_eq!(vec::len(rights), 0u); } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 35ffd88c8f4..185b84a09c5 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -1954,13 +1954,3 @@ mod tests { } } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libcore/libc.rs b/src/libcore/libc.rs index 999a5d9b350..53aaf5726dd 100644 --- a/src/libcore/libc.rs +++ b/src/libcore/libc.rs @@ -1846,12 +1846,3 @@ pub mod funcs { } } } - - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libcore/num/cmath.rs b/src/libcore/num/cmath.rs index 30b0c54dc2d..8a0a88235d2 100644 --- a/src/libcore/num/cmath.rs +++ b/src/libcore/num/cmath.rs @@ -267,14 +267,3 @@ pub mod c_double_targ_consts { } */ - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// - diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 04ddd63a177..a00225e85bc 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -986,13 +986,3 @@ mod tests { assert_eq!(Primitive::bytes::(), sys::size_of::()); } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index 9f1944e3fad..c3bd89b0e03 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -1033,13 +1033,3 @@ mod tests { assert_eq!(Primitive::bytes::(), sys::size_of::()); } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libcore/num/float.rs b/src/libcore/num/float.rs index f163d67a69c..b487fa48782 100644 --- a/src/libcore/num/float.rs +++ b/src/libcore/num/float.rs @@ -1139,13 +1139,3 @@ mod tests { assert_eq!(to_str_digits(-infinity, 10u), ~"-inf"); } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 17192b4257b..47ec1fabcb8 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -565,11 +565,3 @@ fn test_get_or_zero() { let no_stuff: Option = None; assert!(no_stuff.get_or_zero() == 0); } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs index 94ba5ba31b7..80f69f067eb 100644 --- a/src/libcore/rand.rs +++ b/src/libcore/rand.rs @@ -1073,12 +1073,3 @@ mod tests { } } } - - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libcore/run.rs b/src/libcore/run.rs index 37401788ca2..d0c495dd19e 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -639,11 +639,3 @@ mod tests { test_destroy_actually_kills(true); } } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libcore/sys.rs b/src/libcore/sys.rs index 8cad0a22886..c0c1ad6d896 100644 --- a/src/libcore/sys.rs +++ b/src/libcore/sys.rs @@ -343,11 +343,3 @@ mod tests { #[should_fail] fn fail_owned() { FailWithCause::fail_with(~"cause", file!(), line!()) } } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libcore/unstable/extfmt.rs b/src/libcore/unstable/extfmt.rs index b812be5575a..f65b1e6726e 100644 --- a/src/libcore/unstable/extfmt.rs +++ b/src/libcore/unstable/extfmt.rs @@ -688,11 +688,3 @@ mod test { let _s = fmt!("%s", s); } } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libcore/unstable/lang.rs b/src/libcore/unstable/lang.rs index 611862a79e7..a6599e03d6b 100644 --- a/src/libcore/unstable/lang.rs +++ b/src/libcore/unstable/lang.rs @@ -183,11 +183,3 @@ pub fn start(main: *u8, argc: int, argv: **c_char, crate_map: *c_void) -> c_int; } } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libfuzzer/fuzzer.rc b/src/libfuzzer/fuzzer.rc index fc1efd3313c..7c93d867f50 100644 --- a/src/libfuzzer/fuzzer.rc +++ b/src/libfuzzer/fuzzer.rc @@ -693,10 +693,3 @@ pub fn main() { error!("Fuzzer done"); } - -// Local Variables: -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/back/abi.rs b/src/librustc/back/abi.rs index 70a029ede6f..842dd89a7cd 100644 --- a/src/librustc/back/abi.rs +++ b/src/librustc/back/abi.rs @@ -77,12 +77,3 @@ pub fn bzero_glue_name() -> ~str { return ~"rust_bzero_glue"; } pub fn yield_glue_name() -> ~str { return ~"rust_yield_glue"; } pub fn no_op_type_glue_name() -> ~str { return ~"rust_no_op_type_glue"; } -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/back/arm.rs b/src/librustc/back/arm.rs index 97c3a588a7f..dfe5751f21b 100644 --- a/src/librustc/back/arm.rs +++ b/src/librustc/back/arm.rs @@ -72,14 +72,3 @@ pub fn get_target_strs(target_os: session::os) -> target_strs::t { cc_args: ~[~"-marm"] }; } - - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index adaffe5873d..87e08a73fcb 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -949,13 +949,3 @@ pub fn link_args(sess: Session, return args; } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/back/mips.rs b/src/librustc/back/mips.rs index 93c1879eb0f..b15306a56b0 100644 --- a/src/librustc/back/mips.rs +++ b/src/librustc/back/mips.rs @@ -72,14 +72,3 @@ pub fn get_target_strs(target_os: session::os) -> target_strs::t { cc_args: ~[] }; } - - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/back/upcall.rs b/src/librustc/back/upcall.rs index 4cdd279e2fc..8fcc5234e8b 100644 --- a/src/librustc/back/upcall.rs +++ b/src/librustc/back/upcall.rs @@ -59,12 +59,3 @@ pub fn declare_upcalls(targ_cfg: @session::config, nothrow(dv(~"reset_stack_limit", ~[])) } } -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/back/x86.rs b/src/librustc/back/x86.rs index 2cc812c3d41..759f5f63c9e 100644 --- a/src/librustc/back/x86.rs +++ b/src/librustc/back/x86.rs @@ -55,13 +55,3 @@ pub fn get_target_strs(target_os: session::os) -> target_strs::t { cc_args: ~[~"-m32"] }; } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/back/x86_64.rs b/src/librustc/back/x86_64.rs index b68073974dc..ed6f1d28514 100644 --- a/src/librustc/back/x86_64.rs +++ b/src/librustc/back/x86_64.rs @@ -63,13 +63,3 @@ pub fn get_target_strs(target_os: session::os) -> target_strs::t { cc_args: ~[~"-m64"] }; } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index 8c053c265fa..afd0e0acfe9 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -951,11 +951,3 @@ mod test { assert!((vec::len(test_items) == 1u)); } } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index ff623049f75..b9e0eeb3466 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -430,10 +430,3 @@ mod test { assert!(building_library(lib_crate, crate, true)); } } - -// Local Variables: -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/front/config.rs b/src/librustc/front/config.rs index 75ae8724d72..2246dd9d2f0 100644 --- a/src/librustc/front/config.rs +++ b/src/librustc/front/config.rs @@ -194,11 +194,3 @@ pub fn metas_in_cfg(cfg: ast::crate_cfg, }) }) } - - -// Local Variables: -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index 02e2a4c8734..4506feece2b 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -456,11 +456,3 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> @ast::expr { ); e } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/lib/llvm.rs b/src/librustc/lib/llvm.rs index 31050448e75..fbb3380554d 100644 --- a/src/librustc/lib/llvm.rs +++ b/src/librustc/lib/llvm.rs @@ -2196,13 +2196,3 @@ pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter { } } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index 0d0f0d7ab69..da7a2c15f30 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -328,11 +328,3 @@ fn resolve_crate_deps(e: @mut Env, cdata: @~[u8]) -> cstore::cnum_map { } return @mut cnum_map; } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index f8dc34f9cee..375989b0ebe 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -243,11 +243,3 @@ pub fn get_link_args_for_crate(cstore: @mut cstore::CStore, let cdata = cstore::get_crate_data(cstore, crate_num); decoder::get_link_args_for_crate(cdata) } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs index 05275a4c665..21815a9ed47 100644 --- a/src/librustc/metadata/cstore.rs +++ b/src/librustc/metadata/cstore.rs @@ -161,11 +161,3 @@ pub fn get_dep_hashes(cstore: &CStore) -> ~[~str] { sorted.map(|ch| /*bad*/copy *ch.hash) } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index fb7b3f9c8b1..61454c802cc 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -1176,11 +1176,3 @@ pub fn get_link_args_for_crate(cdata: cmd) -> ~[~str] { } result } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index ba6a4f30857..2a4334781e4 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -1420,12 +1420,3 @@ pub fn encoded_ty(tcx: ty::ctxt, t: ty::t) -> ~str { tyencode::enc_ty(wr, cx, t); } } - - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index 011ee115e8c..b12db430afc 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -567,13 +567,3 @@ fn parse_bounds(st: @mut PState, conv: conv_did) -> @~[ty::param_bound] { } @bounds } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs index 763b1984b81..0548204b154 100644 --- a/src/librustc/metadata/tyencode.rs +++ b/src/librustc/metadata/tyencode.rs @@ -416,13 +416,3 @@ pub fn enc_type_param_def(w: @io::Writer, cx: @ctxt, v: &ty::TypeParameterDef) { w.write_char('|'); enc_bounds(w, cx, v.bounds); } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index 6a47eedcea8..36be65ed63f 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -253,11 +253,3 @@ pub fn check_item_recursion(sess: Session, visit::visit_expr(e, env, v); } } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 852eb1b50a4..e412a0e5102 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -862,11 +862,3 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt, (vt.visit_pat)(*pat, false, vt); } } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index 86b7379bb69..63b9fcf7096 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -484,12 +484,3 @@ pub fn lit_expr_eq(tcx: middle::ty::ctxt, a: @expr, b: @expr) -> bool { pub fn lit_eq(a: @lit, b: @lit) -> bool { compare_const_vals(&lit_to_const(a), &lit_to_const(b)) == 0 } - - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/middle/freevars.rs b/src/librustc/middle/freevars.rs index 4c8d36f93f4..419b75a2ad9 100644 --- a/src/librustc/middle/freevars.rs +++ b/src/librustc/middle/freevars.rs @@ -119,11 +119,3 @@ pub fn get_freevars(tcx: ty::ctxt, fid: ast::node_id) -> freevar_info { pub fn has_freevars(tcx: ty::ctxt, fid: ast::node_id) -> bool { return vec::len(*get_freevars(tcx, fid)) != 0u; } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index 0925e8cdd63..90e6f7c6af9 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -587,13 +587,3 @@ pub fn check_kind_bounds_of_cast(cx: Context, source: @expr, target: @expr) { _ => {} // Nothing to do. } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index b67d74bc272..f6db25065b7 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -946,13 +946,3 @@ pub fn check_crate(tcx: ty::ctxt, crate: @ast::crate) { tcx.sess.abort_if_errors(); } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 3755cca8c35..197b537fe90 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -1862,11 +1862,3 @@ pub fn bind_irrefutable_pat(bcx: block, } return bcx; } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 2090e50000b..0c3e3ba3cb6 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -3172,12 +3172,3 @@ pub fn trans_crate(sess: session::Session, return (llmod, link_meta); } } -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs index f5c496484a0..a02ac96e520 100644 --- a/src/librustc/middle/trans/build.rs +++ b/src/librustc/middle/trans/build.rs @@ -1086,13 +1086,3 @@ pub fn AtomicRMW(cx: block, op: AtomicBinOp, llvm::LLVMBuildAtomicRMW(B(cx), op, dst, src, order) } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index f8fb0f4b7cf..d31caffe77a 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -1521,13 +1521,3 @@ pub fn dummy_substs(tps: ~[ty::t]) -> ty::substs { pub fn bool_to_i1(bcx: block, llval: ValueRef) -> ValueRef { build::ICmp(bcx, lib::llvm::IntNE, llval, C_bool(false)) } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index 30a7648e7ea..da1cdfa4db1 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -594,13 +594,3 @@ pub fn iter_vec_unboxed(bcx: block, body_ptr: ValueRef, vec_ty: ty::t, let dataptr = get_dataptr(bcx, body_ptr); return iter_vec_raw(bcx, dataptr, vec_ty, fill, f); } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index ccd7cc6a8ab..1546c885a6d 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -4370,11 +4370,3 @@ pub fn visitor_object_ty(tcx: ctxt) -> (@TraitRef, t) { (trait_ref, mk_trait(tcx, trait_ref.def_id, copy trait_ref.substs, BoxTraitStore, ast::m_imm)) } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs index 646b6412f55..b0e0b7319ac 100644 --- a/src/librustc/middle/typeck/mod.rs +++ b/src/librustc/middle/typeck/mod.rs @@ -426,12 +426,3 @@ pub fn check_crate(tcx: ty::ctxt, tcx.sess.abort_if_errors(); (ccx.method_map, ccx.vtable_map) } -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/rustc.rc b/src/librustc/rustc.rc index 54c51cf2e48..adb1c2fcc41 100644 --- a/src/librustc/rustc.rc +++ b/src/librustc/rustc.rc @@ -357,11 +357,3 @@ pub fn main() { run_compiler(&args, demitter); } } - - -// Local Variables: -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index 38f55b2b6e4..b4a479fc597 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -112,13 +112,3 @@ pub fn pluralize(n: uint, s: ~str) -> ~str { // A set of node IDs (used to keep track of which node IDs are for statements) pub type stmt_set = @mut HashSet; - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index aa8c3f8fd1b..69849a8d51b 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -739,11 +739,3 @@ impl Repr for ty::vstore { vstore_to_str(tcx, *self) } } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index 5314c35419c..078ed6af5a0 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -1507,13 +1507,3 @@ mod tests { } } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libstd/dbg.rs b/src/libstd/dbg.rs index 34dd6390ecc..4b2d2a60a68 100644 --- a/src/libstd/dbg.rs +++ b/src/libstd/dbg.rs @@ -76,11 +76,3 @@ fn test_breakpoint_should_not_abort_process_when_not_under_gdb() { // the process under normal circumstances breakpoint(); } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index fda5c105da5..c03042fe9c2 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -1374,11 +1374,3 @@ Options: assert!(usage == expected) } } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libstd/list.rs b/src/libstd/list.rs index 401cc121a62..2b6fa0bc056 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -242,11 +242,3 @@ mod tests { == list::append(list::from_vec(~[1,2]), list::from_vec(~[3,4]))); } } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libstd/sha1.rs b/src/libstd/sha1.rs index 7371250b38a..a8e0f7d062a 100644 --- a/src/libstd/sha1.rs +++ b/src/libstd/sha1.rs @@ -412,11 +412,3 @@ mod tests { } } } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 3e6011e80df..172532a2e5b 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -1202,11 +1202,3 @@ mod big_tests { } } } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 0a5348d7976..ea099090eba 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -121,11 +121,3 @@ pub mod std { pub use serialize; pub use test; } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libstd/term.rs b/src/libstd/term.rs index 022f1f8564e..a79b9f4c849 100644 --- a/src/libstd/term.rs +++ b/src/libstd/term.rs @@ -76,10 +76,3 @@ pub fn fg(writer: @io::Writer, color: u8) { pub fn bg(writer: @io::Writer, color: u8) { return set_color(writer, '4' as u8, color); } - -// Local Variables: -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 278a326d1de..65fb0c7426a 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -960,12 +960,3 @@ mod tests { } } } - - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 4bb2d220ad6..a295952439f 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1346,12 +1346,3 @@ mod test { } */ -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index d2125cebb5e..69397276c4f 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -404,11 +404,3 @@ pub fn node_item_query(items: map, id: node_id, _ => fail!(error_msg) } } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 2b3793e45e9..47ef7227842 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -832,11 +832,3 @@ mod test { } } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 2f8405c6e96..f4f0def2843 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -341,13 +341,3 @@ pub fn require_unique_names(diagnostic: @span_handler, } } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 1194506a887..5f4967351e1 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -522,15 +522,3 @@ mod test { fm.next_line(BytePos(2)); } } - - - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index dfebf6f786a..53f40113532 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -187,15 +187,3 @@ pub fn expand_asm(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) span: sp }) } - - - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 2d6d74b5c1e..1c03ad13759 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -543,13 +543,3 @@ mod test { assert_eq!(*(m.find(&@~"def").get()),16); } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs index 5e5fd7d97b1..5b1e3737b23 100644 --- a/src/libsyntax/ext/env.rs +++ b/src/libsyntax/ext/env.rs @@ -34,13 +34,3 @@ pub fn expand_syntax_ext(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) }; MRExpr(e) } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index fde5a259422..02a698b283d 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -721,11 +721,3 @@ mod test { } } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index 9bbe617eb07..62641279f88 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -322,12 +322,3 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span, return mk_block(cx, fmt_sp, ~[], stms, Some(buf())); } -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 70aa9472c85..ab22b3152f4 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -150,13 +150,3 @@ fn res_rel_file(cx: @ext_ctxt, sp: codemap::span, arg: &Path) -> Path { copy *arg } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index e4e033e0fff..0c1e619985d 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -438,11 +438,3 @@ pub fn parse_nt(p: &Parser, name: ~str) -> nonterminal { _ => p.fatal(~"Unsupported builtin nonterminal parser: " + name) } } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 36565395e59..229a8664d0c 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -859,13 +859,3 @@ impl AstFoldExtensions for @ast_fold { pub fn make_fold(afp: ast_fold_fns) -> @ast_fold { afp as @ast_fold } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index cc580155d70..037b2c089f4 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -179,13 +179,3 @@ impl parser_attr for Parser { } } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index 60d6ce504fd..16a7ef71317 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -892,13 +892,3 @@ mod test { assert_eq!(tok, token::LIFETIME(id)); } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 5d51a54d770..74e4f562ce5 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -674,13 +674,3 @@ mod test { string_to_expr(@~"a::z.froob(b,@(987+3))"); } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index a582748edb3..8459fc8c627 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4509,14 +4509,3 @@ pub impl Parser { } } } - - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 338b7c99d97..fe7bd5b3bc1 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -556,11 +556,3 @@ pub fn reserved_keyword_table() -> HashSet<~str> { } return words; } - - -// Local Variables: -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index e2ad5becb12..3fa615939b7 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -587,14 +587,3 @@ pub fn hardbreak_tok_offset(off: int) -> token { } pub fn hardbreak_tok() -> token { return hardbreak_tok_offset(0); } - - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index ab958d8b5ce..76de109eebd 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2280,13 +2280,3 @@ mod test { assert_eq!(&varstr,&~"pub principal_skinner"); } } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 71cfbab9108..9a0c97d7616 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -757,11 +757,3 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> { v_struct_method(v.visit_struct_method, a, b, c) }); } - -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/test/run-pass/item-attributes.rs b/src/test/run-pass/item-attributes.rs index 24fe6713372..c616d46a833 100644 --- a/src/test/run-pass/item-attributes.rs +++ b/src/test/run-pass/item-attributes.rs @@ -195,13 +195,3 @@ fn test_fn_inner() { } pub fn main() { } - -// -// Local Variables: -// mode: rust -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/test/run-pass/spawn.rs b/src/test/run-pass/spawn.rs index db4ca7b3ed8..63c2b7da38f 100644 --- a/src/test/run-pass/spawn.rs +++ b/src/test/run-pass/spawn.rs @@ -18,11 +18,3 @@ pub fn main() { } fn child(&&i: int) { error!(i); assert!((i == 10)); } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/test/run-pass/spawn2.rs b/src/test/run-pass/spawn2.rs index f9350746349..e748a1636ea 100644 --- a/src/test/run-pass/spawn2.rs +++ b/src/test/run-pass/spawn2.rs @@ -32,11 +32,3 @@ fn child(&&args: (int, int, int, int, int, int, int, int, int)) { assert!((i8 == 80)); assert!((i9 == 90)); } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/test/run-pass/task-killjoin-rsrc.rs b/src/test/run-pass/task-killjoin-rsrc.rs index 7cd08695da0..879f668577f 100644 --- a/src/test/run-pass/task-killjoin-rsrc.rs +++ b/src/test/run-pass/task-killjoin-rsrc.rs @@ -83,11 +83,3 @@ fn supervisor() { pub fn main() { join(joinable(supervisor)); } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: diff --git a/src/test/run-pass/task-killjoin.rs b/src/test/run-pass/task-killjoin.rs index 563e35be3d6..73c069e560c 100644 --- a/src/test/run-pass/task-killjoin.rs +++ b/src/test/run-pass/task-killjoin.rs @@ -33,11 +33,3 @@ fn supervisor() { pub fn main() { task::spawn_unlinked(supervisor) } - -// Local Variables: -// mode: rust; -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -- cgit 1.4.1-3-g733a5 From 35b91e2f73cec610af4a2a653389562ad7cbc85e Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Fri, 3 May 2013 01:28:53 +0900 Subject: Use static strings --- src/librustc/middle/borrowck/loan.rs | 6 +- src/librustc/middle/borrowck/mod.rs | 4 +- src/librustc/middle/borrowck/preserve.rs | 2 +- src/librustc/middle/trans/_match.rs | 3 +- src/librustc/middle/trans/base.rs | 9 ++- src/librustc/middle/trans/callee.rs | 4 +- src/librustc/middle/trans/consts.rs | 35 +++----- src/librustc/middle/trans/datum.rs | 4 +- src/librustc/middle/trans/debuginfo.rs | 23 +++--- src/librustc/middle/trans/expr.rs | 11 ++- src/librustc/middle/trans/foreign.rs | 2 +- src/librustc/middle/trans/monomorphize.rs | 2 +- src/librustc/middle/trans/reachable.rs | 10 ++- src/librustc/middle/trans/tvec.rs | 4 +- src/librustc/middle/typeck/astconv.rs | 31 +++----- src/librustc/middle/typeck/check/_match.rs | 37 ++++----- src/librustc/middle/typeck/check/method.rs | 14 ++-- src/librustc/middle/typeck/check/mod.rs | 92 ++++++++++------------ src/librustc/middle/typeck/check/regionck.rs | 18 ++--- src/librustc/middle/typeck/check/vtable.rs | 2 +- src/librustc/middle/typeck/coherence.rs | 52 +++++------- src/librustc/middle/typeck/collect.rs | 5 +- .../middle/typeck/infer/region_inference.rs | 8 +- src/librustc/middle/typeck/mod.rs | 8 +- src/libsyntax/ext/base.rs | 2 +- src/libsyntax/parse/parser.rs | 69 ++++++++-------- 26 files changed, 201 insertions(+), 256 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/librustc/middle/borrowck/loan.rs b/src/librustc/middle/borrowck/loan.rs index 21de29b8f60..4dd727390aa 100644 --- a/src/librustc/middle/borrowck/loan.rs +++ b/src/librustc/middle/borrowck/loan.rs @@ -115,7 +115,7 @@ pub impl LoanContext { if cmt.lp.is_none() { self.bccx.tcx.sess.span_bug( cmt.span, - ~"loan() called with non-lendable value"); + "loan() called with non-lendable value"); } match cmt.cat { @@ -123,7 +123,7 @@ pub impl LoanContext { // should never be loanable self.bccx.tcx.sess.span_bug( cmt.span, - ~"rvalue with a non-none lp"); + "rvalue with a non-none lp"); } cat_local(local_id) | cat_arg(local_id) | cat_self(local_id) => { // FIXME(#4903) @@ -188,7 +188,7 @@ pub impl LoanContext { // Aliased data is simply not lendable. self.bccx.tcx.sess.span_bug( cmt.span, - ~"aliased ptr with a non-none lp"); + "aliased ptr with a non-none lp"); } } } diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index 3746f9c6e60..f1d45e6e9aa 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -525,11 +525,11 @@ pub impl BorrowckCtxt { self.note_and_explain_bckerr(err); } - fn span_err(&self, s: span, m: ~str) { + fn span_err(&self, s: span, m: &str) { self.tcx.sess.span_err(s, m); } - fn span_note(&self, s: span, m: ~str) { + fn span_note(&self, s: span, m: &str) { self.tcx.sess.span_note(s, m); } diff --git a/src/librustc/middle/borrowck/preserve.rs b/src/librustc/middle/borrowck/preserve.rs index c44920fffa5..62358823f23 100644 --- a/src/librustc/middle/borrowck/preserve.rs +++ b/src/librustc/middle/borrowck/preserve.rs @@ -124,7 +124,7 @@ pub impl<'self> PreserveCtxt<'self> { if self.root_managed_data { self.tcx().sess.span_bug( cmt.span, - ~"preserve() called with local and !root_managed_data"); + "preserve() called with local and !root_managed_data"); } let local_region = self.tcx().region_maps.encl_region(local_id); self.compare_scope(cmt, local_region) diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 197b537fe90..3bd2a8269b7 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -557,8 +557,7 @@ pub fn enter_opt<'r>(bcx: block, struct_id = found_struct_id; } _ => { - tcx.sess.span_bug(p.span, ~"expected enum \ - variant def"); + tcx.sess.span_bug(p.span, "expected enum variant def"); } } diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 0c3e3ba3cb6..87e347d2004 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -1125,10 +1125,11 @@ pub fn init_local(bcx: block, local: @ast::local) -> block { } let llptr = match bcx.fcx.lllocals.find(&local.node.id) { - Some(&local_mem(v)) => v, - _ => { bcx.tcx().sess.span_bug(local.span, - ~"init_local: Someone forgot to document why it's\ - safe to assume local.node.init must be local_mem!"); + Some(&local_mem(v)) => v, + _ => { + bcx.tcx().sess.span_bug(local.span, + "init_local: Someone forgot to document why it's\ + safe to assume local.node.init must be local_mem!"); } }; diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index ad0fea3b4b4..ed7f91bf04a 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -356,9 +356,7 @@ pub fn trans_method_call(in_cx: block, origin) } None => { - cx.tcx().sess.span_bug(call_ex.span, - ~"method call expr wasn't in \ - method map") + cx.tcx().sess.span_bug(call_ex.span, "method call expr wasn't in method map") } } }, diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index c6c5561854c..9d04905bcc9 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -58,8 +58,7 @@ pub fn const_lit(cx: @CrateContext, e: @ast::expr, lit: ast::lit) } _ => { cx.sess.span_bug(lit.span, - ~"floating point literal doesn't have the right \ - type"); + "floating point literal doesn't have the right type"); } } } @@ -281,7 +280,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef { else { llvm::LLVMConstURem(te1, te2) } } ast::and | - ast::or => cx.sess.span_unimpl(e.span, ~"binop logic"), + ast::or => cx.sess.span_unimpl(e.span, "binop logic"), ast::bitxor => llvm::LLVMConstXor(te1, te2), ast::bitand => llvm::LLVMConstAnd(te1, te2), ast::bitor => llvm::LLVMConstOr(te1, te2), @@ -295,7 +294,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef { ast::le | ast::ne | ast::ge | - ast::gt => cx.sess.span_unimpl(e.span, ~"binop comparator") + ast::gt => cx.sess.span_unimpl(e.span, "binop comparator") } } ast::expr_unary(u, e) => { @@ -344,8 +343,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef { const_eval::const_int(i) => i as u64, const_eval::const_uint(u) => u, _ => cx.sess.span_bug(index.span, - ~"index is not an integer-constant \ - expression") + "index is not an integer-constant expression") }; let (arr, len) = match ty::get(bt).sty { ty::ty_evec(_, vstore) | ty::ty_estr(vstore) => @@ -363,12 +361,10 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef { unit_sz)) }, _ => cx.sess.span_bug(base.span, - ~"index-expr base must be \ - fixed-size or slice") + "index-expr base must be fixed-size or slice") }, _ => cx.sess.span_bug(base.span, - ~"index-expr base must be \ - a vector or string type") + "index-expr base must be a vector or string type") }; let len = llvm::LLVMConstIntGetZExtValue(len) as u64; @@ -380,7 +376,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef { // FIXME #3170: report this earlier on in the const-eval // pass. Reporting here is a bit late. cx.sess.span_err(e.span, - ~"const index-expr is out of bounds"); + "const index-expr is out of bounds"); } const_get_elt(cx, arr, [iv as c_uint]) } @@ -454,8 +450,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef { match fs.find(|f| field_ty.ident == f.node.ident) { Some(ref f) => const_expr(cx, (*f).node.expr), None => { - cx.tcx.sess.span_bug( - e.span, ~"missing struct field"); + cx.tcx.sess.span_bug(e.span, "missing struct field"); } } }); @@ -471,8 +466,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef { ast::expr_lit(ref lit) => { match lit.node { ast::lit_str(*) => { const_expr(cx, sub) } - _ => { cx.sess.span_bug(e.span, - ~"bad const-slice lit") } + _ => { cx.sess.span_bug(e.span, "bad const-slice lit") } } } ast::expr_vec(ref es, ast::m_imm) => { @@ -487,8 +481,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef { let p = const_ptrcast(cx, gv, llunitty); C_struct(~[p, sz]) } - _ => cx.sess.span_bug(e.span, - ~"bad const-slice expr") + _ => cx.sess.span_bug(e.span, "bad const-slice expr") } } ast::expr_path(pth) => { @@ -520,8 +513,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef { C_null(llty) } _ => { - cx.sess.span_bug(e.span, ~"expected a const, fn, \ - struct, or variant def") + cx.sess.span_bug(e.span, "expected a const, fn, struct, or variant def") } } } @@ -542,13 +534,12 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef { adt::trans_const(cx, repr, vinfo.disr_val, args.map(|a| const_expr(cx, *a))) } - _ => cx.sess.span_bug(e.span, ~"expected a struct or \ - variant def") + _ => cx.sess.span_bug(e.span, "expected a struct or variant def") } } ast::expr_paren(e) => { return const_expr(cx, e); } _ => cx.sess.span_bug(e.span, - ~"bad constant expression type in consts::const_expr") + "bad constant expression type in consts::const_expr") }; } } diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index fa27f652ac8..cf5fbb6e216 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -761,8 +761,8 @@ pub impl Datum { match self.try_deref(bcx, expr.id, derefs, false) { (Some(lvres), bcx) => DatumBlock { bcx: bcx, datum: lvres }, (None, _) => { - bcx.ccx().sess.span_bug( - expr.span, ~"Cannot deref this expression"); + bcx.ccx().sess.span_bug(expr.span, + "Cannot deref this expression"); } } } diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index 58fc5ea3be6..b7a1a90741c 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -756,7 +756,7 @@ fn create_ty(cx: @CrateContext, t: ty::t, span: span) } }, ty::ty_enum(_did, ref _substs) => { - cx.sess.span_bug(span, ~"debuginfo for enum NYI") + cx.sess.span_bug(span, "debuginfo for enum NYI") } ty::ty_box(ref mt) | ty::ty_uniq(ref mt) => { let boxed = create_ty(cx, mt.ty, span); @@ -782,7 +782,7 @@ fn create_ty(cx: @CrateContext, t: ty::t, span: span) create_pointer_type(cx, t, span, pointee) }, ty::ty_rptr(ref _region, ref _mt) => { - cx.sess.span_bug(span, ~"debuginfo for rptr NYI") + cx.sess.span_bug(span, "debuginfo for rptr NYI") }, ty::ty_bare_fn(ref barefnty) => { let inputs = do barefnty.sig.inputs.map |a| { a.ty }; @@ -790,10 +790,10 @@ fn create_ty(cx: @CrateContext, t: ty::t, span: span) create_fn_ty(cx, t, inputs, output, span) }, ty::ty_closure(ref _closurety) => { - cx.sess.span_bug(span, ~"debuginfo for closure NYI") + cx.sess.span_bug(span, "debuginfo for closure NYI") }, ty::ty_trait(_did, ref _substs, ref _vstore, _) => { - cx.sess.span_bug(span, ~"debuginfo for trait NYI") + cx.sess.span_bug(span, "debuginfo for trait NYI") }, ty::ty_struct(did, ref substs) => { let fields = ty::struct_fields(cx.tcx, did, substs); @@ -860,14 +860,12 @@ pub fn create_local_var(bcx: block, local: @ast::local) let llptr = match bcx.fcx.lllocals.find(&local.node.id) { option::Some(&local_mem(v)) => v, option::Some(_) => { - bcx.tcx().sess.span_bug(local.span, ~"local is bound to \ - something weird"); + bcx.tcx().sess.span_bug(local.span, "local is bound to something weird"); } option::None => { match *bcx.fcx.lllocals.get(&local.node.pat.id) { local_imm(v) => v, - _ => bcx.tcx().sess.span_bug(local.span, ~"local is bound to \ - something weird") + _ => bcx.tcx().sess.span_bug(local.span, "local is bound to something weird") } } }; @@ -966,8 +964,7 @@ pub fn create_function(fcx: fn_ctxt) -> @Metadata { ast::item_fn(ref decl, _, _, _, _) => { (item.ident, decl.output, item.id) } - _ => fcx.ccx.sess.span_bug(item.span, ~"create_function: item \ - bound to non-function") + _ => fcx.ccx.sess.span_bug(item.span, "create_function: item bound to non-function") } } ast_map::node_method(method, _, _) => { @@ -979,12 +976,10 @@ pub fn create_function(fcx: fn_ctxt) -> @Metadata { ((dbg_cx.names)(~"fn"), decl.output, expr.id) } _ => fcx.ccx.sess.span_bug(expr.span, - ~"create_function: \ - expected an expr_fn_block here") + "create_function: expected an expr_fn_block here") } } - _ => fcx.ccx.sess.bug(~"create_function: unexpected \ - sort of node") + _ => fcx.ccx.sess.bug("create_function: unexpected sort of node") }; debug!("%?", ident); diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index ae510ae6d11..7cdd7c3799e 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -690,7 +690,7 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr, } _ => { bcx.tcx().sess.span_bug(expr.span, - ~"expr_cast of non-trait"); + "expr_cast of non-trait"); } } } @@ -700,8 +700,7 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr, _ => { bcx.tcx().sess.span_bug( expr.span, - fmt!("trans_rvalue_dps_unadjusted reached \ - fall-through case: %?", + fmt!("trans_rvalue_dps_unadjusted reached fall-through case: %?", expr.node)); } } @@ -1202,7 +1201,7 @@ fn trans_rec_or_struct(bcx: block, } None => { tcx.sess.span_bug(field.span, - ~"Couldn't find field in struct type") + "Couldn't find field in struct type") } } }; @@ -1478,7 +1477,7 @@ fn trans_eager_binop(bcx: block, } else { if !ty::type_is_scalar(rhs_t) { bcx.tcx().sess.span_bug(binop_expr.span, - ~"non-scalar comparison"); + "non-scalar comparison"); } let cmpr = base::compare_scalar_types(bcx, lhs, rhs, rhs_t, op); bcx = cmpr.bcx; @@ -1486,7 +1485,7 @@ fn trans_eager_binop(bcx: block, } } _ => { - bcx.tcx().sess.span_bug(binop_expr.span, ~"unexpected binop"); + bcx.tcx().sess.span_bug(binop_expr.span, "unexpected binop"); } }; diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs index c45ba64c584..0e2bf80cc5e 100644 --- a/src/librustc/middle/trans/foreign.rs +++ b/src/librustc/middle/trans/foreign.rs @@ -1080,7 +1080,7 @@ pub fn trans_intrinsic(ccx: @CrateContext, _ => { // Could we make this an enum rather than a string? does it get // checked earlier? - ccx.sess.span_bug(item.span, ~"unknown intrinsic"); + ccx.sess.span_bug(item.span, "unknown intrinsic"); } } build_return(bcx); diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs index aa49915d175..2640dab1c04 100644 --- a/src/librustc/middle/trans/monomorphize.rs +++ b/src/librustc/middle/trans/monomorphize.rs @@ -160,7 +160,7 @@ pub fn monomorphic_fn(ccx: @CrateContext, // causing an infinite expansion. if depth > 30 { ccx.sess.span_fatal( - span, ~"overly deep expansion of inlined function"); + span, "overly deep expansion of inlined function"); } ccx.monomorphizing.insert(fn_id, depth + 1); diff --git a/src/librustc/middle/trans/reachable.rs b/src/librustc/middle/trans/reachable.rs index 234473dd35b..f301a7d2973 100644 --- a/src/librustc/middle/trans/reachable.rs +++ b/src/librustc/middle/trans/reachable.rs @@ -170,11 +170,13 @@ fn traverse_inline_body(cx: &ctx, body: &blk) { expr_path(_) => { match cx.tcx.def_map.find(&e.id) { Some(&d) => { - traverse_def_id(cx, def_id_of_def(d)); + traverse_def_id(cx, def_id_of_def(d)); } - None => cx.tcx.sess.span_bug(e.span, fmt!("Unbound node \ - id %? while traversing %s", e.id, - expr_to_str(e, cx.tcx.sess.intr()))) + None => cx.tcx.sess.span_bug( + e.span, + fmt!("Unbound node id %? while traversing %s", + e.id, + expr_to_str(e, cx.tcx.sess.intr()))) } } expr_field(_, _, _) => { diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index da1cdfa4db1..e8075c1f2ad 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -469,7 +469,7 @@ pub fn write_content(bcx: block, } _ => { bcx.tcx().sess.span_bug(content_expr.span, - ~"Unexpected evec content"); + "Unexpected evec content"); } } } @@ -503,7 +503,7 @@ pub fn elements_required(bcx: block, content_expr: @ast::expr) -> uint { ty::eval_repeat_count(bcx.tcx(), count_expr) } _ => bcx.tcx().sess.span_bug(content_expr.span, - ~"Unexpected evec content") + "Unexpected evec content") } } diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index ffaa6d46d33..7ef77646f52 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -291,10 +291,8 @@ pub fn ast_ty_to_ty( ty::vstore_fixed(*) => { tcx.sess.span_err( path.span, - ~"@trait, ~trait or &trait \ - are the only supported \ - forms of casting-to-\ - trait"); + "@trait, ~trait or &trait are the only supported \ + forms of casting-to-trait"); ty::BoxTraitStore } }; @@ -321,7 +319,7 @@ pub fn ast_ty_to_ty( if path.types.len() > 0u { tcx.sess.span_err( path.span, - ~"type parameters are not allowed on this type"); + "type parameters are not allowed on this type"); } } @@ -329,7 +327,7 @@ pub fn ast_ty_to_ty( if path.rp.is_some() { tcx.sess.span_err( path.span, - ~"region parameters are not allowed on this type"); + "region parameters are not allowed on this type"); } } } @@ -339,9 +337,8 @@ pub fn ast_ty_to_ty( match tcx.ast_ty_to_ty_cache.find(&ast_ty.id) { Some(&ty::atttce_resolved(ty)) => return ty, Some(&ty::atttce_unresolved) => { - tcx.sess.span_fatal(ast_ty.span, ~"illegal recursive type; \ - insert an enum in the cycle, \ - if this is desired"); + tcx.sess.span_fatal(ast_ty.span, "illegal recursive type; \ + insert an enum in the cycle, if this is desired"); } None => { /* go on */ } } @@ -359,11 +356,9 @@ pub fn ast_ty_to_ty( |tmt| ty::mk_uniq(tcx, tmt)) } ast::ty_vec(ref mt) => { - tcx.sess.span_err(ast_ty.span, - ~"bare `[]` is not a type"); + tcx.sess.span_err(ast_ty.span, "bare `[]` is not a type"); // return /something/ so they can at least get more errors - ty::mk_evec(tcx, ast_mt_to_mt(self, rscope, mt), - ty::vstore_uniq) + ty::mk_evec(tcx, ast_mt_to_mt(self, rscope, mt), ty::vstore_uniq) } ast::ty_ptr(ref mt) => { ty::mk_ptr(tcx, ast_mt_to_mt(self, rscope, mt)) @@ -434,7 +429,7 @@ pub fn ast_ty_to_ty( } ast::ty_str => { tcx.sess.span_err(ast_ty.span, - ~"bare `str` is not a type"); + "bare `str` is not a type"); // return /something/ so they can at least get more errors ty::mk_estr(tcx, ty::vstore_uniq) } @@ -454,7 +449,7 @@ pub fn ast_ty_to_ty( } _ => { tcx.sess.span_fatal(ast_ty.span, - ~"found type name used as a variable"); + "found type name used as a variable"); } } } @@ -470,7 +465,7 @@ pub fn ast_ty_to_ty( ty::vstore_fixed(i as uint)), _ => { tcx.sess.span_fatal( - ast_ty.span, ~"expected constant expr for vector length"); + ast_ty.span, "expected constant expr for vector length"); } } } @@ -489,11 +484,11 @@ pub fn ast_ty_to_ty( // routine. self.tcx().sess.span_bug( ast_ty.span, - ~"found `ty_infer` in unexpected place"); + "found `ty_infer` in unexpected place"); } ast::ty_mac(_) => { tcx.sess.span_bug(ast_ty.span, - ~"found `ty_mac` in unexpected place"); + "found `ty_mac` in unexpected place"); } }; diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index 5ff71057121..de384d02dc3 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -204,8 +204,7 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: @ast::Path, if arg_len > 0 { // N-ary variant. if arg_len != subpats_len { - let s = fmt!("this pattern has %u field%s, but the corresponding \ - %s has %u field%s", + let s = fmt!("this pattern has %u field%s, but the corresponding %s has %u field%s", subpats_len, if subpats_len == 1u { ~"" } else { ~"s" }, kind_name, @@ -223,13 +222,12 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: @ast::Path, } } } else if subpats_len > 0 { - tcx.sess.span_err - (pat.span, fmt!("this pattern has %u field%s, but the \ - corresponding %s has no fields", - subpats_len, - if subpats_len == 1u { ~"" } - else { ~"s" }, - kind_name)); + tcx.sess.span_err(pat.span, + fmt!("this pattern has %u field%s, but the corresponding %s has no \ + fields", + subpats_len, + if subpats_len == 1u { "" } else { "s" }, + kind_name)); error_happened = true; } @@ -319,20 +317,19 @@ pub fn check_struct_pat(pcx: &pat_ctxt, pat_id: ast::node_id, span: span, Some(&ast::def_struct(*)) | Some(&ast::def_variant(*)) => { let name = pprust::path_to_str(path, tcx.sess.intr()); tcx.sess.span_err(span, - fmt!("mismatched types: expected `%s` but \ - found `%s`", + fmt!("mismatched types: expected `%s` but found `%s`", fcx.infcx().ty_to_str(expected), name)); } _ => { - tcx.sess.span_bug(span, ~"resolve didn't write in class"); + tcx.sess.span_bug(span, "resolve didn't write in class"); } } // Forbid pattern-matching structs with destructors. if ty::has_dtor(tcx, class_id) { - tcx.sess.span_err(span, ~"deconstructing struct not allowed in \ - pattern (it has a destructor)"); + tcx.sess.span_err(span, "deconstructing struct not allowed in pattern \ + (it has a destructor)"); } check_struct_pat_fields(pcx, span, path, fields, class_fields, class_id, @@ -370,7 +367,7 @@ pub fn check_struct_like_enum_variant_pat(pcx: &pat_ctxt, name)); } _ => { - tcx.sess.span_bug(span, ~"resolve didn't write in variant"); + tcx.sess.span_bug(span, "resolve didn't write in variant"); } } } @@ -404,10 +401,9 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) { { // no-op } else if !ty::type_is_numeric(b_ty) { - tcx.sess.span_err(pat.span, ~"non-numeric type used in range"); + tcx.sess.span_err(pat.span, "non-numeric type used in range"); } else if !valid_range_bounds(fcx.ccx, begin, end) { - tcx.sess.span_err(begin.span, ~"lower range bound must be less \ - than upper"); + tcx.sess.span_err(begin.span, "lower range bound must be less than upper"); } fcx.write_ty(pat.id, b_ty); } @@ -476,9 +472,8 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) { } _ => { tcx.sess.span_err(pat.span, - fmt!("mismatched types: expected `%s` \ - but found struct", - fcx.infcx().ty_to_str(expected))); + fmt!("mismatched types: expected `%s` but found struct", + fcx.infcx().ty_to_str(expected))); error_happened = true; } } diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index fb5b53d9400..abaadceb053 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -872,7 +872,7 @@ pub impl<'self> LookupContext<'self> { if relevant_candidates.len() > 1 { self.tcx().sess.span_err( self.expr.span, - ~"multiple applicable methods in scope"); + "multiple applicable methods in scope"); for uint::range(0, relevant_candidates.len()) |idx| { self.report_candidate(idx, &relevant_candidates[idx].origin); } @@ -983,12 +983,12 @@ pub impl<'self> LookupContext<'self> { } else if num_method_tps == 0u { tcx.sess.span_err( self.expr.span, - ~"this method does not take type parameters"); + "this method does not take type parameters"); self.fcx.infcx().next_ty_vars(num_method_tps) } else if num_supplied_tps != num_method_tps { tcx.sess.span_err( self.expr.span, - ~"incorrect number of type \ + "incorrect number of type \ parameters given for this method"); self.fcx.infcx().next_ty_vars(num_method_tps) } else { @@ -1082,14 +1082,14 @@ pub impl<'self> LookupContext<'self> { if ty::type_has_self(method_fty) { self.tcx().sess.span_err( self.expr.span, - ~"cannot call a method whose type contains a \ - self-type through a boxed trait"); + "cannot call a method whose type contains a \ + self-type through a boxed trait"); } if candidate.method_ty.generics.has_type_params() { self.tcx().sess.span_err( self.expr.span, - ~"cannot call a generic method through a boxed trait"); + "cannot call a generic method through a boxed trait"); } } @@ -1109,7 +1109,7 @@ pub impl<'self> LookupContext<'self> { if bad { self.tcx().sess.span_err(self.expr.span, - ~"explicit call to destructor"); + "explicit call to destructor"); } } diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index d1c5ae18bc3..69775771d96 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -542,17 +542,15 @@ pub fn check_no_duplicate_fields(tcx: ty::ctxt, let (id, sp) = *p; let orig_sp = field_names.find(&id).map_consume(|x| *x); match orig_sp { - Some(orig_sp) => { - tcx.sess.span_err(sp, fmt!("Duplicate field \ - name %s in record type declaration", - *tcx.sess.str_of(id))); - tcx.sess.span_note(orig_sp, ~"First declaration of \ - this field occurred here"); - break; - } - None => { - field_names.insert(id, sp); - } + Some(orig_sp) => { + tcx.sess.span_err(sp, fmt!("Duplicate field name %s in record type declaration", + *tcx.sess.str_of(id))); + tcx.sess.span_note(orig_sp, "First declaration of this field occurred here"); + break; + } + None => { + field_names.insert(id, sp); + } } } } @@ -1252,8 +1250,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, ty::ty_rptr(_, mt) => formal_ty = mt.ty, ty::ty_err => (), _ => { - fcx.ccx.tcx.sess.span_bug(arg.span, - ~"no ref"); + fcx.ccx.tcx.sess.span_bug(arg.span, "no ref"); } } } @@ -1559,8 +1556,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, match ty::get(lhs_resolved_t).sty { ty::ty_bare_fn(_) | ty::ty_closure(_) => { tcx.sess.span_note( - ex.span, ~"did you forget the `do` keyword \ - for the call?"); + ex.span, "did you forget the `do` keyword for the call?"); } _ => () } @@ -1851,9 +1847,9 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, tcx.sess.span_err(span, fmt!("missing field%s: %s", if missing_fields.len() == 1 { - ~"" + "" } else { - ~"s" + "s" }, str::connect(missing_fields, ~", "))); } @@ -1901,7 +1897,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, } _ => { tcx.sess.span_bug(span, - ~"resolve didn't map this to a class"); + "resolve didn't map this to a class"); } } } else { @@ -1989,7 +1985,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, } _ => { tcx.sess.span_bug(span, - ~"resolve didn't map this to an enum"); + "resolve didn't map this to an enum"); } } } else { @@ -2201,7 +2197,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, } } _ => - tcx.sess.span_bug(expr.span, ~"vstore modifier on non-sequence") + tcx.sess.span_bug(expr.span, "vstore modifier on non-sequence") }; fcx.write_ty(ev.id, typ); fcx.write_ty(id, typ); @@ -2284,21 +2280,18 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, ty::ty_enum(*) => { tcx.sess.span_err( expr.span, - ~"can only dereference enums \ - with a single variant which has a \ - single argument"); + "can only dereference enums with a single variant which \ + has a single argument"); } ty::ty_struct(*) => { tcx.sess.span_err( expr.span, - ~"can only dereference structs with \ - one anonymous field"); + "can only dereference structs with one anonymous field"); } _ => { fcx.type_error_message(expr.span, |actual| { - fmt!("type %s cannot be \ - dereferenced", actual) + fmt!("type %s cannot be dereferenced", actual) }, oprnd_t, None); } } @@ -2394,7 +2387,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, result::Err(_) => { tcx.sess.span_err( expr.span, - ~"`return;` in function returning non-nil"); + "`return;` in function returning non-nil"); } }, Some(e) => { @@ -2758,8 +2751,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, variant_id, *fields); } _ => { - tcx.sess.span_bug(path.span, ~"structure constructor does \ - not name a structure type"); + tcx.sess.span_bug(path.span, + "structure constructor does not name a structure type"); } } } @@ -2961,7 +2954,7 @@ pub fn check_block_with_expected(fcx: @mut FnCtxt, } _ => false } { - fcx.ccx.tcx.sess.span_warn(s.span, ~"unreachable statement"); + fcx.ccx.tcx.sess.span_warn(s.span, "unreachable statement"); warned = true; } if ty::type_is_bot(s_ty) { @@ -2982,7 +2975,7 @@ pub fn check_block_with_expected(fcx: @mut FnCtxt, }, Some(e) => { if any_bot && !warned { - fcx.ccx.tcx.sess.span_warn(e.span, ~"unreachable expression"); + fcx.ccx.tcx.sess.span_warn(e.span, "unreachable expression"); } check_expr_with_opt_hint(fcx, e, expected); let ety = fcx.expr_ty(e); @@ -3073,8 +3066,8 @@ pub fn check_enum_variants(ccx: @mut CrateCtxt, *disr_val = val as int; } Ok(_) => { - ccx.tcx.sess.span_err(e.span, ~"expected signed integer \ - constant"); + ccx.tcx.sess.span_err(e.span, "expected signed integer \ + constant"); } Err(ref err) => { ccx.tcx.sess.span_err(e.span, @@ -3085,7 +3078,7 @@ pub fn check_enum_variants(ccx: @mut CrateCtxt, } if vec::contains(*disr_vals, &*disr_val) { ccx.tcx.sess.span_err(v.span, - ~"discriminator value already exists"); + "discriminator value already exists"); } disr_vals.push(*disr_val); let ctor_ty = ty::node_id_to_type(ccx.tcx, v.node.id); @@ -3142,9 +3135,9 @@ pub fn check_enum_variants(ccx: @mut CrateCtxt, _ => false } }) { - ccx.tcx.sess.span_err(sp, ~"illegal recursive enum type; \ - wrap the inner value in a box to \ - make it representable"); + ccx.tcx.sess.span_err(sp, + "illegal recursive enum type; \ + wrap the inner value in a box to make it representable"); } // Check that it is possible to instantiate this enum: @@ -3205,26 +3198,25 @@ pub fn ty_param_bounds_and_ty_for_def(fcx: @mut FnCtxt, ast::def_ty(_) | ast::def_prim_ty(_) | ast::def_ty_param(*)=> { - fcx.ccx.tcx.sess.span_bug(sp, ~"expected value but found type"); + fcx.ccx.tcx.sess.span_bug(sp, "expected value but found type"); } ast::def_mod(*) | ast::def_foreign_mod(*) => { - fcx.ccx.tcx.sess.span_bug(sp, ~"expected value but found module"); + fcx.ccx.tcx.sess.span_bug(sp, "expected value but found module"); } ast::def_use(*) => { - fcx.ccx.tcx.sess.span_bug(sp, ~"expected value but found use"); + fcx.ccx.tcx.sess.span_bug(sp, "expected value but found use"); } ast::def_region(*) => { - fcx.ccx.tcx.sess.span_bug(sp, ~"expected value but found region"); + fcx.ccx.tcx.sess.span_bug(sp, "expected value but found region"); } ast::def_typaram_binder(*) => { - fcx.ccx.tcx.sess.span_bug(sp, ~"expected value but found type \ - parameter"); + fcx.ccx.tcx.sess.span_bug(sp, "expected value but found type parameter"); } ast::def_label(*) => { - fcx.ccx.tcx.sess.span_bug(sp, ~"expected value but found label"); + fcx.ccx.tcx.sess.span_bug(sp, "expected value but found label"); } ast::def_self_ty(*) => { - fcx.ccx.tcx.sess.span_bug(sp, ~"expected value but found self ty"); + fcx.ccx.tcx.sess.span_bug(sp, "expected value but found self ty"); } } } @@ -3253,7 +3245,7 @@ pub fn instantiate_path(fcx: @mut FnCtxt, match tpt.generics.region_param { None => { // ...but the type is not lifetime parameterized! fcx.ccx.tcx.sess.span_err - (span, ~"this item is not region-parameterized"); + (span, "this item is not region-parameterized"); None } Some(_) => { // ...and the type is lifetime parameterized, ok. @@ -3273,15 +3265,15 @@ pub fn instantiate_path(fcx: @mut FnCtxt, fcx.infcx().next_ty_vars(ty_param_count) } else if ty_param_count == 0 { fcx.ccx.tcx.sess.span_err - (span, ~"this item does not take type parameters"); + (span, "this item does not take type parameters"); fcx.infcx().next_ty_vars(ty_param_count) } else if ty_substs_len > ty_param_count { fcx.ccx.tcx.sess.span_err - (span, ~"too many type parameters provided for this item"); + (span, "too many type parameters provided for this item"); fcx.infcx().next_ty_vars(ty_param_count) } else if ty_substs_len < ty_param_count { fcx.ccx.tcx.sess.span_err - (span, ~"not enough type parameters provided for this item"); + (span, "not enough type parameters provided for this item"); fcx.infcx().next_ty_vars(ty_param_count) } else { pth.types.map(|aty| fcx.to_ty(*aty)) diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index cb2b854276d..3a38d0b1d7b 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -490,13 +490,13 @@ fn constrain_auto_ref(rcx: @mut Rcx, expr: @ast::expr) { // reporting an error would be the correct path. tcx.sess.span_err( expr.span, - ~"lifetime of borrowed pointer does not include \ - the expression being borrowed"); + "lifetime of borrowed pointer does not include \ + the expression being borrowed"); note_and_explain_region( tcx, - ~"lifetime of the borrowed pointer is", + "lifetime of the borrowed pointer is", region, - ~""); + ""); rcx.errors_reported += 1; } } @@ -522,17 +522,17 @@ fn constrain_free_variables( result::Err(_) => { tcx.sess.span_err( freevar.span, - ~"captured variable does not outlive the enclosing closure"); + "captured variable does not outlive the enclosing closure"); note_and_explain_region( tcx, - ~"captured variable is valid for ", + "captured variable is valid for ", en_region, - ~""); + ""); note_and_explain_region( tcx, - ~"closure is valid for ", + "closure is valid for ", region, - ~""); + ""); } } } diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index 44b62122612..532638faa68 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -414,7 +414,7 @@ fn lookup_vtable(vcx: &VtableContext, if !is_early { vcx.tcx().sess.span_err( location_info.span, - ~"multiple applicable methods in scope"); + "multiple applicable methods in scope"); } return Some(/*bad*/copy found[0]); } diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index 05b2f6f577b..7fff756b01d 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -76,10 +76,8 @@ pub fn get_base_type(inference_context: @mut InferCtxt, } _ => { inference_context.tcx.sess.span_fatal(span, - ~"the type of this value \ - must be known in order \ - to determine the base \ - type"); + "the type of this value must be known in order \ + to determine the base type"); } } @@ -257,9 +255,8 @@ pub impl CoherenceChecker { None => { let session = self.crate_context.tcx.sess; session.span_err(item.span, - ~"no base type found for inherent \ - implementation; implement a \ - trait or new type instead"); + "no base type found for inherent implementation; \ + implement a trait or new type instead"); } Some(_) => { // Nothing to do. @@ -483,11 +480,9 @@ pub impl CoherenceChecker { if self.polytypes_unify(polytype_a, polytype_b) { let session = self.crate_context.tcx.sess; session.span_err(self.span_of_impl(implementation_b), - ~"conflicting implementations for a \ - trait"); + "conflicting implementations for a trait"); session.span_note(self.span_of_impl(implementation_a), - ~"note conflicting implementation \ - here"); + "note conflicting implementation here"); } } } @@ -667,11 +662,9 @@ pub impl CoherenceChecker { // This is an error. let session = self.crate_context.tcx.sess; session.span_err(item.span, - ~"cannot associate methods with \ - a type outside the crate the \ - type is defined in; define \ - and implement a trait or new \ - type instead"); + "cannot associate methods with a type outside the \ + crate the type is defined in; define and implement \ + a trait or new type instead"); } } item_impl(_, Some(trait_ref), _, _) => { @@ -690,10 +683,8 @@ pub impl CoherenceChecker { if trait_def_id.crate != local_crate { let session = self.crate_context.tcx.sess; session.span_err(item.span, - ~"cannot provide an \ - extension implementation \ - for a trait not defined \ - in this crate"); + "cannot provide an extension implementation \ + for a trait not defined in this crate"); } } @@ -765,7 +756,7 @@ pub impl CoherenceChecker { None => { self.crate_context.tcx.sess.span_bug( original_type.span, - ~"resolve didn't resolve this type?!"); + "resolve didn't resolve this type?!"); } Some(&node_item(item, _)) => { match item.node { @@ -849,8 +840,7 @@ pub impl CoherenceChecker { } _ => { self.crate_context.tcx.sess.span_bug(item.span, - ~"can't convert a \ - non-impl to an impl"); + "can't convert a non-impl to an impl"); } } } @@ -862,9 +852,8 @@ pub impl CoherenceChecker { return item.span; } _ => { - self.crate_context.tcx.sess.bug(~"span_of_impl() called on \ - something that wasn't an \ - impl!"); + self.crate_context.tcx.sess.bug("span_of_impl() called on something that \ + wasn't an impl!"); } } } @@ -1045,17 +1034,16 @@ pub impl CoherenceChecker { match tcx.items.find(&impl_info.did.node) { Some(&ast_map::node_item(@ref item, _)) => { tcx.sess.span_err((*item).span, - ~"the Drop trait may only \ - be implemented on \ - structures"); + "the Drop trait may only be implemented on \ + structures"); } _ => { - tcx.sess.bug(~"didn't find impl in ast map"); + tcx.sess.bug("didn't find impl in ast map"); } } } else { - tcx.sess.bug(~"found external impl of Drop trait on \ - something other than a struct"); + tcx.sess.bug("found external impl of Drop trait on \ + something other than a struct"); } } } diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 10537711b32..45d61bb7357 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -151,7 +151,7 @@ impl AstConv for CrateCtxt { fn ty_infer(&self, span: span) -> ty::t { self.tcx.sess.span_bug(span, - ~"found `ty_infer` in unexpected place"); + "found `ty_infer` in unexpected place"); } } @@ -416,8 +416,7 @@ pub fn ensure_supertraits(ccx: &CrateCtxt, if ty_trait_refs.any(|other_trait| other_trait.def_id == trait_ref.def_id) { // This means a trait inherited from the same supertrait more // than once. - tcx.sess.span_err(sp, ~"Duplicate supertrait in trait \ - declaration"); + tcx.sess.span_err(sp, "Duplicate supertrait in trait declaration"); break; } else { ty_trait_refs.push(trait_ref); diff --git a/src/librustc/middle/typeck/infer/region_inference.rs b/src/librustc/middle/typeck/infer/region_inference.rs index e12a3f2e975..25e65d7a18b 100644 --- a/src/librustc/middle/typeck/infer/region_inference.rs +++ b/src/librustc/middle/typeck/infer/region_inference.rs @@ -1587,9 +1587,9 @@ pub impl RegionVarBindings { note_and_explain_region( self.tcx, - ~"first, the lifetime cannot outlive ", + "first, the lifetime cannot outlive ", upper_bound.region, - ~"..."); + "..."); self.tcx.sess.span_note( upper_bound.span, @@ -1597,9 +1597,9 @@ pub impl RegionVarBindings { note_and_explain_region( self.tcx, - ~"but, the lifetime must be valid for ", + "but, the lifetime must be valid for ", lower_bound.region, - ~"..."); + "..."); self.tcx.sess.span_note( lower_bound.span, diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs index b0e0b7319ac..0012eb70030 100644 --- a/src/librustc/middle/typeck/mod.rs +++ b/src/librustc/middle/typeck/mod.rs @@ -214,7 +214,7 @@ pub fn lookup_def_tcx(tcx: ty::ctxt, sp: span, id: ast::node_id) -> ast::def { match tcx.def_map.find(&id) { Some(&x) => x, _ => { - tcx.sess.span_fatal(sp, ~"internal error looking up a definition") + tcx.sess.span_fatal(sp, "internal error looking up a definition") } } } @@ -301,8 +301,7 @@ fn check_main_fn_ty(ccx: @mut CrateCtxt, if ps.is_parameterized() => { tcx.sess.span_err( main_span, - ~"main function is not allowed \ - to have type parameters"); + "main function is not allowed to have type parameters"); return; } _ => () @@ -343,8 +342,7 @@ fn check_start_fn_ty(ccx: @mut CrateCtxt, if ps.is_parameterized() => { tcx.sess.span_err( start_span, - ~"start function is not allowed to have type \ - parameters"); + "start function is not allowed to have type parameters"); return; } _ => () diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 1c03ad13759..db4912d2131 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -342,7 +342,7 @@ pub fn expr_to_str(cx: @ext_ctxt, expr: @ast::expr, err_msg: ~str) -> ~str { pub fn expr_to_ident(cx: @ext_ctxt, expr: @ast::expr, - err_msg: ~str) -> ast::ident { + err_msg: &str) -> ast::ident { match expr.node { ast::expr_path(p) => { if vec::len(p.types) > 0u || vec::len(p.idents) != 1u { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 8459fc8c627..5ae101a567c 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -308,22 +308,22 @@ pub impl Parser { } return copy self.buffer[(*self.buffer_start + dist - 1) & 3].tok; } - fn fatal(&self, m: ~str) -> ! { + fn fatal(&self, m: &str) -> ! { self.sess.span_diagnostic.span_fatal(*copy self.span, m) } - fn span_fatal(&self, sp: span, m: ~str) -> ! { + fn span_fatal(&self, sp: span, m: &str) -> ! { self.sess.span_diagnostic.span_fatal(sp, m) } - fn span_note(&self, sp: span, m: ~str) { + fn span_note(&self, sp: span, m: &str) { self.sess.span_diagnostic.span_note(sp, m) } - fn bug(&self, m: ~str) -> ! { + fn bug(&self, m: &str) -> ! { self.sess.span_diagnostic.span_bug(*copy self.span, m) } - fn warn(&self, m: ~str) { + fn warn(&self, m: &str) { self.sess.span_diagnostic.span_warn(*copy self.span, m) } - fn span_err(&self, sp: span, m: ~str) { + fn span_err(&self, sp: span, m: &str) { self.sess.span_diagnostic.span_err(sp, m) } fn abort_if_errors(&self) { @@ -2029,8 +2029,7 @@ pub impl Parser { // This is a 'continue' expression if opt_ident.is_some() { self.span_err(*self.last_span, - ~"a label may not be used with a `loop` \ - expression"); + "a label may not be used with a `loop` expression"); } let lo = self.span.lo; @@ -2167,7 +2166,7 @@ pub impl Parser { @ast::pat { node: pat_wild, _ } => (), @ast::pat { node: pat_ident(_, _, _), _ } => (), @ast::pat { span, _ } => self.span_fatal( - span, ~"expected an identifier or `_`" + span, "expected an identifier or `_`" ) } slice = Some(subpat); @@ -2459,7 +2458,7 @@ pub impl Parser { -> ast::pat_ { if !is_plain_ident(&*self.token) { self.span_fatal(*self.last_span, - ~"expected identifier, found path"); + "expected identifier, found path"); } // why a path here, and not just an identifier? let name = self.parse_path_without_tps(); @@ -2478,7 +2477,7 @@ pub impl Parser { if *self.token == token::LPAREN { self.span_fatal( *self.last_span, - ~"expected identifier, found enum pattern"); + "expected identifier, found enum pattern"); } pat_ident(binding_mode, name, sub) @@ -2609,19 +2608,19 @@ pub impl Parser { match self.parse_item_or_view_item(/*bad*/ copy item_attrs, false) { - iovi_item(i) => { - let hi = i.span.hi; - let decl = @spanned(lo, hi, decl_item(i)); - return @spanned(lo, hi, stmt_decl(decl, self.get_id())); - } - iovi_view_item(vi) => { - self.span_fatal(vi.span, ~"view items must be declared at \ - the top of the block"); - } - iovi_foreign_item(_) => { - self.fatal(~"foreign items are not allowed here"); - } - iovi_none() => { /* fallthrough */ } + iovi_item(i) => { + let hi = i.span.hi; + let decl = @spanned(lo, hi, decl_item(i)); + return @spanned(lo, hi, stmt_decl(decl, self.get_id())); + } + iovi_view_item(vi) => { + self.span_fatal(vi.span, + "view items must be declared at the top of the block"); + } + iovi_foreign_item(_) => { + self.fatal(~"foreign items are not allowed here"); + } + iovi_none() => { /* fallthrough */ } } check_expected_item(self, item_attrs); @@ -2822,8 +2821,7 @@ pub impl Parser { result.push(RegionTyParamBound); } else { self.span_err(*self.span, - ~"`'static` is the only permissible \ - region bound here"); + "`'static` is the only permissible region bound here"); } self.bump(); } @@ -3238,7 +3236,7 @@ pub impl Parser { }) } _ => { - self.span_err(*self.span, ~"not a trait"); + self.span_err(*self.span, "not a trait"); None } }; @@ -3467,9 +3465,8 @@ pub impl Parser { ) { iovi_item(item) => items.push(item), iovi_view_item(view_item) => { - self.span_fatal(view_item.span, ~"view items must be \ - declared at the top of the \ - module"); + self.span_fatal(view_item.span, "view items must be declared at the top of the \ + module"); } _ => { self.fatal( @@ -3762,7 +3759,7 @@ pub impl Parser { } if opt_abis.is_some() { - self.span_err(*self.span, ~"an ABI may not be specified here"); + self.span_err(*self.span, "an ABI may not be specified here"); } // extern mod foo; @@ -4397,9 +4394,7 @@ pub impl Parser { view_item_extern_mod(*) if !extern_mod_allowed => { self.span_err(view_item.span, - ~"\"extern mod\" \ - declarations are not \ - allowed here"); + "\"extern mod\" declarations are not allowed here"); } view_item_extern_mod(*) => {} } @@ -4425,8 +4420,7 @@ pub impl Parser { iovi_none => break, iovi_view_item(view_item) => { self.span_err(view_item.span, - ~"`use` and `extern mod` declarations \ - must precede items"); + "`use` and `extern mod` declarations must precede items"); } iovi_item(item) => { items.push(item) @@ -4461,8 +4455,7 @@ pub impl Parser { iovi_view_item(view_item) => { // I think this can't occur: self.span_err(view_item.span, - ~"`use` and `extern mod` declarations \ - must precede items"); + "`use` and `extern mod` declarations must precede items"); } iovi_item(_) => { // FIXME #5668: this will occur for a macro invocation: -- cgit 1.4.1-3-g733a5 From dc5df61bc1914224d50d92cdd5599b6337ac68f2 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 1 May 2013 17:54:54 -0700 Subject: librustc: Update the serializer to work properly with INHTWAMA, removing mutable fields in the process --- src/librustc/metadata/decoder.rs | 9 + src/librustc/metadata/encoder.rs | 1638 ++++++++++++++++++++++--- src/librustc/middle/astencode.rs | 888 ++++++++++++-- src/libstd/arena.rs | 4 +- src/libstd/ebml.rs | 818 +++++++++++- src/libstd/flatpipes.rs | 33 +- src/libstd/json.rs | 871 +++++++++++-- src/libstd/serialize.rs | 1145 ++++++++++++++++- src/libstd/workcache.rs | 53 +- src/libsyntax/ast.rs | 38 +- src/libsyntax/codemap.rs | 17 + src/libsyntax/ext/auto_encode.rs | 304 +++-- src/libsyntax/ext/deriving/decodable.rs | 49 +- src/libsyntax/ext/deriving/encodable.rs | 42 +- src/libsyntax/parse/mod.rs | 3 +- src/test/bench/shootout-binarytrees.rs | 23 +- src/test/run-pass/auto-encode.rs | 7 +- src/test/run-pass/issue-4036.rs | 3 +- src/test/run-pass/placement-new-arena.rs | 3 +- src/test/run-pass/regions-mock-trans-impls.rs | 28 +- 20 files changed, 5381 insertions(+), 595 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 61454c802cc..1be49528b9e 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -272,12 +272,21 @@ fn item_ty_param_defs(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd, @bounds } +#[cfg(stage0)] fn item_ty_region_param(item: ebml::Doc) -> Option { reader::maybe_get_doc(item, tag_region_param).map(|doc| { Decodable::decode(&reader::Decoder(*doc)) }) } +#[cfg(not(stage0))] +fn item_ty_region_param(item: ebml::Doc) -> Option { + reader::maybe_get_doc(item, tag_region_param).map(|doc| { + let mut decoder = reader::Decoder(*doc); + Decodable::decode(&mut decoder) + }) +} + fn item_ty_param_count(item: ebml::Doc) -> uint { let mut n = 0u; reader::tagged_docs(item, tag_items_data_item_ty_param_bounds, diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 2a4334781e4..77373076137 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -42,11 +42,18 @@ use writer = std::ebml::writer; // used by astencode: type abbrev_map = @mut HashMap; +#[cfg(stage0)] pub type encode_inlined_item = @fn(ecx: @EncodeContext, ebml_w: &writer::Encoder, path: &[ast_map::path_elt], ii: ast::inlined_item); +#[cfg(not(stage0))] +pub type encode_inlined_item = @fn(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + path: &[ast_map::path_elt], + ii: ast::inlined_item); + pub struct EncodeParams { diag: @span_handler, tcx: ty::ctxt, @@ -91,21 +98,47 @@ pub fn reachable(ecx: @EncodeContext, id: node_id) -> bool { ecx.reachable.contains(&id) } +#[cfg(stage0)] fn encode_name(ecx: @EncodeContext, ebml_w: &writer::Encoder, name: ident) { ebml_w.wr_tagged_str(tag_paths_data_name, *ecx.tcx.sess.str_of(name)); } -fn encode_impl_type_basename(ecx: @EncodeContext, ebml_w: &writer::Encoder, +#[cfg(not(stage0))] +fn encode_name(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + name: ident) { + ebml_w.wr_tagged_str(tag_paths_data_name, *ecx.tcx.sess.str_of(name)); +} + +#[cfg(stage0)] +fn encode_impl_type_basename(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + name: ident) { + ebml_w.wr_tagged_str(tag_item_impl_type_basename, + *ecx.tcx.sess.str_of(name)); +} + +#[cfg(not(stage0))] +fn encode_impl_type_basename(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, name: ident) { ebml_w.wr_tagged_str(tag_item_impl_type_basename, *ecx.tcx.sess.str_of(name)); } +#[cfg(stage0)] pub fn encode_def_id(ebml_w: &writer::Encoder, id: def_id) { ebml_w.wr_tagged_str(tag_def_id, def_to_str(id)); } -fn encode_region_param(ecx: @EncodeContext, ebml_w: &writer::Encoder, +#[cfg(not(stage0))] +pub fn encode_def_id(ebml_w: &mut writer::Encoder, id: def_id) { + ebml_w.wr_tagged_str(tag_def_id, def_to_str(id)); +} + +#[cfg(stage0)] +fn encode_region_param(ecx: @EncodeContext, + ebml_w: &writer::Encoder, it: @ast::item) { let opt_rp = ecx.tcx.region_paramd_items.find(&it.id); for opt_rp.each |rp| { @@ -115,6 +148,19 @@ fn encode_region_param(ecx: @EncodeContext, ebml_w: &writer::Encoder, } } +#[cfg(not(stage0))] +fn encode_region_param(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + it: @ast::item) { + let opt_rp = ecx.tcx.region_paramd_items.find(&it.id); + for opt_rp.each |rp| { + ebml_w.start_tag(tag_region_param); + rp.encode(ebml_w); + ebml_w.end_tag(); + } +} + +#[cfg(stage0)] fn encode_mutability(ebml_w: &writer::Encoder, mt: struct_mutability) { do ebml_w.wr_tag(tag_struct_mut) { let val = match mt { @@ -125,13 +171,45 @@ fn encode_mutability(ebml_w: &writer::Encoder, mt: struct_mutability) { } } +#[cfg(not(stage0))] +fn encode_mutability(ebml_w: &mut writer::Encoder, mt: struct_mutability) { + ebml_w.start_tag(tag_struct_mut); + let val = match mt { + struct_immutable => 'a', + struct_mutable => 'm' + }; + ebml_w.writer.write(&[val as u8]); + ebml_w.end_tag(); +} + struct entry { val: T, pos: uint } -fn add_to_index(ecx: @EncodeContext, ebml_w: &writer::Encoder, path: &[ident], - index: &mut ~[entry<~str>], name: ident) { +#[cfg(stage0)] +fn add_to_index(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + path: &[ident], + index: &mut ~[entry<~str>], + name: ident) { + let mut full_path = ~[]; + full_path.push_all(path); + full_path.push(name); + index.push( + entry { + val: ast_util::path_name_i(full_path, + ecx.tcx.sess.parse_sess.interner), + pos: ebml_w.writer.tell() + }); +} + +#[cfg(not(stage0))] +fn add_to_index(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + path: &[ident], + index: &mut ~[entry<~str>], + name: ident) { let mut full_path = ~[]; full_path.push_all(path); full_path.push(name); @@ -143,11 +221,28 @@ fn add_to_index(ecx: @EncodeContext, ebml_w: &writer::Encoder, path: &[ident], }); } +#[cfg(stage0)] fn encode_trait_ref(ebml_w: &writer::Encoder, ecx: @EncodeContext, trait_ref: &ty::TraitRef, - tag: uint) -{ + tag: uint) { + let ty_str_ctxt = @tyencode::ctxt { + diag: ecx.diag, + ds: def_to_str, + tcx: ecx.tcx, + reachable: |a| reachable(ecx, a), + abbrevs: tyencode::ac_use_abbrevs(ecx.type_abbrevs)}; + + ebml_w.start_tag(tag); + tyencode::enc_trait_ref(ebml_w.writer, ty_str_ctxt, trait_ref); + ebml_w.end_tag(); +} + +#[cfg(not(stage0))] +fn encode_trait_ref(ebml_w: &mut writer::Encoder, + ecx: @EncodeContext, + trait_ref: &ty::TraitRef, + tag: uint) { let ty_str_ctxt = @tyencode::ctxt { diag: ecx.diag, ds: def_to_str, @@ -161,14 +256,26 @@ fn encode_trait_ref(ebml_w: &writer::Encoder, } // Item info table encoding +#[cfg(stage0)] fn encode_family(ebml_w: &writer::Encoder, c: char) { ebml_w.start_tag(tag_items_data_item_family); ebml_w.writer.write(&[c as u8]); ebml_w.end_tag(); } -pub fn def_to_str(did: def_id) -> ~str { fmt!("%d:%d", did.crate, did.node) } +// Item info table encoding +#[cfg(not(stage0))] +fn encode_family(ebml_w: &mut writer::Encoder, c: char) { + ebml_w.start_tag(tag_items_data_item_family); + ebml_w.writer.write(&[c as u8]); + ebml_w.end_tag(); +} + +pub fn def_to_str(did: def_id) -> ~str { + fmt!("%d:%d", did.crate, did.node) +} +#[cfg(stage0)] fn encode_ty_type_param_defs(ebml_w: &writer::Encoder, ecx: @EncodeContext, params: @~[ty::TypeParameterDef], @@ -186,6 +293,25 @@ fn encode_ty_type_param_defs(ebml_w: &writer::Encoder, } } +#[cfg(not(stage0))] +fn encode_ty_type_param_defs(ebml_w: &mut writer::Encoder, + ecx: @EncodeContext, + params: @~[ty::TypeParameterDef], + tag: uint) { + let ty_str_ctxt = @tyencode::ctxt { + diag: ecx.diag, + ds: def_to_str, + tcx: ecx.tcx, + reachable: |a| reachable(ecx, a), + abbrevs: tyencode::ac_use_abbrevs(ecx.type_abbrevs)}; + for params.each |param| { + ebml_w.start_tag(tag); + tyencode::enc_type_param_def(ebml_w.writer, ty_str_ctxt, param); + ebml_w.end_tag(); + } +} + +#[cfg(stage0)] fn encode_type_param_bounds(ebml_w: &writer::Encoder, ecx: @EncodeContext, params: &OptVec) { @@ -195,13 +321,31 @@ fn encode_type_param_bounds(ebml_w: &writer::Encoder, tag_items_data_item_ty_param_bounds); } +#[cfg(not(stage0))] +fn encode_type_param_bounds(ebml_w: &mut writer::Encoder, + ecx: @EncodeContext, + params: &OptVec) { + let ty_param_defs = + @params.map_to_vec(|param| *ecx.tcx.ty_param_defs.get(¶m.id)); + encode_ty_type_param_defs(ebml_w, ecx, ty_param_defs, + tag_items_data_item_ty_param_bounds); +} +#[cfg(stage0)] fn encode_variant_id(ebml_w: &writer::Encoder, vid: def_id) { ebml_w.start_tag(tag_items_data_item_variant); ebml_w.writer.write(str::to_bytes(def_to_str(vid))); ebml_w.end_tag(); } +#[cfg(not(stage0))] +fn encode_variant_id(ebml_w: &mut writer::Encoder, vid: def_id) { + ebml_w.start_tag(tag_items_data_item_variant); + ebml_w.writer.write(str::to_bytes(def_to_str(vid))); + ebml_w.end_tag(); +} + +#[cfg(stage0)] pub fn write_type(ecx: @EncodeContext, ebml_w: &writer::Encoder, typ: ty::t) { let ty_str_ctxt = @tyencode::ctxt { diag: ecx.diag, @@ -212,7 +356,35 @@ pub fn write_type(ecx: @EncodeContext, ebml_w: &writer::Encoder, typ: ty::t) { tyencode::enc_ty(ebml_w.writer, ty_str_ctxt, typ); } -pub fn write_vstore(ecx: @EncodeContext, ebml_w: &writer::Encoder, +#[cfg(not(stage0))] +pub fn write_type(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + typ: ty::t) { + let ty_str_ctxt = @tyencode::ctxt { + diag: ecx.diag, + ds: def_to_str, + tcx: ecx.tcx, + reachable: |a| reachable(ecx, a), + abbrevs: tyencode::ac_use_abbrevs(ecx.type_abbrevs)}; + tyencode::enc_ty(ebml_w.writer, ty_str_ctxt, typ); +} + +#[cfg(stage0)] +pub fn write_vstore(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + vstore: ty::vstore) { + let ty_str_ctxt = @tyencode::ctxt { + diag: ecx.diag, + ds: def_to_str, + tcx: ecx.tcx, + reachable: |a| reachable(ecx, a), + abbrevs: tyencode::ac_use_abbrevs(ecx.type_abbrevs)}; + tyencode::enc_vstore(ebml_w.writer, ty_str_ctxt, vstore); +} + +#[cfg(not(stage0))] +pub fn write_vstore(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, vstore: ty::vstore) { let ty_str_ctxt = @tyencode::ctxt { diag: ecx.diag, @@ -223,16 +395,37 @@ pub fn write_vstore(ecx: @EncodeContext, ebml_w: &writer::Encoder, tyencode::enc_vstore(ebml_w.writer, ty_str_ctxt, vstore); } +#[cfg(stage0)] fn encode_type(ecx: @EncodeContext, ebml_w: &writer::Encoder, typ: ty::t) { ebml_w.start_tag(tag_items_data_item_type); write_type(ecx, ebml_w, typ); ebml_w.end_tag(); } +#[cfg(not(stage0))] +fn encode_type(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + typ: ty::t) { + ebml_w.start_tag(tag_items_data_item_type); + write_type(ecx, ebml_w, typ); + ebml_w.end_tag(); +} + +#[cfg(stage0)] fn encode_transformed_self_ty(ecx: @EncodeContext, ebml_w: &writer::Encoder, - opt_typ: Option) -{ + opt_typ: Option) { + for opt_typ.each |&typ| { + ebml_w.start_tag(tag_item_method_transformed_self_ty); + write_type(ecx, ebml_w, typ); + ebml_w.end_tag(); + } +} + +#[cfg(not(stage0))] +fn encode_transformed_self_ty(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + opt_typ: Option) { for opt_typ.each |&typ| { ebml_w.start_tag(tag_item_method_transformed_self_ty); write_type(ecx, ebml_w, typ); @@ -240,10 +433,27 @@ fn encode_transformed_self_ty(ecx: @EncodeContext, } } +#[cfg(stage0)] fn encode_method_fty(ecx: @EncodeContext, ebml_w: &writer::Encoder, - typ: &ty::BareFnTy) -{ + typ: &ty::BareFnTy) { + ebml_w.start_tag(tag_item_method_fty); + + let ty_str_ctxt = @tyencode::ctxt { + diag: ecx.diag, + ds: def_to_str, + tcx: ecx.tcx, + reachable: |a| reachable(ecx, a), + abbrevs: tyencode::ac_use_abbrevs(ecx.type_abbrevs)}; + tyencode::enc_bare_fn_ty(ebml_w.writer, ty_str_ctxt, typ); + + ebml_w.end_tag(); +} + +#[cfg(not(stage0))] +fn encode_method_fty(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + typ: &ty::BareFnTy) { ebml_w.start_tag(tag_item_method_fty); let ty_str_ctxt = @tyencode::ctxt { @@ -257,6 +467,7 @@ fn encode_method_fty(ecx: @EncodeContext, ebml_w.end_tag(); } +#[cfg(stage0)] fn encode_symbol(ecx: @EncodeContext, ebml_w: &writer::Encoder, id: node_id) { ebml_w.start_tag(tag_items_data_item_symbol); match ecx.item_symbols.find(&id) { @@ -272,28 +483,123 @@ fn encode_symbol(ecx: @EncodeContext, ebml_w: &writer::Encoder, id: node_id) { ebml_w.end_tag(); } -fn encode_discriminant(ecx: @EncodeContext, ebml_w: &writer::Encoder, +#[cfg(not(stage0))] +fn encode_symbol(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + id: node_id) { + ebml_w.start_tag(tag_items_data_item_symbol); + match ecx.item_symbols.find(&id) { + Some(x) => { + debug!("encode_symbol(id=%?, str=%s)", id, *x); + ebml_w.writer.write(str::to_bytes(*x)); + } + None => { + ecx.diag.handler().bug( + fmt!("encode_symbol: id not found %d", id)); + } + } + ebml_w.end_tag(); +} + +#[cfg(stage0)] +fn encode_discriminant(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + id: node_id) { + ebml_w.start_tag(tag_items_data_item_symbol); + ebml_w.writer.write(str::to_bytes(**ecx.discrim_symbols.get(&id))); + ebml_w.end_tag(); +} + +#[cfg(not(stage0))] +fn encode_discriminant(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, id: node_id) { ebml_w.start_tag(tag_items_data_item_symbol); ebml_w.writer.write(str::to_bytes(**ecx.discrim_symbols.get(&id))); ebml_w.end_tag(); } -fn encode_disr_val(_ecx: @EncodeContext, ebml_w: &writer::Encoder, +#[cfg(stage0)] +fn encode_disr_val(_: @EncodeContext, + ebml_w: &writer::Encoder, disr_val: int) { ebml_w.start_tag(tag_disr_val); ebml_w.writer.write(str::to_bytes(int::to_str(disr_val))); ebml_w.end_tag(); } +#[cfg(not(stage0))] +fn encode_disr_val(_: @EncodeContext, + ebml_w: &mut writer::Encoder, + disr_val: int) { + ebml_w.start_tag(tag_disr_val); + ebml_w.writer.write(str::to_bytes(int::to_str(disr_val))); + ebml_w.end_tag(); +} + +#[cfg(stage0)] fn encode_parent_item(ebml_w: &writer::Encoder, id: def_id) { ebml_w.start_tag(tag_items_data_parent_item); ebml_w.writer.write(str::to_bytes(def_to_str(id))); ebml_w.end_tag(); } -fn encode_enum_variant_info(ecx: @EncodeContext, ebml_w: &writer::Encoder, - id: node_id, variants: &[variant], +#[cfg(not(stage0))] +fn encode_parent_item(ebml_w: &mut writer::Encoder, id: def_id) { + ebml_w.start_tag(tag_items_data_parent_item); + ebml_w.writer.write(str::to_bytes(def_to_str(id))); + ebml_w.end_tag(); +} + +#[cfg(stage0)] +fn encode_enum_variant_info(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + id: node_id, + variants: &[variant], + path: &[ast_map::path_elt], + index: @mut ~[entry], + generics: &ast::Generics) { + debug!("encode_enum_variant_info(id=%?)", id); + + let mut disr_val = 0; + let mut i = 0; + let vi = ty::enum_variants(ecx.tcx, + ast::def_id { crate: local_crate, node: id }); + for variants.each |variant| { + index.push(entry {val: variant.node.id, pos: ebml_w.writer.tell()}); + ebml_w.start_tag(tag_items_data_item); + encode_def_id(ebml_w, local_def(variant.node.id)); + encode_family(ebml_w, 'v'); + encode_name(ecx, ebml_w, variant.node.name); + encode_parent_item(ebml_w, local_def(id)); + encode_type(ecx, ebml_w, + node_id_to_type(ecx.tcx, variant.node.id)); + match variant.node.kind { + ast::tuple_variant_kind(ref args) + if args.len() > 0 && generics.ty_params.len() == 0 => { + encode_symbol(ecx, ebml_w, variant.node.id); + } + ast::tuple_variant_kind(_) | ast::struct_variant_kind(_) => {} + } + encode_discriminant(ecx, ebml_w, variant.node.id); + if vi[i].disr_val != disr_val { + encode_disr_val(ecx, ebml_w, vi[i].disr_val); + disr_val = vi[i].disr_val; + } + encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); + encode_path(ecx, ebml_w, path, + ast_map::path_name(variant.node.name)); + ebml_w.end_tag(); + disr_val += 1; + i += 1; + } +} + +#[cfg(not(stage0))] +fn encode_enum_variant_info(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + id: node_id, + variants: &[variant], path: &[ast_map::path_elt], index: @mut ~[entry], generics: &ast::Generics) { @@ -333,8 +639,11 @@ fn encode_enum_variant_info(ecx: @EncodeContext, ebml_w: &writer::Encoder, } } -fn encode_path(ecx: @EncodeContext, ebml_w: &writer::Encoder, - path: &[ast_map::path_elt], name: ast_map::path_elt) { +#[cfg(stage0)] +fn encode_path(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + path: &[ast_map::path_elt], + name: ast_map::path_elt) { fn encode_path_elt(ecx: @EncodeContext, ebml_w: &writer::Encoder, elt: ast_map::path_elt) { let (tag, name) = match elt { @@ -354,8 +663,37 @@ fn encode_path(ecx: @EncodeContext, ebml_w: &writer::Encoder, } } -fn encode_info_for_mod(ecx: @EncodeContext, ebml_w: &writer::Encoder, - md: &_mod, id: node_id, path: &[ast_map::path_elt], +#[cfg(not(stage0))] +fn encode_path(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + path: &[ast_map::path_elt], + name: ast_map::path_elt) { + fn encode_path_elt(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + elt: ast_map::path_elt) { + let (tag, name) = match elt { + ast_map::path_mod(name) => (tag_path_elt_mod, name), + ast_map::path_name(name) => (tag_path_elt_name, name) + }; + + ebml_w.wr_tagged_str(tag, *ecx.tcx.sess.str_of(name)); + } + + ebml_w.start_tag(tag_path); + ebml_w.wr_tagged_u32(tag_path_len, (path.len() + 1) as u32); + for path.each |pe| { + encode_path_elt(ecx, ebml_w, *pe); + } + encode_path_elt(ecx, ebml_w, name); + ebml_w.end_tag(); +} + +#[cfg(stage0)] +fn encode_info_for_mod(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + md: &_mod, + id: node_id, + path: &[ast_map::path_elt], name: ident) { ebml_w.start_tag(tag_items_data_item); encode_def_id(ebml_w, local_def(id)); @@ -412,32 +750,164 @@ fn encode_info_for_mod(ecx: @EncodeContext, ebml_w: &writer::Encoder, ebml_w.end_tag(); } -fn encode_struct_field_family(ebml_w: &writer::Encoder, - visibility: visibility) { - encode_family(ebml_w, match visibility { - public => 'g', - private => 'j', - inherited => 'N' - }); -} - -fn encode_visibility(ebml_w: &writer::Encoder, visibility: visibility) { - ebml_w.start_tag(tag_items_data_item_visibility); - let ch = match visibility { - public => 'y', - private => 'n', - inherited => 'i', - }; - ebml_w.wr_str(str::from_char(ch)); - ebml_w.end_tag(); -} +#[cfg(not(stage0))] +fn encode_info_for_mod(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + md: &_mod, + id: node_id, + path: &[ast_map::path_elt], + name: ident) { + ebml_w.start_tag(tag_items_data_item); + encode_def_id(ebml_w, local_def(id)); + encode_family(ebml_w, 'm'); + encode_name(ecx, ebml_w, name); + debug!("(encoding info for module) encoding info for module ID %d", id); -fn encode_self_type(ebml_w: &writer::Encoder, self_type: ast::self_ty_) { - ebml_w.start_tag(tag_item_trait_method_self_ty); + // Encode info about all the module children. + for md.items.each |item| { + match item.node { + item_impl(*) => { + let (ident, did) = (item.ident, item.id); + debug!("(encoding info for module) ... encoding impl %s \ + (%?/%?)", + *ecx.tcx.sess.str_of(ident), + did, + ast_map::node_id_to_str(ecx.tcx.items, did, ecx.tcx + .sess.parse_sess.interner)); - // Encode the base self type. - match self_type { - sty_static => { + ebml_w.start_tag(tag_mod_impl); + ebml_w.wr_str(def_to_str(local_def(did))); + ebml_w.end_tag(); + } + _ => {} // FIXME #4573: Encode these too. + } + } + + encode_path(ecx, ebml_w, path, ast_map::path_mod(name)); + + // Encode the reexports of this module. + debug!("(encoding info for module) encoding reexports for %d", id); + match ecx.reexports2.find(&id) { + Some(ref exports) => { + debug!("(encoding info for module) found reexports for %d", id); + for exports.each |exp| { + debug!("(encoding info for module) reexport '%s' for %d", + *exp.name, id); + ebml_w.start_tag(tag_items_data_item_reexport); + ebml_w.start_tag(tag_items_data_item_reexport_def_id); + ebml_w.wr_str(def_to_str(exp.def_id)); + ebml_w.end_tag(); + ebml_w.start_tag(tag_items_data_item_reexport_name); + ebml_w.wr_str(*exp.name); + ebml_w.end_tag(); + ebml_w.end_tag(); + } + } + None => { + debug!("(encoding info for module) found no reexports for %d", + id); + } + } + + ebml_w.end_tag(); +} + +#[cfg(stage0)] +fn encode_struct_field_family(ebml_w: &writer::Encoder, + visibility: visibility) { + encode_family(ebml_w, match visibility { + public => 'g', + private => 'j', + inherited => 'N' + }); +} + +#[cfg(not(stage0))] +fn encode_struct_field_family(ebml_w: &mut writer::Encoder, + visibility: visibility) { + encode_family(ebml_w, match visibility { + public => 'g', + private => 'j', + inherited => 'N' + }); +} + +#[cfg(stage0)] +fn encode_visibility(ebml_w: &writer::Encoder, visibility: visibility) { + ebml_w.start_tag(tag_items_data_item_visibility); + let ch = match visibility { + public => 'y', + private => 'n', + inherited => 'i', + }; + ebml_w.wr_str(str::from_char(ch)); + ebml_w.end_tag(); +} + +#[cfg(not(stage0))] +fn encode_visibility(ebml_w: &mut writer::Encoder, visibility: visibility) { + ebml_w.start_tag(tag_items_data_item_visibility); + let ch = match visibility { + public => 'y', + private => 'n', + inherited => 'i', + }; + ebml_w.wr_str(str::from_char(ch)); + ebml_w.end_tag(); +} + +#[cfg(stage0)] +fn encode_self_type(ebml_w: &writer::Encoder, self_type: ast::self_ty_) { + ebml_w.start_tag(tag_item_trait_method_self_ty); + + // Encode the base self type. + match self_type { + sty_static => { + ebml_w.writer.write(&[ 's' as u8 ]); + } + sty_value => { + ebml_w.writer.write(&[ 'v' as u8 ]); + } + sty_region(_, m) => { + // FIXME(#4846) encode custom lifetime + ebml_w.writer.write(&[ '&' as u8 ]); + encode_mutability(ebml_w, m); + } + sty_box(m) => { + ebml_w.writer.write(&[ '@' as u8 ]); + encode_mutability(ebml_w, m); + } + sty_uniq(m) => { + ebml_w.writer.write(&[ '~' as u8 ]); + encode_mutability(ebml_w, m); + } + } + + ebml_w.end_tag(); + + fn encode_mutability(ebml_w: &writer::Encoder, + m: ast::mutability) { + match m { + m_imm => { + ebml_w.writer.write(&[ 'i' as u8 ]); + } + m_mutbl => { + ebml_w.writer.write(&[ 'm' as u8 ]); + } + m_const => { + ebml_w.writer.write(&[ 'c' as u8 ]); + } + } + } +} + +#[cfg(not(stage0))] +fn encode_self_type(ebml_w: &mut writer::Encoder, self_type: ast::self_ty_) { + ebml_w.start_tag(tag_item_trait_method_self_ty); + + // Encode the base self type. + match self_type { + sty_static => { ebml_w.writer.write(&[ 's' as u8 ]); } sty_value => { @@ -476,17 +946,68 @@ fn encode_self_type(ebml_w: &writer::Encoder, self_type: ast::self_ty_) { } } +#[cfg(stage0)] fn encode_method_sort(ebml_w: &writer::Encoder, sort: char) { ebml_w.start_tag(tag_item_trait_method_sort); ebml_w.writer.write(&[ sort as u8 ]); ebml_w.end_tag(); } +#[cfg(not(stage0))] +fn encode_method_sort(ebml_w: &mut writer::Encoder, sort: char) { + ebml_w.start_tag(tag_item_trait_method_sort); + ebml_w.writer.write(&[ sort as u8 ]); + ebml_w.end_tag(); +} + /* Returns an index of items in this class */ -fn encode_info_for_struct(ecx: @EncodeContext, ebml_w: &writer::Encoder, - path: &[ast_map::path_elt], - fields: &[@struct_field], - global_index: @mut~[entry]) -> ~[entry] { +#[cfg(stage0)] +fn encode_info_for_struct(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + path: &[ast_map::path_elt], + fields: &[@struct_field], + global_index: @mut~[entry]) + -> ~[entry] { + /* Each class has its own index, since different classes + may have fields with the same name */ + let index = @mut ~[]; + let tcx = ecx.tcx; + /* We encode both private and public fields -- need to include + private fields to get the offsets right */ + for fields.each |field| { + let (nm, mt, vis) = match field.node.kind { + named_field(nm, mt, vis) => (nm, mt, vis), + unnamed_field => ( + special_idents::unnamed_field, + struct_immutable, + inherited + ) + }; + + let id = field.node.id; + index.push(entry {val: id, pos: ebml_w.writer.tell()}); + global_index.push(entry {val: id, pos: ebml_w.writer.tell()}); + ebml_w.start_tag(tag_items_data_item); + debug!("encode_info_for_struct: doing %s %d", + *tcx.sess.str_of(nm), id); + encode_struct_field_family(ebml_w, vis); + encode_name(ecx, ebml_w, nm); + encode_path(ecx, ebml_w, path, ast_map::path_name(nm)); + encode_type(ecx, ebml_w, node_id_to_type(tcx, id)); + encode_mutability(ebml_w, mt); + encode_def_id(ebml_w, local_def(id)); + ebml_w.end_tag(); + } + /*bad*/copy *index +} + +#[cfg(not(stage0))] +fn encode_info_for_struct(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + path: &[ast_map::path_elt], + fields: &[@struct_field], + global_index: @mut ~[entry]) + -> ~[entry] { /* Each class has its own index, since different classes may have fields with the same name */ let index = @mut ~[]; @@ -521,6 +1042,7 @@ fn encode_info_for_struct(ecx: @EncodeContext, ebml_w: &writer::Encoder, } // This is for encoding info for ctors and dtors +#[cfg(stage0)] fn encode_info_for_ctor(ecx: @EncodeContext, ebml_w: &writer::Encoder, id: node_id, @@ -550,6 +1072,37 @@ fn encode_info_for_ctor(ecx: @EncodeContext, ebml_w.end_tag(); } +#[cfg(not(stage0))] +fn encode_info_for_ctor(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + id: node_id, + ident: ident, + path: &[ast_map::path_elt], + item: Option, + generics: &ast::Generics) { + ebml_w.start_tag(tag_items_data_item); + encode_name(ecx, ebml_w, ident); + encode_def_id(ebml_w, local_def(id)); + encode_family(ebml_w, purity_fn_family(ast::impure_fn)); + encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); + let its_ty = node_id_to_type(ecx.tcx, id); + debug!("fn name = %s ty = %s its node id = %d", + *ecx.tcx.sess.str_of(ident), + ty_to_str(ecx.tcx, its_ty), id); + encode_type(ecx, ebml_w, its_ty); + encode_path(ecx, ebml_w, path, ast_map::path_name(ident)); + match item { + Some(it) => { + (ecx.encode_inlined_item)(ecx, ebml_w, path, it); + } + None => { + encode_symbol(ecx, ebml_w, id); + } + } + ebml_w.end_tag(); +} + +#[cfg(stage0)] fn encode_info_for_struct_ctor(ecx: @EncodeContext, ebml_w: &writer::Encoder, path: &[ast_map::path_elt], @@ -569,100 +1122,489 @@ fn encode_info_for_struct_ctor(ecx: @EncodeContext, encode_symbol(ecx, ebml_w, ctor_id); } - ebml_w.end_tag(); -} + ebml_w.end_tag(); +} + +#[cfg(not(stage0))] +fn encode_info_for_struct_ctor(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + path: &[ast_map::path_elt], + name: ast::ident, + ctor_id: node_id, + index: @mut ~[entry]) { + index.push(entry { val: ctor_id, pos: ebml_w.writer.tell() }); + + ebml_w.start_tag(tag_items_data_item); + encode_def_id(ebml_w, local_def(ctor_id)); + encode_family(ebml_w, 'f'); + encode_name(ecx, ebml_w, name); + encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, ctor_id)); + encode_path(ecx, ebml_w, path, ast_map::path_name(name)); + + if ecx.item_symbols.contains_key(&ctor_id) { + encode_symbol(ecx, ebml_w, ctor_id); + } + + ebml_w.end_tag(); +} + +#[cfg(stage0)] +fn encode_method_ty_fields(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + method_ty: &ty::method) { + encode_def_id(ebml_w, method_ty.def_id); + encode_name(ecx, ebml_w, method_ty.ident); + encode_ty_type_param_defs(ebml_w, ecx, + method_ty.generics.type_param_defs, + tag_item_method_tps); + encode_transformed_self_ty(ecx, ebml_w, method_ty.transformed_self_ty); + encode_method_fty(ecx, ebml_w, &method_ty.fty); + encode_visibility(ebml_w, method_ty.vis); + encode_self_type(ebml_w, method_ty.self_ty); +} + +#[cfg(not(stage0))] +fn encode_method_ty_fields(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + method_ty: &ty::method) { + encode_def_id(ebml_w, method_ty.def_id); + encode_name(ecx, ebml_w, method_ty.ident); + encode_ty_type_param_defs(ebml_w, ecx, + method_ty.generics.type_param_defs, + tag_item_method_tps); + encode_transformed_self_ty(ecx, ebml_w, method_ty.transformed_self_ty); + encode_method_fty(ecx, ebml_w, &method_ty.fty); + encode_visibility(ebml_w, method_ty.vis); + encode_self_type(ebml_w, method_ty.self_ty); +} + +#[cfg(stage0)] +fn encode_info_for_method(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + impl_path: &[ast_map::path_elt], + should_inline: bool, + parent_id: node_id, + m: @method, + owner_generics: &ast::Generics, + method_generics: &ast::Generics) { + debug!("encode_info_for_method: %d %s %u %u", m.id, + *ecx.tcx.sess.str_of(m.ident), + owner_generics.ty_params.len(), + method_generics.ty_params.len()); + ebml_w.start_tag(tag_items_data_item); + + let method_def_id = local_def(m.id); + let method_ty: @ty::method = ty::method(ecx.tcx, method_def_id); + encode_method_ty_fields(ecx, ebml_w, method_ty); + + match m.self_ty.node { + ast::sty_static => { + encode_family(ebml_w, purity_static_method_family(m.purity)); + } + _ => encode_family(ebml_w, purity_fn_family(m.purity)) + } + + let mut combined_ty_params = opt_vec::Empty; + combined_ty_params.push_all(&owner_generics.ty_params); + combined_ty_params.push_all(&method_generics.ty_params); + let len = combined_ty_params.len(); + encode_type_param_bounds(ebml_w, ecx, &combined_ty_params); + + encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, m.id)); + encode_path(ecx, ebml_w, impl_path, ast_map::path_name(m.ident)); + + if len > 0u || should_inline { + (ecx.encode_inlined_item)( + ecx, ebml_w, impl_path, + ii_method(local_def(parent_id), m)); + } else { + encode_symbol(ecx, ebml_w, m.id); + } + + ebml_w.end_tag(); +} + +#[cfg(not(stage0))] +fn encode_info_for_method(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + impl_path: &[ast_map::path_elt], + should_inline: bool, + parent_id: node_id, + m: @method, + owner_generics: &ast::Generics, + method_generics: &ast::Generics) { + debug!("encode_info_for_method: %d %s %u %u", m.id, + *ecx.tcx.sess.str_of(m.ident), + owner_generics.ty_params.len(), + method_generics.ty_params.len()); + ebml_w.start_tag(tag_items_data_item); + + let method_def_id = local_def(m.id); + let method_ty: @ty::method = ty::method(ecx.tcx, method_def_id); + encode_method_ty_fields(ecx, ebml_w, method_ty); + + match m.self_ty.node { + ast::sty_static => { + encode_family(ebml_w, purity_static_method_family(m.purity)); + } + _ => encode_family(ebml_w, purity_fn_family(m.purity)) + } + + let mut combined_ty_params = opt_vec::Empty; + combined_ty_params.push_all(&owner_generics.ty_params); + combined_ty_params.push_all(&method_generics.ty_params); + let len = combined_ty_params.len(); + encode_type_param_bounds(ebml_w, ecx, &combined_ty_params); + + encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, m.id)); + encode_path(ecx, ebml_w, impl_path, ast_map::path_name(m.ident)); + + if len > 0u || should_inline { + (ecx.encode_inlined_item)( + ecx, ebml_w, impl_path, + ii_method(local_def(parent_id), m)); + } else { + encode_symbol(ecx, ebml_w, m.id); + } + + ebml_w.end_tag(); +} + +fn purity_fn_family(p: purity) -> char { + match p { + unsafe_fn => 'u', + pure_fn => 'p', + impure_fn => 'f', + extern_fn => 'e' + } +} + +fn purity_static_method_family(p: purity) -> char { + match p { + unsafe_fn => 'U', + pure_fn => 'P', + impure_fn => 'F', + _ => fail!(~"extern fn can't be static") + } +} + + +fn should_inline(attrs: &[attribute]) -> bool { + match attr::find_inline_attr(attrs) { + attr::ia_none | attr::ia_never => false, + attr::ia_hint | attr::ia_always => true + } +} + +#[cfg(stage0)] +fn encode_info_for_item(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + item: @item, + index: @mut ~[entry], + path: &[ast_map::path_elt]) { + let tcx = ecx.tcx; + let must_write = + match item.node { + item_enum(_, _) | item_impl(*) | item_trait(*) | item_struct(*) | + item_mod(*) | item_foreign_mod(*) | item_const(*) => true, + _ => false + }; + if !must_write && !reachable(ecx, item.id) { return; } + + fn add_to_index_(item: @item, ebml_w: &writer::Encoder, + index: @mut ~[entry]) { + index.push(entry { val: item.id, pos: ebml_w.writer.tell() }); + } + let add_to_index: &fn() = || add_to_index_(item, ebml_w, index); + + debug!("encoding info for item at %s", + ecx.tcx.sess.codemap.span_to_str(item.span)); + + match item.node { + item_const(_, _) => { + add_to_index(); + ebml_w.start_tag(tag_items_data_item); + encode_def_id(ebml_w, local_def(item.id)); + encode_family(ebml_w, 'c'); + encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); + encode_symbol(ecx, ebml_w, item.id); + encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); + (ecx.encode_inlined_item)(ecx, ebml_w, path, ii_item(item)); + ebml_w.end_tag(); + } + item_fn(_, purity, _, ref generics, _) => { + add_to_index(); + ebml_w.start_tag(tag_items_data_item); + encode_def_id(ebml_w, local_def(item.id)); + encode_family(ebml_w, purity_fn_family(purity)); + let tps_len = generics.ty_params.len(); + encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); + encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); + encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); + encode_attributes(ebml_w, item.attrs); + if tps_len > 0u || should_inline(item.attrs) { + (ecx.encode_inlined_item)(ecx, ebml_w, path, ii_item(item)); + } else { + encode_symbol(ecx, ebml_w, item.id); + } + ebml_w.end_tag(); + } + item_mod(ref m) => { + add_to_index(); + encode_info_for_mod(ecx, ebml_w, m, item.id, path, item.ident); + } + item_foreign_mod(_) => { + add_to_index(); + ebml_w.start_tag(tag_items_data_item); + encode_def_id(ebml_w, local_def(item.id)); + encode_family(ebml_w, 'n'); + encode_name(ecx, ebml_w, item.ident); + encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); + ebml_w.end_tag(); + } + item_ty(_, ref generics) => { + add_to_index(); + ebml_w.start_tag(tag_items_data_item); + encode_def_id(ebml_w, local_def(item.id)); + encode_family(ebml_w, 'y'); + encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); + encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); + encode_name(ecx, ebml_w, item.ident); + encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); + encode_region_param(ecx, ebml_w, item); + ebml_w.end_tag(); + } + item_enum(ref enum_definition, ref generics) => { + add_to_index(); + do ebml_w.wr_tag(tag_items_data_item) { + encode_def_id(ebml_w, local_def(item.id)); + encode_family(ebml_w, 't'); + encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); + encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); + encode_name(ecx, ebml_w, item.ident); + for (*enum_definition).variants.each |v| { + encode_variant_id(ebml_w, local_def(v.node.id)); + } + (ecx.encode_inlined_item)(ecx, ebml_w, path, ii_item(item)); + encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); + encode_region_param(ecx, ebml_w, item); + } + encode_enum_variant_info(ecx, + ebml_w, + item.id, + (*enum_definition).variants, + path, + index, + generics); + } + item_struct(struct_def, ref generics) => { + /* First, encode the fields + These come first because we need to write them to make + the index, and the index needs to be in the item for the + class itself */ + let idx = encode_info_for_struct(ecx, ebml_w, path, + struct_def.fields, index); + + /* Index the class*/ + add_to_index(); + + /* Now, make an item for the class itself */ + ebml_w.start_tag(tag_items_data_item); + encode_def_id(ebml_w, local_def(item.id)); + encode_family(ebml_w, 'S'); + encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); + encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); + + // If this is a tuple- or enum-like struct, encode the type of the + // constructor. + if struct_def.fields.len() > 0 && + struct_def.fields[0].node.kind == ast::unnamed_field { + let ctor_id = match struct_def.ctor_id { + Some(ctor_id) => ctor_id, + None => ecx.tcx.sess.bug(~"struct def didn't have ctor id"), + }; + + encode_info_for_struct_ctor(ecx, + ebml_w, + path, + item.ident, + ctor_id, + index); + } + + encode_name(ecx, ebml_w, item.ident); + encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); + encode_region_param(ecx, ebml_w, item); + + /* Encode def_ids for each field and method + for methods, write all the stuff get_trait_method + needs to know*/ + for struct_def.fields.each |f| { + match f.node.kind { + named_field(ident, _, vis) => { + ebml_w.start_tag(tag_item_field); + encode_struct_field_family(ebml_w, vis); + encode_name(ecx, ebml_w, ident); + encode_def_id(ebml_w, local_def(f.node.id)); + ebml_w.end_tag(); + } + unnamed_field => { + ebml_w.start_tag(tag_item_unnamed_field); + encode_def_id(ebml_w, local_def(f.node.id)); + ebml_w.end_tag(); + } + } + } + + /* Each class has its own index -- encode it */ + let bkts = create_index(idx); + encode_index(ebml_w, bkts, write_int); + ebml_w.end_tag(); + } + item_impl(ref generics, opt_trait, ty, ref methods) => { + add_to_index(); + ebml_w.start_tag(tag_items_data_item); + encode_def_id(ebml_w, local_def(item.id)); + encode_family(ebml_w, 'i'); + encode_region_param(ecx, ebml_w, item); + encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); + encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); + encode_name(ecx, ebml_w, item.ident); + encode_attributes(ebml_w, item.attrs); + match ty.node { + ast::ty_path(path, _) if path.idents.len() == 1 => { + encode_impl_type_basename(ecx, ebml_w, + ast_util::path_to_ident(path)); + } + _ => {} + } + for methods.each |m| { + ebml_w.start_tag(tag_item_impl_method); + let method_def_id = local_def(m.id); + ebml_w.writer.write(str::to_bytes(def_to_str(method_def_id))); + ebml_w.end_tag(); + } + for opt_trait.each |ast_trait_ref| { + let trait_ref = ty::node_id_to_trait_ref(ecx.tcx, ast_trait_ref.ref_id); + encode_trait_ref(ebml_w, ecx, trait_ref, tag_item_trait_ref); + } + encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); + ebml_w.end_tag(); + + // >:-< + let mut impl_path = vec::append(~[], path); + impl_path += ~[ast_map::path_name(item.ident)]; + + for methods.each |m| { + index.push(entry {val: m.id, pos: ebml_w.writer.tell()}); + encode_info_for_method(ecx, + ebml_w, + impl_path, + should_inline(m.attrs), + item.id, + *m, + generics, + &m.generics); + } + } + item_trait(ref generics, ref super_traits, ref ms) => { + add_to_index(); + ebml_w.start_tag(tag_items_data_item); + encode_def_id(ebml_w, local_def(item.id)); + encode_family(ebml_w, 'I'); + encode_region_param(ecx, ebml_w, item); + encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); + let trait_def = ty::lookup_trait_def(tcx, local_def(item.id)); + encode_trait_ref(ebml_w, ecx, trait_def.trait_ref, tag_item_trait_ref); + encode_name(ecx, ebml_w, item.ident); + encode_attributes(ebml_w, item.attrs); + for ty::trait_method_def_ids(tcx, local_def(item.id)).each |&method_def_id| { + ebml_w.start_tag(tag_item_trait_method); + encode_def_id(ebml_w, method_def_id); + ebml_w.end_tag(); + } + encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); + for super_traits.each |ast_trait_ref| { + let trait_ref = ty::node_id_to_trait_ref(ecx.tcx, ast_trait_ref.ref_id); + encode_trait_ref(ebml_w, ecx, trait_ref, tag_item_super_trait_ref); + } + ebml_w.end_tag(); + + // Now output the method info for each method. + for ty::trait_method_def_ids(tcx, local_def(item.id)).eachi |i, &method_def_id| { + assert!(method_def_id.crate == ast::local_crate); -fn encode_method_ty_fields(ecx: @EncodeContext, - ebml_w: &writer::Encoder, - method_ty: &ty::method) -{ - encode_def_id(ebml_w, method_ty.def_id); - encode_name(ecx, ebml_w, method_ty.ident); - encode_ty_type_param_defs(ebml_w, ecx, - method_ty.generics.type_param_defs, - tag_item_method_tps); - encode_transformed_self_ty(ecx, ebml_w, method_ty.transformed_self_ty); - encode_method_fty(ecx, ebml_w, &method_ty.fty); - encode_visibility(ebml_w, method_ty.vis); - encode_self_type(ebml_w, method_ty.self_ty); -} + let method_ty: @ty::method = ty::method(tcx, method_def_id); -fn encode_info_for_method(ecx: @EncodeContext, - ebml_w: &writer::Encoder, - impl_path: &[ast_map::path_elt], - should_inline: bool, - parent_id: node_id, - m: @method, - owner_generics: &ast::Generics, - method_generics: &ast::Generics) { - debug!("encode_info_for_method: %d %s %u %u", m.id, - *ecx.tcx.sess.str_of(m.ident), - owner_generics.ty_params.len(), - method_generics.ty_params.len()); - ebml_w.start_tag(tag_items_data_item); + index.push(entry {val: method_def_id.node, pos: ebml_w.writer.tell()}); - let method_def_id = local_def(m.id); - let method_ty: @ty::method = ty::method(ecx.tcx, method_def_id); - encode_method_ty_fields(ecx, ebml_w, method_ty); + ebml_w.start_tag(tag_items_data_item); - match m.self_ty.node { - ast::sty_static => { - encode_family(ebml_w, purity_static_method_family(m.purity)); - } - _ => encode_family(ebml_w, purity_fn_family(m.purity)) - } + encode_method_ty_fields(ecx, ebml_w, method_ty); - let mut combined_ty_params = opt_vec::Empty; - combined_ty_params.push_all(&owner_generics.ty_params); - combined_ty_params.push_all(&method_generics.ty_params); - let len = combined_ty_params.len(); - encode_type_param_bounds(ebml_w, ecx, &combined_ty_params); + encode_parent_item(ebml_w, local_def(item.id)); - encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, m.id)); - encode_path(ecx, ebml_w, impl_path, ast_map::path_name(m.ident)); + let mut trait_path = vec::append(~[], path); + trait_path.push(ast_map::path_name(item.ident)); + encode_path(ecx, ebml_w, trait_path, ast_map::path_name(method_ty.ident)); - if len > 0u || should_inline { - (ecx.encode_inlined_item)( - ecx, ebml_w, impl_path, - ii_method(local_def(parent_id), m)); - } else { - encode_symbol(ecx, ebml_w, m.id); - } + match method_ty.self_ty { + sty_static => { + encode_family(ebml_w, + purity_static_method_family( + method_ty.fty.purity)); - ebml_w.end_tag(); -} + let tpt = ty::lookup_item_type(tcx, method_def_id); + encode_ty_type_param_defs(ebml_w, ecx, + tpt.generics.type_param_defs, + tag_items_data_item_ty_param_bounds); + encode_type(ecx, ebml_w, tpt.ty); + } -fn purity_fn_family(p: purity) -> char { - match p { - unsafe_fn => 'u', - pure_fn => 'p', - impure_fn => 'f', - extern_fn => 'e' - } -} + _ => { + encode_family(ebml_w, + purity_fn_family( + method_ty.fty.purity)); + } + } -fn purity_static_method_family(p: purity) -> char { - match p { - unsafe_fn => 'U', - pure_fn => 'P', - impure_fn => 'F', - _ => fail!(~"extern fn can't be static") - } -} + match ms[i] { + required(_) => { + encode_method_sort(ebml_w, 'r'); + } + provided(m) => { + // This is obviously a bogus assert but I don't think this + // ever worked before anyhow...near as I can tell, before + // we would emit two items. + if method_ty.self_ty == sty_static { + tcx.sess.span_unimpl( + item.span, + fmt!("Method %s is both provided and static", + *tcx.sess.intr().get(method_ty.ident))); + } + encode_type_param_bounds(ebml_w, ecx, + &m.generics.ty_params); + encode_method_sort(ebml_w, 'p'); + (ecx.encode_inlined_item)( + ecx, ebml_w, path, + ii_method(local_def(item.id), m)); + } + } -fn should_inline(attrs: &[attribute]) -> bool { - match attr::find_inline_attr(attrs) { - attr::ia_none | attr::ia_never => false, - attr::ia_hint | attr::ia_always => true + ebml_w.end_tag(); + } + } + item_mac(*) => fail!(~"item macros unimplemented") } } - -fn encode_info_for_item(ecx: @EncodeContext, ebml_w: &writer::Encoder, - item: @item, index: @mut ~[entry], +#[cfg(not(stage0))] +fn encode_info_for_item(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + item: @item, + index: @mut ~[entry], path: &[ast_map::path_elt]) { - let tcx = ecx.tcx; let must_write = match item.node { @@ -737,19 +1679,21 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: &writer::Encoder, } item_enum(ref enum_definition, ref generics) => { add_to_index(); - do ebml_w.wr_tag(tag_items_data_item) { - encode_def_id(ebml_w, local_def(item.id)); - encode_family(ebml_w, 't'); - encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); - encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); - encode_name(ecx, ebml_w, item.ident); - for (*enum_definition).variants.each |v| { - encode_variant_id(ebml_w, local_def(v.node.id)); - } - (ecx.encode_inlined_item)(ecx, ebml_w, path, ii_item(item)); - encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); - encode_region_param(ecx, ebml_w, item); + + ebml_w.start_tag(tag_items_data_item); + encode_def_id(ebml_w, local_def(item.id)); + encode_family(ebml_w, 't'); + encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); + encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); + encode_name(ecx, ebml_w, item.ident); + for (*enum_definition).variants.each |v| { + encode_variant_id(ebml_w, local_def(v.node.id)); } + (ecx.encode_inlined_item)(ecx, ebml_w, path, ii_item(item)); + encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); + encode_region_param(ecx, ebml_w, item); + ebml_w.end_tag(); + encode_enum_variant_info(ecx, ebml_w, item.id, @@ -960,6 +1904,7 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: &writer::Encoder, } } +#[cfg(stage0)] fn encode_info_for_foreign_item(ecx: @EncodeContext, ebml_w: &writer::Encoder, nitem: @foreign_item, @@ -994,8 +1939,46 @@ fn encode_info_for_foreign_item(ecx: @EncodeContext, ebml_w.end_tag(); } -fn encode_info_for_items(ecx: @EncodeContext, ebml_w: &writer::Encoder, - crate: &crate) -> ~[entry] { +#[cfg(not(stage0))] +fn encode_info_for_foreign_item(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + nitem: @foreign_item, + index: @mut ~[entry], + path: ast_map::path, + abi: AbiSet) { + if !reachable(ecx, nitem.id) { return; } + index.push(entry { val: nitem.id, pos: ebml_w.writer.tell() }); + + ebml_w.start_tag(tag_items_data_item); + match nitem.node { + foreign_item_fn(_, purity, ref generics) => { + encode_def_id(ebml_w, local_def(nitem.id)); + encode_family(ebml_w, purity_fn_family(purity)); + encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); + encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, nitem.id)); + if abi.is_intrinsic() { + (ecx.encode_inlined_item)(ecx, ebml_w, path, ii_foreign(nitem)); + } else { + encode_symbol(ecx, ebml_w, nitem.id); + } + encode_path(ecx, ebml_w, path, ast_map::path_name(nitem.ident)); + } + foreign_item_const(*) => { + encode_def_id(ebml_w, local_def(nitem.id)); + encode_family(ebml_w, 'c'); + encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, nitem.id)); + encode_symbol(ecx, ebml_w, nitem.id); + encode_path(ecx, ebml_w, path, ast_map::path_name(nitem.ident)); + } + } + ebml_w.end_tag(); +} + +#[cfg(stage0)] +fn encode_info_for_items(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + crate: &crate) + -> ~[entry] { let index = @mut ~[]; ebml_w.start_tag(tag_items_data); index.push(entry { val: crate_node_id, pos: ebml_w.writer.tell() }); @@ -1038,6 +2021,57 @@ fn encode_info_for_items(ecx: @EncodeContext, ebml_w: &writer::Encoder, return /*bad*/copy *index; } +#[cfg(not(stage0))] +fn encode_info_for_items(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + crate: &crate) + -> ~[entry] { + let index = @mut ~[]; + ebml_w.start_tag(tag_items_data); + index.push(entry { val: crate_node_id, pos: ebml_w.writer.tell() }); + encode_info_for_mod(ecx, ebml_w, &crate.node.module, + crate_node_id, ~[], + syntax::parse::token::special_idents::invalid); + visit::visit_crate(crate, (), visit::mk_vt(@visit::Visitor { + visit_expr: |_e, _cx, _v| { }, + visit_item: { + let ebml_w = copy *ebml_w; + |i, cx, v| { + visit::visit_item(i, cx, v); + match *ecx.tcx.items.get(&i.id) { + ast_map::node_item(_, pt) => { + let mut ebml_w = copy ebml_w; + encode_info_for_item(ecx, &mut ebml_w, i, index, *pt); + } + _ => fail!(~"bad item") + } + } + }, + visit_foreign_item: { + let ebml_w = copy *ebml_w; + |ni, cx, v| { + visit::visit_foreign_item(ni, cx, v); + match *ecx.tcx.items.get(&ni.id) { + ast_map::node_foreign_item(_, abi, _, pt) => { + let mut ebml_w = copy ebml_w; + encode_info_for_foreign_item(ecx, + &mut ebml_w, + ni, + index, + /*bad*/copy *pt, + abi); + } + // case for separate item and foreign-item tables + _ => fail!(~"bad foreign item") + } + } + }, + ..*visit::default_visitor() + })); + ebml_w.end_tag(); + return /*bad*/copy *index; +} + // Path and definition ID indexing @@ -1049,15 +2083,47 @@ fn create_index(index: ~[entry]) -> let h = elt.val.hash() as uint; buckets[h % 256].push(*elt); } - - let mut buckets_frozen = ~[]; - for buckets.each |bucket| { - buckets_frozen.push(@/*bad*/copy **bucket); + + let mut buckets_frozen = ~[]; + for buckets.each |bucket| { + buckets_frozen.push(@/*bad*/copy **bucket); + } + return buckets_frozen; +} + +#[cfg(stage0)] +fn encode_index(ebml_w: &writer::Encoder, + buckets: ~[@~[entry]], + write_fn: &fn(@io::Writer, &T)) { + let writer = ebml_w.writer; + ebml_w.start_tag(tag_index); + let mut bucket_locs: ~[uint] = ~[]; + ebml_w.start_tag(tag_index_buckets); + for buckets.each |bucket| { + bucket_locs.push(ebml_w.writer.tell()); + ebml_w.start_tag(tag_index_buckets_bucket); + for vec::each(**bucket) |elt| { + ebml_w.start_tag(tag_index_buckets_bucket_elt); + assert!(elt.pos < 0xffff_ffff); + writer.write_be_u32(elt.pos as u32); + write_fn(writer, &elt.val); + ebml_w.end_tag(); + } + ebml_w.end_tag(); + } + ebml_w.end_tag(); + ebml_w.start_tag(tag_index_table); + for bucket_locs.each |pos| { + assert!(*pos < 0xffff_ffff); + writer.write_be_u32(*pos as u32); } - return buckets_frozen; + ebml_w.end_tag(); + ebml_w.end_tag(); } -fn encode_index(ebml_w: &writer::Encoder, buckets: ~[@~[entry]], +#[cfg(not(stage0))] +fn encode_index(ebml_w: &mut writer::Encoder, + buckets: ~[@~[entry]], write_fn: &fn(@io::Writer, &T)) { let writer = ebml_w.writer; ebml_w.start_tag(tag_index); @@ -1085,13 +2151,16 @@ fn encode_index(ebml_w: &writer::Encoder, buckets: ~[@~[entry]], ebml_w.end_tag(); } -fn write_str(writer: @io::Writer, s: ~str) { writer.write_str(s); } +fn write_str(writer: @io::Writer, s: ~str) { + writer.write_str(s); +} fn write_int(writer: @io::Writer, &n: &int) { assert!(n < 0x7fff_ffff); writer.write_be_u32(n as u32); } +#[cfg(stage0)] fn encode_meta_item(ebml_w: &writer::Encoder, mi: @meta_item) { match mi.node { meta_word(name) => { @@ -1129,6 +2198,45 @@ fn encode_meta_item(ebml_w: &writer::Encoder, mi: @meta_item) { } } +#[cfg(not(stage0))] +fn encode_meta_item(ebml_w: &mut writer::Encoder, mi: @meta_item) { + match mi.node { + meta_word(name) => { + ebml_w.start_tag(tag_meta_item_word); + ebml_w.start_tag(tag_meta_item_name); + ebml_w.writer.write(str::to_bytes(*name)); + ebml_w.end_tag(); + ebml_w.end_tag(); + } + meta_name_value(name, value) => { + match value.node { + lit_str(value) => { + ebml_w.start_tag(tag_meta_item_name_value); + ebml_w.start_tag(tag_meta_item_name); + ebml_w.writer.write(str::to_bytes(*name)); + ebml_w.end_tag(); + ebml_w.start_tag(tag_meta_item_value); + ebml_w.writer.write(str::to_bytes(*value)); + ebml_w.end_tag(); + ebml_w.end_tag(); + } + _ => {/* FIXME (#623): encode other variants */ } + } + } + meta_list(name, ref items) => { + ebml_w.start_tag(tag_meta_item_list); + ebml_w.start_tag(tag_meta_item_name); + ebml_w.writer.write(str::to_bytes(*name)); + ebml_w.end_tag(); + for items.each |inner_item| { + encode_meta_item(ebml_w, *inner_item); + } + ebml_w.end_tag(); + } + } +} + +#[cfg(stage0)] fn encode_attributes(ebml_w: &writer::Encoder, attrs: &[attribute]) { ebml_w.start_tag(tag_attributes); for attrs.each |attr| { @@ -1139,6 +2247,17 @@ fn encode_attributes(ebml_w: &writer::Encoder, attrs: &[attribute]) { ebml_w.end_tag(); } +#[cfg(not(stage0))] +fn encode_attributes(ebml_w: &mut writer::Encoder, attrs: &[attribute]) { + ebml_w.start_tag(tag_attributes); + for attrs.each |attr| { + ebml_w.start_tag(tag_attribute); + encode_meta_item(ebml_w, attr.node.value); + ebml_w.end_tag(); + } + ebml_w.end_tag(); +} + // So there's a special crate attribute called 'link' which defines the // metadata that Rust cares about for linking crates. This attribute requires // 'name' and 'vers' items, so if the user didn't provide them we will throw @@ -1193,6 +2312,7 @@ fn synthesize_crate_attrs(ecx: @EncodeContext, return attrs; } +#[cfg(stage0)] fn encode_crate_deps(ecx: @EncodeContext, ebml_w: &writer::Encoder, cstore: @mut cstore::CStore) { @@ -1235,6 +2355,50 @@ fn encode_crate_deps(ecx: @EncodeContext, ebml_w.end_tag(); } +#[cfg(not(stage0))] +fn encode_crate_deps(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + cstore: @mut cstore::CStore) { + fn get_ordered_deps(ecx: @EncodeContext, cstore: @mut cstore::CStore) + -> ~[decoder::crate_dep] { + type numdep = decoder::crate_dep; + + // Pull the cnums and name,vers,hash out of cstore + let mut deps = ~[]; + do cstore::iter_crate_data(cstore) |key, val| { + let dep = decoder::crate_dep {cnum: key, + name: ecx.tcx.sess.ident_of(/*bad*/ copy *val.name), + vers: decoder::get_crate_vers(val.data), + hash: decoder::get_crate_hash(val.data)}; + deps.push(dep); + }; + + // Sort by cnum + std::sort::quick_sort(deps, |kv1, kv2| kv1.cnum <= kv2.cnum); + + // Sanity-check the crate numbers + let mut expected_cnum = 1; + for deps.each |n| { + assert!((n.cnum == expected_cnum)); + expected_cnum += 1; + } + + // mut -> immutable hack for vec::map + deps.slice(0, deps.len()).to_owned() + } + + // We're just going to write a list of crate 'name-hash-version's, with + // the assumption that they are numbered 1 to n. + // FIXME (#2166): This is not nearly enough to support correct versioning + // but is enough to get transitive crate dependencies working. + ebml_w.start_tag(tag_crate_deps); + for get_ordered_deps(ecx, cstore).each |dep| { + encode_crate_dep(ecx, ebml_w, *dep); + } + ebml_w.end_tag(); +} + +#[cfg(stage0)] fn encode_lang_items(ecx: @EncodeContext, ebml_w: &writer::Encoder) { ebml_w.start_tag(tag_lang_items); @@ -1259,8 +2423,47 @@ fn encode_lang_items(ecx: @EncodeContext, ebml_w: &writer::Encoder) { ebml_w.end_tag(); // tag_lang_items } -fn encode_link_args(ecx: @EncodeContext, - ebml_w: &writer::Encoder) { +#[cfg(not(stage0))] +fn encode_lang_items(ecx: @EncodeContext, ebml_w: &mut writer::Encoder) { + ebml_w.start_tag(tag_lang_items); + + for ecx.tcx.lang_items.each_item |def_id, i| { + if def_id.crate != local_crate { + loop; + } + + ebml_w.start_tag(tag_lang_items_item); + + ebml_w.start_tag(tag_lang_items_item_id); + ebml_w.writer.write_be_u32(i as u32); + ebml_w.end_tag(); // tag_lang_items_item_id + + ebml_w.start_tag(tag_lang_items_item_node_id); + ebml_w.writer.write_be_u32(def_id.node as u32); + ebml_w.end_tag(); // tag_lang_items_item_node_id + + ebml_w.end_tag(); // tag_lang_items_item + } + + ebml_w.end_tag(); // tag_lang_items +} + +#[cfg(stage0)] +fn encode_link_args(ecx: @EncodeContext, ebml_w: &writer::Encoder) { + ebml_w.start_tag(tag_link_args); + + let link_args = cstore::get_used_link_args(ecx.cstore); + for link_args.each |link_arg| { + ebml_w.start_tag(tag_link_args_arg); + ebml_w.writer.write_str(link_arg.to_str()); + ebml_w.end_tag(); + } + + ebml_w.end_tag(); +} + +#[cfg(not(stage0))] +fn encode_link_args(ecx: @EncodeContext, ebml_w: &mut writer::Encoder) { ebml_w.start_tag(tag_link_args); let link_args = cstore::get_used_link_args(ecx.cstore); @@ -1273,7 +2476,26 @@ fn encode_link_args(ecx: @EncodeContext, ebml_w.end_tag(); } -fn encode_crate_dep(ecx: @EncodeContext, ebml_w: &writer::Encoder, +#[cfg(stage0)] +fn encode_crate_dep(ecx: @EncodeContext, + ebml_w: &writer::Encoder, + dep: decoder::crate_dep) { + ebml_w.start_tag(tag_crate_dep); + ebml_w.start_tag(tag_crate_dep_name); + ebml_w.writer.write(str::to_bytes(*ecx.tcx.sess.str_of(dep.name))); + ebml_w.end_tag(); + ebml_w.start_tag(tag_crate_dep_vers); + ebml_w.writer.write(str::to_bytes(*dep.vers)); + ebml_w.end_tag(); + ebml_w.start_tag(tag_crate_dep_hash); + ebml_w.writer.write(str::to_bytes(*dep.hash)); + ebml_w.end_tag(); + ebml_w.end_tag(); +} + +#[cfg(not(stage0))] +fn encode_crate_dep(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, dep: decoder::crate_dep) { ebml_w.start_tag(tag_crate_dep); ebml_w.start_tag(tag_crate_dep_name); @@ -1288,12 +2510,20 @@ fn encode_crate_dep(ecx: @EncodeContext, ebml_w: &writer::Encoder, ebml_w.end_tag(); } +#[cfg(stage0)] fn encode_hash(ebml_w: &writer::Encoder, hash: &str) { ebml_w.start_tag(tag_crate_hash); ebml_w.writer.write(str::to_bytes(hash)); ebml_w.end_tag(); } +#[cfg(not(stage0))] +fn encode_hash(ebml_w: &mut writer::Encoder, hash: &str) { + ebml_w.start_tag(tag_crate_hash); + ebml_w.writer.write(str::to_bytes(hash)); + ebml_w.end_tag(); +} + // NB: Increment this as you change the metadata encoding version. pub static metadata_encoding_version : &'static [u8] = &[0x72, //'r' as u8, @@ -1302,6 +2532,7 @@ pub static metadata_encoding_version : &'static [u8] = 0x74, //'t' as u8, 0, 0, 0, 1 ]; +#[cfg(stage0)] pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] { let wr = @io::BytesWriter(); let stats = Stats { @@ -1408,6 +2639,113 @@ pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] { }) + flate::deflate_bytes(wr.bytes) } +#[cfg(not(stage0))] +pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] { + let wr = @io::BytesWriter(); + let stats = Stats { + inline_bytes: 0, + attr_bytes: 0, + dep_bytes: 0, + lang_item_bytes: 0, + link_args_bytes: 0, + item_bytes: 0, + index_bytes: 0, + zero_bytes: 0, + total_bytes: 0, + n_inlines: 0 + }; + let EncodeParams{item_symbols, diag, tcx, reachable, reexports2, + discrim_symbols, cstore, encode_inlined_item, + link_meta, _} = parms; + let ecx = @EncodeContext { + diag: diag, + tcx: tcx, + stats: @mut stats, + reachable: reachable, + reexports2: reexports2, + item_symbols: item_symbols, + discrim_symbols: discrim_symbols, + link_meta: link_meta, + cstore: cstore, + encode_inlined_item: encode_inlined_item, + type_abbrevs: @mut HashMap::new() + }; + + let mut ebml_w = writer::Encoder(wr as @io::Writer); + + encode_hash(&mut ebml_w, ecx.link_meta.extras_hash); + + let mut i = wr.pos; + let crate_attrs = synthesize_crate_attrs(ecx, crate); + encode_attributes(&mut ebml_w, crate_attrs); + ecx.stats.attr_bytes = wr.pos - i; + + i = wr.pos; + encode_crate_deps(ecx, &mut ebml_w, ecx.cstore); + ecx.stats.dep_bytes = wr.pos - i; + + // Encode the language items. + i = wr.pos; + encode_lang_items(ecx, &mut ebml_w); + ecx.stats.lang_item_bytes = wr.pos - i; + + // Encode the link args. + i = wr.pos; + encode_link_args(ecx, &mut ebml_w); + ecx.stats.link_args_bytes = wr.pos - i; + + // Encode and index the items. + ebml_w.start_tag(tag_items); + i = wr.pos; + let items_index = encode_info_for_items(ecx, &mut ebml_w, crate); + ecx.stats.item_bytes = wr.pos - i; + + i = wr.pos; + let items_buckets = create_index(items_index); + encode_index(&mut ebml_w, items_buckets, write_int); + ecx.stats.index_bytes = wr.pos - i; + ebml_w.end_tag(); + + ecx.stats.total_bytes = wr.pos; + + if (tcx.sess.meta_stats()) { + + do wr.bytes.each |e| { + if *e == 0 { + ecx.stats.zero_bytes += 1; + } + true + } + + io::println("metadata stats:"); + io::println(fmt!(" inline bytes: %u", ecx.stats.inline_bytes)); + io::println(fmt!(" attribute bytes: %u", ecx.stats.attr_bytes)); + io::println(fmt!(" dep bytes: %u", ecx.stats.dep_bytes)); + io::println(fmt!(" lang item bytes: %u", ecx.stats.lang_item_bytes)); + io::println(fmt!(" link args bytes: %u", ecx.stats.link_args_bytes)); + io::println(fmt!(" item bytes: %u", ecx.stats.item_bytes)); + io::println(fmt!(" index bytes: %u", ecx.stats.index_bytes)); + io::println(fmt!(" zero bytes: %u", ecx.stats.zero_bytes)); + io::println(fmt!(" total bytes: %u", ecx.stats.total_bytes)); + } + + // Pad this, since something (LLVM, presumably) is cutting off the + // remaining % 4 bytes. + wr.write(&[0u8, 0u8, 0u8, 0u8]); + + // FIXME #3396: weird bug here, for reasons unclear this emits random + // looking bytes (mostly 0x1) if we use the version byte-array constant + // above; so we use a string constant inline instead. + // + // Should be: + // + // vec::from_slice(metadata_encoding_version) + + + (do str::as_bytes(&~"rust\x00\x00\x00\x01") |bytes| { + vec::slice(*bytes, 0, 8).to_vec() + }) + flate::deflate_bytes(wr.bytes) +} + // Get the encoded string for a type pub fn encoded_ty(tcx: ty::ctxt, t: ty::t) -> ~str { let cx = @tyencode::ctxt { diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 2f753523a7b..2a9f19fc846 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -77,6 +77,7 @@ trait tr_intern { // ______________________________________________________________________ // Top-level methods. +#[cfg(stage0)] pub fn encode_inlined_item(ecx: @e::EncodeContext, ebml_w: &writer::Encoder, path: &[ast_map::path_elt], @@ -100,6 +101,32 @@ pub fn encode_inlined_item(ecx: @e::EncodeContext, ebml_w.writer.tell()); } +#[cfg(not(stage0))] +pub fn encode_inlined_item(ecx: @e::EncodeContext, + ebml_w: &mut writer::Encoder, + path: &[ast_map::path_elt], + ii: ast::inlined_item, + maps: Maps) { + debug!("> Encoding inlined item: %s::%s (%u)", + ast_map::path_to_str(path, ecx.tcx.sess.parse_sess.interner), + *ecx.tcx.sess.str_of(ii.ident()), + ebml_w.writer.tell()); + + let id_range = ast_util::compute_id_range_for_inlined_item(&ii); + + ebml_w.start_tag(c::tag_ast as uint); + id_range.encode(ebml_w); + encode_ast(ebml_w, simplify_ast(&ii)); + encode_side_tables_for_ii(ecx, maps, ebml_w, &ii); + ebml_w.end_tag(); + + debug!("< Encoded inlined fn: %s::%s (%u)", + ast_map::path_to_str(path, ecx.tcx.sess.parse_sess.interner), + *ecx.tcx.sess.str_of(ii.ident()), + ebml_w.writer.tell()); +} + +#[cfg(stage0)] pub fn decode_inlined_item(cdata: @cstore::crate_metadata, tcx: ty::ctxt, maps: Maps, @@ -145,6 +172,52 @@ pub fn decode_inlined_item(cdata: @cstore::crate_metadata, } } +#[cfg(not(stage0))] +pub fn decode_inlined_item(cdata: @cstore::crate_metadata, + tcx: ty::ctxt, + maps: Maps, + path: ast_map::path, + par_doc: ebml::Doc) + -> Option { + let dcx = @DecodeContext { + cdata: cdata, + tcx: tcx, + maps: maps + }; + match par_doc.opt_child(c::tag_ast) { + None => None, + Some(ast_doc) => { + debug!("> Decoding inlined fn: %s::?", + ast_map::path_to_str(path, tcx.sess.parse_sess.interner)); + let mut ast_dsr = reader::Decoder(ast_doc); + let from_id_range = Decodable::decode(&mut ast_dsr); + let to_id_range = reserve_id_range(dcx.tcx.sess, from_id_range); + let xcx = @ExtendedDecodeContext { + dcx: dcx, + from_id_range: from_id_range, + to_id_range: to_id_range + }; + let raw_ii = decode_ast(ast_doc); + let ii = renumber_ast(xcx, raw_ii); + debug!("Fn named: %s", *tcx.sess.str_of(ii.ident())); + debug!("< Decoded inlined fn: %s::%s", + ast_map::path_to_str(path, tcx.sess.parse_sess.interner), + *tcx.sess.str_of(ii.ident())); + ast_map::map_decoded_item(tcx.sess.diagnostic(), + dcx.tcx.items, path, &ii); + decode_side_tables(xcx, ast_doc); + match ii { + ast::ii_item(i) => { + debug!(">>> DECODED ITEM >>>\n%s\n<<< DECODED ITEM <<<", + syntax::print::pprust::item_to_str(i, tcx.sess.intr())); + } + _ => { } + } + Some(ii) + } + } +} + // ______________________________________________________________________ // Enumerating the IDs which appear in an AST @@ -236,28 +309,56 @@ impl tr for span { } } +#[cfg(stage0)] trait def_id_encoder_helpers { fn emit_def_id(&self, did: ast::def_id); } +#[cfg(not(stage0))] +trait def_id_encoder_helpers { + fn emit_def_id(&mut self, did: ast::def_id); +} + +#[cfg(stage0)] impl def_id_encoder_helpers for S { fn emit_def_id(&self, did: ast::def_id) { did.encode(self) } } +#[cfg(not(stage0))] +impl def_id_encoder_helpers for S { + fn emit_def_id(&mut self, did: ast::def_id) { + did.encode(self) + } +} + +#[cfg(stage0)] trait def_id_decoder_helpers { fn read_def_id(&self, xcx: @ExtendedDecodeContext) -> ast::def_id; } -impl def_id_decoder_helpers for D { +#[cfg(not(stage0))] +trait def_id_decoder_helpers { + fn read_def_id(&mut self, xcx: @ExtendedDecodeContext) -> ast::def_id; +} +#[cfg(stage0)] +impl def_id_decoder_helpers for D { fn read_def_id(&self, xcx: @ExtendedDecodeContext) -> ast::def_id { let did: ast::def_id = Decodable::decode(self); did.tr(xcx) } } +#[cfg(not(stage0))] +impl def_id_decoder_helpers for D { + fn read_def_id(&mut self, xcx: @ExtendedDecodeContext) -> ast::def_id { + let did: ast::def_id = Decodable::decode(self); + did.tr(xcx) + } +} + // ______________________________________________________________________ // Encoding and decoding the AST itself // @@ -273,12 +374,20 @@ impl def_id_decoder_helpers for D { // We also have to adjust the spans: for now we just insert a dummy span, // but eventually we should add entries to the local codemap as required. +#[cfg(stage0)] fn encode_ast(ebml_w: &writer::Encoder, item: ast::inlined_item) { do ebml_w.wr_tag(c::tag_tree as uint) { item.encode(ebml_w) } } +#[cfg(not(stage0))] +fn encode_ast(ebml_w: &mut writer::Encoder, item: ast::inlined_item) { + ebml_w.start_tag(c::tag_tree as uint); + item.encode(ebml_w); + ebml_w.end_tag(); +} + // Produces a simplified copy of the AST which does not include things // that we do not need to or do not want to export. For example, we // do not include any nested items: if these nested items are to be @@ -330,12 +439,20 @@ fn simplify_ast(ii: &ast::inlined_item) -> ast::inlined_item { } } +#[cfg(stage0)] fn decode_ast(par_doc: ebml::Doc) -> ast::inlined_item { let chi_doc = par_doc.get(c::tag_tree as uint); let d = &reader::Decoder(chi_doc); Decodable::decode(d) } +#[cfg(not(stage0))] +fn decode_ast(par_doc: ebml::Doc) -> ast::inlined_item { + let chi_doc = par_doc.get(c::tag_tree as uint); + let mut d = reader::Decoder(chi_doc); + Decodable::decode(&mut d) +} + fn renumber_ast(xcx: @ExtendedDecodeContext, ii: ast::inlined_item) -> ast::inlined_item { let fld = fold::make_fold(@fold::AstFoldFns{ @@ -360,16 +477,30 @@ fn renumber_ast(xcx: @ExtendedDecodeContext, ii: ast::inlined_item) // ______________________________________________________________________ // Encoding and decoding of ast::def +#[cfg(stage0)] fn encode_def(ebml_w: &writer::Encoder, def: ast::def) { def.encode(ebml_w) } +#[cfg(not(stage0))] +fn encode_def(ebml_w: &mut writer::Encoder, def: ast::def) { + def.encode(ebml_w) +} + +#[cfg(stage0)] fn decode_def(xcx: @ExtendedDecodeContext, doc: ebml::Doc) -> ast::def { let dsr = &reader::Decoder(doc); let def: ast::def = Decodable::decode(dsr); def.tr(xcx) } +#[cfg(not(stage0))] +fn decode_def(xcx: @ExtendedDecodeContext, doc: ebml::Doc) -> ast::def { + let mut dsr = reader::Decoder(doc); + let def: ast::def = Decodable::decode(&mut dsr); + def.tr(xcx) +} + impl tr for ast::def { fn tr(&self, xcx: @ExtendedDecodeContext) -> ast::def { match *self { @@ -471,18 +602,41 @@ impl tr for ty::bound_region { // ______________________________________________________________________ // Encoding and decoding of freevar information +#[cfg(stage0)] fn encode_freevar_entry(ebml_w: &writer::Encoder, fv: @freevar_entry) { (*fv).encode(ebml_w) } +#[cfg(not(stage0))] +fn encode_freevar_entry(ebml_w: &mut writer::Encoder, fv: @freevar_entry) { + (*fv).encode(ebml_w) +} + +#[cfg(stage0)] trait ebml_decoder_helper { fn read_freevar_entry(&self, xcx: @ExtendedDecodeContext) - -> freevar_entry; + -> freevar_entry; +} + +#[cfg(not(stage0))] +trait ebml_decoder_helper { + fn read_freevar_entry(&mut self, xcx: @ExtendedDecodeContext) + -> freevar_entry; } +#[cfg(stage0)] impl ebml_decoder_helper for reader::Decoder { fn read_freevar_entry(&self, xcx: @ExtendedDecodeContext) - -> freevar_entry { + -> freevar_entry { + let fv: freevar_entry = Decodable::decode(self); + fv.tr(xcx) + } +} + +#[cfg(not(stage0))] +impl ebml_decoder_helper for reader::Decoder { + fn read_freevar_entry(&mut self, xcx: @ExtendedDecodeContext) + -> freevar_entry { let fv: freevar_entry = Decodable::decode(self); fv.tr(xcx) } @@ -500,14 +654,31 @@ impl tr for freevar_entry { // ______________________________________________________________________ // Encoding and decoding of CaptureVar information +#[cfg(stage0)] trait capture_var_helper { fn read_capture_var(&self, xcx: @ExtendedDecodeContext) - -> moves::CaptureVar; + -> moves::CaptureVar; } +#[cfg(not(stage0))] +trait capture_var_helper { + fn read_capture_var(&mut self, xcx: @ExtendedDecodeContext) + -> moves::CaptureVar; +} + +#[cfg(stage0)] impl capture_var_helper for reader::Decoder { fn read_capture_var(&self, xcx: @ExtendedDecodeContext) - -> moves::CaptureVar { + -> moves::CaptureVar { + let cvar: moves::CaptureVar = Decodable::decode(self); + cvar.tr(xcx) + } +} + +#[cfg(not(stage0))] +impl capture_var_helper for reader::Decoder { + fn read_capture_var(&mut self, xcx: @ExtendedDecodeContext) + -> moves::CaptureVar { let cvar: moves::CaptureVar = Decodable::decode(self); cvar.tr(xcx) } @@ -527,14 +698,18 @@ impl tr for moves::CaptureVar { // Encoding and decoding of method_map_entry trait read_method_map_entry_helper { + #[cfg(stage0)] fn read_method_map_entry(&self, xcx: @ExtendedDecodeContext) - -> method_map_entry; + -> method_map_entry; + #[cfg(not(stage0))] + fn read_method_map_entry(&mut self, xcx: @ExtendedDecodeContext) + -> method_map_entry; } #[cfg(stage0)] fn encode_method_map_entry(ecx: @e::EncodeContext, - ebml_w: &writer::Encoder, - mme: method_map_entry) { + ebml_w: &writer::Encoder, + mme: method_map_entry) { do ebml_w.emit_struct("method_map_entry", 3) { do ebml_w.emit_field(~"self_arg", 0u) { ebml_w.emit_arg(ecx, mme.self_arg); @@ -551,23 +726,21 @@ fn encode_method_map_entry(ecx: @e::EncodeContext, } } -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] +#[cfg(not(stage0))] fn encode_method_map_entry(ecx: @e::EncodeContext, - ebml_w: &writer::Encoder, - mme: method_map_entry) { - do ebml_w.emit_struct("method_map_entry", 3) { - do ebml_w.emit_struct_field("self_arg", 0u) { + ebml_w: &mut writer::Encoder, + mme: method_map_entry) { + do ebml_w.emit_struct("method_map_entry", 3) |ebml_w| { + do ebml_w.emit_struct_field("self_arg", 0u) |ebml_w| { ebml_w.emit_arg(ecx, mme.self_arg); } - do ebml_w.emit_struct_field("explicit_self", 2u) { + do ebml_w.emit_struct_field("explicit_self", 2u) |ebml_w| { mme.explicit_self.encode(ebml_w); } - do ebml_w.emit_struct_field("origin", 1u) { + do ebml_w.emit_struct_field("origin", 1u) |ebml_w| { mme.origin.encode(ebml_w); } - do ebml_w.emit_struct_field("self_mode", 3) { + do ebml_w.emit_struct_field("self_mode", 3) |ebml_w| { mme.self_mode.encode(ebml_w); } } @@ -576,7 +749,7 @@ fn encode_method_map_entry(ecx: @e::EncodeContext, impl read_method_map_entry_helper for reader::Decoder { #[cfg(stage0)] fn read_method_map_entry(&self, xcx: @ExtendedDecodeContext) - -> method_map_entry { + -> method_map_entry { do self.read_struct("method_map_entry", 3) { method_map_entry { self_arg: self.read_field(~"self_arg", 0u, || { @@ -599,27 +772,27 @@ impl read_method_map_entry_helper for reader::Decoder { } } - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] - fn read_method_map_entry(&self, xcx: @ExtendedDecodeContext) - -> method_map_entry { - do self.read_struct("method_map_entry", 3) { + #[cfg(not(stage0))] + fn read_method_map_entry(&mut self, xcx: @ExtendedDecodeContext) + -> method_map_entry { + do self.read_struct("method_map_entry", 3) |this| { method_map_entry { - self_arg: self.read_struct_field("self_arg", 0u, || { - self.read_arg(xcx) + self_arg: this.read_struct_field("self_arg", 0, |this| { + this.read_arg(xcx) }), - explicit_self: self.read_struct_field("explicit_self", 2, || { - let self_type: ast::self_ty_ = Decodable::decode(self); + explicit_self: this.read_struct_field("explicit_self", + 2, + |this| { + let self_type: ast::self_ty_ = Decodable::decode(this); self_type }), - origin: self.read_struct_field("origin", 1u, || { + origin: this.read_struct_field("origin", 1, |this| { let method_origin: method_origin = - Decodable::decode(self); + Decodable::decode(this); method_origin.tr(xcx) }), - self_mode: self.read_struct_field("self_mode", 3, || { - let self_mode: ty::SelfMode = Decodable::decode(self); + self_mode: this.read_struct_field("self_mode", 3, |this| { + let self_mode: ty::SelfMode = Decodable::decode(this); self_mode }), } @@ -657,6 +830,7 @@ impl tr for method_origin { // ______________________________________________________________________ // Encoding and decoding vtable_res +#[cfg(stage0)] fn encode_vtable_res(ecx: @e::EncodeContext, ebml_w: &writer::Encoder, dr: typeck::vtable_res) { @@ -669,6 +843,20 @@ fn encode_vtable_res(ecx: @e::EncodeContext, } } +#[cfg(not(stage0))] +fn encode_vtable_res(ecx: @e::EncodeContext, + ebml_w: &mut writer::Encoder, + dr: typeck::vtable_res) { + // can't autogenerate this code because automatic code of + // ty::t doesn't work, and there is no way (atm) to have + // hand-written encoding routines combine with auto-generated + // ones. perhaps we should fix this. + do ebml_w.emit_from_vec(*dr) |ebml_w, vtable_origin| { + encode_vtable_origin(ecx, ebml_w, vtable_origin) + } +} + +#[cfg(stage0)] fn encode_vtable_origin(ecx: @e::EncodeContext, ebml_w: &writer::Encoder, vtable_origin: &typeck::vtable_origin) { @@ -699,24 +887,72 @@ fn encode_vtable_origin(ecx: @e::EncodeContext, } } } +} +#[cfg(not(stage0))] +fn encode_vtable_origin(ecx: @e::EncodeContext, + ebml_w: &mut writer::Encoder, + vtable_origin: &typeck::vtable_origin) { + do ebml_w.emit_enum(~"vtable_origin") |ebml_w| { + match *vtable_origin { + typeck::vtable_static(def_id, ref tys, vtable_res) => { + do ebml_w.emit_enum_variant(~"vtable_static", 0u, 3u) |ebml_w| { + do ebml_w.emit_enum_variant_arg(0u) |ebml_w| { + ebml_w.emit_def_id(def_id) + } + do ebml_w.emit_enum_variant_arg(1u) |ebml_w| { + ebml_w.emit_tys(ecx, /*bad*/copy *tys); + } + do ebml_w.emit_enum_variant_arg(2u) |ebml_w| { + encode_vtable_res(ecx, ebml_w, vtable_res); + } + } + } + typeck::vtable_param(pn, bn) => { + do ebml_w.emit_enum_variant(~"vtable_param", 1u, 2u) |ebml_w| { + do ebml_w.emit_enum_variant_arg(0u) |ebml_w| { + ebml_w.emit_uint(pn); + } + do ebml_w.emit_enum_variant_arg(1u) |ebml_w| { + ebml_w.emit_uint(bn); + } + } + } + } + } } trait vtable_decoder_helpers { + #[cfg(stage0)] fn read_vtable_res(&self, xcx: @ExtendedDecodeContext) -> typeck::vtable_res; + #[cfg(not(stage0))] + fn read_vtable_res(&mut self, xcx: @ExtendedDecodeContext) + -> typeck::vtable_res; + #[cfg(stage0)] fn read_vtable_origin(&self, xcx: @ExtendedDecodeContext) - -> typeck::vtable_origin; + -> typeck::vtable_origin; + #[cfg(not(stage0))] + fn read_vtable_origin(&mut self, xcx: @ExtendedDecodeContext) + -> typeck::vtable_origin; } impl vtable_decoder_helpers for reader::Decoder { + #[cfg(stage0)] fn read_vtable_res(&self, xcx: @ExtendedDecodeContext) -> typeck::vtable_res { - @self.read_to_vec(|| self.read_vtable_origin(xcx) ) + @self.read_to_vec(|| self.read_vtable_origin(xcx)) } + #[cfg(not(stage0))] + fn read_vtable_res(&mut self, xcx: @ExtendedDecodeContext) + -> typeck::vtable_res { + @self.read_to_vec(|this| this.read_vtable_origin(xcx)) + } + + #[cfg(stage0)] fn read_vtable_origin(&self, xcx: @ExtendedDecodeContext) - -> typeck::vtable_origin { + -> typeck::vtable_origin { do self.read_enum("vtable_origin") { do self.read_enum_variant(["vtable_static", "vtable_param"]) |i| { match i { @@ -749,6 +985,43 @@ impl vtable_decoder_helpers for reader::Decoder { } } } + + #[cfg(not(stage0))] + fn read_vtable_origin(&mut self, xcx: @ExtendedDecodeContext) + -> typeck::vtable_origin { + do self.read_enum("vtable_origin") |this| { + do this.read_enum_variant(["vtable_static", "vtable_param"]) + |this, i| { + match i { + 0 => { + typeck::vtable_static( + do this.read_enum_variant_arg(0u) |this| { + this.read_def_id(xcx) + }, + do this.read_enum_variant_arg(1u) |this| { + this.read_tys(xcx) + }, + do this.read_enum_variant_arg(2u) |this| { + this.read_vtable_res(xcx) + } + ) + } + 1 => { + typeck::vtable_param( + do this.read_enum_variant_arg(0u) |this| { + this.read_uint() + }, + do this.read_enum_variant_arg(1u) |this| { + this.read_uint() + } + ) + } + // hard to avoid - user input + _ => fail!(~"bad enum variant") + } + } + } + } } // ______________________________________________________________________ @@ -769,6 +1042,7 @@ impl get_ty_str_ctxt for e::EncodeContext { } } +#[cfg(stage0)] trait ebml_writer_helpers { fn emit_arg(&self, ecx: @e::EncodeContext, arg: ty::arg); fn emit_ty(&self, ecx: @e::EncodeContext, ty: ty::t); @@ -781,31 +1055,78 @@ trait ebml_writer_helpers { tpbt: ty::ty_param_bounds_and_ty); } +#[cfg(not(stage0))] +trait ebml_writer_helpers { + fn emit_arg(&mut self, ecx: @e::EncodeContext, arg: ty::arg); + fn emit_ty(&mut self, ecx: @e::EncodeContext, ty: ty::t); + fn emit_vstore(&mut self, ecx: @e::EncodeContext, vstore: ty::vstore); + fn emit_tys(&mut self, ecx: @e::EncodeContext, tys: ~[ty::t]); + fn emit_type_param_def(&mut self, + ecx: @e::EncodeContext, + type_param_def: &ty::TypeParameterDef); + fn emit_tpbt(&mut self, + ecx: @e::EncodeContext, + tpbt: ty::ty_param_bounds_and_ty); +} + impl ebml_writer_helpers for writer::Encoder { + #[cfg(stage0)] fn emit_ty(&self, ecx: @e::EncodeContext, ty: ty::t) { do self.emit_opaque { e::write_type(ecx, self, ty) } } + #[cfg(not(stage0))] + fn emit_ty(&mut self, ecx: @e::EncodeContext, ty: ty::t) { + do self.emit_opaque |this| { + e::write_type(ecx, this, ty) + } + } + + #[cfg(stage0)] fn emit_vstore(&self, ecx: @e::EncodeContext, vstore: ty::vstore) { do self.emit_opaque { e::write_vstore(ecx, self, vstore) } } + #[cfg(not(stage0))] + fn emit_vstore(&mut self, ecx: @e::EncodeContext, vstore: ty::vstore) { + do self.emit_opaque |this| { + e::write_vstore(ecx, this, vstore) + } + } + + #[cfg(stage0)] fn emit_arg(&self, ecx: @e::EncodeContext, arg: ty::arg) { do self.emit_opaque { tyencode::enc_arg(self.writer, ecx.ty_str_ctxt(), arg); } } + #[cfg(not(stage0))] + fn emit_arg(&mut self, ecx: @e::EncodeContext, arg: ty::arg) { + do self.emit_opaque |this| { + tyencode::enc_arg(this.writer, ecx.ty_str_ctxt(), arg); + } + } + + #[cfg(stage0)] fn emit_tys(&self, ecx: @e::EncodeContext, tys: ~[ty::t]) { do self.emit_from_vec(tys) |ty| { self.emit_ty(ecx, *ty) } } + #[cfg(not(stage0))] + fn emit_tys(&mut self, ecx: @e::EncodeContext, tys: ~[ty::t]) { + do self.emit_from_vec(tys) |this, ty| { + this.emit_ty(ecx, *ty) + } + } + + #[cfg(stage0)] fn emit_type_param_def(&self, ecx: @e::EncodeContext, type_param_def: &ty::TypeParameterDef) { @@ -815,16 +1136,27 @@ impl ebml_writer_helpers for writer::Encoder { } } + #[cfg(not(stage0))] + fn emit_type_param_def(&mut self, + ecx: @e::EncodeContext, + type_param_def: &ty::TypeParameterDef) { + do self.emit_opaque |this| { + tyencode::enc_type_param_def(this.writer, + ecx.ty_str_ctxt(), + type_param_def) + } + } + #[cfg(stage0)] - fn emit_tpbt(&self, ecx: @e::EncodeContext, + fn emit_tpbt(&self, + ecx: @e::EncodeContext, tpbt: ty::ty_param_bounds_and_ty) { do self.emit_struct("ty_param_bounds_and_ty", 2) { do self.emit_field(~"generics", 0) { do self.emit_struct("Generics", 2) { do self.emit_field(~"type_param_defs", 0) { do self.emit_from_vec(*tpbt.generics.type_param_defs) - |type_param_def| - { + |type_param_def| { self.emit_type_param_def(ecx, type_param_def); } } @@ -839,38 +1171,44 @@ impl ebml_writer_helpers for writer::Encoder { } } - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] - fn emit_tpbt(&self, ecx: @e::EncodeContext, + #[cfg(not(stage0))] + fn emit_tpbt(&mut self, + ecx: @e::EncodeContext, tpbt: ty::ty_param_bounds_and_ty) { - do self.emit_struct("ty_param_bounds_and_ty", 2) { - do self.emit_struct_field("generics", 0) { - do self.emit_struct("Generics", 2) { - do self.emit_struct_field("type_param_defs", 0) { - do self.emit_from_vec(*tpbt.generics.type_param_defs) - |type_param_def| - { - self.emit_type_param_def(ecx, type_param_def); + do self.emit_struct("ty_param_bounds_and_ty", 2) |this| { + do this.emit_struct_field(~"generics", 0) |this| { + do this.emit_struct("Generics", 2) |this| { + do this.emit_struct_field(~"type_param_defs", 0) |this| { + do this.emit_from_vec(*tpbt.generics.type_param_defs) + |this, type_param_def| { + this.emit_type_param_def(ecx, type_param_def); } } - do self.emit_struct_field("region_param", 1) { - tpbt.generics.region_param.encode(self); + do this.emit_struct_field(~"region_param", 1) |this| { + tpbt.generics.region_param.encode(this); } } } - do self.emit_struct_field("ty", 1) { - self.emit_ty(ecx, tpbt.ty); + do this.emit_struct_field(~"ty", 1) |this| { + this.emit_ty(ecx, tpbt.ty); } } } } +#[cfg(stage0)] trait write_tag_and_id { fn tag(&self, tag_id: c::astencode_tag, f: &fn()); fn id(&self, id: ast::node_id); } +#[cfg(not(stage0))] +trait write_tag_and_id { + fn tag(&mut self, tag_id: c::astencode_tag, f: &fn(&mut Self)); + fn id(&mut self, id: ast::node_id); +} + +#[cfg(stage0)] impl write_tag_and_id for writer::Encoder { fn tag(&self, tag_id: c::astencode_tag, f: &fn()) { do self.wr_tag(tag_id as uint) { f() } @@ -881,6 +1219,22 @@ impl write_tag_and_id for writer::Encoder { } } +#[cfg(not(stage0))] +impl write_tag_and_id for writer::Encoder { + fn tag(&mut self, + tag_id: c::astencode_tag, + f: &fn(&mut writer::Encoder)) { + self.start_tag(tag_id as uint); + f(self); + self.end_tag(); + } + + fn id(&mut self, id: ast::node_id) { + self.wr_tagged_u64(c::tag_table_id as uint, id as u64) + } +} + +#[cfg(stage0)] fn encode_side_tables_for_ii(ecx: @e::EncodeContext, maps: Maps, ebml_w: &writer::Encoder, @@ -899,6 +1253,26 @@ fn encode_side_tables_for_ii(ecx: @e::EncodeContext, } } +#[cfg(not(stage0))] +fn encode_side_tables_for_ii(ecx: @e::EncodeContext, + maps: Maps, + ebml_w: &mut writer::Encoder, + ii: &ast::inlined_item) { + ebml_w.start_tag(c::tag_table as uint); + let new_ebml_w = copy *ebml_w; + ast_util::visit_ids_for_inlined_item( + ii, + |id: ast::node_id| { + // Note: this will cause a copy of ebml_w, which is bad as + // it is mutable. But I believe it's harmless since we generate + // balanced EBML. + let mut new_ebml_w = copy new_ebml_w; + encode_side_tables_for_id(ecx, maps, &mut new_ebml_w, id) + }); + ebml_w.end_tag(); +} + +#[cfg(stage0)] fn encode_side_tables_for_id(ecx: @e::EncodeContext, maps: Maps, ebml_w: &writer::Encoder, @@ -1028,6 +1402,136 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext, } } +#[cfg(not(stage0))] +fn encode_side_tables_for_id(ecx: @e::EncodeContext, + maps: Maps, + ebml_w: &mut writer::Encoder, + id: ast::node_id) { + let tcx = ecx.tcx; + + debug!("Encoding side tables for id %d", id); + + for tcx.def_map.find(&id).each |def| { + do ebml_w.tag(c::tag_table_def) |ebml_w| { + ebml_w.id(id); + do ebml_w.tag(c::tag_table_val) |ebml_w| { + (*def).encode(ebml_w) + } + } + } + + for tcx.node_types.find(&(id as uint)).each |&ty| { + do ebml_w.tag(c::tag_table_node_type) |ebml_w| { + ebml_w.id(id); + do ebml_w.tag(c::tag_table_val) |ebml_w| { + ebml_w.emit_ty(ecx, *ty); + } + } + } + + for tcx.node_type_substs.find(&id).each |tys| { + do ebml_w.tag(c::tag_table_node_type_subst) |ebml_w| { + ebml_w.id(id); + do ebml_w.tag(c::tag_table_val) |ebml_w| { + // FIXME(#5562): removing this copy causes a segfault + // before stage2 + ebml_w.emit_tys(ecx, /*bad*/copy **tys) + } + } + } + + for tcx.freevars.find(&id).each |&fv| { + do ebml_w.tag(c::tag_table_freevars) |ebml_w| { + ebml_w.id(id); + do ebml_w.tag(c::tag_table_val) |ebml_w| { + do ebml_w.emit_from_vec(**fv) |ebml_w, fv_entry| { + encode_freevar_entry(ebml_w, *fv_entry) + } + } + } + } + + let lid = ast::def_id { crate: ast::local_crate, node: id }; + for tcx.tcache.find(&lid).each |&tpbt| { + do ebml_w.tag(c::tag_table_tcache) |ebml_w| { + ebml_w.id(id); + do ebml_w.tag(c::tag_table_val) |ebml_w| { + ebml_w.emit_tpbt(ecx, *tpbt); + } + } + } + + for tcx.ty_param_defs.find(&id).each |&type_param_def| { + do ebml_w.tag(c::tag_table_param_defs) |ebml_w| { + ebml_w.id(id); + do ebml_w.tag(c::tag_table_val) |ebml_w| { + ebml_w.emit_type_param_def(ecx, type_param_def) + } + } + } + + if maps.mutbl_map.contains(&id) { + do ebml_w.tag(c::tag_table_mutbl) |ebml_w| { + ebml_w.id(id); + } + } + + for maps.last_use_map.find(&id).each |&m| { + do ebml_w.tag(c::tag_table_last_use) |ebml_w| { + ebml_w.id(id); + do ebml_w.tag(c::tag_table_val) |ebml_w| { + do ebml_w.emit_from_vec(/*bad*/ copy **m) |ebml_w, id| { + id.encode(ebml_w); + } + } + } + } + + for maps.method_map.find(&id).each |&mme| { + do ebml_w.tag(c::tag_table_method_map) |ebml_w| { + ebml_w.id(id); + do ebml_w.tag(c::tag_table_val) |ebml_w| { + encode_method_map_entry(ecx, ebml_w, *mme) + } + } + } + + for maps.vtable_map.find(&id).each |&dr| { + do ebml_w.tag(c::tag_table_vtable_map) |ebml_w| { + ebml_w.id(id); + do ebml_w.tag(c::tag_table_val) |ebml_w| { + encode_vtable_res(ecx, ebml_w, *dr); + } + } + } + + for tcx.adjustments.find(&id).each |adj| { + do ebml_w.tag(c::tag_table_adjustments) |ebml_w| { + ebml_w.id(id); + do ebml_w.tag(c::tag_table_val) |ebml_w| { + (**adj).encode(ebml_w) + } + } + } + + if maps.moves_map.contains(&id) { + do ebml_w.tag(c::tag_table_moves_map) |ebml_w| { + ebml_w.id(id); + } + } + + for maps.capture_map.find(&id).each |&cap_vars| { + do ebml_w.tag(c::tag_table_capture_map) |ebml_w| { + ebml_w.id(id); + do ebml_w.tag(c::tag_table_val) |ebml_w| { + do ebml_w.emit_from_vec(*cap_vars) |ebml_w, cap_var| { + cap_var.encode(ebml_w); + } + } + } + } +} + trait doc_decoder_helpers { fn as_int(&self) -> int; fn opt_child(&self, tag: c::astencode_tag) -> Option; @@ -1040,6 +1544,7 @@ impl doc_decoder_helpers for ebml::Doc { } } +#[cfg(stage0)] trait ebml_decoder_decoder_helpers { fn read_arg(&self, xcx: @ExtendedDecodeContext) -> ty::arg; fn read_ty(&self, xcx: @ExtendedDecodeContext) -> ty::t; @@ -1052,7 +1557,24 @@ trait ebml_decoder_decoder_helpers { did: ast::def_id) -> ast::def_id; } +#[cfg(not(stage0))] +trait ebml_decoder_decoder_helpers { + fn read_arg(&mut self, xcx: @ExtendedDecodeContext) -> ty::arg; + fn read_ty(&mut self, xcx: @ExtendedDecodeContext) -> ty::t; + fn read_tys(&mut self, xcx: @ExtendedDecodeContext) -> ~[ty::t]; + fn read_type_param_def(&mut self, xcx: @ExtendedDecodeContext) + -> ty::TypeParameterDef; + fn read_ty_param_bounds_and_ty(&mut self, xcx: @ExtendedDecodeContext) + -> ty::ty_param_bounds_and_ty; + fn convert_def_id(&mut self, + xcx: @ExtendedDecodeContext, + source: DefIdSource, + did: ast::def_id) + -> ast::def_id; +} + impl ebml_decoder_decoder_helpers for reader::Decoder { + #[cfg(stage0)] fn read_arg(&self, xcx: @ExtendedDecodeContext) -> ty::arg { do self.read_opaque |doc| { tydecode::parse_arg_data( @@ -1061,6 +1583,19 @@ impl ebml_decoder_decoder_helpers for reader::Decoder { } } + #[cfg(not(stage0))] + fn read_arg(&mut self, xcx: @ExtendedDecodeContext) -> ty::arg { + do self.read_opaque |this, doc| { + tydecode::parse_arg_data( + doc.data, + xcx.dcx.cdata.cnum, + doc.start, + xcx.dcx.tcx, + |s, a| this.convert_def_id(xcx, s, a)) + } + } + + #[cfg(stage0)] fn read_ty(&self, xcx: @ExtendedDecodeContext) -> ty::t { // Note: regions types embed local node ids. In principle, we // should translate these node ids into the new decode @@ -1088,11 +1623,50 @@ impl ebml_decoder_decoder_helpers for reader::Decoder { } } + #[cfg(not(stage0))] + fn read_ty(&mut self, xcx: @ExtendedDecodeContext) -> ty::t { + // Note: regions types embed local node ids. In principle, we + // should translate these node ids into the new decode + // context. However, we do not bother, because region types + // are not used during trans. + + return do self.read_opaque |this, doc| { + let ty = tydecode::parse_ty_data( + doc.data, + xcx.dcx.cdata.cnum, + doc.start, + xcx.dcx.tcx, + |s, a| this.convert_def_id(xcx, s, a)); + + debug!("read_ty(%s) = %s", + type_string(doc), + ty_to_str(xcx.dcx.tcx, ty)); + + ty + }; + + fn type_string(doc: ebml::Doc) -> ~str { + let mut str = ~""; + for uint::range(doc.start, doc.end) |i| { + str::push_char(&mut str, doc.data[i] as char); + } + str + } + } + + #[cfg(stage0)] fn read_tys(&self, xcx: @ExtendedDecodeContext) -> ~[ty::t] { self.read_to_vec(|| self.read_ty(xcx) ) } - fn read_type_param_def(&self, xcx: @ExtendedDecodeContext) -> ty::TypeParameterDef { + #[cfg(not(stage0))] + fn read_tys(&mut self, xcx: @ExtendedDecodeContext) -> ~[ty::t] { + self.read_to_vec(|this| this.read_ty(xcx) ) + } + + #[cfg(stage0)] + fn read_type_param_def(&self, xcx: @ExtendedDecodeContext) + -> ty::TypeParameterDef { do self.read_opaque |doc| { tydecode::parse_type_param_def_data( doc.data, doc.start, xcx.dcx.cdata.cnum, xcx.dcx.tcx, @@ -1100,20 +1674,34 @@ impl ebml_decoder_decoder_helpers for reader::Decoder { } } + #[cfg(not(stage0))] + fn read_type_param_def(&mut self, xcx: @ExtendedDecodeContext) + -> ty::TypeParameterDef { + do self.read_opaque |this, doc| { + tydecode::parse_type_param_def_data( + doc.data, + doc.start, + xcx.dcx.cdata.cnum, + xcx.dcx.tcx, + |s, a| this.convert_def_id(xcx, s, a)) + } + } + #[cfg(stage0)] fn read_ty_param_bounds_and_ty(&self, xcx: @ExtendedDecodeContext) - -> ty::ty_param_bounds_and_ty - { + -> ty::ty_param_bounds_and_ty { do self.read_struct("ty_param_bounds_and_ty", 2) { ty::ty_param_bounds_and_ty { - generics: do self.read_struct("Generics", 2) { - ty::Generics { - type_param_defs: self.read_field("type_param_defs", 0, || { - @self.read_to_vec(|| self.read_type_param_def(xcx)) - }), - region_param: self.read_field(~"region_param", 1, || { - Decodable::decode(self) - }) + generics: do self.read_field("generics", 0) { + do self.read_struct("Generics", 2) { + ty::Generics { + type_param_defs: self.read_field("type_param_defs", 0, || { + @self.read_to_vec(|| self.read_type_param_def(xcx)) + }), + region_param: self.read_field(~"region_param", 1, || { + Decodable::decode(self) + }) + } } }, ty: self.read_field(~"ty", 1, || { @@ -1123,34 +1711,71 @@ impl ebml_decoder_decoder_helpers for reader::Decoder { } } - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] - fn read_ty_param_bounds_and_ty(&self, xcx: @ExtendedDecodeContext) - -> ty::ty_param_bounds_and_ty - { - do self.read_struct("ty_param_bounds_and_ty", 2) { + #[cfg(not(stage0))] + fn read_ty_param_bounds_and_ty(&mut self, xcx: @ExtendedDecodeContext) + -> ty::ty_param_bounds_and_ty { + do self.read_struct("ty_param_bounds_and_ty", 2) |this| { ty::ty_param_bounds_and_ty { - generics: do self.read_struct("Generics", 2) { - ty::Generics { - type_param_defs: self.read_struct_field("type_param_defs", 0, || { - @self.read_to_vec(|| self.read_type_param_def(xcx)) - }), - region_param: self.read_struct_field(~"region_param", 1, || { - Decodable::decode(self) - }) + generics: do this.read_struct_field("generics", 0) |this| { + do this.read_struct("Generics", 2) |this| { + ty::Generics { + type_param_defs: + this.read_struct_field("type_param_defs", + 0, + |this| { + @this.read_to_vec(|this| + this.read_type_param_def(xcx)) + }), + region_param: + this.read_struct_field("region_param", + 1, + |this| { + Decodable::decode(this) + }) + } } }, - ty: self.read_struct_field("ty", 1, || { - self.read_ty(xcx) + ty: this.read_struct_field("ty", 1, |this| { + this.read_ty(xcx) }) } } } - fn convert_def_id(&self, xcx: @ExtendedDecodeContext, + #[cfg(stage0)] + fn convert_def_id(&self, + xcx: @ExtendedDecodeContext, source: tydecode::DefIdSource, - did: ast::def_id) -> ast::def_id { + did: ast::def_id) + -> ast::def_id { + /*! + * + * Converts a def-id that appears in a type. The correct + * translation will depend on what kind of def-id this is. + * This is a subtle point: type definitions are not + * inlined into the current crate, so if the def-id names + * a nominal type or type alias, then it should be + * translated to refer to the source crate. + * + * However, *type parameters* are cloned along with the function + * they are attached to. So we should translate those def-ids + * to refer to the new, cloned copy of the type parameter. + */ + + let r = match source { + NominalType | TypeWithId => xcx.tr_def_id(did), + TypeParameter => xcx.tr_intern_def_id(did) + }; + debug!("convert_def_id(source=%?, did=%?)=%?", source, did, r); + return r; + } + + #[cfg(not(stage0))] + fn convert_def_id(&mut self, + xcx: @ExtendedDecodeContext, + source: tydecode::DefIdSource, + did: ast::def_id) + -> ast::def_id { /*! * * Converts a def-id that appears in a type. The correct @@ -1174,6 +1799,7 @@ impl ebml_decoder_decoder_helpers for reader::Decoder { } } +#[cfg(stage0)] fn decode_side_tables(xcx: @ExtendedDecodeContext, ast_doc: ebml::Doc) { let dcx = xcx.dcx; @@ -1248,21 +1874,97 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext, } } +#[cfg(not(stage0))] +fn decode_side_tables(xcx: @ExtendedDecodeContext, + ast_doc: ebml::Doc) { + let dcx = xcx.dcx; + let tbl_doc = ast_doc.get(c::tag_table as uint); + for reader::docs(tbl_doc) |tag, entry_doc| { + let id0 = entry_doc.get(c::tag_table_id as uint).as_int(); + let id = xcx.tr_id(id0); + + debug!(">> Side table document with tag 0x%x \ + found for id %d (orig %d)", + tag, id, id0); + + if tag == (c::tag_table_mutbl as uint) { + dcx.maps.mutbl_map.insert(id); + } else if tag == (c::tag_table_moves_map as uint) { + dcx.maps.moves_map.insert(id); + } else { + let val_doc = entry_doc.get(c::tag_table_val as uint); + let mut val_dsr = reader::Decoder(val_doc); + let val_dsr = &mut val_dsr; + if tag == (c::tag_table_def as uint) { + let def = decode_def(xcx, val_doc); + dcx.tcx.def_map.insert(id, def); + } else if tag == (c::tag_table_node_type as uint) { + let ty = val_dsr.read_ty(xcx); + debug!("inserting ty for node %?: %s", + id, ty_to_str(dcx.tcx, ty)); + dcx.tcx.node_types.insert(id as uint, ty); + } else if tag == (c::tag_table_node_type_subst as uint) { + let tys = val_dsr.read_tys(xcx); + dcx.tcx.node_type_substs.insert(id, tys); + } else if tag == (c::tag_table_freevars as uint) { + let fv_info = @val_dsr.read_to_vec(|val_dsr| { + @val_dsr.read_freevar_entry(xcx) + }); + dcx.tcx.freevars.insert(id, fv_info); + } else if tag == (c::tag_table_tcache as uint) { + let tpbt = val_dsr.read_ty_param_bounds_and_ty(xcx); + let lid = ast::def_id { crate: ast::local_crate, node: id }; + dcx.tcx.tcache.insert(lid, tpbt); + } else if tag == (c::tag_table_param_defs as uint) { + let bounds = val_dsr.read_type_param_def(xcx); + dcx.tcx.ty_param_defs.insert(id, bounds); + } else if tag == (c::tag_table_last_use as uint) { + let ids = val_dsr.read_to_vec(|val_dsr| { + xcx.tr_id(val_dsr.read_int()) + }); + dcx.maps.last_use_map.insert(id, @mut ids); + } else if tag == (c::tag_table_method_map as uint) { + dcx.maps.method_map.insert( + id, + val_dsr.read_method_map_entry(xcx)); + } else if tag == (c::tag_table_vtable_map as uint) { + dcx.maps.vtable_map.insert(id, + val_dsr.read_vtable_res(xcx)); + } else if tag == (c::tag_table_adjustments as uint) { + let adj: @ty::AutoAdjustment = @Decodable::decode(val_dsr); + adj.tr(xcx); + dcx.tcx.adjustments.insert(id, adj); + } else if tag == (c::tag_table_capture_map as uint) { + let cvars = + at_vec::from_owned( + val_dsr.read_to_vec( + |val_dsr| val_dsr.read_capture_var(xcx))); + dcx.maps.capture_map.insert(id, cvars); + } else { + xcx.dcx.tcx.sess.bug( + fmt!("unknown tag found in side tables: %x", tag)); + } + } + + debug!(">< Side table doc loaded"); + } +} + // ______________________________________________________________________ // Testing of astencode_gen #[cfg(test)] -fn encode_item_ast(ebml_w: &writer::Encoder, item: @ast::item) { - do ebml_w.wr_tag(c::tag_tree as uint) { - (*item).encode(ebml_w) - } +fn encode_item_ast(ebml_w: &mut writer::Encoder, item: @ast::item) { + ebml_w.start_tag(c::tag_tree as uint); + (*item).encode(ebml_w); + ebml_w.end_tag(); } #[cfg(test)] fn decode_item_ast(par_doc: ebml::Doc) -> @ast::item { let chi_doc = par_doc.get(c::tag_tree as uint); - let d = &reader::Decoder(chi_doc); - @Decodable::decode(d) + let mut d = reader::Decoder(chi_doc); + @Decodable::decode(&mut d) } #[cfg(test)] @@ -1303,8 +2005,8 @@ fn roundtrip(in_item: Option<@ast::item>) { let in_item = in_item.get(); let bytes = do io::with_bytes_writer |wr| { - let ebml_w = writer::Encoder(wr); - encode_item_ast(&ebml_w, in_item); + let mut ebml_w = writer::Encoder(wr); + encode_item_ast(&mut ebml_w, in_item); }; let ebml_doc = reader::Doc(@bytes); let out_item = decode_item_ast(ebml_doc); diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs index bea7935d5c3..0e9b2ed3da8 100644 --- a/src/libstd/arena.rs +++ b/src/libstd/arena.rs @@ -348,7 +348,7 @@ pub impl Arena { #[test] fn test_arena_destructors() { - let arena = Arena(); + let mut arena = Arena(); for uint::range(0, 10) |i| { // Arena allocate something with drop glue to make sure it // doesn't leak. @@ -363,7 +363,7 @@ fn test_arena_destructors() { #[should_fail] #[ignore(cfg(windows))] fn test_arena_destructors_fail() { - let arena = Arena(); + let mut arena = Arena(); // Put some stuff in the arena. for uint::range(0, 10) |i| { // Arena allocate something with drop glue to make sure it diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index 2598e96a141..41c5a0f7690 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -36,13 +36,27 @@ pub struct TaggedDoc { } pub enum EbmlEncoderTag { - EsUint, EsU64, EsU32, EsU16, EsU8, - EsInt, EsI64, EsI32, EsI16, EsI8, - EsBool, - EsStr, - EsF64, EsF32, EsFloat, - EsEnum, EsEnumVid, EsEnumBody, - EsVec, EsVecLen, EsVecElt, + EsUint, // 0 + EsU64, // 1 + EsU32, // 2 + EsU16, // 3 + EsU8, // 4 + EsInt, // 5 + EsI64, // 6 + EsI32, // 7 + EsI16, // 8 + EsI8, // 9 + EsBool, // 10 + EsStr, // 11 + EsF64, // 12 + EsF32, // 13 + EsFloat, // 14 + EsEnum, // 15 + EsEnumVid, // 16 + EsEnumBody, // 17 + EsVec, // 18 + EsVecLen, // 19 + EsVecElt, // 20 EsOpaque, @@ -249,17 +263,27 @@ pub mod reader { pub fn doc_as_i32(d: Doc) -> i32 { doc_as_u32(d) as i32 } pub fn doc_as_i64(d: Doc) -> i64 { doc_as_u64(d) as i64 } - + #[cfg(stage0)] pub struct Decoder { priv mut parent: Doc, priv mut pos: uint, } + #[cfg(not(stage0))] + pub struct Decoder { + priv parent: Doc, + priv pos: uint, + } + pub fn Decoder(d: Doc) -> Decoder { - Decoder { parent: d, pos: d.start } + Decoder { + parent: d, + pos: d.start + } } priv impl Decoder { + #[cfg(stage0)] fn _check_label(&self, lbl: &str) { if self.pos < self.parent.end { let TaggedDoc { tag: r_tag, doc: r_doc } = @@ -269,13 +293,33 @@ pub mod reader { self.pos = r_doc.end; let str = doc_as_str(r_doc); if lbl != str { - fail!(fmt!("Expected label %s but found %s", lbl, - str)); + fail!(fmt!("Expected label %s but found %s", + lbl, + str)); + } + } + } + } + + #[cfg(not(stage0))] + fn _check_label(&mut self, lbl: &str) { + if self.pos < self.parent.end { + let TaggedDoc { tag: r_tag, doc: r_doc } = + doc_at(self.parent.data, self.pos); + + if r_tag == (EsLabel as uint) { + self.pos = r_doc.end; + let str = doc_as_str(r_doc); + if lbl != str { + fail!(fmt!("Expected label %s but found %s", + lbl, + str)); } } } } + #[cfg(stage0)] fn next_doc(&self, exp_tag: EbmlEncoderTag) -> Doc { debug!(". next_doc(exp_tag=%?)", exp_tag); if self.pos >= self.parent.end { @@ -298,6 +342,30 @@ pub mod reader { r_doc } + #[cfg(not(stage0))] + fn next_doc(&mut self, exp_tag: EbmlEncoderTag) -> Doc { + debug!(". next_doc(exp_tag=%?)", exp_tag); + if self.pos >= self.parent.end { + fail!(~"no more documents in current node!"); + } + let TaggedDoc { tag: r_tag, doc: r_doc } = + doc_at(self.parent.data, self.pos); + debug!("self.parent=%?-%? self.pos=%? r_tag=%? r_doc=%?-%?", + copy self.parent.start, copy self.parent.end, + copy self.pos, r_tag, r_doc.start, r_doc.end); + if r_tag != (exp_tag as uint) { + fail!(fmt!("expected EBML doc with tag %? but found tag %?", + exp_tag, r_tag)); + } + if r_doc.end > self.parent.end { + fail!(fmt!("invalid EBML, child extends to 0x%x, \ + parent to 0x%x", r_doc.end, self.parent.end)); + } + self.pos = r_doc.end; + r_doc + } + + #[cfg(stage0)] fn push_doc(&self, d: Doc, f: &fn() -> T) -> T { let old_parent = self.parent; let old_pos = self.pos; @@ -309,21 +377,58 @@ pub mod reader { r } + #[cfg(not(stage0))] + fn push_doc(&mut self, d: Doc, f: &fn() -> T) -> T { + let old_parent = self.parent; + let old_pos = self.pos; + self.parent = d; + self.pos = d.start; + let r = f(); + self.parent = old_parent; + self.pos = old_pos; + r + } + + #[cfg(stage0)] fn _next_uint(&self, exp_tag: EbmlEncoderTag) -> uint { let r = doc_as_u32(self.next_doc(exp_tag)); debug!("_next_uint exp_tag=%? result=%?", exp_tag, r); r as uint } + + #[cfg(not(stage0))] + fn _next_uint(&mut self, exp_tag: EbmlEncoderTag) -> uint { + let r = doc_as_u32(self.next_doc(exp_tag)); + debug!("_next_uint exp_tag=%? result=%?", exp_tag, r); + r as uint + } } pub impl Decoder { + #[cfg(stage0)] fn read_opaque(&self, op: &fn(Doc) -> R) -> R { do self.push_doc(self.next_doc(EsOpaque)) { op(copy self.parent) } } + + #[cfg(not(stage0))] + fn read_opaque(&mut self, op: &fn(&mut Decoder, Doc) -> R) -> R { + let doc = self.next_doc(EsOpaque); + + let (old_parent, old_pos) = (self.parent, self.pos); + self.parent = doc; + self.pos = doc.start; + + let result = op(self, doc); + + self.parent = old_parent; + self.pos = old_pos; + result + } } + #[cfg(stage0)] impl serialize::Decoder for Decoder { fn read_nil(&self) -> () { () } @@ -339,10 +444,18 @@ pub mod reader { v as uint } - fn read_i64(&self) -> i64 { doc_as_u64(self.next_doc(EsI64)) as i64 } - fn read_i32(&self) -> i32 { doc_as_u32(self.next_doc(EsI32)) as i32 } - fn read_i16(&self) -> i16 { doc_as_u16(self.next_doc(EsI16)) as i16 } - fn read_i8 (&self) -> i8 { doc_as_u8 (self.next_doc(EsI8 )) as i8 } + fn read_i64(&self) -> i64 { + doc_as_u64(self.next_doc(EsI64)) as i64 + } + fn read_i32(&self) -> i32 { + doc_as_u32(self.next_doc(EsI32)) as i32 + } + fn read_i16(&self) -> i16 { + doc_as_u16(self.next_doc(EsI16)) as i16 + } + fn read_i8 (&self) -> i8 { + doc_as_u8(self.next_doc(EsI8 )) as i8 + } fn read_int(&self) -> int { let v = doc_as_u64(self.next_doc(EsInt)) as i64; if v > (int::max_value as i64) || v < (int::min_value as i64) { @@ -351,8 +464,9 @@ pub mod reader { v as int } - fn read_bool(&self) -> bool { doc_as_u8(self.next_doc(EsBool)) - as bool } + fn read_bool(&self) -> bool { + doc_as_u8(self.next_doc(EsBool)) as bool + } fn read_f64(&self) -> f64 { fail!(~"read_f64()"); } fn read_f32(&self) -> f32 { fail!(~"read_f32()"); } @@ -367,7 +481,10 @@ pub mod reader { self.push_doc(self.next_doc(EsEnum), f) } - fn read_enum_variant(&self, _names: &[&str], f: &fn(uint) -> T) -> T { + fn read_enum_variant(&self, + _: &[&str], + f: &fn(uint) -> T) + -> T { debug!("read_enum_variant()"); let idx = self._next_uint(EsEnumVid); debug!(" idx=%u", idx); @@ -376,12 +493,17 @@ pub mod reader { } } - fn read_enum_variant_arg(&self, idx: uint, f: &fn() -> T) -> T { + fn read_enum_variant_arg(&self, + idx: uint, + f: &fn() -> T) -> T { debug!("read_enum_variant_arg(idx=%u)", idx); f() } - fn read_enum_struct_variant(&self, _names: &[&str], f: &fn(uint) -> T) -> T { + fn read_enum_struct_variant(&self, + _: &[&str], + f: &fn(uint) -> T) + -> T { debug!("read_enum_struct_variant()"); let idx = self._next_uint(EsEnumVid); debug!(" idx=%u", idx); @@ -390,32 +512,34 @@ pub mod reader { } } - fn read_enum_struct_variant_field(&self, name: &str, idx: uint, f: &fn() -> T) -> T { + fn read_enum_struct_variant_field(&self, + name: &str, + idx: uint, + f: &fn() -> T) + -> T { debug!("read_enum_struct_variant_arg(name=%?, idx=%u)", name, idx); f() } - fn read_struct(&self, name: &str, _len: uint, f: &fn() -> T) -> T { + fn read_struct(&self, + name: &str, + _: uint, + f: &fn() -> T) + -> T { debug!("read_struct(name=%s)", name); f() } - #[cfg(stage0)] - fn read_field(&self, name: &str, idx: uint, f: &fn() -> T) -> T { + fn read_field(&self, + name: &str, + idx: uint, + f: &fn() -> T) + -> T { debug!("read_field(name=%?, idx=%u)", name, idx); self._check_label(name); f() } - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] - fn read_struct_field(&self, name: &str, idx: uint, f: &fn() -> T) -> T { - debug!("read_struct_field(name=%?, idx=%u)", name, idx); - self._check_label(name); - f() - } - fn read_tuple(&self, f: &fn(uint) -> T) -> T { debug!("read_tuple()"); self.read_seq(f) @@ -426,12 +550,18 @@ pub mod reader { self.read_seq_elt(idx, f) } - fn read_tuple_struct(&self, name: &str, f: &fn(uint) -> T) -> T { + fn read_tuple_struct(&self, + name: &str, + f: &fn(uint) -> T) + -> T { debug!("read_tuple_struct(name=%?)", name); self.read_tuple(f) } - fn read_tuple_struct_arg(&self, idx: uint, f: &fn() -> T) -> T { + fn read_tuple_struct_arg(&self, + idx: uint, + f: &fn() -> T) + -> T { debug!("read_tuple_struct_arg(idx=%u)", idx); self.read_tuple_arg(idx, f) } @@ -478,6 +608,245 @@ pub mod reader { fail!(~"read_map_elt_val is unimplemented"); } } + + #[cfg(not(stage0))] + impl serialize::Decoder for Decoder { + fn read_nil(&mut self) -> () { () } + + fn read_u64(&mut self) -> u64 { doc_as_u64(self.next_doc(EsU64)) } + fn read_u32(&mut self) -> u32 { doc_as_u32(self.next_doc(EsU32)) } + fn read_u16(&mut self) -> u16 { doc_as_u16(self.next_doc(EsU16)) } + fn read_u8 (&mut self) -> u8 { doc_as_u8 (self.next_doc(EsU8 )) } + fn read_uint(&mut self) -> uint { + let v = doc_as_u64(self.next_doc(EsUint)); + if v > (::core::uint::max_value as u64) { + fail!(fmt!("uint %? too large for this architecture", v)); + } + v as uint + } + + fn read_i64(&mut self) -> i64 { + doc_as_u64(self.next_doc(EsI64)) as i64 + } + fn read_i32(&mut self) -> i32 { + doc_as_u32(self.next_doc(EsI32)) as i32 + } + fn read_i16(&mut self) -> i16 { + doc_as_u16(self.next_doc(EsI16)) as i16 + } + fn read_i8 (&mut self) -> i8 { + doc_as_u8(self.next_doc(EsI8 )) as i8 + } + fn read_int(&mut self) -> int { + let v = doc_as_u64(self.next_doc(EsInt)) as i64; + if v > (int::max_value as i64) || v < (int::min_value as i64) { + fail!(fmt!("int %? out of range for this architecture", v)); + } + v as int + } + + fn read_bool(&mut self) -> bool { + doc_as_u8(self.next_doc(EsBool)) as bool + } + + fn read_f64(&mut self) -> f64 { fail!(~"read_f64()"); } + fn read_f32(&mut self) -> f32 { fail!(~"read_f32()"); } + fn read_float(&mut self) -> float { fail!(~"read_float()"); } + fn read_char(&mut self) -> char { fail!(~"read_char()"); } + fn read_str(&mut self) -> ~str { doc_as_str(self.next_doc(EsStr)) } + + // Compound types: + fn read_enum(&mut self, + name: &str, + f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_enum(%s)", name); + self._check_label(name); + + let doc = self.next_doc(EsEnum); + + let (old_parent, old_pos) = (self.parent, self.pos); + self.parent = doc; + self.pos = self.parent.start; + + let result = f(self); + + self.parent = old_parent; + self.pos = old_pos; + result + } + + fn read_enum_variant(&mut self, + _: &[&str], + f: &fn(&mut Decoder, uint) -> T) + -> T { + debug!("read_enum_variant()"); + let idx = self._next_uint(EsEnumVid); + debug!(" idx=%u", idx); + + let doc = self.next_doc(EsEnumBody); + + let (old_parent, old_pos) = (self.parent, self.pos); + self.parent = doc; + self.pos = self.parent.start; + + let result = f(self, idx); + + self.parent = old_parent; + self.pos = old_pos; + result + } + + fn read_enum_variant_arg(&mut self, + idx: uint, + f: &fn(&mut Decoder) -> T) -> T { + debug!("read_enum_variant_arg(idx=%u)", idx); + f(self) + } + + fn read_enum_struct_variant(&mut self, + _: &[&str], + f: &fn(&mut Decoder, uint) -> T) + -> T { + debug!("read_enum_struct_variant()"); + let idx = self._next_uint(EsEnumVid); + debug!(" idx=%u", idx); + + let doc = self.next_doc(EsEnumBody); + + let (old_parent, old_pos) = (self.parent, self.pos); + self.parent = doc; + self.pos = self.parent.start; + + let result = f(self, idx); + + self.parent = old_parent; + self.pos = old_pos; + result + } + + fn read_enum_struct_variant_field(&mut self, + name: &str, + idx: uint, + f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_enum_struct_variant_arg(name=%?, idx=%u)", name, idx); + f(self) + } + + fn read_struct(&mut self, + name: &str, + _: uint, + f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_struct(name=%s)", name); + f(self) + } + + fn read_struct_field(&mut self, + name: &str, + idx: uint, + f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_struct_field(name=%?, idx=%u)", name, idx); + self._check_label(name); + f(self) + } + + fn read_tuple(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T { + debug!("read_tuple()"); + self.read_seq(f) + } + + fn read_tuple_arg(&mut self, idx: uint, f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_tuple_arg(idx=%u)", idx); + self.read_seq_elt(idx, f) + } + + fn read_tuple_struct(&mut self, + name: &str, + f: &fn(&mut Decoder, uint) -> T) + -> T { + debug!("read_tuple_struct(name=%?)", name); + self.read_tuple(f) + } + + fn read_tuple_struct_arg(&mut self, + idx: uint, + f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_tuple_struct_arg(idx=%u)", idx); + self.read_tuple_arg(idx, f) + } + + fn read_option(&mut self, f: &fn(&mut Decoder, bool) -> T) -> T { + debug!("read_option()"); + do self.read_enum("Option") |this| { + do this.read_enum_variant(["None", "Some"]) |this, idx| { + match idx { + 0 => f(this, false), + 1 => f(this, true), + _ => fail!(), + } + } + } + } + + fn read_seq(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T { + debug!("read_seq()"); + let doc = self.next_doc(EsVec); + + let (old_parent, old_pos) = (self.parent, self.pos); + self.parent = doc; + self.pos = self.parent.start; + + let len = self._next_uint(EsVecLen); + debug!(" len=%u", len); + let result = f(self, len); + + self.parent = old_parent; + self.pos = old_pos; + result + } + + fn read_seq_elt(&mut self, idx: uint, f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_seq_elt(idx=%u)", idx); + let doc = self.next_doc(EsVecElt); + + let (old_parent, old_pos) = (self.parent, self.pos); + self.parent = doc; + self.pos = self.parent.start; + + let result = f(self); + + self.parent = old_parent; + self.pos = old_pos; + result + } + + fn read_map(&mut self, _: &fn(&mut Decoder, uint) -> T) -> T { + debug!("read_map()"); + fail!(~"read_map is unimplemented"); + } + + fn read_map_elt_key(&mut self, + idx: uint, + _: &fn(&mut Decoder) -> T) + -> T { + debug!("read_map_elt_key(idx=%u)", idx); + fail!(~"read_map_elt_val is unimplemented"); + } + + fn read_map_elt_val(&mut self, + idx: uint, + _: &fn(&mut Decoder) -> T) + -> T { + debug!("read_map_elt_val(idx=%u)", idx); + fail!(~"read_map_elt_val is unimplemented"); + } + } } pub mod writer { @@ -522,6 +891,7 @@ pub mod writer { } // FIXME (#2741): Provide a function to write the standard ebml header. + #[cfg(stage0)] pub impl Encoder { fn start_tag(&self, tag_id: uint) { debug!("Start tag %u", tag_id); @@ -617,13 +987,111 @@ pub mod writer { } } + // FIXME (#2741): Provide a function to write the standard ebml header. + #[cfg(not(stage0))] + pub impl Encoder { + fn start_tag(&mut self, tag_id: uint) { + debug!("Start tag %u", tag_id); + + // Write the enum ID: + write_vuint(self.writer, tag_id); + + // Write a placeholder four-byte size. + self.size_positions.push(self.writer.tell()); + let zeroes: &[u8] = &[0u8, 0u8, 0u8, 0u8]; + self.writer.write(zeroes); + } + + fn end_tag(&mut self) { + let last_size_pos = self.size_positions.pop(); + let cur_pos = self.writer.tell(); + self.writer.seek(last_size_pos as int, io::SeekSet); + let size = (cur_pos - last_size_pos - 4u); + write_sized_vuint(self.writer, size, 4u); + self.writer.seek(cur_pos as int, io::SeekSet); + + debug!("End tag (size = %u)", size); + } + + fn wr_tag(&mut self, tag_id: uint, blk: &fn()) { + self.start_tag(tag_id); + blk(); + self.end_tag(); + } + + fn wr_tagged_bytes(&mut self, tag_id: uint, b: &[u8]) { + write_vuint(self.writer, tag_id); + write_vuint(self.writer, vec::len(b)); + self.writer.write(b); + } + + fn wr_tagged_u64(&mut self, tag_id: uint, v: u64) { + do io::u64_to_be_bytes(v, 8u) |v| { + self.wr_tagged_bytes(tag_id, v); + } + } + + fn wr_tagged_u32(&mut self, tag_id: uint, v: u32) { + do io::u64_to_be_bytes(v as u64, 4u) |v| { + self.wr_tagged_bytes(tag_id, v); + } + } + + fn wr_tagged_u16(&mut self, tag_id: uint, v: u16) { + do io::u64_to_be_bytes(v as u64, 2u) |v| { + self.wr_tagged_bytes(tag_id, v); + } + } + + fn wr_tagged_u8(&mut self, tag_id: uint, v: u8) { + self.wr_tagged_bytes(tag_id, &[v]); + } + + fn wr_tagged_i64(&mut self, tag_id: uint, v: i64) { + do io::u64_to_be_bytes(v as u64, 8u) |v| { + self.wr_tagged_bytes(tag_id, v); + } + } + + fn wr_tagged_i32(&mut self, tag_id: uint, v: i32) { + do io::u64_to_be_bytes(v as u64, 4u) |v| { + self.wr_tagged_bytes(tag_id, v); + } + } + + fn wr_tagged_i16(&mut self, tag_id: uint, v: i16) { + do io::u64_to_be_bytes(v as u64, 2u) |v| { + self.wr_tagged_bytes(tag_id, v); + } + } + + fn wr_tagged_i8(&mut self, tag_id: uint, v: i8) { + self.wr_tagged_bytes(tag_id, &[v as u8]); + } + + fn wr_tagged_str(&mut self, tag_id: uint, v: &str) { + str::byte_slice(v, |b| self.wr_tagged_bytes(tag_id, b)); + } + + fn wr_bytes(&mut self, b: &[u8]) { + debug!("Write %u bytes", vec::len(b)); + self.writer.write(b); + } + + fn wr_str(&mut self, s: &str) { + debug!("Write str: %?", s); + self.writer.write(str::to_bytes(s)); + } + } + // FIXME (#2743): optionally perform "relaxations" on end_tag to more // efficiently encode sizes; this is a fixed point iteration // Set to true to generate more debugging in EBML code. // Totally lame approach. - static debug: bool = false; + static debug: bool = true; + #[cfg(stage0)] priv impl Encoder { // used internally to emit things like the vector length and so on fn _emit_tagged_uint(&self, t: EbmlEncoderTag, v: uint) { @@ -642,6 +1110,26 @@ pub mod writer { } } + #[cfg(not(stage0))] + priv impl Encoder { + // used internally to emit things like the vector length and so on + fn _emit_tagged_uint(&mut self, t: EbmlEncoderTag, v: uint) { + assert!(v <= 0xFFFF_FFFF_u); + self.wr_tagged_u32(t as uint, v as u32); + } + + fn _emit_label(&mut self, label: &str) { + // There are various strings that we have access to, such as + // the name of a record field, which do not actually appear in + // the encoded EBML (normally). This is just for + // efficiency. When debugging, though, we can emit such + // labels and then they will be checked by decoder to + // try and check failures more quickly. + if debug { self.wr_tagged_str(EsLabel as uint, label) } + } + } + + #[cfg(stage0)] pub impl Encoder { fn emit_opaque(&self, f: &fn()) { do self.wr_tag(EsOpaque as uint) { @@ -650,24 +1138,50 @@ pub mod writer { } } + #[cfg(not(stage0))] + pub impl Encoder { + fn emit_opaque(&mut self, f: &fn(&mut Encoder)) { + self.start_tag(EsOpaque as uint); + f(self); + self.end_tag(); + } + } + + #[cfg(stage0)] impl ::serialize::Encoder for Encoder { fn emit_nil(&self) {} fn emit_uint(&self, v: uint) { self.wr_tagged_u64(EsUint as uint, v as u64); } - fn emit_u64(&self, v: u64) { self.wr_tagged_u64(EsU64 as uint, v); } - fn emit_u32(&self, v: u32) { self.wr_tagged_u32(EsU32 as uint, v); } - fn emit_u16(&self, v: u16) { self.wr_tagged_u16(EsU16 as uint, v); } - fn emit_u8(&self, v: u8) { self.wr_tagged_u8 (EsU8 as uint, v); } + fn emit_u64(&self, v: u64) { + self.wr_tagged_u64(EsU64 as uint, v); + } + fn emit_u32(&self, v: u32) { + self.wr_tagged_u32(EsU32 as uint, v); + } + fn emit_u16(&self, v: u16) { + self.wr_tagged_u16(EsU16 as uint, v); + } + fn emit_u8(&self, v: u8) { + self.wr_tagged_u8(EsU8 as uint, v); + } fn emit_int(&self, v: int) { self.wr_tagged_i64(EsInt as uint, v as i64); } - fn emit_i64(&self, v: i64) { self.wr_tagged_i64(EsI64 as uint, v); } - fn emit_i32(&self, v: i32) { self.wr_tagged_i32(EsI32 as uint, v); } - fn emit_i16(&self, v: i16) { self.wr_tagged_i16(EsI16 as uint, v); } - fn emit_i8(&self, v: i8) { self.wr_tagged_i8 (EsI8 as uint, v); } + fn emit_i64(&self, v: i64) { + self.wr_tagged_i64(EsI64 as uint, v); + } + fn emit_i32(&self, v: i32) { + self.wr_tagged_i32(EsI32 as uint, v); + } + fn emit_i16(&self, v: i16) { + self.wr_tagged_i16(EsI16 as uint, v); + } + fn emit_i8(&self, v: i8) { + self.wr_tagged_i8(EsI8 as uint, v); + } fn emit_bool(&self, v: bool) { self.wr_tagged_u8(EsBool as uint, v as u8) @@ -697,41 +1211,56 @@ pub mod writer { self.wr_tag(EsEnum as uint, f) } - fn emit_enum_variant(&self, _v_name: &str, v_id: uint, _cnt: uint, + fn emit_enum_variant(&self, + _: &str, + v_id: uint, + _: uint, f: &fn()) { self._emit_tagged_uint(EsEnumVid, v_id); self.wr_tag(EsEnumBody as uint, f) } - fn emit_enum_variant_arg(&self, _idx: uint, f: &fn()) { f() } + fn emit_enum_variant_arg(&self, _: uint, f: &fn()) { + f() + } - fn emit_enum_struct_variant(&self, v_name: &str, v_id: uint, cnt: uint, f: &fn()) { + fn emit_enum_struct_variant(&self, + v_name: &str, + v_id: uint, + cnt: uint, + f: &fn()) { self.emit_enum_variant(v_name, v_id, cnt, f) } - fn emit_enum_struct_variant_field(&self, _f_name: &str, idx: uint, f: &fn()) { + fn emit_enum_struct_variant_field(&self, + _: &str, + idx: uint, + f: &fn()) { self.emit_enum_variant_arg(idx, f) } - fn emit_struct(&self, _name: &str, _len: uint, f: &fn()) { f() } - #[cfg(stage0)] - fn emit_field(&self, name: &str, _idx: uint, f: &fn()) { - self._emit_label(name); + fn emit_struct(&self, _: &str, _len: uint, f: &fn()) { f() } - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] - fn emit_struct_field(&self, name: &str, _idx: uint, f: &fn()) { + + fn emit_field(&self, name: &str, _idx: uint, f: &fn()) { self._emit_label(name); f() } - fn emit_tuple(&self, len: uint, f: &fn()) { self.emit_seq(len, f) } - fn emit_tuple_arg(&self, idx: uint, f: &fn()) { self.emit_seq_elt(idx, f) } + fn emit_tuple(&self, len: uint, f: &fn()) { + self.emit_seq(len, f) + } + fn emit_tuple_arg(&self, idx: uint, f: &fn()) { + self.emit_seq_elt(idx, f) + } - fn emit_tuple_struct(&self, _name: &str, len: uint, f: &fn()) { self.emit_seq(len, f) } - fn emit_tuple_struct_arg(&self, idx: uint, f: &fn()) { self.emit_seq_elt(idx, f) } + fn emit_tuple_struct(&self, _name: &str, len: uint, f: &fn()) { + self.emit_seq(len, f) + } + fn emit_tuple_struct_arg(&self, idx: uint, f: &fn()) { + self.emit_seq_elt(idx, f) + } fn emit_option(&self, f: &fn()) { self.emit_enum("Option", f); @@ -766,6 +1295,167 @@ pub mod writer { fail!(~"emit_map_elt_val is unimplemented"); } } + + #[cfg(not(stage0))] + impl ::serialize::Encoder for Encoder { + fn emit_nil(&mut self) {} + + fn emit_uint(&mut self, v: uint) { + self.wr_tagged_u64(EsUint as uint, v as u64); + } + fn emit_u64(&mut self, v: u64) { + self.wr_tagged_u64(EsU64 as uint, v); + } + fn emit_u32(&mut self, v: u32) { + self.wr_tagged_u32(EsU32 as uint, v); + } + fn emit_u16(&mut self, v: u16) { + self.wr_tagged_u16(EsU16 as uint, v); + } + fn emit_u8(&mut self, v: u8) { + self.wr_tagged_u8(EsU8 as uint, v); + } + + fn emit_int(&mut self, v: int) { + self.wr_tagged_i64(EsInt as uint, v as i64); + } + fn emit_i64(&mut self, v: i64) { + self.wr_tagged_i64(EsI64 as uint, v); + } + fn emit_i32(&mut self, v: i32) { + self.wr_tagged_i32(EsI32 as uint, v); + } + fn emit_i16(&mut self, v: i16) { + self.wr_tagged_i16(EsI16 as uint, v); + } + fn emit_i8(&mut self, v: i8) { + self.wr_tagged_i8(EsI8 as uint, v); + } + + fn emit_bool(&mut self, v: bool) { + self.wr_tagged_u8(EsBool as uint, v as u8) + } + + // FIXME (#2742): implement these + fn emit_f64(&mut self, _v: f64) { + fail!(~"Unimplemented: serializing an f64"); + } + fn emit_f32(&mut self, _v: f32) { + fail!(~"Unimplemented: serializing an f32"); + } + fn emit_float(&mut self, _v: float) { + fail!(~"Unimplemented: serializing a float"); + } + + fn emit_char(&mut self, _v: char) { + fail!(~"Unimplemented: serializing a char"); + } + + fn emit_str(&mut self, v: &str) { + self.wr_tagged_str(EsStr as uint, v) + } + + fn emit_enum(&mut self, name: &str, f: &fn(&mut Encoder)) { + self._emit_label(name); + self.start_tag(EsEnum as uint); + f(self); + self.end_tag(); + } + + fn emit_enum_variant(&mut self, + _: &str, + v_id: uint, + _: uint, + f: &fn(&mut Encoder)) { + self._emit_tagged_uint(EsEnumVid, v_id); + self.start_tag(EsEnumBody as uint); + f(self); + self.end_tag(); + } + + fn emit_enum_variant_arg(&mut self, _: uint, f: &fn(&mut Encoder)) { + f(self) + } + + fn emit_enum_struct_variant(&mut self, + v_name: &str, + v_id: uint, + cnt: uint, + f: &fn(&mut Encoder)) { + self.emit_enum_variant(v_name, v_id, cnt, f) + } + + fn emit_enum_struct_variant_field(&mut self, + _: &str, + idx: uint, + f: &fn(&mut Encoder)) { + self.emit_enum_variant_arg(idx, f) + } + + fn emit_struct(&mut self, _: &str, _len: uint, f: &fn(&mut Encoder)) { + f(self) + } + + fn emit_struct_field(&mut self, + name: &str, + _: uint, + f: &fn(&mut Encoder)) { + self._emit_label(name); + f(self) + } + + fn emit_tuple(&mut self, len: uint, f: &fn(&mut Encoder)) { + self.emit_seq(len, f) + } + fn emit_tuple_arg(&mut self, idx: uint, f: &fn(&mut Encoder)) { + self.emit_seq_elt(idx, f) + } + + fn emit_tuple_struct(&mut self, + _: &str, + len: uint, + f: &fn(&mut Encoder)) { + self.emit_seq(len, f) + } + fn emit_tuple_struct_arg(&mut self, idx: uint, f: &fn(&mut Encoder)) { + self.emit_seq_elt(idx, f) + } + + fn emit_option(&mut self, f: &fn(&mut Encoder)) { + self.emit_enum("Option", f); + } + fn emit_option_none(&mut self) { + self.emit_enum_variant("None", 0, 0, |_| ()) + } + fn emit_option_some(&mut self, f: &fn(&mut Encoder)) { + self.emit_enum_variant("Some", 1, 1, f) + } + + fn emit_seq(&mut self, len: uint, f: &fn(&mut Encoder)) { + self.start_tag(EsVec as uint); + self._emit_tagged_uint(EsVecLen, len); + f(self); + self.end_tag(); + } + + fn emit_seq_elt(&mut self, _idx: uint, f: &fn(&mut Encoder)) { + self.start_tag(EsVecElt as uint); + f(self); + self.end_tag(); + } + + fn emit_map(&mut self, _len: uint, _f: &fn(&mut Encoder)) { + fail!(~"emit_map is unimplemented"); + } + + fn emit_map_elt_key(&mut self, _idx: uint, _f: &fn(&mut Encoder)) { + fail!(~"emit_map_elt_key is unimplemented"); + } + + fn emit_map_elt_val(&mut self, _idx: uint, _f: &fn(&mut Encoder)) { + fail!(~"emit_map_elt_val is unimplemented"); + } + } } // ___________________________________________________________________________ @@ -786,12 +1476,12 @@ mod tests { fn test_v(v: Option) { debug!("v == %?", v); let bytes = do io::with_bytes_writer |wr| { - let ebml_w = writer::Encoder(wr); - v.encode(&ebml_w) + let mut ebml_w = writer::Encoder(wr); + v.encode(&mut ebml_w) }; let ebml_doc = reader::Doc(@bytes); - let deser = reader::Decoder(ebml_doc); - let v1 = serialize::Decodable::decode(&deser); + let mut deser = reader::Decoder(ebml_doc); + let v1 = serialize::Decodable::decode(&mut deser); debug!("v1 == %?", v1); assert!(v == v1); } diff --git a/src/libstd/flatpipes.rs b/src/libstd/flatpipes.rs index bd0acb849fc..55ea9c2948b 100644 --- a/src/libstd/flatpipes.rs +++ b/src/libstd/flatpipes.rs @@ -438,8 +438,11 @@ pub mod flatteners { SerializingFlattener */ + #[cfg(stage0)] pub fn deserialize_buffer>(buf: &[u8]) -> T { + T: Decodable>( + buf: &[u8]) + -> T { let buf = vec::from_slice(buf); let buf_reader = @BufReader::new(buf); let reader = buf_reader as @Reader; @@ -447,14 +450,40 @@ pub mod flatteners { Decodable::decode(&deser) } + #[cfg(not(stage0))] + pub fn deserialize_buffer>( + buf: &[u8]) + -> T { + let buf = vec::from_slice(buf); + let buf_reader = @BufReader::new(buf); + let reader = buf_reader as @Reader; + let mut deser: D = FromReader::from_reader(reader); + Decodable::decode(&mut deser) + } + + #[cfg(stage0)] pub fn serialize_value>(val: &T) -> ~[u8] { + T: Encodable>( + val: &T) + -> ~[u8] { do io::with_bytes_writer |writer| { let ser = FromWriter::from_writer(writer); val.encode(&ser); } } + #[cfg(not(stage0))] + pub fn serialize_value>( + val: &T) + -> ~[u8] { + do io::with_bytes_writer |writer| { + let mut ser = FromWriter::from_writer(writer); + val.encode(&mut ser); + } + } + pub trait FromReader { fn from_reader(r: @Reader) -> Self; } diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 7353bec7333..6951ee377c9 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -72,9 +72,12 @@ pub struct Encoder { } pub fn Encoder(wr: @io::Writer) -> Encoder { - Encoder { wr: wr } + Encoder { + wr: wr + } } +#[cfg(stage0)] impl serialize::Encoder for Encoder { fn emit_nil(&self) { self.wr.write_str("null") } @@ -109,7 +112,11 @@ impl serialize::Encoder for Encoder { fn emit_enum(&self, _name: &str, f: &fn()) { f() } - fn emit_enum_variant(&self, name: &str, _id: uint, cnt: uint, f: &fn()) { + fn emit_enum_variant(&self, + name: &str, + _id: uint, + cnt: uint, + f: &fn()) { // enums are encoded as strings or vectors: // Bunny => "Bunny" // Kangaroo(34,"William") => ["Kangaroo",[34,"William"]] @@ -130,19 +137,27 @@ impl serialize::Encoder for Encoder { f(); } - fn emit_enum_struct_variant(&self, name: &str, id: uint, cnt: uint, f: &fn()) { + fn emit_enum_struct_variant(&self, + name: &str, + id: uint, + cnt: uint, + f: &fn()) { self.emit_enum_variant(name, id, cnt, f) } - fn emit_enum_struct_variant_field(&self, _field: &str, idx: uint, f: &fn()) { + fn emit_enum_struct_variant_field(&self, + _: &str, + idx: uint, + f: &fn()) { self.emit_enum_variant_arg(idx, f) } - fn emit_struct(&self, _name: &str, _len: uint, f: &fn()) { + fn emit_struct(&self, _: &str, _: uint, f: &fn()) { self.wr.write_char('{'); f(); self.wr.write_char('}'); } + #[cfg(stage0)] fn emit_field(&self, name: &str, idx: uint, f: &fn()) { if idx != 0 { self.wr.write_char(','); } @@ -150,6 +165,7 @@ impl serialize::Encoder for Encoder { self.wr.write_char(':'); f(); } + #[cfg(stage1)] #[cfg(stage2)] #[cfg(stage3)] @@ -161,10 +177,16 @@ impl serialize::Encoder for Encoder { } fn emit_tuple(&self, len: uint, f: &fn()) { self.emit_seq(len, f) } - fn emit_tuple_arg(&self, idx: uint, f: &fn()) { self.emit_seq_elt(idx, f) } + fn emit_tuple_arg(&self, idx: uint, f: &fn()) { + self.emit_seq_elt(idx, f) + } - fn emit_tuple_struct(&self, _name: &str, len: uint, f: &fn()) { self.emit_seq(len, f) } - fn emit_tuple_struct_arg(&self, idx: uint, f: &fn()) { self.emit_seq_elt(idx, f) } + fn emit_tuple_struct(&self, _name: &str, len: uint, f: &fn()) { + self.emit_seq(len, f) + } + fn emit_tuple_struct_arg(&self, idx: uint, f: &fn()) { + self.emit_seq_elt(idx, f) + } fn emit_option(&self, f: &fn()) { f(); } fn emit_option_none(&self) { self.emit_nil(); } @@ -198,15 +220,163 @@ impl serialize::Encoder for Encoder { } } +#[cfg(not(stage0))] +impl serialize::Encoder for Encoder { + fn emit_nil(&mut self) { self.wr.write_str("null") } + + fn emit_uint(&mut self, v: uint) { self.emit_float(v as float); } + fn emit_u64(&mut self, v: u64) { self.emit_float(v as float); } + fn emit_u32(&mut self, v: u32) { self.emit_float(v as float); } + fn emit_u16(&mut self, v: u16) { self.emit_float(v as float); } + fn emit_u8(&mut self, v: u8) { self.emit_float(v as float); } + + fn emit_int(&mut self, v: int) { self.emit_float(v as float); } + fn emit_i64(&mut self, v: i64) { self.emit_float(v as float); } + fn emit_i32(&mut self, v: i32) { self.emit_float(v as float); } + fn emit_i16(&mut self, v: i16) { self.emit_float(v as float); } + fn emit_i8(&mut self, v: i8) { self.emit_float(v as float); } + + fn emit_bool(&mut self, v: bool) { + if v { + self.wr.write_str("true"); + } else { + self.wr.write_str("false"); + } + } + + fn emit_f64(&mut self, v: f64) { self.emit_float(v as float); } + fn emit_f32(&mut self, v: f32) { self.emit_float(v as float); } + fn emit_float(&mut self, v: float) { + self.wr.write_str(float::to_str_digits(v, 6u)); + } + + fn emit_char(&mut self, v: char) { self.emit_str(str::from_char(v)) } + fn emit_str(&mut self, v: &str) { self.wr.write_str(escape_str(v)) } + + fn emit_enum(&mut self, _name: &str, f: &fn(&mut Encoder)) { f(self) } + + fn emit_enum_variant(&mut self, + name: &str, + _id: uint, + cnt: uint, + f: &fn(&mut Encoder)) { + // enums are encoded as strings or vectors: + // Bunny => "Bunny" + // Kangaroo(34,"William") => ["Kangaroo",[34,"William"]] + + if cnt == 0 { + self.wr.write_str(escape_str(name)); + } else { + self.wr.write_char('['); + self.wr.write_str(escape_str(name)); + self.wr.write_char(','); + f(self); + self.wr.write_char(']'); + } + } + + fn emit_enum_variant_arg(&mut self, idx: uint, f: &fn(&mut Encoder)) { + if idx != 0 { + self.wr.write_char(','); + } + f(self); + } + + fn emit_enum_struct_variant(&mut self, + name: &str, + id: uint, + cnt: uint, + f: &fn(&mut Encoder)) { + self.emit_enum_variant(name, id, cnt, f) + } + + fn emit_enum_struct_variant_field(&mut self, + _: &str, + idx: uint, + f: &fn(&mut Encoder)) { + self.emit_enum_variant_arg(idx, f) + } + + fn emit_struct(&mut self, _: &str, _: uint, f: &fn(&mut Encoder)) { + self.wr.write_char('{'); + f(self); + self.wr.write_char('}'); + } + + fn emit_struct_field(&mut self, + name: &str, + idx: uint, + f: &fn(&mut Encoder)) { + if idx != 0 { self.wr.write_char(','); } + self.wr.write_str(escape_str(name)); + self.wr.write_char(':'); + f(self); + } + + fn emit_tuple(&mut self, len: uint, f: &fn(&mut Encoder)) { + self.emit_seq(len, f) + } + fn emit_tuple_arg(&mut self, idx: uint, f: &fn(&mut Encoder)) { + self.emit_seq_elt(idx, f) + } + + fn emit_tuple_struct(&mut self, + _name: &str, + len: uint, + f: &fn(&mut Encoder)) { + self.emit_seq(len, f) + } + fn emit_tuple_struct_arg(&mut self, idx: uint, f: &fn(&mut Encoder)) { + self.emit_seq_elt(idx, f) + } + + fn emit_option(&mut self, f: &fn(&mut Encoder)) { f(self); } + fn emit_option_none(&mut self) { self.emit_nil(); } + fn emit_option_some(&mut self, f: &fn(&mut Encoder)) { f(self); } + + fn emit_seq(&mut self, _len: uint, f: &fn(&mut Encoder)) { + self.wr.write_char('['); + f(self); + self.wr.write_char(']'); + } + + fn emit_seq_elt(&mut self, idx: uint, f: &fn(&mut Encoder)) { + if idx != 0 { + self.wr.write_char(','); + } + f(self) + } + + fn emit_map(&mut self, _len: uint, f: &fn(&mut Encoder)) { + self.wr.write_char('{'); + f(self); + self.wr.write_char('}'); + } + + fn emit_map_elt_key(&mut self, idx: uint, f: &fn(&mut Encoder)) { + if idx != 0 { self.wr.write_char(','); } + f(self) + } + + fn emit_map_elt_val(&mut self, _idx: uint, f: &fn(&mut Encoder)) { + self.wr.write_char(':'); + f(self) + } +} + pub struct PrettyEncoder { priv wr: @io::Writer, priv mut indent: uint, } pub fn PrettyEncoder(wr: @io::Writer) -> PrettyEncoder { - PrettyEncoder { wr: wr, indent: 0 } + PrettyEncoder { + wr: wr, + indent: 0, + } } +#[cfg(stage0)] impl serialize::Encoder for PrettyEncoder { fn emit_nil(&self) { self.wr.write_str("null") } @@ -241,7 +411,11 @@ impl serialize::Encoder for PrettyEncoder { fn emit_enum(&self, _name: &str, f: &fn()) { f() } - fn emit_enum_variant(&self, name: &str, _id: uint, cnt: uint, f: &fn()) { + fn emit_enum_variant(&self, + name: &str, + _: uint, + cnt: uint, + f: &fn()) { if cnt == 0 { self.wr.write_str(escape_str(name)); } else { @@ -267,11 +441,18 @@ impl serialize::Encoder for PrettyEncoder { f() } - fn emit_enum_struct_variant(&self, name: &str, id: uint, cnt: uint, f: &fn()) { + fn emit_enum_struct_variant(&self, + name: &str, + id: uint, + cnt: uint, + f: &fn()) { self.emit_enum_variant(name, id, cnt, f) } - fn emit_enum_struct_variant_field(&self, _field: &str, idx: uint, f: &fn()) { + fn emit_enum_struct_variant_field(&self, + _: &str, + idx: uint, + f: &fn()) { self.emit_enum_variant_arg(idx, f) } @@ -289,6 +470,7 @@ impl serialize::Encoder for PrettyEncoder { self.wr.write_char('}'); } } + #[cfg(stage0)] fn emit_field(&self, name: &str, idx: uint, f: &fn()) { if idx == 0 { @@ -301,6 +483,7 @@ impl serialize::Encoder for PrettyEncoder { self.wr.write_str(": "); f(); } + #[cfg(stage1)] #[cfg(stage2)] #[cfg(stage3)] @@ -316,11 +499,19 @@ impl serialize::Encoder for PrettyEncoder { f(); } - fn emit_tuple(&self, len: uint, f: &fn()) { self.emit_seq(len, f) } - fn emit_tuple_arg(&self, idx: uint, f: &fn()) { self.emit_seq_elt(idx, f) } + fn emit_tuple(&self, len: uint, f: &fn()) { + self.emit_seq(len, f) + } + fn emit_tuple_arg(&self, idx: uint, f: &fn()) { + self.emit_seq_elt(idx, f) + } - fn emit_tuple_struct(&self, _name: &str, len: uint, f: &fn()) { self.emit_seq(len, f) } - fn emit_tuple_struct_arg(&self, idx: uint, f: &fn()) { self.emit_seq_elt(idx, f) } + fn emit_tuple_struct(&self, _name: &str, len: uint, f: &fn()) { + self.emit_seq(len, f) + } + fn emit_tuple_struct_arg(&self, idx: uint, f: &fn()) { + self.emit_seq_elt(idx, f) + } fn emit_option(&self, f: &fn()) { f(); } fn emit_option_none(&self) { self.emit_nil(); } @@ -339,6 +530,7 @@ impl serialize::Encoder for PrettyEncoder { self.wr.write_char(']'); } } + fn emit_seq_elt(&self, idx: uint, f: &fn()) { if idx == 0 { self.wr.write_char('\n'); @@ -362,6 +554,7 @@ impl serialize::Encoder for PrettyEncoder { self.wr.write_char('}'); } } + fn emit_map_elt_key(&self, idx: uint, f: &fn()) { if idx == 0 { self.wr.write_char('\n'); @@ -378,6 +571,201 @@ impl serialize::Encoder for PrettyEncoder { } } +#[cfg(not(stage0))] +impl serialize::Encoder for PrettyEncoder { + fn emit_nil(&mut self) { self.wr.write_str("null") } + + fn emit_uint(&mut self, v: uint) { self.emit_float(v as float); } + fn emit_u64(&mut self, v: u64) { self.emit_float(v as float); } + fn emit_u32(&mut self, v: u32) { self.emit_float(v as float); } + fn emit_u16(&mut self, v: u16) { self.emit_float(v as float); } + fn emit_u8(&mut self, v: u8) { self.emit_float(v as float); } + + fn emit_int(&mut self, v: int) { self.emit_float(v as float); } + fn emit_i64(&mut self, v: i64) { self.emit_float(v as float); } + fn emit_i32(&mut self, v: i32) { self.emit_float(v as float); } + fn emit_i16(&mut self, v: i16) { self.emit_float(v as float); } + fn emit_i8(&mut self, v: i8) { self.emit_float(v as float); } + + fn emit_bool(&mut self, v: bool) { + if v { + self.wr.write_str("true"); + } else { + self.wr.write_str("false"); + } + } + + fn emit_f64(&mut self, v: f64) { self.emit_float(v as float); } + fn emit_f32(&mut self, v: f32) { self.emit_float(v as float); } + fn emit_float(&mut self, v: float) { + self.wr.write_str(float::to_str_digits(v, 6u)); + } + + fn emit_char(&mut self, v: char) { self.emit_str(str::from_char(v)) } + fn emit_str(&mut self, v: &str) { self.wr.write_str(escape_str(v)); } + + fn emit_enum(&mut self, _name: &str, f: &fn(&mut PrettyEncoder)) { + f(self) + } + + fn emit_enum_variant(&mut self, + name: &str, + _: uint, + cnt: uint, + f: &fn(&mut PrettyEncoder)) { + if cnt == 0 { + self.wr.write_str(escape_str(name)); + } else { + self.wr.write_char('['); + self.indent += 2; + self.wr.write_char('\n'); + self.wr.write_str(spaces(self.indent)); + self.wr.write_str(escape_str(name)); + self.wr.write_str(",\n"); + f(self); + self.wr.write_char('\n'); + self.indent -= 2; + self.wr.write_str(spaces(self.indent)); + self.wr.write_char(']'); + } + } + + fn emit_enum_variant_arg(&mut self, + idx: uint, + f: &fn(&mut PrettyEncoder)) { + if idx != 0 { + self.wr.write_str(",\n"); + } + self.wr.write_str(spaces(self.indent)); + f(self) + } + + fn emit_enum_struct_variant(&mut self, + name: &str, + id: uint, + cnt: uint, + f: &fn(&mut PrettyEncoder)) { + self.emit_enum_variant(name, id, cnt, f) + } + + fn emit_enum_struct_variant_field(&mut self, + _: &str, + idx: uint, + f: &fn(&mut PrettyEncoder)) { + self.emit_enum_variant_arg(idx, f) + } + + + fn emit_struct(&mut self, + _: &str, + len: uint, + f: &fn(&mut PrettyEncoder)) { + if len == 0 { + self.wr.write_str("{}"); + } else { + self.wr.write_char('{'); + self.indent += 2; + f(self); + self.wr.write_char('\n'); + self.indent -= 2; + self.wr.write_str(spaces(self.indent)); + self.wr.write_char('}'); + } + } + + fn emit_struct_field(&mut self, + name: &str, + idx: uint, + f: &fn(&mut PrettyEncoder)) { + if idx == 0 { + self.wr.write_char('\n'); + } else { + self.wr.write_str(",\n"); + } + self.wr.write_str(spaces(self.indent)); + self.wr.write_str(escape_str(name)); + self.wr.write_str(": "); + f(self); + } + + fn emit_tuple(&mut self, len: uint, f: &fn(&mut PrettyEncoder)) { + self.emit_seq(len, f) + } + fn emit_tuple_arg(&mut self, idx: uint, f: &fn(&mut PrettyEncoder)) { + self.emit_seq_elt(idx, f) + } + + fn emit_tuple_struct(&mut self, + _: &str, + len: uint, + f: &fn(&mut PrettyEncoder)) { + self.emit_seq(len, f) + } + fn emit_tuple_struct_arg(&mut self, + idx: uint, + f: &fn(&mut PrettyEncoder)) { + self.emit_seq_elt(idx, f) + } + + fn emit_option(&mut self, f: &fn(&mut PrettyEncoder)) { f(self); } + fn emit_option_none(&mut self) { self.emit_nil(); } + fn emit_option_some(&mut self, f: &fn(&mut PrettyEncoder)) { f(self); } + + fn emit_seq(&mut self, len: uint, f: &fn(&mut PrettyEncoder)) { + if len == 0 { + self.wr.write_str("[]"); + } else { + self.wr.write_char('['); + self.indent += 2; + f(self); + self.wr.write_char('\n'); + self.indent -= 2; + self.wr.write_str(spaces(self.indent)); + self.wr.write_char(']'); + } + } + + fn emit_seq_elt(&mut self, idx: uint, f: &fn(&mut PrettyEncoder)) { + if idx == 0 { + self.wr.write_char('\n'); + } else { + self.wr.write_str(",\n"); + } + self.wr.write_str(spaces(self.indent)); + f(self) + } + + fn emit_map(&mut self, len: uint, f: &fn(&mut PrettyEncoder)) { + if len == 0 { + self.wr.write_str("{}"); + } else { + self.wr.write_char('{'); + self.indent += 2; + f(self); + self.wr.write_char('\n'); + self.indent -= 2; + self.wr.write_str(spaces(self.indent)); + self.wr.write_char('}'); + } + } + + fn emit_map_elt_key(&mut self, idx: uint, f: &fn(&mut PrettyEncoder)) { + if idx == 0 { + self.wr.write_char('\n'); + } else { + self.wr.write_str(",\n"); + } + self.wr.write_str(spaces(self.indent)); + f(self); + } + + fn emit_map_elt_val(&mut self, _idx: uint, f: &fn(&mut PrettyEncoder)) { + self.wr.write_str(": "); + f(self); + } +} + +#[cfg(stage0)] impl serialize::Encodable for Json { fn encode(&self, e: &E) { match *self { @@ -391,9 +779,32 @@ impl serialize::Encodable for Json { } } +#[cfg(not(stage0))] +impl serialize::Encodable for Json { + fn encode(&self, e: &mut E) { + match *self { + Number(v) => v.encode(e), + String(ref v) => v.encode(e), + Boolean(v) => v.encode(e), + List(ref v) => v.encode(e), + Object(ref v) => v.encode(e), + Null => e.emit_nil(), + } + } +} + /// Encodes a json value into a io::writer +#[cfg(stage0)] pub fn to_writer(wr: @io::Writer, json: &Json) { - json.encode(&Encoder(wr)) + let encoder = Encoder(wr); + json.encode(&encoder) +} + +/// Encodes a json value into a io::writer +#[cfg(not(stage0))] +pub fn to_writer(wr: @io::Writer, json: &Json) { + let mut encoder = Encoder(wr); + json.encode(&mut encoder) } /// Encodes a json value into a string @@ -402,8 +813,17 @@ pub fn to_str(json: &Json) -> ~str { } /// Encodes a json value into a io::writer +#[cfg(stage0)] pub fn to_pretty_writer(wr: @io::Writer, json: &Json) { - json.encode(&PrettyEncoder(wr)) + let encoder = PrettyEncoder(wr); + json.encode(&encoder) +} + +/// Encodes a json value into a io::writer +#[cfg(not(stage0))] +pub fn to_pretty_writer(wr: @io::Writer, json: &Json) { + let mut encoder = PrettyEncoder(wr); + json.encode(&mut encoder) } /// Encodes a json value into a string @@ -794,9 +1214,12 @@ pub struct Decoder { } pub fn Decoder(json: Json) -> Decoder { - Decoder { stack: ~[json] } + Decoder { + stack: ~[json] + } } +#[cfg(stage0)] impl serialize::Decoder for Decoder { fn read_nil(&self) -> () { debug!("read_nil"); @@ -856,7 +1279,10 @@ impl serialize::Decoder for Decoder { f() } - fn read_enum_variant(&self, names: &[&str], f: &fn(uint) -> T) -> T { + fn read_enum_variant(&self, + names: &[&str], + f: &fn(uint) -> T) + -> T { debug!("read_enum_variant(names=%?)", names); let name = match self.stack.pop() { String(s) => s, @@ -883,13 +1309,20 @@ impl serialize::Decoder for Decoder { f() } - fn read_enum_struct_variant(&self, names: &[&str], f: &fn(uint) -> T) -> T { + fn read_enum_struct_variant(&self, + names: &[&str], + f: &fn(uint) -> T) + -> T { debug!("read_enum_struct_variant(names=%?)", names); self.read_enum_variant(names, f) } - fn read_enum_struct_variant_field(&self, name: &str, idx: uint, f: &fn() -> T) -> T { + fn read_enum_struct_variant_field(&self, + name: &str, + idx: uint, + f: &fn() -> T) + -> T { debug!("read_enum_struct_variant_field(name=%?, idx=%u)", name, idx); self.read_enum_variant_arg(idx, f) } @@ -924,7 +1357,11 @@ impl serialize::Decoder for Decoder { #[cfg(stage1)] #[cfg(stage2)] #[cfg(stage3)] - fn read_struct_field(&self, name: &str, idx: uint, f: &fn() -> T) -> T { + fn read_struct_field(&self, + name: &str, + idx: uint, + f: &fn() -> T) + -> T { debug!("read_struct_field(name=%?, idx=%u)", name, idx); match self.stack.pop() { Object(obj) => { @@ -1018,6 +1455,262 @@ impl serialize::Decoder for Decoder { } } +#[cfg(not(stage0))] +impl serialize::Decoder for Decoder { + fn read_nil(&mut self) -> () { + debug!("read_nil"); + match self.stack.pop() { + Null => (), + value => fail!(fmt!("not a null: %?", value)) + } + } + + fn read_u64(&mut self) -> u64 { self.read_float() as u64 } + fn read_u32(&mut self) -> u32 { self.read_float() as u32 } + fn read_u16(&mut self) -> u16 { self.read_float() as u16 } + fn read_u8 (&mut self) -> u8 { self.read_float() as u8 } + fn read_uint(&mut self) -> uint { self.read_float() as uint } + + fn read_i64(&mut self) -> i64 { self.read_float() as i64 } + fn read_i32(&mut self) -> i32 { self.read_float() as i32 } + fn read_i16(&mut self) -> i16 { self.read_float() as i16 } + fn read_i8 (&mut self) -> i8 { self.read_float() as i8 } + fn read_int(&mut self) -> int { self.read_float() as int } + + fn read_bool(&mut self) -> bool { + debug!("read_bool"); + match self.stack.pop() { + Boolean(b) => b, + value => fail!(fmt!("not a boolean: %?", value)) + } + } + + fn read_f64(&mut self) -> f64 { self.read_float() as f64 } + fn read_f32(&mut self) -> f32 { self.read_float() as f32 } + fn read_float(&mut self) -> float { + debug!("read_float"); + match self.stack.pop() { + Number(f) => f, + value => fail!(fmt!("not a number: %?", value)) + } + } + + fn read_char(&mut self) -> char { + let mut v = ~[]; + for str::each_char(self.read_str()) |c| { v.push(c) } + if v.len() != 1 { fail!(~"string must have one character") } + v[0] + } + + fn read_str(&mut self) -> ~str { + debug!("read_str"); + match self.stack.pop() { + String(s) => s, + json => fail!(fmt!("not a string: %?", json)) + } + } + + fn read_enum(&mut self, name: &str, f: &fn(&mut Decoder) -> T) -> T { + debug!("read_enum(%s)", name); + f(self) + } + + fn read_enum_variant(&mut self, + names: &[&str], + f: &fn(&mut Decoder, uint) -> T) + -> T { + debug!("read_enum_variant(names=%?)", names); + let name = match self.stack.pop() { + String(s) => s, + List(list) => { + do vec::consume_reverse(list) |_i, v| { + self.stack.push(v); + } + match self.stack.pop() { + String(s) => s, + value => fail!(fmt!("invalid variant name: %?", value)), + } + } + ref json => fail!(fmt!("invalid variant: %?", *json)), + }; + let idx = match vec::position(names, |n| str::eq_slice(*n, name)) { + Some(idx) => idx, + None => fail!(fmt!("Unknown variant name: %?", name)), + }; + f(self, idx) + } + + fn read_enum_variant_arg(&mut self, + idx: uint, + f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_enum_variant_arg(idx=%u)", idx); + f(self) + } + + fn read_enum_struct_variant(&mut self, + names: &[&str], + f: &fn(&mut Decoder, uint) -> T) + -> T { + debug!("read_enum_struct_variant(names=%?)", names); + self.read_enum_variant(names, f) + } + + + fn read_enum_struct_variant_field(&mut self, + name: &str, + idx: uint, + f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_enum_struct_variant_field(name=%?, idx=%u)", name, idx); + self.read_enum_variant_arg(idx, f) + } + + fn read_struct(&mut self, + name: &str, + len: uint, + f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_struct(name=%s, len=%u)", name, len); + let value = f(self); + self.stack.pop(); + value + } + + #[cfg(stage0)] + fn read_field(&mut self, name: &str, idx: uint, f: &fn() -> T) -> T { + debug!("read_field(name=%?, idx=%u)", name, idx); + match self.stack.pop() { + Object(obj) => { + let mut obj = obj; + let value = match obj.pop(&name.to_owned()) { + None => fail!(fmt!("no such field: %s", name)), + Some(json) => { + self.stack.push(json); + f() + } + }; + self.stack.push(Object(obj)); + value + } + value => fail!(fmt!("not an object: %?", value)) + } + } + + #[cfg(stage1)] + #[cfg(stage2)] + #[cfg(stage3)] + fn read_struct_field(&mut self, + name: &str, + idx: uint, + f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_struct_field(name=%?, idx=%u)", name, idx); + match self.stack.pop() { + Object(obj) => { + let mut obj = obj; + let value = match obj.pop(&name.to_owned()) { + None => fail!(fmt!("no such field: %s", name)), + Some(json) => { + self.stack.push(json); + f(self) + } + }; + self.stack.push(Object(obj)); + value + } + value => fail!(fmt!("not an object: %?", value)) + } + } + + fn read_tuple(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T { + debug!("read_tuple()"); + self.read_seq(f) + } + + fn read_tuple_arg(&mut self, + idx: uint, + f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_tuple_arg(idx=%u)", idx); + self.read_seq_elt(idx, f) + } + + fn read_tuple_struct(&mut self, + name: &str, + f: &fn(&mut Decoder, uint) -> T) + -> T { + debug!("read_tuple_struct(name=%?)", name); + self.read_tuple(f) + } + + fn read_tuple_struct_arg(&mut self, + idx: uint, + f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_tuple_struct_arg(idx=%u)", idx); + self.read_tuple_arg(idx, f) + } + + fn read_option(&mut self, f: &fn(&mut Decoder, bool) -> T) -> T { + match self.stack.pop() { + Null => f(self, false), + value => { self.stack.push(value); f(self, true) } + } + } + + fn read_seq(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T { + debug!("read_seq()"); + let len = match self.stack.pop() { + List(list) => { + let len = list.len(); + do vec::consume_reverse(list) |_i, v| { + self.stack.push(v); + } + len + } + _ => fail!(~"not a list"), + }; + f(self, len) + } + + fn read_seq_elt(&mut self, idx: uint, f: &fn(&mut Decoder) -> T) -> T { + debug!("read_seq_elt(idx=%u)", idx); + f(self) + } + + fn read_map(&mut self, f: &fn(&mut Decoder, uint) -> T) -> T { + debug!("read_map()"); + let len = match self.stack.pop() { + Object(obj) => { + let mut obj = obj; + let len = obj.len(); + do obj.consume |key, value| { + self.stack.push(value); + self.stack.push(String(key)); + } + len + } + json => fail!(fmt!("not an object: %?", json)), + }; + f(self, len) + } + + fn read_map_elt_key(&mut self, + idx: uint, + f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_map_elt_key(idx=%u)", idx); + f(self) + } + + fn read_map_elt_val(&mut self, idx: uint, f: &fn(&mut Decoder) -> T) + -> T { + debug!("read_map_elt_val(idx=%u)", idx); + f(self) + } +} + impl Eq for Json { fn eq(&self, other: &Json) -> bool { match (self) { @@ -1452,15 +2145,15 @@ mod tests { let animal = Dog; assert_eq!( do io::with_str_writer |wr| { - let encoder = Encoder(wr); - animal.encode(&encoder); + let mut encoder = Encoder(wr); + animal.encode(&mut encoder); }, ~"\"Dog\"" ); assert_eq!( do io::with_str_writer |wr| { - let encoder = PrettyEncoder(wr); - animal.encode(&encoder); + let mut encoder = PrettyEncoder(wr); + animal.encode(&mut encoder); }, ~"\"Dog\"" ); @@ -1468,15 +2161,15 @@ mod tests { let animal = Frog(~"Henry", 349); assert_eq!( do io::with_str_writer |wr| { - let encoder = Encoder(wr); - animal.encode(&encoder); + let mut encoder = Encoder(wr); + animal.encode(&mut encoder); }, ~"[\"Frog\",\"Henry\",349]" ); assert_eq!( do io::with_str_writer |wr| { - let encoder = PrettyEncoder(wr); - animal.encode(&encoder); + let mut encoder = PrettyEncoder(wr); + animal.encode(&mut encoder); }, ~"\ [\n \ @@ -1491,15 +2184,15 @@ mod tests { fn test_write_some() { let value = Some(~"jodhpurs"); let s = do io::with_str_writer |wr| { - let encoder = Encoder(wr); - value.encode(&encoder); + let mut encoder = Encoder(wr); + value.encode(&mut encoder); }; assert_eq!(s, ~"\"jodhpurs\""); let value = Some(~"jodhpurs"); let s = do io::with_str_writer |wr| { - let encoder = PrettyEncoder(wr); - value.encode(&encoder); + let mut encoder = PrettyEncoder(wr); + value.encode(&mut encoder); }; assert_eq!(s, ~"\"jodhpurs\""); } @@ -1508,14 +2201,14 @@ mod tests { fn test_write_none() { let value: Option<~str> = None; let s = do io::with_str_writer |wr| { - let encoder = Encoder(wr); - value.encode(&encoder); + let mut encoder = Encoder(wr); + value.encode(&mut encoder); }; assert_eq!(s, ~"null"); let s = do io::with_str_writer |wr| { - let encoder = Encoder(wr); - value.encode(&encoder); + let mut encoder = Encoder(wr); + value.encode(&mut encoder); }; assert_eq!(s, ~"null"); } @@ -1563,13 +2256,16 @@ mod tests { #[test] fn test_decode_identifiers() { - let v: () = Decodable::decode(&Decoder(from_str(~"null").unwrap())); + let mut decoder = Decoder(from_str(~"null").unwrap()); + let v: () = Decodable::decode(&mut decoder); assert_eq!(v, ()); - let v: bool = Decodable::decode(&Decoder(from_str(~"true").unwrap())); + let mut decoder = Decoder(from_str(~"true").unwrap()); + let v: bool = Decodable::decode(&mut decoder); assert_eq!(v, true); - let v: bool = Decodable::decode(&Decoder(from_str(~"false").unwrap())); + let mut decoder = Decoder(from_str(~"false").unwrap()); + let v: bool = Decodable::decode(&mut decoder); assert_eq!(v, false); } @@ -1603,25 +2299,32 @@ mod tests { #[test] fn test_decode_numbers() { - let v: float = Decodable::decode(&Decoder(from_str(~"3").unwrap())); + let mut decoder = Decoder(from_str(~"3").unwrap()); + let v: float = Decodable::decode(&mut decoder); assert_eq!(v, 3f); - let v: float = Decodable::decode(&Decoder(from_str(~"3.1").unwrap())); + let mut decoder = Decoder(from_str(~"3.1").unwrap()); + let v: float = Decodable::decode(&mut decoder); assert_eq!(v, 3.1f); - let v: float = Decodable::decode(&Decoder(from_str(~"-1.2").unwrap())); + let mut decoder = Decoder(from_str(~"-1.2").unwrap()); + let v: float = Decodable::decode(&mut decoder); assert_eq!(v, -1.2f); - let v: float = Decodable::decode(&Decoder(from_str(~"0.4").unwrap())); + let mut decoder = Decoder(from_str(~"0.4").unwrap()); + let v: float = Decodable::decode(&mut decoder); assert_eq!(v, 0.4f); - let v: float = Decodable::decode(&Decoder(from_str(~"0.4e5").unwrap())); + let mut decoder = Decoder(from_str(~"0.4e5").unwrap()); + let v: float = Decodable::decode(&mut decoder); assert_eq!(v, 0.4e5f); - let v: float = Decodable::decode(&Decoder(from_str(~"0.4e15").unwrap())); + let mut decoder = Decoder(from_str(~"0.4e15").unwrap()); + let v: float = Decodable::decode(&mut decoder); assert_eq!(v, 0.4e15f); - let v: float = Decodable::decode(&Decoder(from_str(~"0.4e-01").unwrap())); + let mut decoder = Decoder(from_str(~"0.4e-01").unwrap()); + let v: float = Decodable::decode(&mut decoder); assert_eq!(v, 0.4e-01f); } @@ -1648,31 +2351,40 @@ mod tests { #[test] fn test_decode_str() { - let v: ~str = Decodable::decode(&Decoder(from_str(~"\"\"").unwrap())); + let mut decoder = Decoder(from_str(~"\"\"").unwrap()); + let v: ~str = Decodable::decode(&mut decoder); assert_eq!(v, ~""); - let v: ~str = Decodable::decode(&Decoder(from_str(~"\"foo\"").unwrap())); + let mut decoder = Decoder(from_str(~"\"foo\"").unwrap()); + let v: ~str = Decodable::decode(&mut decoder); assert_eq!(v, ~"foo"); - let v: ~str = Decodable::decode(&Decoder(from_str(~"\"\\\"\"").unwrap())); + let mut decoder = Decoder(from_str(~"\"\\\"\"").unwrap()); + let v: ~str = Decodable::decode(&mut decoder); assert_eq!(v, ~"\""); - let v: ~str = Decodable::decode(&Decoder(from_str(~"\"\\b\"").unwrap())); + let mut decoder = Decoder(from_str(~"\"\\b\"").unwrap()); + let v: ~str = Decodable::decode(&mut decoder); assert_eq!(v, ~"\x08"); - let v: ~str = Decodable::decode(&Decoder(from_str(~"\"\\n\"").unwrap())); + let mut decoder = Decoder(from_str(~"\"\\n\"").unwrap()); + let v: ~str = Decodable::decode(&mut decoder); assert_eq!(v, ~"\n"); - let v: ~str = Decodable::decode(&Decoder(from_str(~"\"\\r\"").unwrap())); + let mut decoder = Decoder(from_str(~"\"\\r\"").unwrap()); + let v: ~str = Decodable::decode(&mut decoder); assert_eq!(v, ~"\r"); - let v: ~str = Decodable::decode(&Decoder(from_str(~"\"\\t\"").unwrap())); + let mut decoder = Decoder(from_str(~"\"\\t\"").unwrap()); + let v: ~str = Decodable::decode(&mut decoder); assert_eq!(v, ~"\t"); - let v: ~str = Decodable::decode(&Decoder(from_str(~"\"\\u12ab\"").unwrap())); + let mut decoder = Decoder(from_str(~"\"\\u12ab\"").unwrap()); + let v: ~str = Decodable::decode(&mut decoder); assert_eq!(v, ~"\u12ab"); - let v: ~str = Decodable::decode(&Decoder(from_str(~"\"\\uAB12\"").unwrap())); + let mut decoder = Decoder(from_str(~"\"\\uAB12\"").unwrap()); + let v: ~str = Decodable::decode(&mut decoder); assert_eq!(v, ~"\uAB12"); } @@ -1704,23 +2416,28 @@ mod tests { #[test] fn test_decode_list() { - let v: ~[()] = Decodable::decode(&Decoder(from_str(~"[]").unwrap())); + let mut decoder = Decoder(from_str(~"[]").unwrap()); + let v: ~[()] = Decodable::decode(&mut decoder); assert_eq!(v, ~[]); - let v: ~[()] = Decodable::decode(&Decoder(from_str(~"[null]").unwrap())); + let mut decoder = Decoder(from_str(~"[null]").unwrap()); + let v: ~[()] = Decodable::decode(&mut decoder); assert_eq!(v, ~[()]); - - let v: ~[bool] = Decodable::decode(&Decoder(from_str(~"[true]").unwrap())); + let mut decoder = Decoder(from_str(~"[true]").unwrap()); + let v: ~[bool] = Decodable::decode(&mut decoder); assert_eq!(v, ~[true]); - let v: ~[bool] = Decodable::decode(&Decoder(from_str(~"[true]").unwrap())); + let mut decoder = Decoder(from_str(~"[true]").unwrap()); + let v: ~[bool] = Decodable::decode(&mut decoder); assert_eq!(v, ~[true]); - let v: ~[int] = Decodable::decode(&Decoder(from_str(~"[3, 1]").unwrap())); + let mut decoder = Decoder(from_str(~"[3, 1]").unwrap()); + let v: ~[int] = Decodable::decode(&mut decoder); assert_eq!(v, ~[3, 1]); - let v: ~[~[uint]] = Decodable::decode(&Decoder(from_str(~"[[3], [1, 2]]").unwrap())); + let mut decoder = Decoder(from_str(~"[[3], [1, 2]]").unwrap()); + let v: ~[~[uint]] = Decodable::decode(&mut decoder); assert_eq!(v, ~[~[3], ~[1, 2]]); } @@ -1822,7 +2539,8 @@ mod tests { { \"a\": null, \"b\": 2, \"c\": [\"abc\", \"xyz\"] } ] }"; - let v: Outer = Decodable::decode(&Decoder(from_str(s).unwrap())); + let mut decoder = Decoder(from_str(s).unwrap()); + let v: Outer = Decodable::decode(&mut decoder); assert_eq!( v, Outer { @@ -1835,31 +2553,32 @@ mod tests { #[test] fn test_decode_option() { - let decoder = Decoder(from_str(~"null").unwrap()); - let value: Option<~str> = Decodable::decode(&decoder); + let mut decoder = Decoder(from_str(~"null").unwrap()); + let value: Option<~str> = Decodable::decode(&mut decoder); assert_eq!(value, None); - let decoder = Decoder(from_str(~"\"jodhpurs\"").unwrap()); - let value: Option<~str> = Decodable::decode(&decoder); + let mut decoder = Decoder(from_str(~"\"jodhpurs\"").unwrap()); + let value: Option<~str> = Decodable::decode(&mut decoder); assert_eq!(value, Some(~"jodhpurs")); } #[test] fn test_decode_enum() { - let decoder = Decoder(from_str(~"\"Dog\"").unwrap()); - let value: Animal = Decodable::decode(&decoder); + let mut decoder = Decoder(from_str(~"\"Dog\"").unwrap()); + let value: Animal = Decodable::decode(&mut decoder); assert_eq!(value, Dog); - let decoder = Decoder(from_str(~"[\"Frog\",\"Henry\",349]").unwrap()); - let value: Animal = Decodable::decode(&decoder); + let mut decoder = + Decoder(from_str(~"[\"Frog\",\"Henry\",349]").unwrap()); + let value: Animal = Decodable::decode(&mut decoder); assert_eq!(value, Frog(~"Henry", 349)); } #[test] fn test_decode_map() { let s = ~"{\"a\": \"Dog\", \"b\": [\"Frog\", \"Henry\", 349]}"; - let decoder = Decoder(from_str(s).unwrap()); - let mut map: HashMap<~str, Animal> = Decodable::decode(&decoder); + let mut decoder = Decoder(from_str(s).unwrap()); + let mut map: HashMap<~str, Animal> = Decodable::decode(&mut decoder); assert_eq!(map.pop(&~"a"), Some(Dog)); assert_eq!(map.pop(&~"b"), Some(Frog(~"Henry", 349))); diff --git a/src/libstd/serialize.rs b/src/libstd/serialize.rs index 1ad581ba993..33efb2c6a5a 100644 --- a/src/libstd/serialize.rs +++ b/src/libstd/serialize.rs @@ -25,6 +25,7 @@ use dlist::DList; #[cfg(stage3)] use treemap::{TreeMap, TreeSet}; +#[cfg(stage0)] pub trait Encoder { // Primitive types: fn emit_nil(&self); @@ -48,11 +49,22 @@ pub trait Encoder { // Compound types: fn emit_enum(&self, name: &str, f: &fn()); - fn emit_enum_variant(&self, v_name: &str, v_id: uint, len: uint, f: &fn()); + fn emit_enum_variant(&self, + v_name: &str, + v_id: uint, + len: uint, + f: &fn()); fn emit_enum_variant_arg(&self, a_idx: uint, f: &fn()); - fn emit_enum_struct_variant(&self, v_name: &str, v_id: uint, len: uint, f: &fn()); - fn emit_enum_struct_variant_field(&self, f_name: &str, f_idx: uint, f: &fn()); + fn emit_enum_struct_variant(&self, + v_name: &str, + v_id: uint, + len: uint, + f: &fn()); + fn emit_enum_struct_variant_field(&self, + f_name: &str, + f_idx: uint, + f: &fn()); fn emit_struct(&self, name: &str, len: uint, f: &fn()); #[cfg(stage0)] @@ -81,6 +93,73 @@ pub trait Encoder { fn emit_map_elt_val(&self, idx: uint, f: &fn()); } +#[cfg(not(stage0))] +pub trait Encoder { + // Primitive types: + fn emit_nil(&mut self); + fn emit_uint(&mut self, v: uint); + fn emit_u64(&mut self, v: u64); + fn emit_u32(&mut self, v: u32); + fn emit_u16(&mut self, v: u16); + fn emit_u8(&mut self, v: u8); + fn emit_int(&mut self, v: int); + fn emit_i64(&mut self, v: i64); + fn emit_i32(&mut self, v: i32); + fn emit_i16(&mut self, v: i16); + fn emit_i8(&mut self, v: i8); + fn emit_bool(&mut self, v: bool); + fn emit_float(&mut self, v: float); + fn emit_f64(&mut self, v: f64); + fn emit_f32(&mut self, v: f32); + fn emit_char(&mut self, v: char); + fn emit_str(&mut self, v: &str); + + // Compound types: + fn emit_enum(&mut self, name: &str, f: &fn(&mut Self)); + + fn emit_enum_variant(&mut self, + v_name: &str, + v_id: uint, + len: uint, + f: &fn(&mut Self)); + fn emit_enum_variant_arg(&mut self, a_idx: uint, f: &fn(&mut Self)); + + fn emit_enum_struct_variant(&mut self, + v_name: &str, + v_id: uint, + len: uint, + f: &fn(&mut Self)); + fn emit_enum_struct_variant_field(&mut self, + f_name: &str, + f_idx: uint, + f: &fn(&mut Self)); + + fn emit_struct(&mut self, name: &str, len: uint, f: &fn(&mut Self)); + fn emit_struct_field(&mut self, + f_name: &str, + f_idx: uint, + f: &fn(&mut Self)); + + fn emit_tuple(&mut self, len: uint, f: &fn(&mut Self)); + fn emit_tuple_arg(&mut self, idx: uint, f: &fn(&mut Self)); + + fn emit_tuple_struct(&mut self, name: &str, len: uint, f: &fn(&mut Self)); + fn emit_tuple_struct_arg(&mut self, f_idx: uint, f: &fn(&mut Self)); + + // Specialized types: + fn emit_option(&mut self, f: &fn(&mut Self)); + fn emit_option_none(&mut self); + fn emit_option_some(&mut self, f: &fn(&mut Self)); + + fn emit_seq(&mut self, len: uint, f: &fn(this: &mut Self)); + fn emit_seq_elt(&mut self, idx: uint, f: &fn(this: &mut Self)); + + fn emit_map(&mut self, len: uint, f: &fn(&mut Self)); + fn emit_map_elt_key(&mut self, idx: uint, f: &fn(&mut Self)); + fn emit_map_elt_val(&mut self, idx: uint, f: &fn(&mut Self)); +} + +#[cfg(stage0)] pub trait Decoder { // Primitive types: fn read_nil(&self) -> (); @@ -104,19 +183,37 @@ pub trait Decoder { // Compound types: fn read_enum(&self, name: &str, f: &fn() -> T) -> T; - fn read_enum_variant(&self, names: &[&str], f: &fn(uint) -> T) -> T; + fn read_enum_variant(&self, + names: &[&str], + f: &fn(uint) -> T) + -> T; fn read_enum_variant_arg(&self, a_idx: uint, f: &fn() -> T) -> T; - fn read_enum_struct_variant(&self, names: &[&str], f: &fn(uint) -> T) -> T; - fn read_enum_struct_variant_field(&self, &f_name: &str, f_idx: uint, f: &fn() -> T) -> T; + fn read_enum_struct_variant(&self, + names: &[&str], + f: &fn(uint) -> T) + -> T; + fn read_enum_struct_variant_field(&self, + &f_name: &str, + f_idx: uint, + f: &fn() -> T) + -> T; fn read_struct(&self, s_name: &str, len: uint, f: &fn() -> T) -> T; #[cfg(stage0)] - fn read_field(&self, f_name: &str, f_idx: uint, f: &fn() -> T) -> T; + fn read_field(&self, + f_name: &str, + f_idx: uint, + f: &fn() -> T) + -> T; #[cfg(stage1)] #[cfg(stage2)] #[cfg(stage3)] - fn read_struct_field(&self, f_name: &str, f_idx: uint, f: &fn() -> T) -> T; + fn read_struct_field(&self, + f_name: &str, + f_idx: uint, + f: &fn() -> T) + -> T; fn read_tuple(&self, f: &fn(uint) -> T) -> T; fn read_tuple_arg(&self, a_idx: uint, f: &fn() -> T) -> T; @@ -135,215 +232,673 @@ pub trait Decoder { fn read_map_elt_val(&self, idx: uint, f: &fn() -> T) -> T; } +#[cfg(not(stage0))] +pub trait Decoder { + // Primitive types: + fn read_nil(&mut self) -> (); + fn read_uint(&mut self) -> uint; + fn read_u64(&mut self) -> u64; + fn read_u32(&mut self) -> u32; + fn read_u16(&mut self) -> u16; + fn read_u8(&mut self) -> u8; + fn read_int(&mut self) -> int; + fn read_i64(&mut self) -> i64; + fn read_i32(&mut self) -> i32; + fn read_i16(&mut self) -> i16; + fn read_i8(&mut self) -> i8; + fn read_bool(&mut self) -> bool; + fn read_f64(&mut self) -> f64; + fn read_f32(&mut self) -> f32; + fn read_float(&mut self) -> float; + fn read_char(&mut self) -> char; + fn read_str(&mut self) -> ~str; + + // Compound types: + fn read_enum(&mut self, name: &str, f: &fn(&mut Self) -> T) -> T; + + fn read_enum_variant(&mut self, + names: &[&str], + f: &fn(&mut Self, uint) -> T) + -> T; + fn read_enum_variant_arg(&mut self, + a_idx: uint, + f: &fn(&mut Self) -> T) + -> T; + + fn read_enum_struct_variant(&mut self, + names: &[&str], + f: &fn(&mut Self, uint) -> T) + -> T; + fn read_enum_struct_variant_field(&mut self, + &f_name: &str, + f_idx: uint, + f: &fn(&mut Self) -> T) + -> T; + + fn read_struct(&mut self, + s_name: &str, + len: uint, + f: &fn(&mut Self) -> T) + -> T; + #[cfg(stage0)] + fn read_field(&mut self, + f_name: &str, + f_idx: uint, + f: &fn() -> T) + -> T; + #[cfg(stage1)] + #[cfg(stage2)] + #[cfg(stage3)] + fn read_struct_field(&mut self, + f_name: &str, + f_idx: uint, + f: &fn(&mut Self) -> T) + -> T; + + fn read_tuple(&mut self, f: &fn(&mut Self, uint) -> T) -> T; + fn read_tuple_arg(&mut self, a_idx: uint, f: &fn(&mut Self) -> T) -> T; + + fn read_tuple_struct(&mut self, + s_name: &str, + f: &fn(&mut Self, uint) -> T) + -> T; + fn read_tuple_struct_arg(&mut self, + a_idx: uint, + f: &fn(&mut Self) -> T) + -> T; + + // Specialized types: + fn read_option(&mut self, f: &fn(&mut Self, bool) -> T) -> T; + + fn read_seq(&mut self, f: &fn(&mut Self, uint) -> T) -> T; + fn read_seq_elt(&mut self, idx: uint, f: &fn(&mut Self) -> T) -> T; + + fn read_map(&mut self, f: &fn(&mut Self, uint) -> T) -> T; + fn read_map_elt_key(&mut self, idx: uint, f: &fn(&mut Self) -> T) -> T; + fn read_map_elt_val(&mut self, idx: uint, f: &fn(&mut Self) -> T) -> T; +} + +#[cfg(stage0)] pub trait Encodable { fn encode(&self, s: &S); } +#[cfg(not(stage0))] +pub trait Encodable { + fn encode(&self, s: &mut S); +} + +#[cfg(stage0)] pub trait Decodable { fn decode(d: &D) -> Self; } +#[cfg(not(stage0))] +pub trait Decodable { + fn decode(d: &mut D) -> Self; +} + +#[cfg(stage0)] impl Encodable for uint { - fn encode(&self, s: &S) { s.emit_uint(*self) } + fn encode(&self, s: &S) { + s.emit_uint(*self) + } } +#[cfg(not(stage0))] +impl Encodable for uint { + fn encode(&self, s: &mut S) { + s.emit_uint(*self) + } +} + +#[cfg(stage0)] impl Decodable for uint { fn decode(d: &D) -> uint { d.read_uint() } } +#[cfg(not(stage0))] +impl Decodable for uint { + fn decode(d: &mut D) -> uint { + d.read_uint() + } +} + +#[cfg(stage0)] impl Encodable for u8 { - fn encode(&self, s: &S) { s.emit_u8(*self) } + fn encode(&self, s: &S) { + s.emit_u8(*self) + } +} + +#[cfg(not(stage0))] +impl Encodable for u8 { + fn encode(&self, s: &mut S) { + s.emit_u8(*self) + } } +#[cfg(stage0)] impl Decodable for u8 { fn decode(d: &D) -> u8 { d.read_u8() } } +#[cfg(not(stage0))] +impl Decodable for u8 { + fn decode(d: &mut D) -> u8 { + d.read_u8() + } +} + +#[cfg(stage0)] impl Encodable for u16 { - fn encode(&self, s: &S) { s.emit_u16(*self) } + fn encode(&self, s: &S) { + s.emit_u16(*self) + } +} + +#[cfg(not(stage0))] +impl Encodable for u16 { + fn encode(&self, s: &mut S) { + s.emit_u16(*self) + } } +#[cfg(stage0)] impl Decodable for u16 { fn decode(d: &D) -> u16 { d.read_u16() } } +#[cfg(not(stage0))] +impl Decodable for u16 { + fn decode(d: &mut D) -> u16 { + d.read_u16() + } +} + +#[cfg(stage0)] impl Encodable for u32 { - fn encode(&self, s: &S) { s.emit_u32(*self) } + fn encode(&self, s: &S) { + s.emit_u32(*self) + } +} + +#[cfg(not(stage0))] +impl Encodable for u32 { + fn encode(&self, s: &mut S) { + s.emit_u32(*self) + } } +#[cfg(stage0)] impl Decodable for u32 { fn decode(d: &D) -> u32 { d.read_u32() } } +#[cfg(not(stage0))] +impl Decodable for u32 { + fn decode(d: &mut D) -> u32 { + d.read_u32() + } +} + +#[cfg(stage0)] +impl Encodable for u64 { + fn encode(&self, s: &S) { + s.emit_u64(*self) + } +} + +#[cfg(not(stage0))] impl Encodable for u64 { - fn encode(&self, s: &S) { s.emit_u64(*self) } + fn encode(&self, s: &mut S) { + s.emit_u64(*self) + } } +#[cfg(stage0)] impl Decodable for u64 { fn decode(d: &D) -> u64 { d.read_u64() } } +#[cfg(not(stage0))] +impl Decodable for u64 { + fn decode(d: &mut D) -> u64 { + d.read_u64() + } +} + +#[cfg(stage0)] impl Encodable for int { - fn encode(&self, s: &S) { s.emit_int(*self) } + fn encode(&self, s: &S) { + s.emit_int(*self) + } } +#[cfg(not(stage0))] +impl Encodable for int { + fn encode(&self, s: &mut S) { + s.emit_int(*self) + } +} + +#[cfg(stage0)] impl Decodable for int { fn decode(d: &D) -> int { d.read_int() } } +#[cfg(not(stage0))] +impl Decodable for int { + fn decode(d: &mut D) -> int { + d.read_int() + } +} + +#[cfg(stage0)] +impl Encodable for i8 { + fn encode(&self, s: &S) { + s.emit_i8(*self) + } +} + +#[cfg(not(stage0))] impl Encodable for i8 { - fn encode(&self, s: &S) { s.emit_i8(*self) } + fn encode(&self, s: &mut S) { + s.emit_i8(*self) + } } +#[cfg(stage0)] impl Decodable for i8 { fn decode(d: &D) -> i8 { d.read_i8() } } +#[cfg(not(stage0))] +impl Decodable for i8 { + fn decode(d: &mut D) -> i8 { + d.read_i8() + } +} + +#[cfg(stage0)] +impl Encodable for i16 { + fn encode(&self, s: &S) { + s.emit_i16(*self) + } +} + +#[cfg(not(stage0))] impl Encodable for i16 { - fn encode(&self, s: &S) { s.emit_i16(*self) } + fn encode(&self, s: &mut S) { + s.emit_i16(*self) + } } +#[cfg(stage0)] impl Decodable for i16 { fn decode(d: &D) -> i16 { d.read_i16() } } +#[cfg(not(stage0))] +impl Decodable for i16 { + fn decode(d: &mut D) -> i16 { + d.read_i16() + } +} + +#[cfg(stage0)] +impl Encodable for i32 { + fn encode(&self, s: &S) { + s.emit_i32(*self) + } +} + +#[cfg(not(stage0))] impl Encodable for i32 { - fn encode(&self, s: &S) { s.emit_i32(*self) } + fn encode(&self, s: &mut S) { + s.emit_i32(*self) + } } +#[cfg(stage0)] impl Decodable for i32 { fn decode(d: &D) -> i32 { d.read_i32() } } +#[cfg(not(stage0))] +impl Decodable for i32 { + fn decode(d: &mut D) -> i32 { + d.read_i32() + } +} + +#[cfg(stage0)] impl Encodable for i64 { - fn encode(&self, s: &S) { s.emit_i64(*self) } + fn encode(&self, s: &S) { + s.emit_i64(*self) + } +} + +#[cfg(not(stage0))] +impl Encodable for i64 { + fn encode(&self, s: &mut S) { + s.emit_i64(*self) + } } +#[cfg(stage0)] impl Decodable for i64 { fn decode(d: &D) -> i64 { d.read_i64() } } +#[cfg(not(stage0))] +impl Decodable for i64 { + fn decode(d: &mut D) -> i64 { + d.read_i64() + } +} + +#[cfg(stage0)] impl<'self, S:Encoder> Encodable for &'self str { - fn encode(&self, s: &S) { s.emit_str(*self) } + fn encode(&self, s: &S) { + s.emit_str(*self) + } } +#[cfg(not(stage0))] +impl<'self, S:Encoder> Encodable for &'self str { + fn encode(&self, s: &mut S) { + s.emit_str(*self) + } +} + +#[cfg(stage0)] +impl Encodable for ~str { + fn encode(&self, s: &S) { + s.emit_str(*self) + } +} + +#[cfg(not(stage0))] impl Encodable for ~str { - fn encode(&self, s: &S) { s.emit_str(*self) } + fn encode(&self, s: &mut S) { + s.emit_str(*self) + } } +#[cfg(stage0)] impl Decodable for ~str { fn decode(d: &D) -> ~str { d.read_str() } } +#[cfg(not(stage0))] +impl Decodable for ~str { + fn decode(d: &mut D) -> ~str { + d.read_str() + } +} + +#[cfg(stage0)] +impl Encodable for @str { + fn encode(&self, s: &S) { + s.emit_str(*self) + } +} + +#[cfg(not(stage0))] impl Encodable for @str { - fn encode(&self, s: &S) { s.emit_str(*self) } + fn encode(&self, s: &mut S) { + s.emit_str(*self) + } } +#[cfg(stage0)] impl Decodable for @str { - fn decode(d: &D) -> @str { d.read_str().to_managed() } + fn decode(d: &D) -> @str { + d.read_str().to_managed() + } } +#[cfg(not(stage0))] +impl Decodable for @str { + fn decode(d: &mut D) -> @str { + d.read_str().to_managed() + } +} + +#[cfg(stage0)] impl Encodable for float { - fn encode(&self, s: &S) { s.emit_float(*self) } + fn encode(&self, s: &S) { + s.emit_float(*self) + } } +#[cfg(not(stage0))] +impl Encodable for float { + fn encode(&self, s: &mut S) { + s.emit_float(*self) + } +} + +#[cfg(stage0)] impl Decodable for float { fn decode(d: &D) -> float { d.read_float() } } +#[cfg(not(stage0))] +impl Decodable for float { + fn decode(d: &mut D) -> float { + d.read_float() + } +} + +#[cfg(stage0)] +impl Encodable for f32 { + fn encode(&self, s: &S) { + s.emit_f32(*self) + } +} + +#[cfg(not(stage0))] impl Encodable for f32 { - fn encode(&self, s: &S) { s.emit_f32(*self) } + fn encode(&self, s: &mut S) { + s.emit_f32(*self) + } } +#[cfg(stage0)] impl Decodable for f32 { fn decode(d: &D) -> f32 { - d.read_f32() } + d.read_f32() + } } +#[cfg(not(stage0))] +impl Decodable for f32 { + fn decode(d: &mut D) -> f32 { + d.read_f32() + } +} + +#[cfg(stage0)] +impl Encodable for f64 { + fn encode(&self, s: &S) { + s.emit_f64(*self) + } +} + +#[cfg(not(stage0))] impl Encodable for f64 { - fn encode(&self, s: &S) { s.emit_f64(*self) } + fn encode(&self, s: &mut S) { + s.emit_f64(*self) + } } +#[cfg(stage0)] impl Decodable for f64 { fn decode(d: &D) -> f64 { d.read_f64() } } +#[cfg(not(stage0))] +impl Decodable for f64 { + fn decode(d: &mut D) -> f64 { + d.read_f64() + } +} + +#[cfg(stage0)] +impl Encodable for bool { + fn encode(&self, s: &S) { + s.emit_bool(*self) + } +} + +#[cfg(not(stage0))] impl Encodable for bool { - fn encode(&self, s: &S) { s.emit_bool(*self) } + fn encode(&self, s: &mut S) { + s.emit_bool(*self) + } } +#[cfg(stage0)] impl Decodable for bool { fn decode(d: &D) -> bool { d.read_bool() } } +#[cfg(not(stage0))] +impl Decodable for bool { + fn decode(d: &mut D) -> bool { + d.read_bool() + } +} + +#[cfg(stage0)] impl Encodable for () { - fn encode(&self, s: &S) { s.emit_nil() } + fn encode(&self, s: &S) { + s.emit_nil() + } } +#[cfg(not(stage0))] +impl Encodable for () { + fn encode(&self, s: &mut S) { + s.emit_nil() + } +} + +#[cfg(stage0)] impl Decodable for () { fn decode(d: &D) -> () { d.read_nil() } } +#[cfg(not(stage0))] +impl Decodable for () { + fn decode(d: &mut D) -> () { + d.read_nil() + } +} + +#[cfg(stage0)] impl<'self, S:Encoder,T:Encodable> Encodable for &'self T { fn encode(&self, s: &S) { (**self).encode(s) } } +#[cfg(not(stage0))] +impl<'self, S:Encoder,T:Encodable> Encodable for &'self T { + fn encode(&self, s: &mut S) { + (**self).encode(s) + } +} + +#[cfg(stage0)] impl> Encodable for ~T { fn encode(&self, s: &S) { (**self).encode(s) } } +#[cfg(not(stage0))] +impl> Encodable for ~T { + fn encode(&self, s: &mut S) { + (**self).encode(s) + } +} + +#[cfg(stage0)] impl> Decodable for ~T { fn decode(d: &D) -> ~T { ~Decodable::decode(d) } } +#[cfg(not(stage0))] +impl> Decodable for ~T { + fn decode(d: &mut D) -> ~T { + ~Decodable::decode(d) + } +} + +#[cfg(stage0)] impl> Encodable for @T { fn encode(&self, s: &S) { (**self).encode(s) } } +#[cfg(not(stage0))] +impl> Encodable for @T { + fn encode(&self, s: &mut S) { + (**self).encode(s) + } +} + +#[cfg(stage0)] impl> Decodable for @T { fn decode(d: &D) -> @T { @Decodable::decode(d) } } +#[cfg(not(stage0))] +impl> Decodable for @T { + fn decode(d: &mut D) -> @T { + @Decodable::decode(d) + } +} + +#[cfg(stage0)] impl<'self, S:Encoder,T:Encodable> Encodable for &'self [T] { fn encode(&self, s: &S) { do s.emit_seq(self.len()) { @@ -354,6 +909,18 @@ impl<'self, S:Encoder,T:Encodable> Encodable for &'self [T] { } } +#[cfg(not(stage0))] +impl<'self, S:Encoder,T:Encodable> Encodable for &'self [T] { + fn encode(&self, s: &mut S) { + do s.emit_seq(self.len()) |s| { + for self.eachi |i, e| { + s.emit_seq_elt(i, |s| e.encode(s)) + } + } + } +} + +#[cfg(stage0)] impl> Encodable for ~[T] { fn encode(&self, s: &S) { do s.emit_seq(self.len()) { @@ -364,6 +931,18 @@ impl> Encodable for ~[T] { } } +#[cfg(not(stage0))] +impl> Encodable for ~[T] { + fn encode(&self, s: &mut S) { + do s.emit_seq(self.len()) |s| { + for self.eachi |i, e| { + s.emit_seq_elt(i, |s| e.encode(s)) + } + } + } +} + +#[cfg(stage0)] impl> Decodable for ~[T] { fn decode(d: &D) -> ~[T] { do d.read_seq |len| { @@ -374,6 +953,18 @@ impl> Decodable for ~[T] { } } +#[cfg(not(stage0))] +impl> Decodable for ~[T] { + fn decode(d: &mut D) -> ~[T] { + do d.read_seq |d, len| { + do vec::from_fn(len) |i| { + d.read_seq_elt(i, |d| Decodable::decode(d)) + } + } + } +} + +#[cfg(stage0)] impl> Encodable for @[T] { fn encode(&self, s: &S) { do s.emit_seq(self.len()) { @@ -384,6 +975,18 @@ impl> Encodable for @[T] { } } +#[cfg(not(stage0))] +impl> Encodable for @[T] { + fn encode(&self, s: &mut S) { + do s.emit_seq(self.len()) |s| { + for self.eachi |i, e| { + s.emit_seq_elt(i, |s| e.encode(s)) + } + } + } +} + +#[cfg(stage0)] impl> Decodable for @[T] { fn decode(d: &D) -> @[T] { do d.read_seq |len| { @@ -394,6 +997,18 @@ impl> Decodable for @[T] { } } +#[cfg(not(stage0))] +impl> Decodable for @[T] { + fn decode(d: &mut D) -> @[T] { + do d.read_seq |d, len| { + do at_vec::from_fn(len) |i| { + d.read_seq_elt(i, |d| Decodable::decode(d)) + } + } + } +} + +#[cfg(stage0)] impl> Encodable for Option { fn encode(&self, s: &S) { do s.emit_option { @@ -405,6 +1020,19 @@ impl> Encodable for Option { } } +#[cfg(not(stage0))] +impl> Encodable for Option { + fn encode(&self, s: &mut S) { + do s.emit_option |s| { + match *self { + None => s.emit_option_none(), + Some(ref v) => s.emit_option_some(|s| v.encode(s)), + } + } + } +} + +#[cfg(stage0)] impl> Decodable for Option { fn decode(d: &D) -> Option { do d.read_option |b| { @@ -417,6 +1045,20 @@ impl> Decodable for Option { } } +#[cfg(not(stage0))] +impl> Decodable for Option { + fn decode(d: &mut D) -> Option { + do d.read_option |d, b| { + if b { + Some(Decodable::decode(d)) + } else { + None + } + } + } +} + +#[cfg(stage0)] impl,T1:Encodable> Encodable for (T0, T1) { fn encode(&self, s: &S) { match *self { @@ -430,6 +1072,21 @@ impl,T1:Encodable> Encodable for (T0, T1) { } } +#[cfg(not(stage0))] +impl,T1:Encodable> Encodable for (T0, T1) { + fn encode(&self, s: &mut S) { + match *self { + (ref t0, ref t1) => { + do s.emit_seq(2) |s| { + s.emit_seq_elt(0, |s| t0.encode(s)); + s.emit_seq_elt(1, |s| t1.encode(s)); + } + } + } + } +} + +#[cfg(stage0)] impl,T1:Decodable> Decodable for (T0, T1) { fn decode(d: &D) -> (T0, T1) { do d.read_seq |len| { @@ -442,6 +1099,20 @@ impl,T1:Decodable> Decodable for (T0, T1) { } } +#[cfg(not(stage0))] +impl,T1:Decodable> Decodable for (T0, T1) { + fn decode(d: &mut D) -> (T0, T1) { + do d.read_seq |d, len| { + assert!(len == 2); + ( + d.read_seq_elt(0, |d| Decodable::decode(d)), + d.read_seq_elt(1, |d| Decodable::decode(d)) + ) + } + } +} + +#[cfg(stage0)] impl< S: Encoder, T0: Encodable, @@ -461,6 +1132,27 @@ impl< } } +#[cfg(not(stage0))] +impl< + S: Encoder, + T0: Encodable, + T1: Encodable, + T2: Encodable +> Encodable for (T0, T1, T2) { + fn encode(&self, s: &mut S) { + match *self { + (ref t0, ref t1, ref t2) => { + do s.emit_seq(3) |s| { + s.emit_seq_elt(0, |s| t0.encode(s)); + s.emit_seq_elt(1, |s| t1.encode(s)); + s.emit_seq_elt(2, |s| t2.encode(s)); + } + } + } + } +} + +#[cfg(stage0)] impl< D: Decoder, T0: Decodable, @@ -479,6 +1171,26 @@ impl< } } +#[cfg(not(stage0))] +impl< + D: Decoder, + T0: Decodable, + T1: Decodable, + T2: Decodable +> Decodable for (T0, T1, T2) { + fn decode(d: &mut D) -> (T0, T1, T2) { + do d.read_seq |d, len| { + assert!(len == 3); + ( + d.read_seq_elt(0, |d| Decodable::decode(d)), + d.read_seq_elt(1, |d| Decodable::decode(d)), + d.read_seq_elt(2, |d| Decodable::decode(d)) + ) + } + } +} + +#[cfg(stage0)] impl< S: Encoder, T0: Encodable, @@ -500,6 +1212,29 @@ impl< } } +#[cfg(not(stage0))] +impl< + S: Encoder, + T0: Encodable, + T1: Encodable, + T2: Encodable, + T3: Encodable +> Encodable for (T0, T1, T2, T3) { + fn encode(&self, s: &mut S) { + match *self { + (ref t0, ref t1, ref t2, ref t3) => { + do s.emit_seq(4) |s| { + s.emit_seq_elt(0, |s| t0.encode(s)); + s.emit_seq_elt(1, |s| t1.encode(s)); + s.emit_seq_elt(2, |s| t2.encode(s)); + s.emit_seq_elt(3, |s| t3.encode(s)); + } + } + } + } +} + +#[cfg(stage0)] impl< D: Decoder, T0: Decodable, @@ -520,6 +1255,28 @@ impl< } } +#[cfg(not(stage0))] +impl< + D: Decoder, + T0: Decodable, + T1: Decodable, + T2: Decodable, + T3: Decodable +> Decodable for (T0, T1, T2, T3) { + fn decode(d: &mut D) -> (T0, T1, T2, T3) { + do d.read_seq |d, len| { + assert!(len == 4); + ( + d.read_seq_elt(0, |d| Decodable::decode(d)), + d.read_seq_elt(1, |d| Decodable::decode(d)), + d.read_seq_elt(2, |d| Decodable::decode(d)), + d.read_seq_elt(3, |d| Decodable::decode(d)) + ) + } + } +} + +#[cfg(stage0)] impl< S: Encoder, T0: Encodable, @@ -543,6 +1300,31 @@ impl< } } +#[cfg(not(stage0))] +impl< + S: Encoder, + T0: Encodable, + T1: Encodable, + T2: Encodable, + T3: Encodable, + T4: Encodable +> Encodable for (T0, T1, T2, T3, T4) { + fn encode(&self, s: &mut S) { + match *self { + (ref t0, ref t1, ref t2, ref t3, ref t4) => { + do s.emit_seq(5) |s| { + s.emit_seq_elt(0, |s| t0.encode(s)); + s.emit_seq_elt(1, |s| t1.encode(s)); + s.emit_seq_elt(2, |s| t2.encode(s)); + s.emit_seq_elt(3, |s| t3.encode(s)); + s.emit_seq_elt(4, |s| t4.encode(s)); + } + } + } + } +} + +#[cfg(stage0)] impl< D: Decoder, T0: Decodable, @@ -551,8 +1333,7 @@ impl< T3: Decodable, T4: Decodable > Decodable for (T0, T1, T2, T3, T4) { - fn decode(d: &D) - -> (T0, T1, T2, T3, T4) { + fn decode(d: &D) -> (T0, T1, T2, T3, T4) { do d.read_seq |len| { assert!(len == 5); ( @@ -566,6 +1347,30 @@ impl< } } +#[cfg(not(stage0))] +impl< + D: Decoder, + T0: Decodable, + T1: Decodable, + T2: Decodable, + T3: Decodable, + T4: Decodable +> Decodable for (T0, T1, T2, T3, T4) { + fn decode(d: &mut D) -> (T0, T1, T2, T3, T4) { + do d.read_seq |d, len| { + assert!(len == 5); + ( + d.read_seq_elt(0, |d| Decodable::decode(d)), + d.read_seq_elt(1, |d| Decodable::decode(d)), + d.read_seq_elt(2, |d| Decodable::decode(d)), + d.read_seq_elt(3, |d| Decodable::decode(d)), + d.read_seq_elt(4, |d| Decodable::decode(d)) + ) + } + } +} + +#[cfg(stage0)] impl< S: Encoder, T: Encodable + Copy @@ -581,6 +1386,23 @@ impl< } } +#[cfg(not(stage0))] +impl< + S: Encoder, + T: Encodable + Copy +> Encodable for @mut DList { + fn encode(&self, s: &mut S) { + do s.emit_seq(self.size) |s| { + let mut i = 0; + for self.each |e| { + s.emit_seq_elt(i, |s| e.encode(s)); + i += 1; + } + } + } +} + +#[cfg(stage0)] impl> Decodable for @mut DList { fn decode(d: &D) -> @mut DList { let list = DList(); @@ -593,6 +1415,20 @@ impl> Decodable for @mut DList { } } +#[cfg(not(stage0))] +impl> Decodable for @mut DList { + fn decode(d: &mut D) -> @mut DList { + let list = DList(); + do d.read_seq |d, len| { + for uint::range(0, len) |i| { + list.push(d.read_seq_elt(i, |d| Decodable::decode(d))); + } + } + list + } +} + +#[cfg(stage0)] impl< S: Encoder, T: Encodable @@ -606,6 +1442,21 @@ impl< } } +#[cfg(not(stage0))] +impl< + S: Encoder, + T: Encodable +> Encodable for Deque { + fn encode(&self, s: &mut S) { + do s.emit_seq(self.len()) |s| { + for self.eachi |i, e| { + s.emit_seq_elt(i, |s| e.encode(s)); + } + } + } +} + +#[cfg(stage0)] impl> Decodable for Deque { fn decode(d: &D) -> Deque { let mut deque = Deque::new(); @@ -618,6 +1469,20 @@ impl> Decodable for Deque { } } +#[cfg(not(stage0))] +impl> Decodable for Deque { + fn decode(d: &mut D) -> Deque { + let mut deque = Deque::new(); + do d.read_seq |d, len| { + for uint::range(0, len) |i| { + deque.add_back(d.read_seq_elt(i, |d| Decodable::decode(d))); + } + } + deque + } +} + +#[cfg(stage0)] impl< E: Encoder, K: Encodable + Hash + IterBytes + Eq, @@ -635,6 +1500,25 @@ impl< } } +#[cfg(not(stage0))] +impl< + E: Encoder, + K: Encodable + Hash + IterBytes + Eq, + V: Encodable +> Encodable for HashMap { + fn encode(&self, e: &mut E) { + do e.emit_map(self.len()) |e| { + let mut i = 0; + for self.each |key, val| { + e.emit_map_elt_key(i, |e| key.encode(e)); + e.emit_map_elt_val(i, |e| val.encode(e)); + i += 1; + } + } + } +} + +#[cfg(stage0)] impl< D: Decoder, K: Decodable + Hash + IterBytes + Eq, @@ -653,6 +1537,26 @@ impl< } } +#[cfg(not(stage0))] +impl< + D: Decoder, + K: Decodable + Hash + IterBytes + Eq, + V: Decodable +> Decodable for HashMap { + fn decode(d: &mut D) -> HashMap { + do d.read_map |d, len| { + let mut map = HashMap::with_capacity(len); + for uint::range(0, len) |i| { + let key = d.read_map_elt_key(i, |d| Decodable::decode(d)); + let val = d.read_map_elt_val(i, |d| Decodable::decode(d)); + map.insert(key, val); + } + map + } + } +} + +#[cfg(stage0)] impl< S: Encoder, T: Encodable + Hash + IterBytes + Eq @@ -668,6 +1572,23 @@ impl< } } +#[cfg(not(stage0))] +impl< + S: Encoder, + T: Encodable + Hash + IterBytes + Eq +> Encodable for HashSet { + fn encode(&self, s: &mut S) { + do s.emit_seq(self.len()) |s| { + let mut i = 0; + for self.each |e| { + s.emit_seq_elt(i, |s| e.encode(s)); + i += 1; + } + } + } +} + +#[cfg(stage0)] impl< D: Decoder, T: Decodable + Hash + IterBytes + Eq @@ -683,6 +1604,23 @@ impl< } } +#[cfg(not(stage0))] +impl< + D: Decoder, + T: Decodable + Hash + IterBytes + Eq +> Decodable for HashSet { + fn decode(d: &mut D) -> HashSet { + do d.read_seq |d, len| { + let mut set = HashSet::with_capacity(len); + for uint::range(0, len) |i| { + set.insert(d.read_seq_elt(i, |d| Decodable::decode(d))); + } + set + } + } +} + +#[cfg(stage0)] impl< E: Encoder, V: Encodable @@ -699,6 +1637,24 @@ impl< } } +#[cfg(not(stage0))] +impl< + E: Encoder, + V: Encodable +> Encodable for TrieMap { + fn encode(&self, e: &mut E) { + do e.emit_map(self.len()) |e| { + let mut i = 0; + for self.each |key, val| { + e.emit_map_elt_key(i, |e| key.encode(e)); + e.emit_map_elt_val(i, |e| val.encode(e)); + i += 1; + } + } + } +} + +#[cfg(stage0)] impl< D: Decoder, V: Decodable @@ -716,6 +1672,25 @@ impl< } } +#[cfg(not(stage0))] +impl< + D: Decoder, + V: Decodable +> Decodable for TrieMap { + fn decode(d: &mut D) -> TrieMap { + do d.read_map |d, len| { + let mut map = TrieMap::new(); + for uint::range(0, len) |i| { + let key = d.read_map_elt_key(i, |d| Decodable::decode(d)); + let val = d.read_map_elt_val(i, |d| Decodable::decode(d)); + map.insert(key, val); + } + map + } + } +} + +#[cfg(stage0)] impl Encodable for TrieSet { fn encode(&self, s: &S) { do s.emit_seq(self.len()) { @@ -728,6 +1703,20 @@ impl Encodable for TrieSet { } } +#[cfg(not(stage0))] +impl Encodable for TrieSet { + fn encode(&self, s: &mut S) { + do s.emit_seq(self.len()) |s| { + let mut i = 0; + for self.each |e| { + s.emit_seq_elt(i, |s| e.encode(s)); + i += 1; + } + } + } +} + +#[cfg(stage0)] impl Decodable for TrieSet { fn decode(d: &D) -> TrieSet { do d.read_seq |len| { @@ -740,40 +1729,49 @@ impl Decodable for TrieSet { } } -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] +#[cfg(not(stage0))] +impl Decodable for TrieSet { + fn decode(d: &mut D) -> TrieSet { + do d.read_seq |d, len| { + let mut set = TrieSet::new(); + for uint::range(0, len) |i| { + set.insert(d.read_seq_elt(i, |d| Decodable::decode(d))); + } + set + } + } +} + +#[cfg(not(stage0))] impl< E: Encoder, K: Encodable + Eq + TotalOrd, V: Encodable + Eq > Encodable for TreeMap { - fn encode(&self, e: &E) { - do e.emit_map(self.len()) { + fn encode(&self, e: &mut E) { + do e.emit_map(self.len()) |e| { let mut i = 0; for self.each |key, val| { - e.emit_map_elt_key(i, || key.encode(e)); - e.emit_map_elt_val(i, || val.encode(e)); + e.emit_map_elt_key(i, |e| key.encode(e)); + e.emit_map_elt_val(i, |e| val.encode(e)); i += 1; } } } } -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] +#[cfg(not(stage0))] impl< D: Decoder, K: Decodable + Eq + TotalOrd, V: Decodable + Eq > Decodable for TreeMap { - fn decode(d: &D) -> TreeMap { - do d.read_map |len| { + fn decode(d: &mut D) -> TreeMap { + do d.read_map |d, len| { let mut map = TreeMap::new(); for uint::range(0, len) |i| { - let key = d.read_map_elt_key(i, || Decodable::decode(d)); - let val = d.read_map_elt_val(i, || Decodable::decode(d)); + let key = d.read_map_elt_key(i, |d| Decodable::decode(d)); + let val = d.read_map_elt_val(i, |d| Decodable::decode(d)); map.insert(key, val); } map @@ -781,36 +1779,32 @@ impl< } } -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] +#[cfg(not(stage0))] impl< S: Encoder, T: Encodable + Eq + TotalOrd > Encodable for TreeSet { - fn encode(&self, s: &S) { - do s.emit_seq(self.len()) { + fn encode(&self, s: &mut S) { + do s.emit_seq(self.len()) |s| { let mut i = 0; for self.each |e| { - s.emit_seq_elt(i, || e.encode(s)); + s.emit_seq_elt(i, |s| e.encode(s)); i += 1; } } } } -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] +#[cfg(not(stage0))] impl< D: Decoder, T: Decodable + Eq + TotalOrd > Decodable for TreeSet { - fn decode(d: &D) -> TreeSet { - do d.read_seq |len| { + fn decode(d: &mut D) -> TreeSet { + do d.read_seq |d, len| { let mut set = TreeSet::new(); for uint::range(0, len) |i| { - set.insert(d.read_seq_elt(i, || Decodable::decode(d))); + set.insert(d.read_seq_elt(i, |d| Decodable::decode(d))); } set } @@ -822,10 +1816,17 @@ impl< // // In some cases, these should eventually be coded as traits. +#[cfg(stage0)] pub trait EncoderHelpers { fn emit_from_vec(&self, v: &[T], f: &fn(v: &T)); } +#[cfg(not(stage0))] +pub trait EncoderHelpers { + fn emit_from_vec(&mut self, v: &[T], f: &fn(&mut Self, v: &T)); +} + +#[cfg(stage0)] impl EncoderHelpers for S { fn emit_from_vec(&self, v: &[T], f: &fn(v: &T)) { do self.emit_seq(v.len()) { @@ -838,10 +1839,30 @@ impl EncoderHelpers for S { } } +#[cfg(not(stage0))] +impl EncoderHelpers for S { + fn emit_from_vec(&mut self, v: &[T], f: &fn(&mut S, &T)) { + do self.emit_seq(v.len()) |this| { + for v.eachi |i, e| { + do this.emit_seq_elt(i) |this| { + f(this, e) + } + } + } + } +} + +#[cfg(stage0)] pub trait DecoderHelpers { fn read_to_vec(&self, f: &fn() -> T) -> ~[T]; } +#[cfg(not(stage0))] +pub trait DecoderHelpers { + fn read_to_vec(&mut self, f: &fn(&mut Self) -> T) -> ~[T]; +} + +#[cfg(stage0)] impl DecoderHelpers for D { fn read_to_vec(&self, f: &fn() -> T) -> ~[T] { do self.read_seq |len| { @@ -851,3 +1872,15 @@ impl DecoderHelpers for D { } } } + +#[cfg(not(stage0))] +impl DecoderHelpers for D { + fn read_to_vec(&mut self, f: &fn(&mut D) -> T) -> ~[T] { + do self.read_seq |this, len| { + do vec::from_fn(len) |i| { + this.read_seq_elt(i, |this| f(this)) + } + } + } +} + diff --git a/src/libstd/workcache.rs b/src/libstd/workcache.rs index bb4a9e97ea1..2cdf36c71c7 100644 --- a/src/libstd/workcache.rs +++ b/src/libstd/workcache.rs @@ -140,6 +140,7 @@ impl WorkMap { fn new() -> WorkMap { WorkMap(HashMap::new()) } } +#[cfg(stage0)] impl Encodable for WorkMap { fn encode(&self, s: &S) { let mut d = ~[]; @@ -151,6 +152,19 @@ impl Encodable for WorkMap { } } +#[cfg(not(stage0))] +impl Encodable for WorkMap { + fn encode(&self, s: &mut S) { + let mut d = ~[]; + for self.each |k, v| { + d.push((copy *k, copy *v)) + } + sort::tim_sort(d); + d.encode(s) + } +} + +#[cfg(stage0)] impl Decodable for WorkMap { fn decode(d: &D) -> WorkMap { let v : ~[(WorkKey,~str)] = Decodable::decode(d); @@ -162,6 +176,18 @@ impl Decodable for WorkMap { } } +#[cfg(not(stage0))] +impl Decodable for WorkMap { + fn decode(d: &mut D) -> WorkMap { + let v : ~[(WorkKey,~str)] = Decodable::decode(d); + let mut w = WorkMap::new(); + for v.each |&(k, v)| { + w.insert(copy k, copy v); + } + w + } +} + struct Database { db_filename: Path, db_cache: HashMap<~str, ~str>, @@ -171,8 +197,8 @@ struct Database { pub impl Database { fn prepare(&mut self, fn_name: &str, - declared_inputs: &WorkMap) -> Option<(WorkMap, WorkMap, ~str)> - { + declared_inputs: &WorkMap) + -> Option<(WorkMap, WorkMap, ~str)> { let k = json_encode(&(fn_name, declared_inputs)); match self.db_cache.find(&k) { None => None, @@ -229,17 +255,38 @@ struct Work { res: Option>> } +#[cfg(stage0)] fn json_encode>(t: &T) -> ~str { do io::with_str_writer |wr| { t.encode(&json::Encoder(wr)); } } +#[cfg(not(stage0))] +fn json_encode>(t: &T) -> ~str { + do io::with_str_writer |wr| { + let mut encoder = json::Encoder(wr); + t.encode(&mut encoder); + } +} + +// FIXME(#5121) +#[cfg(stage0)] +fn json_decode>(s: &str) -> T { + do io::with_str_reader(s) |rdr| { + let j = result::unwrap(json::from_reader(rdr)); + let decoder = json::Decoder(j); + Decodable::decode(&decoder) + } +} + // FIXME(#5121) +#[cfg(not(stage0))] fn json_decode>(s: &str) -> T { do io::with_str_reader(s) |rdr| { let j = result::unwrap(json::from_reader(rdr)); - Decodable::decode(&json::Decoder(j)) + let mut decoder = json::Decoder(j); + Decodable::decode(&mut decoder) } } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index a295952439f..77e79866160 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -70,21 +70,53 @@ pub type Name = uint; // with a macro expansion pub type Mrk = uint; +#[cfg(stage0)] impl Encodable for ident { fn encode(&self, s: &S) { + unsafe { + let intr = + match task::local_data::local_data_get(interner_key!()) { + None => fail!(~"encode: TLS interner not set up"), + Some(intr) => intr + }; + + s.emit_str(*(*intr).get(*self)); + } + } +} + +#[cfg(not(stage0))] +impl Encodable for ident { + fn encode(&self, s: &mut S) { + unsafe { + let intr = + match task::local_data::local_data_get(interner_key!()) { + None => fail!(~"encode: TLS interner not set up"), + Some(intr) => intr + }; + + s.emit_str(*(*intr).get(*self)); + } + } +} + +#[cfg(stage0)] +impl Decodable for ident { + fn decode(d: &D) -> ident { let intr = match unsafe { task::local_data::local_data_get(interner_key!()) } { - None => fail!(~"encode: TLS interner not set up"), + None => fail!(~"decode: TLS interner not set up"), Some(intr) => intr }; - s.emit_str(*(*intr).get(*self)); + (*intr).intern(@d.read_str()) } } +#[cfg(not(stage0))] impl Decodable for ident { - fn decode(d: &D) -> ident { + fn decode(d: &mut D) -> ident { let intr = match unsafe { task::local_data::local_data_get(interner_key!()) } { diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 5f4967351e1..bbb390e9dc9 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -125,17 +125,34 @@ impl cmp::Eq for span { fn ne(&self, other: &span) -> bool { !(*self).eq(other) } } +#[cfg(stage0)] impl Encodable for span { /* Note #1972 -- spans are encoded but not decoded */ fn encode(&self, _s: &S) { _s.emit_nil() } } +#[cfg(not(stage0))] +impl Encodable for span { + /* Note #1972 -- spans are encoded but not decoded */ + fn encode(&self, s: &mut S) { + s.emit_nil() + } +} + +#[cfg(stage0)] impl Decodable for span { fn decode(_d: &D) -> span { dummy_sp() } } +#[cfg(not(stage0))] +impl Decodable for span { + fn decode(_d: &mut D) -> span { + dummy_sp() + } +} + pub fn spanned(lo: BytePos, hi: BytePos, t: T) -> spanned { respan(mk_sp(lo, hi), t) } diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs index 2ceb6f0c4bb..bdf0a2a1dd0 100644 --- a/src/libsyntax/ext/auto_encode.rs +++ b/src/libsyntax/ext/auto_encode.rs @@ -238,7 +238,8 @@ trait ExtCtxtMethods { fn stmt(&self, expr: @ast::expr) -> @ast::stmt; fn lit_str(&self, span: span, s: @~str) -> @ast::expr; fn lit_uint(&self, span: span, i: uint) -> @ast::expr; - fn lambda(&self, blk: ast::blk) -> @ast::expr; + fn lambda0(&self, blk: ast::blk) -> @ast::expr; + fn lambda1(&self, blk: ast::blk, ident: ast::ident) -> @ast::expr; fn blk(&self, span: span, stmts: ~[@ast::stmt]) -> ast::blk; fn expr_blk(&self, expr: @ast::expr) -> ast::blk; fn expr_path(&self, span: span, strs: ~[ast::ident]) -> @ast::expr; @@ -254,8 +255,15 @@ trait ExtCtxtMethods { ident: ast::ident, args: ~[@ast::expr]) -> @ast::expr; - fn lambda_expr(&self, expr: @ast::expr) -> @ast::expr; - fn lambda_stmts(&self, span: span, stmts: ~[@ast::stmt]) -> @ast::expr; + fn lambda_expr_0(&self, expr: @ast::expr) -> @ast::expr; + fn lambda_expr_1(&self, expr: @ast::expr, ident: ast::ident) + -> @ast::expr; + fn lambda_stmts_0(&self, span: span, stmts: ~[@ast::stmt]) -> @ast::expr; + fn lambda_stmts_1(&self, + span: span, + stmts: ~[@ast::stmt], + ident: ast::ident) + -> @ast::expr; } impl ExtCtxtMethods for @ext_ctxt { @@ -388,12 +396,18 @@ impl ExtCtxtMethods for @ext_ctxt { span: span})) } - fn lambda(&self, blk: ast::blk) -> @ast::expr { + fn lambda0(&self, blk: ast::blk) -> @ast::expr { let ext_cx = *self; let blk_e = self.expr(copy blk.span, ast::expr_block(copy blk)); quote_expr!( || $blk_e ) } + fn lambda1(&self, blk: ast::blk, ident: ast::ident) -> @ast::expr { + let ext_cx = *self; + let blk_e = self.expr(copy blk.span, ast::expr_block(copy blk)); + quote_expr!( |$ident| $blk_e ) + } + fn blk(&self, span: span, stmts: ~[@ast::stmt]) -> ast::blk { codemap::spanned { node: ast::blk_ { @@ -461,15 +475,29 @@ impl ExtCtxtMethods for @ext_ctxt { ident: ast::ident, args: ~[@ast::expr] ) -> @ast::expr { - self.expr(span, ast::expr_method_call(expr, ident, ~[], args, ast::NoSugar)) + self.expr(span, + ast::expr_method_call(expr, ident, ~[], args, ast::NoSugar)) + } + + fn lambda_expr_0(&self, expr: @ast::expr) -> @ast::expr { + self.lambda0(self.expr_blk(expr)) + } + + fn lambda_expr_1(&self, expr: @ast::expr, ident: ast::ident) + -> @ast::expr { + self.lambda1(self.expr_blk(expr), ident) } - fn lambda_expr(&self, expr: @ast::expr) -> @ast::expr { - self.lambda(self.expr_blk(expr)) + fn lambda_stmts_0(&self, span: span, stmts: ~[@ast::stmt]) -> @ast::expr { + self.lambda0(self.blk(span, stmts)) } - fn lambda_stmts(&self, span: span, stmts: ~[@ast::stmt]) -> @ast::expr { - self.lambda(self.blk(span, stmts)) + fn lambda_stmts_1(&self, + span: span, + stmts: ~[@ast::stmt], + ident: ast::ident) + -> @ast::expr { + self.lambda1(self.blk(span, stmts), ident) } } @@ -644,7 +672,7 @@ fn mk_ser_method( None, ast::mt { ty: cx.ty_path(span, ~[cx.ident_of(~"__S")], ~[]), - mutbl: ast::m_imm + mutbl: ast::m_mutbl } ), span: span, @@ -706,7 +734,7 @@ fn mk_deser_method( None, ast::mt { ty: cx.ty_path(span, ~[cx.ident_of(~"__D")], ~[]), - mutbl: ast::m_imm + mutbl: ast::m_mutbl } ), span: span, @@ -758,8 +786,8 @@ fn mk_struct_ser_impl( generics: &ast::Generics ) -> @ast::item { let fields = do mk_struct_fields(fields).mapi |idx, field| { - // ast for `|| self.$(name).encode(__s)` - let expr_lambda = cx.lambda_expr( + // ast for `|__s| self.$(name).encode(__s)` + let expr_lambda = cx.lambda_expr_1( cx.expr_method_call( span, cx.expr_field( @@ -769,7 +797,8 @@ fn mk_struct_ser_impl( ), cx.ident_of(~"encode"), ~[cx.expr_var(span, ~"__s")] - ) + ), + cx.ident_of(~"__s") ); // ast for `__s.emit_struct_field($(name), $(idx), $(expr_lambda))` @@ -787,7 +816,7 @@ fn mk_struct_ser_impl( ) }; - // ast for `__s.emit_struct($(name), || $(fields))` + // ast for `__s.emit_struct($(name), |__s| $(fields))` let ser_body = cx.expr_method_call( span, cx.expr_var(span, ~"__s"), @@ -795,7 +824,7 @@ fn mk_struct_ser_impl( ~[ cx.lit_str(span, @cx.str_of(ident)), cx.lit_uint(span, vec::len(fields)), - cx.lambda_stmts(span, fields), + cx.lambda_stmts_1(span, fields, cx.ident_of(~"__s")), ] ); @@ -810,8 +839,8 @@ fn mk_struct_deser_impl( generics: &ast::Generics ) -> @ast::item { let fields = do mk_struct_fields(fields).mapi |idx, field| { - // ast for `|| std::serialize::decode(__d)` - let expr_lambda = cx.lambda( + // ast for `|__d| std::serialize::decode(__d)` + let expr_lambda = cx.lambda1( cx.expr_blk( cx.expr_call( span, @@ -823,7 +852,8 @@ fn mk_struct_deser_impl( ]), ~[cx.expr_var(span, ~"__d")] ) - ) + ), + cx.ident_of(~"__d") ); // ast for `__d.read_struct_field($(name), $(idx), $(expr_lambda))` @@ -848,7 +878,7 @@ fn mk_struct_deser_impl( } }; - // ast for `read_struct($(name), || $(fields))` + // ast for `read_struct($(name), |__d| $(fields))` let body = cx.expr_method_call( span, cx.expr_var(span, ~"__d"), @@ -856,7 +886,7 @@ fn mk_struct_deser_impl( ~[ cx.lit_str(span, @cx.str_of(ident)), cx.lit_uint(span, vec::len(fields)), - cx.lambda_expr( + cx.lambda_expr_1( cx.expr( span, ast::expr_struct( @@ -864,7 +894,8 @@ fn mk_struct_deser_impl( fields, None ) - ) + ), + cx.ident_of(~"__d") ), ] ); @@ -974,14 +1005,15 @@ fn ser_variant( cx.ident_of(~"emit_enum_variant_arg") ); - // ast for `|| $(v).encode(__s)` - let expr_encode = cx.lambda_expr( - cx.expr_method_call( + // ast for `|__s| $(v).encode(__s)` + let expr_encode = cx.lambda_expr_1( + cx.expr_method_call( span, cx.expr_path(span, ~[names[a_idx]]), cx.ident_of(~"encode"), ~[cx.expr_var(span, ~"__s")] - ) + ), + cx.ident_of(~"__s") ); // ast for `$(expr_emit)($(a_idx), $(expr_encode))` @@ -1003,7 +1035,7 @@ fn ser_variant( cx.lit_str(span, @cx.str_of(v_name)), cx.lit_uint(span, v_idx), cx.lit_uint(span, stmts.len()), - cx.lambda_stmts(span, stmts), + cx.lambda_stmts_1(span, stmts, cx.ident_of(~"__s")), ] ); @@ -1050,7 +1082,7 @@ fn mk_enum_ser_body( cx.ident_of(~"emit_enum"), ~[ cx.lit_str(span, @cx.str_of(name)), - cx.lambda_expr(match_expr), + cx.lambda_expr_1(match_expr, cx.ident_of(~"__s")), ] ) } @@ -1062,8 +1094,8 @@ fn mk_enum_deser_variant_nary( args: ~[ast::variant_arg] ) -> @ast::expr { let args = do args.mapi |idx, _arg| { - // ast for `|| std::serialize::decode(__d)` - let expr_lambda = cx.lambda_expr( + // ast for `|__s| std::serialize::decode(__d)` + let expr_lambda = cx.lambda_expr_1( cx.expr_call( span, cx.expr_path_global(span, ~[ @@ -1073,7 +1105,8 @@ fn mk_enum_deser_variant_nary( cx.ident_of(~"decode"), ]), ~[cx.expr_var(span, ~"__d")] - ) + ), + cx.ident_of(~"__d") ); // ast for `__d.read_enum_variant_arg($(a_idx), $(expr_lambda))` @@ -1163,24 +1196,44 @@ fn mk_enum_deser_body( span, ast::expr_fn_block( ast::fn_decl { - inputs: ~[ast::arg { - is_mutbl: false, - ty: @ast::Ty { + inputs: ~[ + ast::arg { + is_mutbl: false, + ty: @ast::Ty { + id: ext_cx.next_id(), + node: ast::ty_infer, + span: span + }, + pat: @ast::pat { + id: ext_cx.next_id(), + node: ast::pat_ident( + ast::bind_by_copy, + ast_util::ident_to_path(span, + ext_cx.ident_of(~"__d")), + None), + span: span, + }, id: ext_cx.next_id(), - node: ast::ty_infer, - span: span }, - pat: @ast::pat { + ast::arg { + is_mutbl: false, + ty: @ast::Ty { + id: ext_cx.next_id(), + node: ast::ty_infer, + span: span + }, + pat: @ast::pat { + id: ext_cx.next_id(), + node: ast::pat_ident( + ast::bind_by_copy, + ast_util::ident_to_path(span, + ext_cx.ident_of(~"i")), + None), + span: span, + }, id: ext_cx.next_id(), - node: ast::pat_ident( - ast::bind_by_copy, - ast_util::ident_to_path(span, - ext_cx.ident_of(~"i")), - None), - span: span, - }, - id: ext_cx.next_id(), - }], + } + ], output: @ast::Ty { id: ext_cx.next_id(), node: ast::ty_infer, @@ -1198,13 +1251,14 @@ fn mk_enum_deser_body( ); // ast for `__d.read_enum_variant($expr_arm_names, $(expr_lambda))` - let expr_lambda = ext_cx.lambda_expr( + let expr_lambda = ext_cx.lambda_expr_1( ext_cx.expr_method_call( span, ext_cx.expr_var(span, ~"__d"), ext_cx.ident_of(~"read_enum_variant"), ~[expr_arm_names, expr_lambda] - ) + ), + ext_cx.ident_of(~"__d") ); // ast for `__d.read_enum($(e_name), $(expr_lambda))` @@ -1256,105 +1310,147 @@ mod test { } impl Encoder for TestEncoder { - fn emit_nil(&self) { self.add_to_log(CallToEmitNil) } + fn emit_nil(&mut self) { self.add_to_log(CallToEmitNil) } - fn emit_uint(&self, v: uint) {self.add_to_log(CallToEmitUint(v)); } - fn emit_u64(&self, _v: u64) { self.add_unknown_to_log(); } - fn emit_u32(&self, _v: u32) { self.add_unknown_to_log(); } - fn emit_u16(&self, _v: u16) { self.add_unknown_to_log(); } - fn emit_u8(&self, _v: u8) { self.add_unknown_to_log(); } + fn emit_uint(&mut self, v: uint) { + self.add_to_log(CallToEmitUint(v)); + } + fn emit_u64(&mut self, _v: u64) { self.add_unknown_to_log(); } + fn emit_u32(&mut self, _v: u32) { self.add_unknown_to_log(); } + fn emit_u16(&mut self, _v: u16) { self.add_unknown_to_log(); } + fn emit_u8(&mut self, _v: u8) { self.add_unknown_to_log(); } - fn emit_int(&self, _v: int) { self.add_unknown_to_log(); } - fn emit_i64(&self, _v: i64) { self.add_unknown_to_log(); } - fn emit_i32(&self, _v: i32) { self.add_unknown_to_log(); } - fn emit_i16(&self, _v: i16) { self.add_unknown_to_log(); } - fn emit_i8(&self, _v: i8) { self.add_unknown_to_log(); } + fn emit_int(&mut self, _v: int) { self.add_unknown_to_log(); } + fn emit_i64(&mut self, _v: i64) { self.add_unknown_to_log(); } + fn emit_i32(&mut self, _v: i32) { self.add_unknown_to_log(); } + fn emit_i16(&mut self, _v: i16) { self.add_unknown_to_log(); } + fn emit_i8(&mut self, _v: i8) { self.add_unknown_to_log(); } - fn emit_bool(&self, _v: bool) { self.add_unknown_to_log(); } + fn emit_bool(&mut self, _v: bool) { self.add_unknown_to_log(); } - fn emit_f64(&self, _v: f64) { self.add_unknown_to_log(); } - fn emit_f32(&self, _v: f32) { self.add_unknown_to_log(); } - fn emit_float(&self, _v: float) { self.add_unknown_to_log(); } + fn emit_f64(&mut self, _v: f64) { self.add_unknown_to_log(); } + fn emit_f32(&mut self, _v: f32) { self.add_unknown_to_log(); } + fn emit_float(&mut self, _v: float) { self.add_unknown_to_log(); } - fn emit_char(&self, _v: char) { self.add_unknown_to_log(); } - fn emit_str(&self, _v: &str) { self.add_unknown_to_log(); } + fn emit_char(&mut self, _v: char) { self.add_unknown_to_log(); } + fn emit_str(&mut self, _v: &str) { self.add_unknown_to_log(); } - fn emit_enum(&self, name: &str, f: &fn()) { - self.add_to_log(CallToEmitEnum(name.to_str())); f(); } + fn emit_enum(&mut self, name: &str, f: &fn(&mut TestEncoder)) { + self.add_to_log(CallToEmitEnum(name.to_str())); + f(self); + } - fn emit_enum_variant(&self, name: &str, id: uint, - cnt: uint, f: &fn()) { - self.add_to_log(CallToEmitEnumVariant (name.to_str(),id,cnt)); - f(); + fn emit_enum_variant(&mut self, + name: &str, + id: uint, + cnt: uint, + f: &fn(&mut TestEncoder)) { + self.add_to_log(CallToEmitEnumVariant(name.to_str(), id, cnt)); + f(self); } - fn emit_enum_variant_arg(&self, idx: uint, f: &fn()) { - self.add_to_log(CallToEmitEnumVariantArg (idx)); f(); + fn emit_enum_variant_arg(&mut self, + idx: uint, + f: &fn(&mut TestEncoder)) { + self.add_to_log(CallToEmitEnumVariantArg(idx)); + f(self); } - fn emit_enum_struct_variant(&self, name: &str, id: uint, cnt: uint, f: &fn()) { + fn emit_enum_struct_variant(&mut self, + name: &str, + id: uint, + cnt: uint, + f: &fn(&mut TestEncoder)) { self.emit_enum_variant(name, id, cnt, f) } - fn emit_enum_struct_variant_field(&self, _name: &str, idx: uint, f: &fn()) { + fn emit_enum_struct_variant_field(&mut self, + _name: &str, + idx: uint, + f: &fn(&mut TestEncoder)) { self.emit_enum_variant_arg(idx, f) } - fn emit_struct(&self, name: &str, len: uint, f: &fn()) { - self.add_to_log(CallToEmitStruct (name.to_str(),len)); f(); + fn emit_struct(&mut self, + name: &str, + len: uint, + f: &fn(&mut TestEncoder)) { + self.add_to_log(CallToEmitStruct (name.to_str(),len)); + f(self); } - fn emit_struct_field(&self, name: &str, idx: uint, f: &fn()) { - self.add_to_log(CallToEmitField (name.to_str(),idx)); f(); + fn emit_struct_field(&mut self, + name: &str, + idx: uint, + f: &fn(&mut TestEncoder)) { + self.add_to_log(CallToEmitField (name.to_str(),idx)); + f(self); } - fn emit_tuple(&self, _len: uint, f: &fn()) { - self.add_unknown_to_log(); f(); + fn emit_tuple(&mut self, _len: uint, f: &fn(&mut TestEncoder)) { + self.add_unknown_to_log(); + f(self); } - fn emit_tuple_arg(&self, _idx: uint, f: &fn()) { - self.add_unknown_to_log(); f(); + fn emit_tuple_arg(&mut self, _idx: uint, f: &fn(&mut TestEncoder)) { + self.add_unknown_to_log(); + f(self); } - fn emit_tuple_struct(&self, _name: &str, _len: uint, f: &fn()) { - self.add_unknown_to_log(); f(); + fn emit_tuple_struct(&mut self, + _name: &str, + _len: uint, + f: &fn(&mut TestEncoder)) { + self.add_unknown_to_log(); + f(self); } - fn emit_tuple_struct_arg(&self, _idx: uint, f: &fn()) { - self.add_unknown_to_log(); f(); + + fn emit_tuple_struct_arg(&mut self, + _idx: uint, + f: &fn(&mut TestEncoder)) { + self.add_unknown_to_log(); + f(self); } - fn emit_option(&self, f: &fn()) { + fn emit_option(&mut self, f: &fn(&mut TestEncoder)) { self.add_to_log(CallToEmitOption); - f(); + f(self); } - fn emit_option_none(&self) { + fn emit_option_none(&mut self) { self.add_to_log(CallToEmitOptionNone); } - fn emit_option_some(&self, f: &fn()) { + fn emit_option_some(&mut self, f: &fn(&mut TestEncoder)) { self.add_to_log(CallToEmitOptionSome); - f(); + f(self); } - fn emit_seq(&self, _len: uint, f: &fn()) { - self.add_unknown_to_log(); f(); + fn emit_seq(&mut self, _len: uint, f: &fn(&mut TestEncoder)) { + self.add_unknown_to_log(); + f(self); } - fn emit_seq_elt(&self, _idx: uint, f: &fn()) { - self.add_unknown_to_log(); f(); + fn emit_seq_elt(&mut self, _idx: uint, f: &fn(&mut TestEncoder)) { + self.add_unknown_to_log(); + f(self); } - fn emit_map(&self, _len: uint, f: &fn()) { - self.add_unknown_to_log(); f(); + fn emit_map(&mut self, _len: uint, f: &fn(&mut TestEncoder)) { + self.add_unknown_to_log(); + f(self); } - fn emit_map_elt_key(&self, _idx: uint, f: &fn()) { - self.add_unknown_to_log(); f(); + fn emit_map_elt_key(&mut self, _idx: uint, f: &fn(&mut TestEncoder)) { + self.add_unknown_to_log(); + f(self); } - fn emit_map_elt_val(&self, _idx: uint, f: &fn()) { - self.add_unknown_to_log(); f(); + fn emit_map_elt_val(&mut self, _idx: uint, f: &fn(&mut TestEncoder)) { + self.add_unknown_to_log(); + f(self); } } fn to_call_log>(val: E) -> ~[call] { - let mut te = TestEncoder {call_log: @mut ~[]}; - val.encode(&te); + let mut te = TestEncoder { + call_log: @mut ~[] + }; + val.encode(&mut te); copy *te.call_log } diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs index 48f6d5baa8b..fe270abc2e4 100644 --- a/src/libsyntax/ext/deriving/decodable.rs +++ b/src/libsyntax/ext/deriving/decodable.rs @@ -96,7 +96,7 @@ fn create_decode_method( cx, span, build::mk_simple_ty_path(cx, span, cx.ident_of(~"__D")), - ast::m_imm + ast::m_mutbl ); let d_ident = cx.ident_of(~"__d"); let d_arg = build::mk_arg(cx, span, d_ident, d_arg_type); @@ -219,6 +219,11 @@ fn create_read_struct_field( // Call the substructure method. let decode_expr = call_substructure_decode_method(cx, span); + let d_arg = build::mk_arg(cx, + span, + cx.ident_of(~"__d"), + build::mk_ty_infer(cx, span)); + let call_expr = build::mk_method_call( cx, span, @@ -227,7 +232,11 @@ fn create_read_struct_field( ~[ build::mk_base_str(cx, span, cx.str_of(ident)), build::mk_uint(cx, span, idx), - build::mk_lambda_no_args(cx, span, decode_expr), + build::mk_lambda(cx, + span, + build::mk_fn_decl(~[d_arg], + build::mk_ty_infer(cx, span)), + decode_expr), ] ); @@ -282,6 +291,11 @@ fn expand_deriving_decodable_struct_method( i += 1; } + let d_arg = build::mk_arg(cx, + span, + cx.ident_of(~"__d"), + build::mk_ty_infer(cx, span)); + let read_struct_expr = build::mk_method_call( cx, span, @@ -294,9 +308,10 @@ fn expand_deriving_decodable_struct_method( ~[ build::mk_base_str(cx, span, cx.str_of(type_ident)), build::mk_uint(cx, span, fields.len()), - build::mk_lambda_no_args( + build::mk_lambda( cx, span, + build::mk_fn_decl(~[d_arg], build::mk_ty_infer(cx, span)), build::mk_struct_e( cx, span, @@ -334,6 +349,12 @@ fn create_read_variant_arg( // Call the substructure method. let expr = call_substructure_decode_method(cx, span); + let d_arg = build::mk_arg(cx, + span, + cx.ident_of(~"__d"), + build::mk_ty_infer(cx, span)); + let t_infer = build::mk_ty_infer(cx, span); + let call_expr = build::mk_method_call( cx, span, @@ -341,7 +362,10 @@ fn create_read_variant_arg( cx.ident_of(~"read_enum_variant_arg"), ~[ build::mk_uint(cx, span, j), - build::mk_lambda_no_args(cx, span, expr), + build::mk_lambda(cx, + span, + build::mk_fn_decl(~[d_arg], t_infer), + expr), ] ); @@ -399,6 +423,12 @@ fn create_read_enum_variant( span, build::mk_fn_decl( ~[ + build::mk_arg( + cx, + span, + cx.ident_of(~"__d"), + build::mk_ty_infer(cx, span) + ), build::mk_arg( cx, span, @@ -434,6 +464,11 @@ fn expand_deriving_decodable_enum_method( enum_definition ); + let d_arg = build::mk_arg(cx, + span, + cx.ident_of(~"__d"), + build::mk_ty_infer(cx, span)); + // Create the read_enum expression let read_enum_expr = build::mk_method_call( cx, @@ -442,7 +477,11 @@ fn expand_deriving_decodable_enum_method( cx.ident_of(~"read_enum"), ~[ build::mk_base_str(cx, span, cx.str_of(type_ident)), - build::mk_lambda_no_args(cx, span, read_enum_variant_expr), + build::mk_lambda(cx, + span, + build::mk_fn_decl(~[d_arg], + build::mk_ty_infer(cx, span)), + read_enum_variant_expr), ] ); diff --git a/src/libsyntax/ext/deriving/encodable.rs b/src/libsyntax/ext/deriving/encodable.rs index 640d0d0ff2d..8f8139790ad 100644 --- a/src/libsyntax/ext/deriving/encodable.rs +++ b/src/libsyntax/ext/deriving/encodable.rs @@ -94,10 +94,9 @@ fn create_encode_method( cx, span, build::mk_simple_ty_path(cx, span, cx.ident_of(~"__E")), - ast::m_imm + ast::m_mutbl ); - let e_ident = cx.ident_of(~"__e"); - let e_arg = build::mk_arg(cx, span, e_ident, e_arg_type); + let e_arg = build::mk_arg(cx, span, cx.ident_of(~"__e"), e_arg_type); // Create the type of the return value. let output_type = @ast::Ty { id: cx.next_id(), node: ty_nil, span: span }; @@ -226,10 +225,16 @@ fn expand_deriving_encodable_struct_method( self_field ); + let e_ident = cx.ident_of(~"__e"); + let e_arg = build::mk_arg(cx, + span, + e_ident, + build::mk_ty_infer(cx, span)); + let blk_expr = build::mk_lambda( cx, span, - build::mk_fn_decl(~[], build::mk_ty_infer(cx, span)), + build::mk_fn_decl(~[e_arg], build::mk_ty_infer(cx, span)), encode_expr ); @@ -257,6 +262,11 @@ fn expand_deriving_encodable_struct_method( idx += 1; } + let e_arg = build::mk_arg(cx, + span, + cx.ident_of(~"__e"), + build::mk_ty_infer(cx, span)); + let emit_struct_stmt = build::mk_method_call( cx, span, @@ -272,7 +282,7 @@ fn expand_deriving_encodable_struct_method( build::mk_lambda_stmts( cx, span, - build::mk_fn_decl(~[], build::mk_ty_infer(cx, span)), + build::mk_fn_decl(~[e_arg], build::mk_ty_infer(cx, span)), statements ), ] @@ -309,10 +319,16 @@ fn expand_deriving_encodable_enum_method( // Call the substructure method. let expr = call_substructure_encode_method(cx, span, field); + let e_ident = cx.ident_of(~"__e"); + let e_arg = build::mk_arg(cx, + span, + e_ident, + build::mk_ty_infer(cx, span)); + let blk_expr = build::mk_lambda( cx, span, - build::mk_fn_decl(~[], build::mk_ty_infer(cx, span)), + build::mk_fn_decl(~[e_arg], build::mk_ty_infer(cx, span)), expr ); @@ -331,6 +347,10 @@ fn expand_deriving_encodable_enum_method( } // Create the pattern body. + let e_arg = build::mk_arg(cx, + span, + cx.ident_of(~"__e"), + build::mk_ty_infer(cx, span)); let call_expr = build::mk_method_call( cx, span, @@ -343,7 +363,7 @@ fn expand_deriving_encodable_enum_method( build::mk_lambda_stmts( cx, span, - build::mk_fn_decl(~[], build::mk_ty_infer(cx, span)), + build::mk_fn_decl(~[e_arg], build::mk_ty_infer(cx, span)), stmts ) ] @@ -359,11 +379,17 @@ fn expand_deriving_encodable_enum_method( } }; + let e_ident = cx.ident_of(~"__e"); + let e_arg = build::mk_arg(cx, + span, + e_ident, + build::mk_ty_infer(cx, span)); + // Create the method body. let lambda_expr = build::mk_lambda( cx, span, - build::mk_fn_decl(~[], build::mk_ty_infer(cx, span)), + build::mk_fn_decl(~[e_arg], build::mk_ty_infer(cx, span)), expand_enum_or_struct_match(cx, span, arms) ); diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 4f1d41a4a7a..0c024958a24 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -420,7 +420,8 @@ mod test { #[cfg(test)] fn to_json_str>(val: @E) -> ~str { do io::with_str_writer |writer| { - val.encode(~std::json::Encoder(writer)); + let mut encoder = std::json::Encoder(writer); + val.encode(&mut encoder); } } diff --git a/src/test/bench/shootout-binarytrees.rs b/src/test/bench/shootout-binarytrees.rs index 8d0675d0884..c420e0cbb2f 100644 --- a/src/test/bench/shootout-binarytrees.rs +++ b/src/test/bench/shootout-binarytrees.rs @@ -1,3 +1,7 @@ +// xfail-test + +// Broken due to arena API problems. + // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. @@ -10,7 +14,6 @@ extern mod std; use std::arena; -use methods = std::arena::Arena; enum tree<'self> { nil, @@ -26,9 +29,7 @@ fn item_check(t: &tree) -> int { } } -fn bottom_up_tree<'r>(arena: &'r arena::Arena, - item: int, - depth: int) +fn bottom_up_tree<'r>(arena: &'r mut arena::Arena, item: int, depth: int) -> &'r tree<'r> { if depth > 0 { return arena.alloc( @@ -58,25 +59,25 @@ fn main() { max_depth = n; } - let stretch_arena = arena::Arena(); + let mut stretch_arena = arena::Arena(); let stretch_depth = max_depth + 1; - let stretch_tree = bottom_up_tree(&stretch_arena, 0, stretch_depth); + let stretch_tree = bottom_up_tree(&mut stretch_arena, 0, stretch_depth); io::println(fmt!("stretch tree of depth %d\t check: %d", stretch_depth, item_check(stretch_tree))); - let long_lived_arena = arena::Arena(); - let long_lived_tree = bottom_up_tree(&long_lived_arena, 0, max_depth); + let mut long_lived_arena = arena::Arena(); + let long_lived_tree = bottom_up_tree(&mut long_lived_arena, 0, max_depth); let mut depth = min_depth; while depth <= max_depth { let iterations = int::pow(2, (max_depth - depth + min_depth) as uint); let mut chk = 0; let mut i = 1; while i <= iterations { - let mut temp_tree = bottom_up_tree(&long_lived_arena, i, depth); + let mut temp_tree = bottom_up_tree(&mut long_lived_arena, i, depth); chk += item_check(temp_tree); - temp_tree = bottom_up_tree(&long_lived_arena, -i, depth); + temp_tree = bottom_up_tree(&mut long_lived_arena, -i, depth); chk += item_check(temp_tree); i += 1; } @@ -87,5 +88,5 @@ fn main() { } io::println(fmt!("long lived trees of depth %d\t check: %d", max_depth, - item_check(long_lived_tree))); + item_check(long_lived_tree))); } diff --git a/src/test/run-pass/auto-encode.rs b/src/test/run-pass/auto-encode.rs index bfc15acaa76..cfac8e8cd06 100644 --- a/src/test/run-pass/auto-encode.rs +++ b/src/test/run-pass/auto-encode.rs @@ -31,11 +31,12 @@ fn test_ebml >(a1: &A) { let bytes = do io::with_bytes_writer |wr| { - let ebml_w = &EBWriter::Encoder(wr); - a1.encode(ebml_w) + let mut ebml_w = EBWriter::Encoder(wr); + a1.encode(&mut ebml_w) }; let d = EBReader::Doc(@bytes); - let a2: A = Decodable::decode(&EBReader::Decoder(d)); + let mut decoder = EBReader::Decoder(d); + let a2: A = Decodable::decode(&mut decoder); assert!(*a1 == a2); } diff --git a/src/test/run-pass/issue-4036.rs b/src/test/run-pass/issue-4036.rs index f24875cbf8e..8b514b11625 100644 --- a/src/test/run-pass/issue-4036.rs +++ b/src/test/run-pass/issue-4036.rs @@ -17,5 +17,6 @@ use self::std::serialize; pub fn main() { let json = json::from_str("[1]").unwrap(); - let _x: ~[int] = serialize::Decodable::decode(&json::Decoder(json)); + let mut decoder = json::Decoder(json); + let _x: ~[int] = serialize::Decodable::decode(&mut decoder); } diff --git a/src/test/run-pass/placement-new-arena.rs b/src/test/run-pass/placement-new-arena.rs index 12c80421932..166435cbc3d 100644 --- a/src/test/run-pass/placement-new-arena.rs +++ b/src/test/run-pass/placement-new-arena.rs @@ -14,7 +14,8 @@ extern mod std; use std::arena; pub fn main() { - let p = &arena::Arena(); + let mut arena = arena::Arena(); + let p = &mut arena; let x = p.alloc(|| 4u); io::print(fmt!("%u", *x)); assert!(*x == 4u); diff --git a/src/test/run-pass/regions-mock-trans-impls.rs b/src/test/run-pass/regions-mock-trans-impls.rs index c1f7a713ca6..e9163505748 100644 --- a/src/test/run-pass/regions-mock-trans-impls.rs +++ b/src/test/run-pass/regions-mock-trans-impls.rs @@ -21,7 +21,7 @@ struct Bcx<'self> { } struct Fcx<'self> { - arena: &'self Arena, + arena: &'self mut Arena, ccx: &'self Ccx } @@ -29,23 +29,27 @@ struct Ccx { x: int } -fn h<'r>(bcx : &'r Bcx<'r>) -> &'r Bcx<'r> { - return bcx.fcx.arena.alloc(|| Bcx { fcx: bcx.fcx }); +fn h<'r>(bcx : &'r mut Bcx<'r>) -> &'r mut Bcx<'r> { + // XXX: Arena has a bad interface here; it should return mutable pointers. + // But this patch is too big to roll that in. + unsafe { + cast::transmute(bcx.fcx.arena.alloc(|| Bcx { fcx: bcx.fcx })) + } } -fn g(fcx : &Fcx) { - let bcx = Bcx { fcx: fcx }; - h(&bcx); +fn g(fcx: &mut Fcx) { + let mut bcx = Bcx { fcx: fcx }; + h(&mut bcx); } -fn f(ccx : &Ccx) { - let a = Arena(); - let fcx = &Fcx { arena: &a, ccx: ccx }; - return g(fcx); +fn f(ccx: &mut Ccx) { + let mut a = Arena(); + let mut fcx = Fcx { arena: &mut a, ccx: ccx }; + return g(&mut fcx); } pub fn main() { - let ccx = Ccx { x: 0 }; - f(&ccx); + let mut ccx = Ccx { x: 0 }; + f(&mut ccx); } -- cgit 1.4.1-3-g733a5 From 2e3e0c0892d6fc9d20374d31db994eee4d083366 Mon Sep 17 00:00:00 2001 From: Björn Steinbrink Date: Fri, 3 May 2013 12:26:45 +0200 Subject: Avoid needless creation of unique strings in fmt!() Only the first portion has to be owned, as it acts as the buffer for the constructed string. The remaining strings can be static. --- src/libsyntax/ext/fmt.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index 62641279f88..e9eebe5b2ac 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -273,15 +273,13 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span, match pc { /* Raw strings get appended via str::push_str */ PieceString(s) => { - let portion = mk_uniq_str(cx, fmt_sp, s); - /* If this is the first portion, then initialize the local buffer with it directly. If it's actually the only piece, then there's no need for it to be mutable */ if i == 0 { - stms.push(mk_local(cx, fmt_sp, npieces > 1, ident, portion)); + stms.push(mk_local(cx, fmt_sp, npieces > 1, ident, mk_uniq_str(cx, fmt_sp, s))); } else { - let args = ~[mk_mut_addr_of(cx, fmt_sp, buf()), portion]; + let args = ~[mk_mut_addr_of(cx, fmt_sp, buf()), mk_base_str(cx, fmt_sp, s)]; let call = mk_call_global(cx, fmt_sp, ~[str_ident, push_ident], -- cgit 1.4.1-3-g733a5 From 86efd97a10fda1f81f5bead0de36e3343a9faa0e Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Fri, 3 May 2013 19:25:04 -0400 Subject: add gitattributes and fix whitespace issues --- .gitattributes | 9 ++++++ COPYRIGHT | 1 - RELEASES.txt | 6 ++-- doc/README | 6 ++-- doc/rust.md | 1 - doc/tutorial-macros.md | 1 - doc/tutorial-tasks.md | 1 - doc/tutorial.md | 8 ++--- doc/version_info.html.template | 1 - mk/platform.mk | 6 ++-- mk/rt.mk | 12 +++---- mk/stage0.mk | 6 ++-- mk/tests.mk | 5 ++- src/etc/check-links.pl | 5 ++- src/etc/gedit/readme.txt | 1 - .../gtksourceview-3.0/language-specs/rust.lang | 5 ++- src/etc/gedit/share/mime/packages/rust.xml | 2 +- src/etc/indenter | 1 - src/etc/latest-unix-snaps.py | 2 -- src/etc/libc.c | 1 - src/etc/licenseck.py | 1 - src/etc/local_stage0.sh | 4 +-- src/etc/mirror-all-snapshots.py | 3 -- src/etc/monodebug.pl | 1 - src/etc/sugarise-doc-comments.py | 1 - src/etc/tidy.py | 1 - src/etc/x86.supp | 4 +-- src/libcore/cleanup.rs | 1 - src/libcore/logging.rs | 1 - src/libcore/owned.rs | 1 - src/libcore/rt/context.rs | 1 - src/libcore/rt/io/comm_adapters.rs | 1 - src/libcore/rt/io/net/ip.rs | 1 - src/libcore/rt/io/net/udp.rs | 1 - src/libcore/rt/io/net/unix.rs | 1 - src/libcore/rt/local_heap.rs | 1 - src/libcore/rt/sched/local_sched.rs | 1 - src/libcore/stackwalk.rs | 1 - src/libcore/unicode.rs | 1 - src/libcore/unstable/exchange_alloc.rs | 1 - src/libcore/unstable/weak_task.rs | 1 - src/librustc/metadata/common.rs | 1 - src/librustc/metadata/mod.rs | 1 - src/librustc/middle/borrowck/check_loans.rs | 1 - src/librustc/middle/borrowck/gather_loans.rs | 1 - src/librustc/middle/borrowck/loan.rs | 1 - src/librustc/middle/lang_items.rs | 1 - src/librustc/middle/mem_categorization.rs | 1 - src/librustc/middle/pat_util.rs | 1 - src/librustc/middle/privacy.rs | 1 - src/librustc/middle/region.rs | 1 - src/librustc/middle/subst.rs | 1 - src/librustc/middle/trans/cabi.rs | 1 - src/librustc/middle/trans/callee.rs | 1 - src/librustc/middle/trans/closure.rs | 1 - src/librustc/middle/trans/controlflow.rs | 1 - src/librustc/middle/trans/datum.rs | 1 - src/librustc/middle/trans/inline.rs | 1 - src/librustc/middle/trans/machine.rs | 1 - src/librustc/middle/trans/macros.rs | 1 - src/librustc/middle/trans/reachable.rs | 1 - src/librustc/middle/trans/reflect.rs | 1 - src/librustc/middle/trans/shape.rs | 1 - src/librustc/middle/trans/type_use.rs | 1 - src/librustc/middle/typeck/check/_match.rs | 1 - src/librustc/middle/typeck/check/demand.rs | 2 -- src/librustc/middle/typeck/check/vtable.rs | 2 -- src/librustc/middle/typeck/coherence.rs | 1 - src/librustc/middle/typeck/infer/combine.rs | 1 - src/librustc/middle/typeck/infer/glb.rs | 1 - src/librustc/middle/typeck/infer/macros.rs | 1 - .../middle/typeck/infer/region_inference.rs | 1 - src/librustc/middle/typeck/infer/resolve.rs | 1 - src/librustc/middle/typeck/infer/sub.rs | 1 - src/librustc/middle/typeck/infer/unify.rs | 2 -- src/librustdoc/path_pass.rs | 1 - src/librustpkg/testsuite/pass/commands.txt | 1 - .../pass/src/deeply/nested/path/foo/src/main.rs | 1 - src/libstd/num/bigint.rs | 1 - src/libstd/serialize.rs | 1 - src/libstd/task_pool.rs | 1 - src/libsyntax/ext/pipes/check.rs | 1 - src/libsyntax/ext/pipes/liveness.rs | 1 - src/libsyntax/ext/pipes/mod.rs | 1 - src/libsyntax/ext/pipes/proto.rs | 1 - src/libsyntax/ext/quote.rs | 1 - src/libsyntax/parse/obsolete.rs | 1 - src/libsyntax/syntax.rc | 1 - src/rt/arch/arm/_context.S | 2 -- src/rt/arch/arm/gpr.cpp | 1 - src/rt/arch/arm/gpr.h | 1 - src/rt/arch/arm/morestack.S | 4 +-- src/rt/arch/arm/record_sp.S | 1 - src/rt/arch/arm/regs.h | 2 -- src/rt/arch/i386/_context.S | 2 -- src/rt/arch/i386/gpr.cpp | 1 - src/rt/arch/i386/gpr.h | 1 - src/rt/arch/i386/morestack.S | 3 +- src/rt/arch/mips/gpr.h | 1 - src/rt/arch/x86_64/_context.S | 1 - src/rt/arch/x86_64/gpr.cpp | 1 - src/rt/arch/x86_64/gpr.h | 1 - src/rt/arch/x86_64/regs.h | 2 -- src/rt/isaac/rand.h | 2 -- src/rt/rust_abi.cpp | 1 - src/rt/rust_abi.h | 1 - src/rt/rust_android_dummy.h | 1 - src/rt/rust_debug.cpp | 1 - src/rt/rust_debug.h | 1 - src/rt/rust_gpr_base.h | 1 - src/rustllvm/README | 1 - src/rustllvm/RustWrapper.cpp | 22 ++++++------- src/snapshots.txt | 2 +- src/test/auxiliary/anon_trait_static_method_lib.rs | 1 - src/test/auxiliary/cci_class_2.rs | 1 - src/test/auxiliary/cci_class_6.rs | 1 - src/test/auxiliary/cci_class_cast.rs | 2 -- src/test/auxiliary/cci_no_inline_lib.rs | 1 - src/test/auxiliary/explicit_self_xcrate.rs | 2 -- src/test/auxiliary/extern_mod_ordering_lib.rs | 1 - src/test/auxiliary/foreign_lib.rs | 1 - src/test/auxiliary/impl_privacy_xc_1.rs | 1 - src/test/auxiliary/impl_privacy_xc_2.rs | 2 -- src/test/auxiliary/issue-2414-a.rs | 1 - src/test/auxiliary/issue-2414-b.rs | 1 - src/test/auxiliary/issue-2526.rs | 1 - src/test/auxiliary/issue_2316_b.rs | 2 -- src/test/auxiliary/issue_3136_a.rs | 5 ++- src/test/auxiliary/issue_3882.rs | 2 +- src/test/auxiliary/moves_based_on_type_lib.rs | 1 - src/test/auxiliary/newtype_struct_xc.rs | 1 - src/test/auxiliary/pub_use_mods_xcrate.rs | 1 - src/test/auxiliary/static_fn_inline_xc_aux.rs | 1 - .../auxiliary/struct_destructuring_cross_crate.rs | 1 - .../auxiliary/trait_inheritance_auto_xc_2_aux.rs | 2 -- .../auxiliary/trait_inheritance_overloading_xc.rs | 1 - src/test/auxiliary/xc_private_method_lib.rs | 1 - src/test/bench/msgsend-pipes-shared.rs | 2 +- src/test/bench/msgsend-pipes.rs | 2 +- src/test/bench/msgsend-ring-mutex-arcs.rs | 2 +- src/test/bench/msgsend-ring-pipes.rs | 2 +- src/test/bench/msgsend-ring-rw-arcs.rs | 2 +- src/test/bench/pingpong.rs | 2 +- src/test/bench/shootout-chameneos-redux.rs | 1 - src/test/bench/shootout-fannkuch-redux.rs | 1 - src/test/bench/shootout-fasta-redux.rs | 1 - src/test/bench/shootout-k-nucleotide-pipes.rs | 1 - src/test/bench/shootout-k-nucleotide.rs | 3 +- src/test/bench/shootout-mandelbrot.rs | 1 - src/test/bench/shootout-pidigits.rs | 1 - src/test/bench/shootout-reverse-complement.rs | 1 - src/test/bench/sudoku.rs | 1 - src/test/compile-fail/alt-tag-nullary.rs | 1 - src/test/compile-fail/alt-tag-unary.rs | 1 - src/test/compile-fail/auto-ref-borrowck-failure.rs | 1 - src/test/compile-fail/bogus-tag.rs | 1 - src/test/compile-fail/borrowck-assign-comp-idx.rs | 1 - src/test/compile-fail/borrowck-assign-comp.rs | 1 - .../borrowck-call-method-from-mut-aliasable.rs | 1 - .../borrowck-loan-local-as-both-mut-and-imm.rs | 2 +- .../borrowck-loan-rcvr-overloaded-op.rs | 3 +- src/test/compile-fail/borrowck-loan-rcvr.rs | 1 - src/test/compile-fail/borrowck-mut-boxed-vec.rs | 1 - src/test/compile-fail/borrowck-ref-into-rvalue.rs | 5 ++- src/test/compile-fail/borrowck-uniq-via-box.rs | 1 - .../borrowck-vec-pattern-loan-from-mut.rs | 1 - .../compile-fail/borrowck-vec-pattern-nesting.rs | 1 - .../borrowck-wg-borrow-mut-to-imm-fail-2.rs | 1 - .../borrowck-wg-borrow-mut-to-imm-fail-3.rs | 1 - .../borrowck-wg-borrow-mut-to-imm-fail.rs | 1 - src/test/compile-fail/borrowck-wg-move-base-2.rs | 2 -- src/test/compile-fail/by-move-pattern-binding.rs | 1 - src/test/compile-fail/dead-code-ret.rs | 1 - src/test/compile-fail/does-nothing.rs | 1 - src/test/compile-fail/drop-on-non-struct.rs | 2 -- src/test/compile-fail/explicit-call-to-dtor.rs | 1 - .../explicit-call-to-supertrait-dtor.rs | 2 -- .../float-literal-inference-restrictions.rs | 1 - src/test/compile-fail/foreign-unsafe-fn-called.rs | 1 - src/test/compile-fail/foreign-unsafe-fn.rs | 2 -- src/test/compile-fail/issue-1451.rs | 1 - src/test/compile-fail/issue-2951.rs | 1 - src/test/compile-fail/issue-3044.rs | 1 - src/test/compile-fail/issue-3096-2.rs | 2 +- src/test/compile-fail/issue-3991.rs | 4 +-- src/test/compile-fail/issue-4265.rs | 4 +-- src/test/compile-fail/issue-4366.rs | 1 - src/test/compile-fail/issue-4968.rs | 1 - src/test/compile-fail/kindck-destructor-owned.rs | 1 - src/test/compile-fail/lint-default-methods.rs | 1 - src/test/compile-fail/lint-type-limits.rs | 1 - src/test/compile-fail/liveness-if-no-else.rs | 4 +-- src/test/compile-fail/liveness-return.rs | 4 +-- .../compile-fail/liveness-uninit-after-item.rs | 1 - src/test/compile-fail/liveness-uninit.rs | 4 +-- src/test/compile-fail/macro-with-seps-err-msg.rs | 2 -- src/test/compile-fail/missing-derivable-attr.rs | 1 - src/test/compile-fail/missing-return.rs | 1 - .../compile-fail/moves-based-on-type-block-bad.rs | 1 - .../moves-based-on-type-capture-clause-bad.rs | 1 - .../moves-based-on-type-cyclic-types-issue-4821.rs | 1 - src/test/compile-fail/no-capture-arc.rs | 2 +- src/test/compile-fail/noexporttypeexe.rs | 1 - .../compile-fail/non-exhaustive-match-nested.rs | 1 - src/test/compile-fail/once-fn-subtyping.rs | 1 - src/test/compile-fail/private-impl-method.rs | 1 - src/test/compile-fail/private-item-simple.rs | 1 - src/test/compile-fail/private-method-inherited.rs | 1 - src/test/compile-fail/private-struct-field-ctor.rs | 1 - .../compile-fail/private-struct-field-pattern.rs | 1 - src/test/compile-fail/qquote-1.rs | 1 - src/test/compile-fail/qquote-2.rs | 1 - .../compile-fail/refutable-pattern-in-fn-arg.rs | 1 - src/test/compile-fail/regions-addr-of-self.rs | 1 - .../regions-infer-borrow-scope-too-big.rs | 1 - .../regions-infer-borrow-scope-within-loop.rs | 4 +-- src/test/compile-fail/regions-ret.rs | 1 - src/test/compile-fail/repeat-to-run-dtor-twice.rs | 1 - src/test/compile-fail/static-method-privacy.rs | 1 - src/test/compile-fail/static-region-bound.rs | 1 - .../compile-fail/struct-like-enum-nonexhaustive.rs | 2 -- src/test/compile-fail/super-at-top-level.rs | 2 -- .../compile-fail/trait-impl-method-mismatch.rs | 4 --- .../trait-inheritance-missing-requirement.rs | 1 - .../compile-fail/tuple-struct-nonexhaustive.rs | 2 -- .../compile-fail/tutorial-suffix-inference-test.rs | 4 +-- src/test/compile-fail/unique-object-noncopyable.rs | 1 - .../compile-fail/use-after-move-based-on-type.rs | 1 - .../use-after-move-self-based-on-type.rs | 1 - src/test/compile-fail/use-after-move-self.rs | 1 - src/test/compile-fail/view-items-at-top.rs | 1 - src/test/compile-fail/while-type-error.rs | 1 - src/test/compile-fail/xc-private-method.rs | 1 - src/test/pretty/doc-comments.rs | 2 +- src/test/run-fail/assert-as-macro.rs | 1 - src/test/run-fail/borrowck-wg-fail-3.rs | 1 - src/test/run-fail/borrowck-wg-fail.rs | 1 - src/test/run-fail/unwind-resource-fail3.rs | 2 +- src/test/run-pass-fulldeps/qquote.rs | 1 - src/test/run-pass-fulldeps/quote-tokens.rs | 1 - src/test/run-pass/anon-trait-static-method.rs | 1 - src/test/run-pass/anon_trait_static_method_exe.rs | 3 -- src/test/run-pass/auto-ref-newtype.rs | 1 - src/test/run-pass/auto-ref.rs | 1 - .../autoderef-and-borrow-method-receiver.rs | 1 - src/test/run-pass/bare-static-string.rs | 1 - src/test/run-pass/binops.rs | 2 +- src/test/run-pass/block-arg-in-parentheses.rs | 1 - src/test/run-pass/borrow-by-val-method-receiver.rs | 1 - src/test/run-pass/borrowck-wg-simple.rs | 1 - src/test/run-pass/boxed-trait-with-vstore.rs | 1 - src/test/run-pass/break.rs | 6 ++-- .../run-pass/class-cast-to-trait-cross-crate-2.rs | 1 - .../run-pass/class-impl-parameterized-trait.rs | 2 +- src/test/run-pass/cleanup-copy-mode.rs | 1 - src/test/run-pass/clone-with-exterior.rs | 2 +- src/test/run-pass/conditional-compile.rs | 2 +- src/test/run-pass/const-enum-vec-index.rs | 2 +- src/test/run-pass/const-enum-vec-ptr.rs | 2 +- src/test/run-pass/const-enum-vector.rs | 2 +- .../run-pass/const-expr-in-fixed-length-vec.rs | 2 +- src/test/run-pass/const-expr-in-vec-repeat.rs | 2 +- src/test/run-pass/const-tuple-struct.rs | 1 - src/test/run-pass/const-unit-struct.rs | 1 - src/test/run-pass/const-vec-syntax.rs | 1 - src/test/run-pass/consts-in-patterns.rs | 1 - src/test/run-pass/cycle-collection.rs | 1 - src/test/run-pass/default-method-simple.rs | 1 - src/test/run-pass/deriving-clone-enum.rs | 1 - src/test/run-pass/deriving-clone-generic-enum.rs | 1 - src/test/run-pass/deriving-clone-generic-struct.rs | 1 - .../deriving-clone-generic-tuple-struct.rs | 1 - src/test/run-pass/deriving-clone-tuple-struct.rs | 1 - src/test/run-pass/deriving-via-extension-c-enum.rs | 1 - src/test/run-pass/deriving-via-extension-enum.rs | 1 - .../deriving-via-extension-iter-bytes-enum.rs | 1 - .../deriving-via-extension-iter-bytes-struct.rs | 2 -- ...iving-via-extension-struct-like-enum-variant.rs | 1 - src/test/run-pass/deriving-via-extension-struct.rs | 1 - .../run-pass/deriving-via-extension-type-params.rs | 1 - src/test/run-pass/drop-trait-generic.rs | 1 - src/test/run-pass/drop-trait.rs | 1 - src/test/run-pass/enum-discrim-range-overflow.rs | 24 +++++++------- src/test/run-pass/enum-disr-val-pretty.rs | 1 - src/test/run-pass/enum-export-inheritance.rs | 1 - .../run-pass/enum-nullable-simplifycfg-misopt.rs | 6 ++-- src/test/run-pass/explicit-self-generic.rs | 1 - src/test/run-pass/explicit-self-objects-box.rs | 2 -- src/test/run-pass/explicit-self-objects-simple.rs | 2 -- src/test/run-pass/explicit-self-objects-uniq.rs | 2 -- src/test/run-pass/explicit_self_xcrate_exe.rs | 1 - src/test/run-pass/expr-repeat-vstore.rs | 1 - src/test/run-pass/extern-mod-abi.rs | 1 - src/test/run-pass/extern-mod-ordering-exe.rs | 1 - src/test/run-pass/extern-mod-syntax.rs | 1 - src/test/run-pass/extern-pass-TwoU16s.rs | 1 - src/test/run-pass/extern-pass-TwoU32s.rs | 1 - src/test/run-pass/extern-pass-TwoU64s-ref.rs | 1 - src/test/run-pass/extern-pass-TwoU64s.rs | 1 - src/test/run-pass/extern-pass-TwoU8s.rs | 1 - src/test/run-pass/extern-pass-char.rs | 1 - src/test/run-pass/extern-pass-double.rs | 1 - src/test/run-pass/extern-pass-u32.rs | 1 - src/test/run-pass/extern-pass-u64.rs | 1 - src/test/run-pass/extern-pub.rs | 2 -- src/test/run-pass/fat-arrow-alt.rs | 1 - src/test/run-pass/fixed_length_copy.rs | 2 +- src/test/run-pass/float-literal-inference.rs | 1 - src/test/run-pass/fn-pattern-expected-type-2.rs | 1 - src/test/run-pass/fn-pattern-expected-type.rs | 1 - src/test/run-pass/foreign-mod-unused-const.rs | 1 - src/test/run-pass/functional-struct-update.rs | 1 - src/test/run-pass/generic-ivec-leak.rs | 1 - src/test/run-pass/generic-ivec.rs | 1 - src/test/run-pass/generic-newtype-struct.rs | 1 - src/test/run-pass/generic-object.rs | 1 - src/test/run-pass/global-scope.rs | 1 - src/test/run-pass/impl-privacy-xc-1.rs | 1 - src/test/run-pass/impl-privacy-xc-2.rs | 1 - src/test/run-pass/infinite-loops.rs | 4 +-- src/test/run-pass/instantiable.rs | 1 - src/test/run-pass/int-conversion-coherence.rs | 1 - src/test/run-pass/intrinsics-integer.rs | 2 +- src/test/run-pass/intrinsics-math.rs | 4 +-- src/test/run-pass/issue-1516.rs | 1 - src/test/run-pass/issue-2185.rs | 4 +-- src/test/run-pass/issue-2216.rs | 2 +- src/test/run-pass/issue-2526-a.rs | 1 - src/test/run-pass/issue-2734.rs | 4 +-- src/test/run-pass/issue-2904.rs | 2 +- src/test/run-pass/issue-3176.rs | 4 +-- src/test/run-pass/issue-3250.rs | 2 -- src/test/run-pass/issue-3429.rs | 1 - src/test/run-pass/issue-3461.rs | 2 +- src/test/run-pass/issue-3556.rs | 8 ++--- src/test/run-pass/issue-3563-3.rs | 5 ++- src/test/run-pass/issue-3609.rs | 1 - src/test/run-pass/issue-3860.rs | 2 +- src/test/run-pass/issue-3895.rs | 2 +- src/test/run-pass/issue-3979-2.rs | 1 - src/test/run-pass/issue-4241.rs | 2 +- src/test/run-pass/issue-4875.rs | 1 - src/test/run-pass/issue-868.rs | 1 - src/test/run-pass/issue_3136_b.rs | 1 - src/test/run-pass/ivec-add.rs | 1 - src/test/run-pass/ivec-pass-by-value.rs | 1 - src/test/run-pass/labeled-break.rs | 1 - src/test/run-pass/let-assignability.rs | 1 - .../liveness-assign-imm-local-after-loop.rs | 2 +- src/test/run-pass/log-linearized.rs | 1 - src/test/run-pass/max-min-classes.rs | 1 - .../module-qualified-struct-destructure.rs | 1 - src/test/run-pass/move-self.rs | 1 - .../run-pass/moves-based-on-type-capture-clause.rs | 1 - src/test/run-pass/multiple-trait-bounds.rs | 1 - src/test/run-pass/mut-vstore-expr.rs | 1 - src/test/run-pass/nested-class.rs | 22 ++++++------- src/test/run-pass/new-impl-syntax.rs | 1 - src/test/run-pass/new-import-syntax.rs | 1 - src/test/run-pass/new-style-constants.rs | 1 - src/test/run-pass/new-style-fixed-length-vec.rs | 3 -- src/test/run-pass/new-vstore-mut-box-syntax.rs | 1 - src/test/run-pass/newtype-struct-with-dtor.rs | 2 -- src/test/run-pass/newtype-struct-xc-2.rs | 1 - src/test/run-pass/newtype-struct-xc.rs | 1 - .../run-pass/nullable-pointer-iotareduction.rs | 2 +- src/test/run-pass/one-tuple.rs | 1 - src/test/run-pass/pattern-in-closure.rs | 1 - src/test/run-pass/pipe-detect-term.rs | 4 +-- src/test/run-pass/pipe-pingpong-bounded.rs | 2 +- src/test/run-pass/pipe-pingpong-proto.rs | 2 +- src/test/run-pass/pipe-select.rs | 6 ++-- src/test/run-pass/pipe-sleep.rs | 2 +- src/test/run-pass/pub-use-xcrate.rs | 1 - src/test/run-pass/pub_use_mods_xcrate_exe.rs | 1 - src/test/run-pass/reexport-star.rs | 1 - .../regions-addr-of-interior-of-unique-box.rs | 1 - src/test/run-pass/regions-addr-of-ret.rs | 1 - src/test/run-pass/regions-fn-subtyping-2.rs | 4 +-- .../run-pass/regions-infer-borrow-scope-addr-of.rs | 16 +++++----- .../run-pass/regions-infer-borrow-scope-view.rs | 1 - .../regions-infer-borrow-scope-within-loop-ok.rs | 2 +- src/test/run-pass/regions-infer-borrow-scope.rs | 1 - src/test/run-pass/regions-mock-trans-impls.rs | 1 - src/test/run-pass/regions-mock-trans.rs | 1 - src/test/run-pass/regions-self-impls.rs | 1 - src/test/run-pass/regions-self-in-enums.rs | 1 - src/test/run-pass/regions-simple.rs | 2 -- src/test/run-pass/repeated-vector-syntax.rs | 1 - src/test/run-pass/resource-cycle.rs | 4 +-- src/test/run-pass/resource-cycle3.rs | 4 +-- src/test/run-pass/self-type-param.rs | 1 - src/test/run-pass/static-methods-in-traits.rs | 37 +++++++++++----------- src/test/run-pass/struct-deref.rs | 1 - src/test/run-pass/struct-field-assignability.rs | 1 - src/test/run-pass/struct-like-variant-construct.rs | 1 - src/test/run-pass/struct-like-variant-match.rs | 1 - src/test/run-pass/struct-pattern-matching.rs | 3 -- src/test/run-pass/super.rs | 1 - src/test/run-pass/tag-disr-val-shape.rs | 1 - src/test/run-pass/tag-variant-disr-val.rs | 2 -- src/test/run-pass/threads.rs | 1 - src/test/run-pass/trait-composition-trivial.rs | 2 -- src/test/run-pass/trait-inheritance-auto-xc-2.rs | 1 - src/test/run-pass/trait-inheritance-auto-xc.rs | 1 - src/test/run-pass/trait-inheritance-auto.rs | 1 - .../trait-inheritance-call-bound-inherited.rs | 1 - .../trait-inheritance-call-bound-inherited2.rs | 1 - ...-inheritance-cast-without-call-to-supertrait.rs | 1 - src/test/run-pass/trait-inheritance-cast.rs | 1 - .../trait-inheritance-cross-trait-call-xc.rs | 1 - .../run-pass/trait-inheritance-cross-trait-call.rs | 1 - .../trait-inheritance-overloading-simple.rs | 1 - .../trait-inheritance-overloading-xc-exe.rs | 1 - src/test/run-pass/trait-inheritance-overloading.rs | 1 - src/test/run-pass/trait-inheritance-self.rs | 1 - src/test/run-pass/trait-inheritance-simple.rs | 1 - src/test/run-pass/trait-inheritance-subst.rs | 1 - src/test/run-pass/trait-inheritance-subst2.rs | 1 - src/test/run-pass/trait-inheritance2.rs | 1 - src/test/run-pass/trait-region-pointer-simple.rs | 1 - .../run-pass/trait-static-method-overwriting.rs | 6 ++-- src/test/run-pass/traits.rs | 1 - src/test/run-pass/tuple-struct-construct.rs | 1 - src/test/run-pass/tuple-struct-destructuring.rs | 1 - src/test/run-pass/tuple-struct-matching.rs | 1 - src/test/run-pass/tuple-struct-trivial.rs | 1 - src/test/run-pass/typeclasses-eq-example-static.rs | 2 +- src/test/run-pass/typeclasses-eq-example.rs | 2 +- src/test/run-pass/unique-object.rs | 1 - src/test/run-pass/unit-like-struct.rs | 1 - src/test/run-pass/unsafe-pointer-assignability.rs | 3 -- src/test/run-pass/vec-fixed-length.rs | 1 - 433 files changed, 196 insertions(+), 597 deletions(-) create mode 100644 .gitattributes (limited to 'src/libsyntax/ext') diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000000..52370e4a509 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,9 @@ +[attr]rust text eol=lf whitespace=tab-in-indent,trailing-space,tabwidth=4 + +* text=auto +*.cpp rust +*.h rust +*.rs rust +src/rt/msvc/* -whitespace +src/rt/vg/* -whitespace +src/rt/linenoise/* -whitespace diff --git a/COPYRIGHT b/COPYRIGHT index 2315c6fe3cb..ffbfadaa339 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -367,4 +367,3 @@ their own copyright notices and license terms: has chosen for the collective work, enumerated at the top of this file. The only difference is the retention of copyright itself, held by the contributor. - diff --git a/RELEASES.txt b/RELEASES.txt index 13e4e0c2039..fb2bbb45e7c 100644 --- a/RELEASES.txt +++ b/RELEASES.txt @@ -250,7 +250,7 @@ Version 0.3 (July 2012) * Slices and fixed-size, interior-allocated vectors * #!-comments for lang versioning, shell execution * Destructors and iface implementation for classes; - type-parameterized classes and class methods + type-parameterized classes and class methods * 'const' type kind for types that can be used to implement shared-memory concurrency patterns @@ -261,7 +261,7 @@ Version 0.3 (July 2012) 'crust', 'native' (now 'extern'), 'cont' (now 'again') * Constructs: do-while loops ('do' repurposed), fn binding, - resources (replaced by destructors) + resources (replaced by destructors) * Compiler reorganization * Syntax-layer of compiler split into separate crate @@ -276,7 +276,7 @@ Version 0.3 (July 2012) * Extensive work on libuv interface * Much vector code moved to libraries * Syntax extensions: #line, #col, #file, #mod, #stringify, - #include, #include_str, #include_bin + #include, #include_str, #include_bin * Tool improvements * Cargo automatically resolves dependencies diff --git a/doc/README b/doc/README index 505b5383dcd..c3bb28a9e85 100644 --- a/doc/README +++ b/doc/README @@ -1,6 +1,6 @@ The markdown docs are only generated by make when node is installed (use -`make doc`). If you don't have node installed you can generate them yourself. -Unfortunately there's no real standard for markdown and all the tools work +`make doc`). If you don't have node installed you can generate them yourself. +Unfortunately there's no real standard for markdown and all the tools work differently. pandoc is one that seems to work well. To generate an html version of a doc do something like: @@ -10,4 +10,4 @@ The syntax for pandoc flavored markdown can be found at: http://johnmacfarlane.net/pandoc/README.html#pandocs-markdown A nice quick reference (for non-pandoc markdown) is at: -http://kramdown.rubyforge.org/quickref.html \ No newline at end of file +http://kramdown.rubyforge.org/quickref.html diff --git a/doc/rust.md b/doc/rust.md index e23613e149c..ac7125be424 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -3351,4 +3351,3 @@ Additional specific influences can be seen from the following languages: * The typeclass system of Haskell. * The lexical identifier rule of Python. * The block syntax of Ruby. - diff --git a/doc/tutorial-macros.md b/doc/tutorial-macros.md index 24e9f4abc38..63fa7e06bae 100644 --- a/doc/tutorial-macros.md +++ b/doc/tutorial-macros.md @@ -402,4 +402,3 @@ tricky. Invoking the `log_syntax!` macro can help elucidate intermediate states, invoking `trace_macros!(true)` will automatically print those intermediate states out, and passing the flag `--pretty expanded` as a command-line argument to the compiler will show the result of expansion. - diff --git a/doc/tutorial-tasks.md b/doc/tutorial-tasks.md index bed69674830..053d9e6d988 100644 --- a/doc/tutorial-tasks.md +++ b/doc/tutorial-tasks.md @@ -511,4 +511,3 @@ The parent task first calls `DuplexStream` to create a pair of bidirectional endpoints. It then uses `task::spawn` to create the child task, which captures one end of the communication channel. As a result, both parent and child can send and receive data to and from the other. - diff --git a/doc/tutorial.md b/doc/tutorial.md index 07eb3bc7681..90ae41affc9 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -1006,9 +1006,9 @@ let mut d = @mut 5; // mutable variable, mutable box d = @mut 15; ~~~~ -A mutable variable and an immutable variable can refer to the same box, given -that their types are compatible. Mutability of a box is a property of its type, -however, so for example a mutable handle to an immutable box cannot be +A mutable variable and an immutable variable can refer to the same box, given +that their types are compatible. Mutability of a box is a property of its type, +however, so for example a mutable handle to an immutable box cannot be assigned a reference to a mutable box. ~~~~ @@ -1041,7 +1041,7 @@ let y = x.clone(); // y is a newly allocated box let z = x; // no new memory allocated, x can no longer be used ~~~~ -Since in owned boxes mutability is a property of the owner, not the +Since in owned boxes mutability is a property of the owner, not the box, mutable boxes may become immutable when they are moved, and vice-versa. ~~~~ diff --git a/doc/version_info.html.template b/doc/version_info.html.template index 9376b29bcdf..aa44097a337 100644 --- a/doc/version_info.html.template +++ b/doc/version_info.html.template @@ -7,4 +7,3 @@ - diff --git a/mk/platform.mk b/mk/platform.mk index 1e102587bf4..e03b7c15247 100644 --- a/mk/platform.mk +++ b/mk/platform.mk @@ -11,7 +11,7 @@ # Create variables HOST_ containing the host part # of each target triple. For example, the triple i686-darwin-macos -# would create a variable HOST_i686-darwin-macos with the value +# would create a variable HOST_i686-darwin-macos with the value # i386. define DEF_HOST_VAR HOST_$(1) = $(subst i686,i386,$(word 1,$(subst -, ,$(1)))) @@ -276,8 +276,8 @@ CFG_GCCISH_CFLAGS_i686-pc-mingw32 := -Wall -Werror -g -march=i686 CFG_GCCISH_CXXFLAGS_i686-pc-mingw32 := -fno-rtti CFG_GCCISH_LINK_FLAGS_i686-pc-mingw32 := -shared -fPIC -g CFG_GCCISH_DEF_FLAG_i686-pc-mingw32 := -CFG_GCCISH_PRE_LIB_FLAGS_i686-pc-mingw32 := -CFG_GCCISH_POST_LIB_FLAGS_i686-pc-mingw32 := +CFG_GCCISH_PRE_LIB_FLAGS_i686-pc-mingw32 := +CFG_GCCISH_POST_LIB_FLAGS_i686-pc-mingw32 := CFG_DEF_SUFFIX_i686-pc-mingw32 := .mingw32.def CFG_INSTALL_NAME_i686-pc-mingw32 = CFG_LIBUV_LINK_FLAGS_i686-pc-mingw32 := -lWs2_32 -lpsapi -liphlpapi diff --git a/mk/rt.mk b/mk/rt.mk index c4c80b99fc0..30dda2fb276 100644 --- a/mk/rt.mk +++ b/mk/rt.mk @@ -1,27 +1,27 @@ # This is a procedure to define the targets for building -# the runtime. +# the runtime. # # Argument 1 is the target triple. # # This is not really the right place to explain this, but # for those of you who are not Makefile gurus, let me briefly -# cover the $ expansion system in use here, because it +# cover the $ expansion system in use here, because it # confused me for a while! The variable DEF_RUNTIME_TARGETS # will be defined once and then expanded with different # values substituted for $(1) each time it is called. -# That resulting text is then eval'd. +# That resulting text is then eval'd. # # For most variables, you could use a single $ sign. The result # is that the substitution would occur when the CALL occurs, # I believe. The problem is that the automatic variables $< and $@ # need to be expanded-per-rule. Therefore, for those variables at -# least, you need $$< and $$@ in the variable text. This way, after +# least, you need $$< and $$@ in the variable text. This way, after # the CALL substitution occurs, you will have $< and $@. This text # will then be evaluated, and all will work as you like. # # Reader beware, this explanantion could be wrong, but it seems to -# fit the experimental data (i.e., I was able to get the system -# working under these assumptions). +# fit the experimental data (i.e., I was able to get the system +# working under these assumptions). # Hack for passing flags into LIBUV, see below. LIBUV_FLAGS_i386 = -m32 -fPIC diff --git a/mk/stage0.mk b/mk/stage0.mk index 7b5cbef1d72..ac1b3e86ac9 100644 --- a/mk/stage0.mk +++ b/mk/stage0.mk @@ -7,16 +7,16 @@ $(HBIN0_H_$(CFG_BUILD_TRIPLE))/rustc$(X_$(CFG_BUILD_TRIPLE)): \ $(S)src/etc/get-snapshot.py $(MKFILE_DEPS) @$(call E, fetch: $@) # Note: the variable "SNAPSHOT_FILE" is generally not set, and so -# we generally only pass one argument to this script. +# we generally only pass one argument to this script. ifdef CFG_ENABLE_LOCAL_RUST $(Q)$(S)src/etc/local_stage0.sh $(CFG_BUILD_TRIPLE) $(CFG_LOCAL_RUST_ROOT) -else +else $(Q)$(CFG_PYTHON) $(S)src/etc/get-snapshot.py $(CFG_BUILD_TRIPLE) $(SNAPSHOT_FILE) ifdef CFG_ENABLE_PAX_FLAGS @$(call E, apply PaX flags: $@) @"$(CFG_PAXCTL)" -cm "$@" endif -endif +endif $(Q)touch $@ # Host libs will be extracted by the above rule diff --git a/mk/tests.mk b/mk/tests.mk index f96b7325f60..175e33c6654 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -179,9 +179,9 @@ tidy: $(Q)find $(S)src/etc -name '*.py' \ | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py $(Q)echo $(ALL_CS) \ - | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py + | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py $(Q)echo $(ALL_HS) \ - | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py + | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py endif @@ -709,4 +709,3 @@ endef $(foreach host,$(CFG_HOST_TRIPLES), \ $(eval $(call DEF_CHECK_FAST_FOR_H,$(host)))) - diff --git a/src/etc/check-links.pl b/src/etc/check-links.pl index a280ed55ba9..6492be53d34 100755 --- a/src/etc/check-links.pl +++ b/src/etc/check-links.pl @@ -9,7 +9,7 @@ my $anchors = {}; my $i = 0; foreach $line (@lines) { $i++; - if ($line =~ m/id="([^"]+)"/) { + if ($line =~ m/id="([^"]+)"/) { $anchors->{$1} = $i; } } @@ -17,10 +17,9 @@ foreach $line (@lines) { $i = 0; foreach $line (@lines) { $i++; - while ($line =~ m/href="#([^"]+)"/g) { + while ($line =~ m/href="#([^"]+)"/g) { if (! exists($anchors->{$1})) { print "$file:$i: $1 referenced\n"; } } } - diff --git a/src/etc/gedit/readme.txt b/src/etc/gedit/readme.txt index 735b0236276..e394f191608 100644 --- a/src/etc/gedit/readme.txt +++ b/src/etc/gedit/readme.txt @@ -8,4 +8,3 @@ Instructions for Ubuntu Linux 12.04+ 2) Copy the included "share" folder into "~/.local/" 3) Open a shell in "~/.local/share/" and run "update-mime-database mime" - diff --git a/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang b/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang index 0b23808b765..a413d0a9062 100644 --- a/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang +++ b/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang @@ -123,11 +123,11 @@ mode_t ssize_t - + self - + true false @@ -261,4 +261,3 @@ - diff --git a/src/etc/gedit/share/mime/packages/rust.xml b/src/etc/gedit/share/mime/packages/rust.xml index 65168aae1d9..d75cffe9600 100644 --- a/src/etc/gedit/share/mime/packages/rust.xml +++ b/src/etc/gedit/share/mime/packages/rust.xml @@ -2,6 +2,6 @@ Rust Source - + diff --git a/src/etc/indenter b/src/etc/indenter index 017cb926981..1a3a4465335 100755 --- a/src/etc/indenter +++ b/src/etc/indenter @@ -14,4 +14,3 @@ while (<>) { $indent -= 1; } } - diff --git a/src/etc/latest-unix-snaps.py b/src/etc/latest-unix-snaps.py index 7a2ddba3a16..7cecf837161 100755 --- a/src/etc/latest-unix-snaps.py +++ b/src/etc/latest-unix-snaps.py @@ -52,5 +52,3 @@ def download_new_file (date, rev, platform, hsh): for ff in newestSet["files"]: download_new_file (newestSet["date"], newestSet["rev"], ff["platform"], ff["hash"]) - - diff --git a/src/etc/libc.c b/src/etc/libc.c index 9acc122f32b..e341f495eeb 100644 --- a/src/etc/libc.c +++ b/src/etc/libc.c @@ -243,4 +243,3 @@ int main() { extra_consts(); printf("}\n"); } - diff --git a/src/etc/licenseck.py b/src/etc/licenseck.py index 973b7deb960..1e0c541cd89 100644 --- a/src/etc/licenseck.py +++ b/src/etc/licenseck.py @@ -96,4 +96,3 @@ def check_license(name, contents): return True return False - diff --git a/src/etc/local_stage0.sh b/src/etc/local_stage0.sh index 5898bc561aa..8d2fd887e3f 100755 --- a/src/etc/local_stage0.sh +++ b/src/etc/local_stage0.sh @@ -1,13 +1,13 @@ #!/bin/sh -TARG_DIR=$1 +TARG_DIR=$1 PREFIX=$2 BINDIR=bin LIBDIR=lib OS=`uname -s` -case $OS in +case $OS in ("Linux"|"FreeBSD") BIN_SUF= LIB_SUF=.so diff --git a/src/etc/mirror-all-snapshots.py b/src/etc/mirror-all-snapshots.py index f1fce7a94b5..3b5f66c4117 100644 --- a/src/etc/mirror-all-snapshots.py +++ b/src/etc/mirror-all-snapshots.py @@ -33,6 +33,3 @@ for line in f.readlines(): print("got download with ok hash") else: raise Exception("bad hash on download") - - - diff --git a/src/etc/monodebug.pl b/src/etc/monodebug.pl index 324c576a4bd..a2d27591cad 100755 --- a/src/etc/monodebug.pl +++ b/src/etc/monodebug.pl @@ -77,4 +77,3 @@ while (my ($key, $substs) = each %funcs) { } print "\n"; } - diff --git a/src/etc/sugarise-doc-comments.py b/src/etc/sugarise-doc-comments.py index 6399cff6b88..7bd4175fbf0 100755 --- a/src/etc/sugarise-doc-comments.py +++ b/src/etc/sugarise-doc-comments.py @@ -80,4 +80,3 @@ def sugarise_file(path): for (dirpath, dirnames, filenames) in os.walk('.'): for name in fnmatch.filter(filenames, '*.r[sc]'): sugarise_file(os.path.join(dirpath, name)) - diff --git a/src/etc/tidy.py b/src/etc/tidy.py index a5cf6141567..06fcb5cb945 100644 --- a/src/etc/tidy.py +++ b/src/etc/tidy.py @@ -81,4 +81,3 @@ except UnicodeDecodeError, e: sys.exit(err) - diff --git a/src/etc/x86.supp b/src/etc/x86.supp index 417f4c9d2c1..def1c5a53c1 100644 --- a/src/etc/x86.supp +++ b/src/etc/x86.supp @@ -366,7 +366,7 @@ ... } -{ +{ llvm-user-new-leak Memcheck:Leak fun:_Znwj @@ -401,7 +401,7 @@ Helgrind:Race fun:_ZN15lock_and_signal27lock_held_by_current_threadEv ... -} +} { lock_and_signal-probably-threadsafe-access-outside-of-lock2 diff --git a/src/libcore/cleanup.rs b/src/libcore/cleanup.rs index a07c6b4811b..bf92d605f2b 100644 --- a/src/libcore/cleanup.rs +++ b/src/libcore/cleanup.rs @@ -226,4 +226,3 @@ pub mod rustrt { pub unsafe fn rust_get_task() -> *c_void; } } - diff --git a/src/libcore/logging.rs b/src/libcore/logging.rs index ba976de50ab..afe8338f2ce 100644 --- a/src/libcore/logging.rs +++ b/src/libcore/logging.rs @@ -59,4 +59,3 @@ pub fn log_type(level: u32, object: &T) { rustrt::rust_log_str(level, transmute(vec::raw::to_ptr(bytes)), len); } } - diff --git a/src/libcore/owned.rs b/src/libcore/owned.rs index c483ec79e21..599591e2f6d 100644 --- a/src/libcore/owned.rs +++ b/src/libcore/owned.rs @@ -31,4 +31,3 @@ impl Ord for ~T { #[inline(always)] fn gt(&self, other: &~T) -> bool { *(*self) > *(*other) } } - diff --git a/src/libcore/rt/context.rs b/src/libcore/rt/context.rs index 4714be9e3d5..9c1e566f218 100644 --- a/src/libcore/rt/context.rs +++ b/src/libcore/rt/context.rs @@ -207,4 +207,3 @@ pub fn mut_offset(ptr: *mut T, count: int) -> *mut T { use core::sys::size_of; (ptr as int + count * (size_of::() as int)) as *mut T } - diff --git a/src/libcore/rt/io/comm_adapters.rs b/src/libcore/rt/io/comm_adapters.rs index 1d6893b3ca6..7e891f1718e 100644 --- a/src/libcore/rt/io/comm_adapters.rs +++ b/src/libcore/rt/io/comm_adapters.rs @@ -56,4 +56,3 @@ impl WriterChan { impl GenericChan<~[u8]> for WriterChan { fn send(&self, _x: ~[u8]) { fail!() } } - diff --git a/src/libcore/rt/io/net/ip.rs b/src/libcore/rt/io/net/ip.rs index d9b7f4e6e40..df1dfe4d38a 100644 --- a/src/libcore/rt/io/net/ip.rs +++ b/src/libcore/rt/io/net/ip.rs @@ -12,4 +12,3 @@ pub enum IpAddr { Ipv4(u8, u8, u8, u8, u16), Ipv6 } - diff --git a/src/libcore/rt/io/net/udp.rs b/src/libcore/rt/io/net/udp.rs index 0cb2978fb1a..1f1254a7029 100644 --- a/src/libcore/rt/io/net/udp.rs +++ b/src/libcore/rt/io/net/udp.rs @@ -47,4 +47,3 @@ impl UdpListener { impl Listener for UdpListener { fn accept(&mut self) -> Option { fail!() } } - diff --git a/src/libcore/rt/io/net/unix.rs b/src/libcore/rt/io/net/unix.rs index 262816beecc..f449a857467 100644 --- a/src/libcore/rt/io/net/unix.rs +++ b/src/libcore/rt/io/net/unix.rs @@ -47,4 +47,3 @@ impl UnixListener { impl Listener for UnixListener { fn accept(&mut self) -> Option { fail!() } } - diff --git a/src/libcore/rt/local_heap.rs b/src/libcore/rt/local_heap.rs index fbd4a77d79b..6bf228a1b22 100644 --- a/src/libcore/rt/local_heap.rs +++ b/src/libcore/rt/local_heap.rs @@ -78,4 +78,3 @@ extern { size: size_t) -> *OpaqueBox; fn rust_boxed_region_free(region: *BoxedRegion, box: *OpaqueBox); } - diff --git a/src/libcore/rt/sched/local_sched.rs b/src/libcore/rt/sched/local_sched.rs index 2d1e06163be..a7e02f30e01 100644 --- a/src/libcore/rt/sched/local_sched.rs +++ b/src/libcore/rt/sched/local_sched.rs @@ -143,4 +143,3 @@ fn borrow_smoke_test() { } let _scheduler = take(); } - diff --git a/src/libcore/stackwalk.rs b/src/libcore/stackwalk.rs index ebf36e4e09a..272bdca8654 100644 --- a/src/libcore/stackwalk.rs +++ b/src/libcore/stackwalk.rs @@ -99,4 +99,3 @@ pub mod rusti { pub fn frame_address(+f: &once fn(x: *u8)); } } - diff --git a/src/libcore/unicode.rs b/src/libcore/unicode.rs index 34175f9888f..d6e2c5eee6a 100644 --- a/src/libcore/unicode.rs +++ b/src/libcore/unicode.rs @@ -2642,4 +2642,3 @@ pub mod derived_property { bsearch_range_table(c, XID_Start_table) } } - diff --git a/src/libcore/unstable/exchange_alloc.rs b/src/libcore/unstable/exchange_alloc.rs index 8ca5486d929..57ed579e88d 100644 --- a/src/libcore/unstable/exchange_alloc.rs +++ b/src/libcore/unstable/exchange_alloc.rs @@ -81,4 +81,3 @@ extern { #[rust_stack] fn rust_get_exchange_count_ptr() -> *mut int; } - diff --git a/src/libcore/unstable/weak_task.rs b/src/libcore/unstable/weak_task.rs index 7a30bb92111..6edbdcb51b0 100644 --- a/src/libcore/unstable/weak_task.rs +++ b/src/libcore/unstable/weak_task.rs @@ -205,4 +205,3 @@ fn test_select_stream_and_oneshot() { chan.send(()); waitport.recv(); } - diff --git a/src/librustc/metadata/common.rs b/src/librustc/metadata/common.rs index 111c201d502..d2b71447f47 100644 --- a/src/librustc/metadata/common.rs +++ b/src/librustc/metadata/common.rs @@ -169,4 +169,3 @@ pub struct LinkMeta { vers: @str, extras_hash: @str } - diff --git a/src/librustc/metadata/mod.rs b/src/librustc/metadata/mod.rs index 78d5be4d4ae..24007380fee 100644 --- a/src/librustc/metadata/mod.rs +++ b/src/librustc/metadata/mod.rs @@ -18,4 +18,3 @@ pub mod cstore; pub mod csearch; pub mod loader; pub mod filesearch; - diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index 526a5a3a9dd..4ab24a17d31 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -802,4 +802,3 @@ fn check_loans_in_block(blk: &ast::blk, visit::visit_block(blk, self, vt); } } - diff --git a/src/librustc/middle/borrowck/gather_loans.rs b/src/librustc/middle/borrowck/gather_loans.rs index da048534118..fd1f6f5c450 100644 --- a/src/librustc/middle/borrowck/gather_loans.rs +++ b/src/librustc/middle/borrowck/gather_loans.rs @@ -639,4 +639,3 @@ fn add_stmt_to_map(stmt: @ast::stmt, } visit::visit_stmt(stmt, self, vt); } - diff --git a/src/librustc/middle/borrowck/loan.rs b/src/librustc/middle/borrowck/loan.rs index 4dd727390aa..641571373bd 100644 --- a/src/librustc/middle/borrowck/loan.rs +++ b/src/librustc/middle/borrowck/loan.rs @@ -309,4 +309,3 @@ pub impl LoanContext { } } } - diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 7298064e1c0..f6d138a4a69 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -423,4 +423,3 @@ pub fn collect_language_items(crate: @crate, collector.collect(); copy items } - diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 866bd5377b9..29ca875806f 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -1179,4 +1179,3 @@ pub impl categorization { } } } - diff --git a/src/librustc/middle/pat_util.rs b/src/librustc/middle/pat_util.rs index 3ca79982b7b..b87adb75bc3 100644 --- a/src/librustc/middle/pat_util.rs +++ b/src/librustc/middle/pat_util.rs @@ -86,4 +86,3 @@ pub fn pat_binding_ids(dm: resolve::DefMap, pat: @pat) -> ~[node_id] { pat_bindings(dm, pat, |_bm, b_id, _sp, _pt| found.push(b_id) ); return found; } - diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index be981956219..083c436c83e 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -603,4 +603,3 @@ pub fn check_crate(tcx: ty::ctxt, }); visit::visit_crate(crate, method_map, visitor); } - diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 4faa2150003..753a6d25cbb 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -968,4 +968,3 @@ pub fn determine_rp_in_crate(sess: Session, // return final set return cx.region_paramd_items; } - diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs index c3a79373931..bf64134704a 100644 --- a/src/librustc/middle/subst.rs +++ b/src/librustc/middle/subst.rs @@ -186,4 +186,3 @@ impl Subst for ty::ty_param_bounds_and_ty { } } } - diff --git a/src/librustc/middle/trans/cabi.rs b/src/librustc/middle/trans/cabi.rs index ed028d14bd6..d49e8e0969a 100644 --- a/src/librustc/middle/trans/cabi.rs +++ b/src/librustc/middle/trans/cabi.rs @@ -190,4 +190,3 @@ pub impl FnType { Store(bcx, llretval, llretptr); } } - diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index ed7f91bf04a..fc645e2bb6c 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -799,4 +799,3 @@ pub fn trans_arg_expr(bcx: block, debug!("--- trans_arg_expr passing %s", val_str(bcx.ccx().tn, val)); return rslt(bcx, val); } - diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs index e35fef6b6f6..84100d7195e 100644 --- a/src/librustc/middle/trans/closure.rs +++ b/src/librustc/middle/trans/closure.rs @@ -599,4 +599,3 @@ pub fn make_opaque_cbox_free_glue( } } } - diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs index 113136fa58d..c9a4f078c79 100644 --- a/src/librustc/middle/trans/controlflow.rs +++ b/src/librustc/middle/trans/controlflow.rs @@ -398,4 +398,3 @@ pub fn trans_fail_bounds_check(bcx: block, sp: span, Unreachable(bcx); return bcx; } - diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index cf5fbb6e216..c6b32930c5f 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -855,4 +855,3 @@ pub impl DatumBlock { self.datum.to_str(self.ccx()) } } - diff --git a/src/librustc/middle/trans/inline.rs b/src/librustc/middle/trans/inline.rs index ad06a9715b4..35136410268 100644 --- a/src/librustc/middle/trans/inline.rs +++ b/src/librustc/middle/trans/inline.rs @@ -122,4 +122,3 @@ pub fn maybe_instantiate_inline(ccx: @CrateContext, fn_id: ast::def_id, } } } - diff --git a/src/librustc/middle/trans/machine.rs b/src/librustc/middle/trans/machine.rs index 3ae2421a555..b1349104e54 100644 --- a/src/librustc/middle/trans/machine.rs +++ b/src/librustc/middle/trans/machine.rs @@ -153,4 +153,3 @@ pub fn static_size_of_enum(cx: @CrateContext, t: ty::t) -> uint { _ => cx.sess.bug(~"static_size_of_enum called on non-enum") } } - diff --git a/src/librustc/middle/trans/macros.rs b/src/librustc/middle/trans/macros.rs index 14ed7692661..43cc66c5568 100644 --- a/src/librustc/middle/trans/macros.rs +++ b/src/librustc/middle/trans/macros.rs @@ -51,4 +51,3 @@ macro_rules! trace( } ) ) - diff --git a/src/librustc/middle/trans/reachable.rs b/src/librustc/middle/trans/reachable.rs index f301a7d2973..217eda870be 100644 --- a/src/librustc/middle/trans/reachable.rs +++ b/src/librustc/middle/trans/reachable.rs @@ -242,4 +242,3 @@ fn traverse_all_resources_and_impls(cx: &ctx, crate_mod: &_mod) { ..*visit::default_visitor() })); } - diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index 7e59f580a2c..9bae0560918 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -404,4 +404,3 @@ pub fn ast_purity_constant(purity: ast::purity) -> uint { ast::extern_fn => 3u } } - diff --git a/src/librustc/middle/trans/shape.rs b/src/librustc/middle/trans/shape.rs index 08337c918b0..6ff9e1cfc57 100644 --- a/src/librustc/middle/trans/shape.rs +++ b/src/librustc/middle/trans/shape.rs @@ -74,4 +74,3 @@ pub fn add_substr(dest: &mut ~[u8], src: ~[u8]) { add_u16(&mut *dest, vec::len(src) as u16); *dest += src; } - diff --git a/src/librustc/middle/trans/type_use.rs b/src/librustc/middle/trans/type_use.rs index e19eba6ca98..794912d8307 100644 --- a/src/librustc/middle/trans/type_use.rs +++ b/src/librustc/middle/trans/type_use.rs @@ -383,4 +383,3 @@ pub fn handle_body(cx: Context, body: &blk) { }); (v.visit_block)(body, cx, v); } - diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index de384d02dc3..8eadf3acc98 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -633,4 +633,3 @@ pub fn check_pointer_pat(pcx: &pat_ctxt, #[deriving(Eq)] enum PointerKind { Managed, Owned, Borrowed } - diff --git a/src/librustc/middle/typeck/check/demand.rs b/src/librustc/middle/typeck/check/demand.rs index 1bb71c156c3..3fa551e4b05 100644 --- a/src/librustc/middle/typeck/check/demand.rs +++ b/src/librustc/middle/typeck/check/demand.rs @@ -66,5 +66,3 @@ pub fn coerce(fcx: @mut FnCtxt, } } } - - diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index 532638faa68..7f390de1f49 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -666,5 +666,3 @@ pub fn resolve_in_block(fcx: @mut FnCtxt, bl: &ast::blk) { .. *visit::default_visitor() })); } - - diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index 7fff756b01d..fe07dc9412d 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -1119,4 +1119,3 @@ pub fn check_coherence(crate_context: @mut CrateCtxt, crate: @crate) { let coherence_checker = @CoherenceChecker(crate_context); coherence_checker.check_coherence(crate); } - diff --git a/src/librustc/middle/typeck/infer/combine.rs b/src/librustc/middle/typeck/infer/combine.rs index de3ffcd63ab..362104e98b0 100644 --- a/src/librustc/middle/typeck/infer/combine.rs +++ b/src/librustc/middle/typeck/infer/combine.rs @@ -635,4 +635,3 @@ pub fn super_trait_refs( }) } } - diff --git a/src/librustc/middle/typeck/infer/glb.rs b/src/librustc/middle/typeck/infer/glb.rs index 2bbcd24595c..dc1e3e845df 100644 --- a/src/librustc/middle/typeck/infer/glb.rs +++ b/src/librustc/middle/typeck/infer/glb.rs @@ -313,4 +313,3 @@ impl Combine for Glb { super_trait_refs(self, a, b) } } - diff --git a/src/librustc/middle/typeck/infer/macros.rs b/src/librustc/middle/typeck/infer/macros.rs index e02772d951c..306f124be3c 100644 --- a/src/librustc/middle/typeck/infer/macros.rs +++ b/src/librustc/middle/typeck/infer/macros.rs @@ -18,4 +18,3 @@ macro_rules! if_ok( } ) ) - diff --git a/src/librustc/middle/typeck/infer/region_inference.rs b/src/librustc/middle/typeck/infer/region_inference.rs index 25e65d7a18b..1ee59c3fe06 100644 --- a/src/librustc/middle/typeck/infer/region_inference.rs +++ b/src/librustc/middle/typeck/infer/region_inference.rs @@ -1746,4 +1746,3 @@ fn iterate_until_fixed_point( } debug!("---- %s Complete after %u iteration(s)", tag, iteration); } - diff --git a/src/librustc/middle/typeck/infer/resolve.rs b/src/librustc/middle/typeck/infer/resolve.rs index 9b648f6a053..2b88825c49a 100644 --- a/src/librustc/middle/typeck/infer/resolve.rs +++ b/src/librustc/middle/typeck/infer/resolve.rs @@ -278,4 +278,3 @@ pub impl ResolveState { } } } - diff --git a/src/librustc/middle/typeck/infer/sub.rs b/src/librustc/middle/typeck/infer/sub.rs index 266d157c4d0..48d7765f88e 100644 --- a/src/librustc/middle/typeck/infer/sub.rs +++ b/src/librustc/middle/typeck/infer/sub.rs @@ -269,4 +269,3 @@ impl Combine for Sub { super_trait_refs(self, a, b) } } - diff --git a/src/librustc/middle/typeck/infer/unify.rs b/src/librustc/middle/typeck/infer/unify.rs index bc130744224..e50f2089e4f 100644 --- a/src/librustc/middle/typeck/infer/unify.rs +++ b/src/librustc/middle/typeck/infer/unify.rs @@ -265,5 +265,3 @@ impl SimplyUnifiable for ast::float_ty { return ty::terr_float_mismatch(err); } } - - diff --git a/src/librustdoc/path_pass.rs b/src/librustdoc/path_pass.rs index 629c6955566..5560f21af61 100644 --- a/src/librustdoc/path_pass.rs +++ b/src/librustdoc/path_pass.rs @@ -112,4 +112,3 @@ fn should_record_fn_paths() { assert!(doc.cratemod().mods()[0].fns()[0].path() == ~[~"a"]); } } - diff --git a/src/librustpkg/testsuite/pass/commands.txt b/src/librustpkg/testsuite/pass/commands.txt index e1a1b2462b2..baeaef1e3c7 100644 --- a/src/librustpkg/testsuite/pass/commands.txt +++ b/src/librustpkg/testsuite/pass/commands.txt @@ -32,4 +32,3 @@ Commands that should succeed: 15. `rustpkg test foo` runs tests and prints their output, if foo contains #[test]s. 16. If foo is installed, `rustpkg uninstall foo; rustpkg list` doesn't include foo in the list - diff --git a/src/librustpkg/testsuite/pass/src/deeply/nested/path/foo/src/main.rs b/src/librustpkg/testsuite/pass/src/deeply/nested/path/foo/src/main.rs index 41041ccb509..62785c06db3 100644 --- a/src/librustpkg/testsuite/pass/src/deeply/nested/path/foo/src/main.rs +++ b/src/librustpkg/testsuite/pass/src/deeply/nested/path/foo/src/main.rs @@ -15,4 +15,3 @@ The test runner should check that, after `rustpkg install deeply/nested/path/foo */ fn main() {} - diff --git a/src/libstd/num/bigint.rs b/src/libstd/num/bigint.rs index 497ce7f41aa..cd347098e25 100644 --- a/src/libstd/num/bigint.rs +++ b/src/libstd/num/bigint.rs @@ -1957,4 +1957,3 @@ mod bigint_tests { assert!(-Zero::zero::() == Zero::zero::()); } } - diff --git a/src/libstd/serialize.rs b/src/libstd/serialize.rs index 33efb2c6a5a..39fb5a45d7e 100644 --- a/src/libstd/serialize.rs +++ b/src/libstd/serialize.rs @@ -1883,4 +1883,3 @@ impl DecoderHelpers for D { } } } - diff --git a/src/libstd/task_pool.rs b/src/libstd/task_pool.rs index 82053602755..661247df1c1 100644 --- a/src/libstd/task_pool.rs +++ b/src/libstd/task_pool.rs @@ -100,4 +100,3 @@ fn test_task_pool() { pool.execute(|i| io::println(fmt!("Hello from thread %u!", *i))); } } - diff --git a/src/libsyntax/ext/pipes/check.rs b/src/libsyntax/ext/pipes/check.rs index c2c0c06342b..38e43d1ade5 100644 --- a/src/libsyntax/ext/pipes/check.rs +++ b/src/libsyntax/ext/pipes/check.rs @@ -80,4 +80,3 @@ impl proto::visitor<(), (), ()> for @ext_ctxt { } } } - diff --git a/src/libsyntax/ext/pipes/liveness.rs b/src/libsyntax/ext/pipes/liveness.rs index 4597dab89cb..18faab8c88d 100644 --- a/src/libsyntax/ext/pipes/liveness.rs +++ b/src/libsyntax/ext/pipes/liveness.rs @@ -104,4 +104,3 @@ pub fn analyze(proto: protocol, _cx: @ext_ctxt) { proto.bounded = Some(true); } } - diff --git a/src/libsyntax/ext/pipes/mod.rs b/src/libsyntax/ext/pipes/mod.rs index 81b2442ea82..85c578bc2ce 100644 --- a/src/libsyntax/ext/pipes/mod.rs +++ b/src/libsyntax/ext/pipes/mod.rs @@ -85,4 +85,3 @@ pub fn expand_proto(cx: @ext_ctxt, _sp: span, id: ast::ident, // compile base::MRItem(proto.compile(cx)) } - diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index 79072a2f577..64e2f1041c1 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -217,4 +217,3 @@ pub fn visit>( }; visitor.visit_proto(proto, states) } - diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index f7412a4502c..2bf4b05aa6b 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -760,4 +760,3 @@ fn expand_parse_call(cx: @ext_ctxt, id_ext(cx, parse_method), arg_exprs) } - diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index c1afc53def0..e486a6254e7 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -298,4 +298,3 @@ pub impl Parser { } } - diff --git a/src/libsyntax/syntax.rc b/src/libsyntax/syntax.rc index a401d9eb8ac..d00719b2590 100644 --- a/src/libsyntax/syntax.rc +++ b/src/libsyntax/syntax.rc @@ -90,4 +90,3 @@ pub mod ext { pub mod trace_macros; } - diff --git a/src/rt/arch/arm/_context.S b/src/rt/arch/arm/_context.S index 9097ebfc070..6441f59a4d3 100644 --- a/src/rt/arch/arm/_context.S +++ b/src/rt/arch/arm/_context.S @@ -48,5 +48,3 @@ swap_registers: msr cpsr_cxsf, r2 mov pc, lr - - diff --git a/src/rt/arch/arm/gpr.cpp b/src/rt/arch/arm/gpr.cpp index 6dd385fb330..77ec9d5182a 100644 --- a/src/rt/arch/arm/gpr.cpp +++ b/src/rt/arch/arm/gpr.cpp @@ -14,4 +14,3 @@ void rust_gpr::load() { LOAD(r8); LOAD(r9); LOAD(r10); LOAD(r11); LOAD(r12); LOAD(r13); LOAD(r14); LOAD(r15); } - diff --git a/src/rt/arch/arm/gpr.h b/src/rt/arch/arm/gpr.h index 49db1429903..c8a3e916a37 100644 --- a/src/rt/arch/arm/gpr.h +++ b/src/rt/arch/arm/gpr.h @@ -21,4 +21,3 @@ public: }; #endif - diff --git a/src/rt/arch/arm/morestack.S b/src/rt/arch/arm/morestack.S index 4f1431a3392..f0ec3f4b7a5 100644 --- a/src/rt/arch/arm/morestack.S +++ b/src/rt/arch/arm/morestack.S @@ -35,7 +35,7 @@ __morestack: mov r0, r4 // The amount of stack needed add r1, fp, #20 // Address of stack arguments mov r2, r5 // Size of stack arguments - + // Create new stack bl upcall_new_stack@plt @@ -64,7 +64,7 @@ __morestack: // Restore return value mov r0, r4 mov r1, r5 - + // Return pop {r6, fp, lr} mov pc, lr diff --git a/src/rt/arch/arm/record_sp.S b/src/rt/arch/arm/record_sp.S index fe680004a89..95fce8746a1 100644 --- a/src/rt/arch/arm/record_sp.S +++ b/src/rt/arch/arm/record_sp.S @@ -28,4 +28,3 @@ get_sp_limit: get_sp: mov r0, sp mov pc, lr - diff --git a/src/rt/arch/arm/regs.h b/src/rt/arch/arm/regs.h index 2b44bd3af35..0d1c24e0fb7 100644 --- a/src/rt/arch/arm/regs.h +++ b/src/rt/arch/arm/regs.h @@ -19,5 +19,3 @@ # define RUSTRT_ARG1_S r1 # define RUSTRT_ARG2_S r2 # define RUSTRT_ARG3_S r3 - - diff --git a/src/rt/arch/i386/_context.S b/src/rt/arch/i386/_context.S index d2643d07c3d..e2e4ffe35b4 100644 --- a/src/rt/arch/i386/_context.S +++ b/src/rt/arch/i386/_context.S @@ -63,5 +63,3 @@ SWAP_REGISTERS: // Return! jmp *48(%eax) - - diff --git a/src/rt/arch/i386/gpr.cpp b/src/rt/arch/i386/gpr.cpp index bebf8019427..e5a59d664b0 100644 --- a/src/rt/arch/i386/gpr.cpp +++ b/src/rt/arch/i386/gpr.cpp @@ -20,4 +20,3 @@ void rust_gpr::load() { LOAD(eax); LOAD(ebx); LOAD(ecx); LOAD(edx); LOAD(esi); LOAD(edi); LOAD(ebp); LOAD(esi); } - diff --git a/src/rt/arch/i386/gpr.h b/src/rt/arch/i386/gpr.h index 6ae53e113f4..1953170301c 100644 --- a/src/rt/arch/i386/gpr.h +++ b/src/rt/arch/i386/gpr.h @@ -29,4 +29,3 @@ public: }; #endif - diff --git a/src/rt/arch/i386/morestack.S b/src/rt/arch/i386/morestack.S index e8a9c1312ed..c1cd11fa432 100644 --- a/src/rt/arch/i386/morestack.S +++ b/src/rt/arch/i386/morestack.S @@ -97,7 +97,7 @@ #endif .globl MORESTACK -// FIXME: What about _WIN32? +// FIXME: What about _WIN32? #if defined(__linux__) || defined(__FreeBSD__) .hidden MORESTACK #else @@ -253,4 +253,3 @@ L_upcall_del_stack$stub: .subsections_via_symbols #endif - diff --git a/src/rt/arch/mips/gpr.h b/src/rt/arch/mips/gpr.h index 4ff0729633a..b48c1d4e732 100644 --- a/src/rt/arch/mips/gpr.h +++ b/src/rt/arch/mips/gpr.h @@ -30,4 +30,3 @@ public: }; #endif - diff --git a/src/rt/arch/x86_64/_context.S b/src/rt/arch/x86_64/_context.S index bedd6855467..f718cac9634 100644 --- a/src/rt/arch/x86_64/_context.S +++ b/src/rt/arch/x86_64/_context.S @@ -121,4 +121,3 @@ SWAP_REGISTERS: // Jump to the instruction pointer // found in regs: jmp *(RUSTRT_IP*8)(ARG1) - diff --git a/src/rt/arch/x86_64/gpr.cpp b/src/rt/arch/x86_64/gpr.cpp index cf43125923a..37247d1dfdc 100644 --- a/src/rt/arch/x86_64/gpr.cpp +++ b/src/rt/arch/x86_64/gpr.cpp @@ -22,4 +22,3 @@ void rust_gpr::load() { LOAD(r8); LOAD(r9); LOAD(r10); LOAD(r11); LOAD(r12); LOAD(r13); LOAD(r14); LOAD(r15); } - diff --git a/src/rt/arch/x86_64/gpr.h b/src/rt/arch/x86_64/gpr.h index 75c3b081e77..18ef77dbba6 100644 --- a/src/rt/arch/x86_64/gpr.h +++ b/src/rt/arch/x86_64/gpr.h @@ -30,4 +30,3 @@ public: }; #endif - diff --git a/src/rt/arch/x86_64/regs.h b/src/rt/arch/x86_64/regs.h index 7d0efd1eec8..1aca452df10 100644 --- a/src/rt/arch/x86_64/regs.h +++ b/src/rt/arch/x86_64/regs.h @@ -43,5 +43,3 @@ # define RUSTRT_ARG4_S %r8 # define RUSTRT_ARG5_S %r9 #endif - - diff --git a/src/rt/isaac/rand.h b/src/rt/isaac/rand.h index 3da2d71b20b..c28b35e688d 100644 --- a/src/rt/isaac/rand.h +++ b/src/rt/isaac/rand.h @@ -52,5 +52,3 @@ void isaac(randctx *r); (r)->randrsl[(r)->randcnt]) #endif /* RAND */ - - diff --git a/src/rt/rust_abi.cpp b/src/rt/rust_abi.cpp index ca8448b39a1..fd1b7860b29 100644 --- a/src/rt/rust_abi.cpp +++ b/src/rt/rust_abi.cpp @@ -86,4 +86,3 @@ symbolicate(const std::vector &frames) { } } // end namespace stack_walk - diff --git a/src/rt/rust_abi.h b/src/rt/rust_abi.h index c56bf96291f..4179bf75157 100644 --- a/src/rt/rust_abi.h +++ b/src/rt/rust_abi.h @@ -76,4 +76,3 @@ std::string symbolicate(const std::vector &frames); uint32_t get_abi_version(); #endif - diff --git a/src/rt/rust_android_dummy.h b/src/rt/rust_android_dummy.h index 95a1774894b..3d6c949fd34 100644 --- a/src/rt/rust_android_dummy.h +++ b/src/rt/rust_android_dummy.h @@ -12,4 +12,3 @@ char **backtrace_symbols (void *__const *__array, int __size); void backtrace_symbols_fd (void *__const *__array, int __size, int __fd); #endif - diff --git a/src/rt/rust_debug.cpp b/src/rt/rust_debug.cpp index 5c5be45bef8..f403b0434b6 100644 --- a/src/rt/rust_debug.cpp +++ b/src/rt/rust_debug.cpp @@ -58,4 +58,3 @@ dump_origin(rust_task *task, void *ptr) { } } // end namespace debug - diff --git a/src/rt/rust_debug.h b/src/rt/rust_debug.h index c9aad098d38..7f025bb908e 100644 --- a/src/rt/rust_debug.h +++ b/src/rt/rust_debug.h @@ -70,4 +70,3 @@ void dump_origin(rust_task *task, void *ptr); } // end namespace debug #endif - diff --git a/src/rt/rust_gpr_base.h b/src/rt/rust_gpr_base.h index 4df6ea3e9ad..7ec2dda9cd4 100644 --- a/src/rt/rust_gpr_base.h +++ b/src/rt/rust_gpr_base.h @@ -31,4 +31,3 @@ public: #endif - diff --git a/src/rustllvm/README b/src/rustllvm/README index 31495f22c0a..c0db3f68a76 100644 --- a/src/rustllvm/README +++ b/src/rustllvm/README @@ -1,3 +1,2 @@ This directory currently contains some LLVM support code. This will generally be sent upstream to LLVM in time; for now it lives here. - diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index 451a390876c..04e616de223 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -120,18 +120,18 @@ void LLVMRustInitializeTargets() { LLVMInitializeX86TargetMC(); LLVMInitializeX86AsmPrinter(); LLVMInitializeX86AsmParser(); - + LLVMInitializeARMTargetInfo(); LLVMInitializeARMTarget(); LLVMInitializeARMTargetMC(); LLVMInitializeARMAsmPrinter(); - LLVMInitializeARMAsmParser(); + LLVMInitializeARMAsmParser(); LLVMInitializeMipsTargetInfo(); LLVMInitializeMipsTarget(); LLVMInitializeMipsTargetMC(); LLVMInitializeMipsAsmPrinter(); - LLVMInitializeMipsAsmParser(); + LLVMInitializeMipsAsmParser(); } // Custom memory manager for MCJITting. It needs special features @@ -438,7 +438,7 @@ LLVMRustWriteOutputFile(LLVMPassManagerRef PMR, const char *path, TargetMachine::CodeGenFileType FileType, CodeGenOpt::Level OptLevel, - bool EnableSegmentedStacks) { + bool EnableSegmentedStacks) { LLVMRustInitializeTargets(); @@ -449,7 +449,7 @@ LLVMRustWriteOutputFile(LLVMPassManagerRef PMR, if (!EnableARMEHABI) { int argc = 3; const char* argv[] = {"rustc", "-arm-enable-ehabi", - "-arm-enable-ehabi-descriptors"}; + "-arm-enable-ehabi-descriptors"}; cl::ParseCommandLineOptions(argc, argv); } @@ -467,8 +467,8 @@ LLVMRustWriteOutputFile(LLVMPassManagerRef PMR, const Target *TheTarget = TargetRegistry::lookupTarget(Trip, Err); TargetMachine *Target = TheTarget->createTargetMachine(Trip, CPUStr, FeaturesStr, - Options, Reloc::PIC_, - CodeModel::Default, OptLevel); + Options, Reloc::PIC_, + CodeModel::Default, OptLevel); Target->addAnalysisPasses(*PM); bool NoVerify = false; @@ -511,10 +511,10 @@ extern "C" LLVMValueRef LLVMRustConstSmallInt(LLVMTypeRef IntTy, unsigned N, return LLVMConstInt(IntTy, (unsigned long long)N, SignExtend); } -extern "C" LLVMValueRef LLVMRustConstInt(LLVMTypeRef IntTy, - unsigned N_hi, - unsigned N_lo, - LLVMBool SignExtend) { +extern "C" LLVMValueRef LLVMRustConstInt(LLVMTypeRef IntTy, + unsigned N_hi, + unsigned N_lo, + LLVMBool SignExtend) { unsigned long long N = N_hi; N <<= 32; N |= N_lo; diff --git a/src/snapshots.txt b/src/snapshots.txt index fafd5467655..00cabe90d84 100644 --- a/src/snapshots.txt +++ b/src/snapshots.txt @@ -151,7 +151,7 @@ S 2012-10-03 5585514 winnt-i386 25680d15a358cf4163e08f4e56e54fb497de5eb4 S 2012-10-02 4d30b34 - macos-i386 2bcce3cde8a7e53df202972cda85b0b59ce4e50d + macos-i386 2bcce3cde8a7e53df202972cda85b0b59ce4e50d macos-x86_64 fc5592828392f9eabe8b51cc59639be6d709cc26 freebsd-x86_64 5e09dad0800f16f5d79286330bcb82b6d2b8782e linux-i386 92fc541d4dde19fe2af5930d72a5a50ca67bad60 diff --git a/src/test/auxiliary/anon_trait_static_method_lib.rs b/src/test/auxiliary/anon_trait_static_method_lib.rs index 9a778b18874..6e111381cba 100644 --- a/src/test/auxiliary/anon_trait_static_method_lib.rs +++ b/src/test/auxiliary/anon_trait_static_method_lib.rs @@ -17,4 +17,3 @@ pub impl Foo { Foo { x: 3 } } } - diff --git a/src/test/auxiliary/cci_class_2.rs b/src/test/auxiliary/cci_class_2.rs index 9dc27054ef7..b120a4d759f 100644 --- a/src/test/auxiliary/cci_class_2.rs +++ b/src/test/auxiliary/cci_class_2.rs @@ -27,4 +27,3 @@ pub mod kitties { } } } - diff --git a/src/test/auxiliary/cci_class_6.rs b/src/test/auxiliary/cci_class_6.rs index 80990099cda..b09606ea1e2 100644 --- a/src/test/auxiliary/cci_class_6.rs +++ b/src/test/auxiliary/cci_class_6.rs @@ -31,4 +31,3 @@ pub mod kitties { } } } - diff --git a/src/test/auxiliary/cci_class_cast.rs b/src/test/auxiliary/cci_class_cast.rs index edda0644b16..ae0407a5bed 100644 --- a/src/test/auxiliary/cci_class_cast.rs +++ b/src/test/auxiliary/cci_class_cast.rs @@ -56,5 +56,3 @@ pub mod kitty { } } } - - diff --git a/src/test/auxiliary/cci_no_inline_lib.rs b/src/test/auxiliary/cci_no_inline_lib.rs index 407f62adb02..f79227d87cd 100644 --- a/src/test/auxiliary/cci_no_inline_lib.rs +++ b/src/test/auxiliary/cci_no_inline_lib.rs @@ -19,4 +19,3 @@ pub fn iter(v: ~[uint], f: &fn(uint)) { i += 1u; } } - diff --git a/src/test/auxiliary/explicit_self_xcrate.rs b/src/test/auxiliary/explicit_self_xcrate.rs index c790252244f..058cb53f918 100644 --- a/src/test/auxiliary/explicit_self_xcrate.rs +++ b/src/test/auxiliary/explicit_self_xcrate.rs @@ -23,5 +23,3 @@ impl Foo for Bar { io::println((*self).x); } } - - diff --git a/src/test/auxiliary/extern_mod_ordering_lib.rs b/src/test/auxiliary/extern_mod_ordering_lib.rs index 8276cea465f..d04351203da 100644 --- a/src/test/auxiliary/extern_mod_ordering_lib.rs +++ b/src/test/auxiliary/extern_mod_ordering_lib.rs @@ -3,4 +3,3 @@ pub mod extern_mod_ordering_lib { pub fn f() {} } - diff --git a/src/test/auxiliary/foreign_lib.rs b/src/test/auxiliary/foreign_lib.rs index 1561ec51ede..fe5b9e45593 100644 --- a/src/test/auxiliary/foreign_lib.rs +++ b/src/test/auxiliary/foreign_lib.rs @@ -15,4 +15,3 @@ pub mod rustrt { pub fn rust_get_argc() -> libc::c_int; } } - diff --git a/src/test/auxiliary/impl_privacy_xc_1.rs b/src/test/auxiliary/impl_privacy_xc_1.rs index 92452cbe8fd..4d98c4d9d2b 100644 --- a/src/test/auxiliary/impl_privacy_xc_1.rs +++ b/src/test/auxiliary/impl_privacy_xc_1.rs @@ -7,4 +7,3 @@ pub struct Fish { pub impl Fish { fn swim(&self) {} } - diff --git a/src/test/auxiliary/impl_privacy_xc_2.rs b/src/test/auxiliary/impl_privacy_xc_2.rs index 0fa15fa14f6..7ef36b1fb66 100644 --- a/src/test/auxiliary/impl_privacy_xc_2.rs +++ b/src/test/auxiliary/impl_privacy_xc_2.rs @@ -11,5 +11,3 @@ mod unexported { fn ne(&self, _: &Fish) -> bool { false } } } - - diff --git a/src/test/auxiliary/issue-2414-a.rs b/src/test/auxiliary/issue-2414-a.rs index 9f4f369b70d..54bb39fd2df 100644 --- a/src/test/auxiliary/issue-2414-a.rs +++ b/src/test/auxiliary/issue-2414-a.rs @@ -20,4 +20,3 @@ trait foo { impl foo for ~str { fn foo(&self) {} } - diff --git a/src/test/auxiliary/issue-2414-b.rs b/src/test/auxiliary/issue-2414-b.rs index 4bebe4e1420..f4ef02a2b7f 100644 --- a/src/test/auxiliary/issue-2414-b.rs +++ b/src/test/auxiliary/issue-2414-b.rs @@ -14,4 +14,3 @@ #[crate_type = "lib"]; extern mod a; - diff --git a/src/test/auxiliary/issue-2526.rs b/src/test/auxiliary/issue-2526.rs index fa32b9603a5..0e9cf39929f 100644 --- a/src/test/auxiliary/issue-2526.rs +++ b/src/test/auxiliary/issue-2526.rs @@ -55,4 +55,3 @@ fn context_res() -> context_res { } pub type context = arc_destruct; - diff --git a/src/test/auxiliary/issue_2316_b.rs b/src/test/auxiliary/issue_2316_b.rs index ed8e69cb4da..32283e5373c 100644 --- a/src/test/auxiliary/issue_2316_b.rs +++ b/src/test/auxiliary/issue_2316_b.rs @@ -17,5 +17,3 @@ pub mod cloth { gingham, flannel, calico } } - - diff --git a/src/test/auxiliary/issue_3136_a.rs b/src/test/auxiliary/issue_3136_a.rs index f7c866da9ae..55de208cc90 100644 --- a/src/test/auxiliary/issue_3136_a.rs +++ b/src/test/auxiliary/issue_3136_a.rs @@ -12,7 +12,7 @@ trait x { fn use_x(&self); } struct y(()); -impl x for y { +impl x for y { fn use_x(&self) { struct foo { //~ ERROR quux i: () @@ -20,6 +20,5 @@ impl x for y { fn new_foo(i: ()) -> foo { foo { i: i } } - } + } } - diff --git a/src/test/auxiliary/issue_3882.rs b/src/test/auxiliary/issue_3882.rs index 63275a05598..bb75758c741 100644 --- a/src/test/auxiliary/issue_3882.rs +++ b/src/test/auxiliary/issue_3882.rs @@ -12,7 +12,7 @@ mod issue_3882 { struct Completions { len: libc::size_t, } - + mod c { extern { fn linenoiseAddCompletion(lc: *mut Completions); diff --git a/src/test/auxiliary/moves_based_on_type_lib.rs b/src/test/auxiliary/moves_based_on_type_lib.rs index 826bd0db129..857593a84d2 100644 --- a/src/test/auxiliary/moves_based_on_type_lib.rs +++ b/src/test/auxiliary/moves_based_on_type_lib.rs @@ -25,4 +25,3 @@ pub fn f() { let y = x; let z = y; } - diff --git a/src/test/auxiliary/newtype_struct_xc.rs b/src/test/auxiliary/newtype_struct_xc.rs index 90036e0f96c..e0d2541dbe3 100644 --- a/src/test/auxiliary/newtype_struct_xc.rs +++ b/src/test/auxiliary/newtype_struct_xc.rs @@ -1,4 +1,3 @@ #[crate_type="lib"]; pub struct Au(int); - diff --git a/src/test/auxiliary/pub_use_mods_xcrate.rs b/src/test/auxiliary/pub_use_mods_xcrate.rs index e085f2312dc..e4890f4fe2d 100644 --- a/src/test/auxiliary/pub_use_mods_xcrate.rs +++ b/src/test/auxiliary/pub_use_mods_xcrate.rs @@ -18,4 +18,3 @@ pub mod a { } } } - diff --git a/src/test/auxiliary/static_fn_inline_xc_aux.rs b/src/test/auxiliary/static_fn_inline_xc_aux.rs index 5fc6621f186..a17a78bcea7 100644 --- a/src/test/auxiliary/static_fn_inline_xc_aux.rs +++ b/src/test/auxiliary/static_fn_inline_xc_aux.rs @@ -21,4 +21,3 @@ pub mod float { fn from_int2(n: int) -> float { return n as float; } } } - diff --git a/src/test/auxiliary/struct_destructuring_cross_crate.rs b/src/test/auxiliary/struct_destructuring_cross_crate.rs index ab7b1a636d3..8887cbee3fe 100644 --- a/src/test/auxiliary/struct_destructuring_cross_crate.rs +++ b/src/test/auxiliary/struct_destructuring_cross_crate.rs @@ -14,4 +14,3 @@ pub struct S { x: int, y: int } - diff --git a/src/test/auxiliary/trait_inheritance_auto_xc_2_aux.rs b/src/test/auxiliary/trait_inheritance_auto_xc_2_aux.rs index 1c7ebd941c3..7d6178db485 100644 --- a/src/test/auxiliary/trait_inheritance_auto_xc_2_aux.rs +++ b/src/test/auxiliary/trait_inheritance_auto_xc_2_aux.rs @@ -17,5 +17,3 @@ pub struct A { x: int } impl Foo for A { fn f(&self) -> int { 10 } } impl Bar for A { fn g(&self) -> int { 20 } } impl Baz for A { fn h(&self) -> int { 30 } } - - diff --git a/src/test/auxiliary/trait_inheritance_overloading_xc.rs b/src/test/auxiliary/trait_inheritance_overloading_xc.rs index 1b480ff17b3..1fb0db25b31 100644 --- a/src/test/auxiliary/trait_inheritance_overloading_xc.rs +++ b/src/test/auxiliary/trait_inheritance_overloading_xc.rs @@ -38,4 +38,3 @@ impl Eq for MyInt { impl MyNum for MyInt; fn mi(v: int) -> MyInt { MyInt { val: v } } - diff --git a/src/test/auxiliary/xc_private_method_lib.rs b/src/test/auxiliary/xc_private_method_lib.rs index f9fda2b0810..05325c3b935 100644 --- a/src/test/auxiliary/xc_private_method_lib.rs +++ b/src/test/auxiliary/xc_private_method_lib.rs @@ -7,4 +7,3 @@ pub struct Foo { impl Foo { fn new() -> Foo { Foo { x: 1 } } } - diff --git a/src/test/bench/msgsend-pipes-shared.rs b/src/test/bench/msgsend-pipes-shared.rs index 3833c884652..6cda0a1945a 100644 --- a/src/test/bench/msgsend-pipes-shared.rs +++ b/src/test/bench/msgsend-pipes-shared.rs @@ -104,7 +104,7 @@ fn main() { ~[~"", ~"10000", ~"4"] } else { copy args - }; + }; debug!("%?", args); run(args); diff --git a/src/test/bench/msgsend-pipes.rs b/src/test/bench/msgsend-pipes.rs index c4044d45f36..a8fb29a47e2 100644 --- a/src/test/bench/msgsend-pipes.rs +++ b/src/test/bench/msgsend-pipes.rs @@ -101,7 +101,7 @@ fn main() { ~[~"", ~"10000", ~"4"] } else { copy args - }; + }; debug!("%?", args); run(args); diff --git a/src/test/bench/msgsend-ring-mutex-arcs.rs b/src/test/bench/msgsend-ring-mutex-arcs.rs index a1ab7384d62..853b057277d 100644 --- a/src/test/bench/msgsend-ring-mutex-arcs.rs +++ b/src/test/bench/msgsend-ring-mutex-arcs.rs @@ -72,7 +72,7 @@ fn main() { ~[~"", ~"10", ~"100"] } else { copy args - }; + }; let num_tasks = uint::from_str(args[1]).get(); let msg_per_task = uint::from_str(args[2]).get(); diff --git a/src/test/bench/msgsend-ring-pipes.rs b/src/test/bench/msgsend-ring-pipes.rs index 14e955dd7bd..1288ac29078 100644 --- a/src/test/bench/msgsend-ring-pipes.rs +++ b/src/test/bench/msgsend-ring-pipes.rs @@ -65,7 +65,7 @@ fn main() { ~[~"", ~"100", ~"1000"] } else { copy args - }; + }; let num_tasks = uint::from_str(args[1]).get(); let msg_per_task = uint::from_str(args[2]).get(); diff --git a/src/test/bench/msgsend-ring-rw-arcs.rs b/src/test/bench/msgsend-ring-rw-arcs.rs index 8e819cc4aba..2cf0fbfc397 100644 --- a/src/test/bench/msgsend-ring-rw-arcs.rs +++ b/src/test/bench/msgsend-ring-rw-arcs.rs @@ -73,7 +73,7 @@ fn main() { ~[~"", ~"10", ~"100"] } else { copy args - }; + }; let num_tasks = uint::from_str(args[1]).get(); let msg_per_task = uint::from_str(args[2]).get(); diff --git a/src/test/bench/pingpong.rs b/src/test/bench/pingpong.rs index 4a6e90f4116..09e663325ed 100644 --- a/src/test/bench/pingpong.rs +++ b/src/test/bench/pingpong.rs @@ -11,7 +11,7 @@ // Compare bounded and unbounded protocol performance. // xfail-pretty - + extern mod std; use core::cell::Cell; diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs index 9dad24646de..5d893d4ec07 100644 --- a/src/test/bench/shootout-chameneos-redux.rs +++ b/src/test/bench/shootout-chameneos-redux.rs @@ -218,4 +218,3 @@ fn main() { rendezvous(nn, ~[Blue, Red, Yellow, Red, Yellow, Blue, Red, Yellow, Red, Blue]); } - diff --git a/src/test/bench/shootout-fannkuch-redux.rs b/src/test/bench/shootout-fannkuch-redux.rs index 21f38245ca3..cb32e0e496e 100644 --- a/src/test/bench/shootout-fannkuch-redux.rs +++ b/src/test/bench/shootout-fannkuch-redux.rs @@ -92,4 +92,3 @@ fn main() { let n: i32 = FromStr::from_str(os::args()[1]).get(); println(fmt!("Pfannkuchen(%d) = %d", n as int, fannkuch_redux(n) as int)); } - diff --git a/src/test/bench/shootout-fasta-redux.rs b/src/test/bench/shootout-fasta-redux.rs index 5ece9810206..d6a0f4b8b25 100644 --- a/src/test/bench/shootout-fasta-redux.rs +++ b/src/test/bench/shootout-fasta-redux.rs @@ -201,4 +201,3 @@ fn main() { fputc('\n' as c_int, stdout); } } - diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index 4cd7b58ce12..d1f3dbf22ce 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -222,4 +222,3 @@ fn main() { io::println(from_child[ii].recv()); } } - diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index 224885a3f79..1791af67ed0 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -252,7 +252,7 @@ fn generate_frequencies(frequencies: &mut Table, mut input: &[u8], frame: i32) { let mut code = Code(0); - + // Pull first frame. for (frame as uint).times { code = code.push_char(input[0]); @@ -313,4 +313,3 @@ fn main() { print_occurrences(frequencies, occurrence); } } - diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs index e62cb8ea849..7d2b25792ec 100644 --- a/src/test/bench/shootout-mandelbrot.rs +++ b/src/test/bench/shootout-mandelbrot.rs @@ -57,4 +57,3 @@ fn main() { } } } - diff --git a/src/test/bench/shootout-pidigits.rs b/src/test/bench/shootout-pidigits.rs index 38e87358ee2..cb7fa969be7 100644 --- a/src/test/bench/shootout-pidigits.rs +++ b/src/test/bench/shootout-pidigits.rs @@ -175,4 +175,3 @@ fn main() { let n: u32 = FromStr::from_str(os::args()[1]).get(); pidigits(n); } - diff --git a/src/test/bench/shootout-reverse-complement.rs b/src/test/bench/shootout-reverse-complement.rs index 72c01c8d55c..a9cb3c7636a 100644 --- a/src/test/bench/shootout-reverse-complement.rs +++ b/src/test/bench/shootout-reverse-complement.rs @@ -152,4 +152,3 @@ fn main() { fwrite(transmute(out.unsafe_ref(0)), 1, pos as size_t, stdout); } } - diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index 9221da8b557..8afddd3a31e 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -274,4 +274,3 @@ fn main() { sudoku.solve(); sudoku.write(io::stdout()); } - diff --git a/src/test/compile-fail/alt-tag-nullary.rs b/src/test/compile-fail/alt-tag-nullary.rs index c74ee3d852a..2b0c3dbf8e8 100644 --- a/src/test/compile-fail/alt-tag-nullary.rs +++ b/src/test/compile-fail/alt-tag-nullary.rs @@ -14,4 +14,3 @@ enum a { A, } enum b { B, } fn main() { let x: a = A; match x { B => { } } } - diff --git a/src/test/compile-fail/alt-tag-unary.rs b/src/test/compile-fail/alt-tag-unary.rs index e01b9a045e5..a129ff19ac6 100644 --- a/src/test/compile-fail/alt-tag-unary.rs +++ b/src/test/compile-fail/alt-tag-unary.rs @@ -14,4 +14,3 @@ enum a { A(int), } enum b { B(int), } fn main() { let x: a = A(0); match x { B(y) => { } } } - diff --git a/src/test/compile-fail/auto-ref-borrowck-failure.rs b/src/test/compile-fail/auto-ref-borrowck-failure.rs index 90b9b44cfbe..894b71357b7 100644 --- a/src/test/compile-fail/auto-ref-borrowck-failure.rs +++ b/src/test/compile-fail/auto-ref-borrowck-failure.rs @@ -28,4 +28,3 @@ fn main() { let x = Foo { x: 3 }; x.printme(); //~ ERROR illegal borrow } - diff --git a/src/test/compile-fail/bogus-tag.rs b/src/test/compile-fail/bogus-tag.rs index 12e8ba56532..89ad7b4245a 100644 --- a/src/test/compile-fail/bogus-tag.rs +++ b/src/test/compile-fail/bogus-tag.rs @@ -21,4 +21,3 @@ fn main() { hsl(h, s, l) => { debug!("hsl"); } } } - diff --git a/src/test/compile-fail/borrowck-assign-comp-idx.rs b/src/test/compile-fail/borrowck-assign-comp-idx.rs index 25b56abb5ba..a284cd5b4a7 100644 --- a/src/test/compile-fail/borrowck-assign-comp-idx.rs +++ b/src/test/compile-fail/borrowck-assign-comp-idx.rs @@ -45,4 +45,3 @@ fn c() { fn main() { } - diff --git a/src/test/compile-fail/borrowck-assign-comp.rs b/src/test/compile-fail/borrowck-assign-comp.rs index 283f04a283f..eb832fe738d 100644 --- a/src/test/compile-fail/borrowck-assign-comp.rs +++ b/src/test/compile-fail/borrowck-assign-comp.rs @@ -42,4 +42,3 @@ fn d() { fn main() { } - diff --git a/src/test/compile-fail/borrowck-call-method-from-mut-aliasable.rs b/src/test/compile-fail/borrowck-call-method-from-mut-aliasable.rs index 2c68429baec..f2c6ae98819 100644 --- a/src/test/compile-fail/borrowck-call-method-from-mut-aliasable.rs +++ b/src/test/compile-fail/borrowck-call-method-from-mut-aliasable.rs @@ -38,4 +38,3 @@ fn c(x: &const Foo) { fn main() { } - diff --git a/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs b/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs index a2ba5ad4891..1c2bd8dc8e1 100644 --- a/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs +++ b/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs @@ -30,6 +30,6 @@ use core::either::{Either, Left, Right}; let y: &Either = &x; let z: &mut Either = &mut x; //~ ERROR conflicts with prior loan *z = *y; - } + } fn main() {} diff --git a/src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs b/src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs index a4ad7e69b33..21bb7434f8d 100644 --- a/src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs +++ b/src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct Point { +struct Point { x: int, y: int, } @@ -56,4 +56,3 @@ fn c() { fn main() { } - diff --git a/src/test/compile-fail/borrowck-loan-rcvr.rs b/src/test/compile-fail/borrowck-loan-rcvr.rs index 4473574926a..36007abf05e 100644 --- a/src/test/compile-fail/borrowck-loan-rcvr.rs +++ b/src/test/compile-fail/borrowck-loan-rcvr.rs @@ -63,4 +63,3 @@ fn c() { fn main() { } - diff --git a/src/test/compile-fail/borrowck-mut-boxed-vec.rs b/src/test/compile-fail/borrowck-mut-boxed-vec.rs index d4c0b5a1e9b..e8ed362176f 100644 --- a/src/test/compile-fail/borrowck-mut-boxed-vec.rs +++ b/src/test/compile-fail/borrowck-mut-boxed-vec.rs @@ -14,4 +14,3 @@ fn main() { v[1] = 4; } } - diff --git a/src/test/compile-fail/borrowck-ref-into-rvalue.rs b/src/test/compile-fail/borrowck-ref-into-rvalue.rs index 37ee747069c..84acd0df20b 100644 --- a/src/test/compile-fail/borrowck-ref-into-rvalue.rs +++ b/src/test/compile-fail/borrowck-ref-into-rvalue.rs @@ -13,9 +13,8 @@ fn main() { match Some(~"Hello") { //~ ERROR illegal borrow Some(ref m) => { msg = m; - }, + }, None => { fail!() } - } + } io::println(*msg); } - diff --git a/src/test/compile-fail/borrowck-uniq-via-box.rs b/src/test/compile-fail/borrowck-uniq-via-box.rs index e1c0e67ff8d..97414ff5e78 100644 --- a/src/test/compile-fail/borrowck-uniq-via-box.rs +++ b/src/test/compile-fail/borrowck-uniq-via-box.rs @@ -52,4 +52,3 @@ fn box_imm_recs(v: @Outer) { fn main() { } - diff --git a/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs b/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs index 27902100373..805b162f1d3 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs @@ -9,4 +9,3 @@ fn a() { } fn main() {} - diff --git a/src/test/compile-fail/borrowck-vec-pattern-nesting.rs b/src/test/compile-fail/borrowck-vec-pattern-nesting.rs index 05ff85d612c..eef99aafd68 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-nesting.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-nesting.rs @@ -18,4 +18,3 @@ fn b() { } fn main() {} - diff --git a/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-2.rs b/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-2.rs index e47ad721b0d..f9e6bc1b22e 100644 --- a/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-2.rs +++ b/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-2.rs @@ -3,4 +3,3 @@ fn main() { let _x = &mut *b; //~ NOTE prior loan as mutable granted here let _y = &mut *b; //~ ERROR loan of dereference of mutable ~ pointer as mutable conflicts with prior loan } - diff --git a/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-3.rs b/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-3.rs index 015f368ecb0..6c82b25a6a1 100644 --- a/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-3.rs +++ b/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail-3.rs @@ -5,4 +5,3 @@ fn main() { let mut d = /*move*/ a; //~ ERROR moving out of mutable local variable prohibited due to outstanding loan *d += 1; } - diff --git a/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail.rs b/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail.rs index 36d32fddda1..dc453d98193 100644 --- a/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail.rs +++ b/src/test/compile-fail/borrowck-wg-borrow-mut-to-imm-fail.rs @@ -4,4 +4,3 @@ fn main() { let mut y = /*move*/ b; //~ ERROR moving out of mutable local variable prohibited *y += 1; } - diff --git a/src/test/compile-fail/borrowck-wg-move-base-2.rs b/src/test/compile-fail/borrowck-wg-move-base-2.rs index ba85616e63f..0ede523daa4 100644 --- a/src/test/compile-fail/borrowck-wg-move-base-2.rs +++ b/src/test/compile-fail/borrowck-wg-move-base-2.rs @@ -7,5 +7,3 @@ fn foo(x: &mut int) { fn main() { } - - diff --git a/src/test/compile-fail/by-move-pattern-binding.rs b/src/test/compile-fail/by-move-pattern-binding.rs index 95091f15ce0..1efed154286 100644 --- a/src/test/compile-fail/by-move-pattern-binding.rs +++ b/src/test/compile-fail/by-move-pattern-binding.rs @@ -20,4 +20,3 @@ fn main() { &Bar(ref identifier) => io::println(*identifier) }; } - diff --git a/src/test/compile-fail/dead-code-ret.rs b/src/test/compile-fail/dead-code-ret.rs index 182a41c1b17..97f6149b162 100644 --- a/src/test/compile-fail/dead-code-ret.rs +++ b/src/test/compile-fail/dead-code-ret.rs @@ -15,4 +15,3 @@ fn f(caller: str) { debug!(caller); } fn main() { return f("main"); debug!("Paul is dead"); } - diff --git a/src/test/compile-fail/does-nothing.rs b/src/test/compile-fail/does-nothing.rs index a360d657957..699baad4d43 100644 --- a/src/test/compile-fail/does-nothing.rs +++ b/src/test/compile-fail/does-nothing.rs @@ -1,3 +1,2 @@ // error-pattern: unresolved name: `this_does_nothing_what_the`. fn main() { debug!("doing"); this_does_nothing_what_the; debug!("boing"); } - diff --git a/src/test/compile-fail/drop-on-non-struct.rs b/src/test/compile-fail/drop-on-non-struct.rs index 4e5b64c8f3d..b2f87686ac6 100644 --- a/src/test/compile-fail/drop-on-non-struct.rs +++ b/src/test/compile-fail/drop-on-non-struct.rs @@ -19,5 +19,3 @@ impl Drop for Foo { //~ ERROR the Drop trait may only be implemented fn main() { } - - diff --git a/src/test/compile-fail/explicit-call-to-dtor.rs b/src/test/compile-fail/explicit-call-to-dtor.rs index 71674186b61..24fedaaabe3 100644 --- a/src/test/compile-fail/explicit-call-to-dtor.rs +++ b/src/test/compile-fail/explicit-call-to-dtor.rs @@ -22,4 +22,3 @@ fn main() { let x = Foo { x: 3 }; x.finalize(); //~ ERROR explicit call to destructor } - diff --git a/src/test/compile-fail/explicit-call-to-supertrait-dtor.rs b/src/test/compile-fail/explicit-call-to-supertrait-dtor.rs index 26b13566f7a..fd49889a3f7 100644 --- a/src/test/compile-fail/explicit-call-to-supertrait-dtor.rs +++ b/src/test/compile-fail/explicit-call-to-supertrait-dtor.rs @@ -31,5 +31,3 @@ impl Bar for Foo { fn main() { let x = Foo { x: 3 }; } - - diff --git a/src/test/compile-fail/float-literal-inference-restrictions.rs b/src/test/compile-fail/float-literal-inference-restrictions.rs index 80aefbbf48f..48dbdd86b11 100644 --- a/src/test/compile-fail/float-literal-inference-restrictions.rs +++ b/src/test/compile-fail/float-literal-inference-restrictions.rs @@ -12,4 +12,3 @@ fn main() { let x: f32 = 1; //~ ERROR mismatched types let y: f32 = 1f; //~ ERROR mismatched types } - diff --git a/src/test/compile-fail/foreign-unsafe-fn-called.rs b/src/test/compile-fail/foreign-unsafe-fn-called.rs index 9122abab713..ed8b8088ee4 100644 --- a/src/test/compile-fail/foreign-unsafe-fn-called.rs +++ b/src/test/compile-fail/foreign-unsafe-fn-called.rs @@ -21,4 +21,3 @@ fn main() { test::free(); //~^ ERROR access to unsafe function requires unsafe function or block } - diff --git a/src/test/compile-fail/foreign-unsafe-fn.rs b/src/test/compile-fail/foreign-unsafe-fn.rs index 32fafe29646..3633267d02c 100644 --- a/src/test/compile-fail/foreign-unsafe-fn.rs +++ b/src/test/compile-fail/foreign-unsafe-fn.rs @@ -21,5 +21,3 @@ fn main() { let x = test::free; //~^ ERROR access to unsafe function requires unsafe function or block } - - diff --git a/src/test/compile-fail/issue-1451.rs b/src/test/compile-fail/issue-1451.rs index acc371076e7..a295e8eb7ed 100644 --- a/src/test/compile-fail/issue-1451.rs +++ b/src/test/compile-fail/issue-1451.rs @@ -30,4 +30,3 @@ fn main() { fooT(T {f: x}); fooT(T {f: bar}); } - diff --git a/src/test/compile-fail/issue-2951.rs b/src/test/compile-fail/issue-2951.rs index 3874d9b13f5..e57d4f09175 100644 --- a/src/test/compile-fail/issue-2951.rs +++ b/src/test/compile-fail/issue-2951.rs @@ -15,5 +15,4 @@ fn foo(x: T, y: U) { } fn main() { - } diff --git a/src/test/compile-fail/issue-3044.rs b/src/test/compile-fail/issue-3044.rs index fcd5b1deee5..635d0aa3df1 100644 --- a/src/test/compile-fail/issue-3044.rs +++ b/src/test/compile-fail/issue-3044.rs @@ -17,4 +17,3 @@ fn main() { // // the first error is, um, non-ideal. } - diff --git a/src/test/compile-fail/issue-3096-2.rs b/src/test/compile-fail/issue-3096-2.rs index da13d450273..eb58cf3e13b 100644 --- a/src/test/compile-fail/issue-3096-2.rs +++ b/src/test/compile-fail/issue-3096-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -enum bottom { } +enum bottom { } fn main() { let x = ptr::to_unsafe_ptr(&()) as *bottom; diff --git a/src/test/compile-fail/issue-3991.rs b/src/test/compile-fail/issue-3991.rs index d1c9057b880..d3016f893b4 100644 --- a/src/test/compile-fail/issue-3991.rs +++ b/src/test/compile-fail/issue-3991.rs @@ -12,11 +12,11 @@ struct HasNested { mut nest: ~[~[int]], } - + impl HasNested { fn method_push_local(&self) { self.nest[0].push(0); } } - + fn main() {} diff --git a/src/test/compile-fail/issue-4265.rs b/src/test/compile-fail/issue-4265.rs index b6a32f5feba..e76d211deda 100644 --- a/src/test/compile-fail/issue-4265.rs +++ b/src/test/compile-fail/issue-4265.rs @@ -11,12 +11,12 @@ struct Foo { baz: uint } - + impl Foo { fn bar() { Foo { baz: 0 }.bar(); } - + fn bar() { //~ ERROR duplicate definition of value bar } } diff --git a/src/test/compile-fail/issue-4366.rs b/src/test/compile-fail/issue-4366.rs index 7d97932d9af..f4e57171599 100644 --- a/src/test/compile-fail/issue-4366.rs +++ b/src/test/compile-fail/issue-4366.rs @@ -37,4 +37,3 @@ mod m1 { fn main() { foo(); //~ ERROR: unresolved name: `foo` } - diff --git a/src/test/compile-fail/issue-4968.rs b/src/test/compile-fail/issue-4968.rs index fc0c29e9a79..700d8a61c3a 100644 --- a/src/test/compile-fail/issue-4968.rs +++ b/src/test/compile-fail/issue-4968.rs @@ -14,4 +14,3 @@ static A: (int,int) = (4,2); fn main() { match 42 { A => () } //~ ERROR mismatched types: expected `` but found `(int,int)` (expected integral variable but found tuple) } - diff --git a/src/test/compile-fail/kindck-destructor-owned.rs b/src/test/compile-fail/kindck-destructor-owned.rs index e956f95b422..faad36a15d2 100644 --- a/src/test/compile-fail/kindck-destructor-owned.rs +++ b/src/test/compile-fail/kindck-destructor-owned.rs @@ -9,4 +9,3 @@ impl Drop for Foo { //~ ERROR cannot implement a destructor on a struct that is } fn main() { } - diff --git a/src/test/compile-fail/lint-default-methods.rs b/src/test/compile-fail/lint-default-methods.rs index 1350c3e3ad1..89b99fcebca 100644 --- a/src/test/compile-fail/lint-default-methods.rs +++ b/src/test/compile-fail/lint-default-methods.rs @@ -5,4 +5,3 @@ trait Foo { //~ ERROR default methods are experimental } fn main() {} - diff --git a/src/test/compile-fail/lint-type-limits.rs b/src/test/compile-fail/lint-type-limits.rs index e45ef38e97a..2eb794fd1c2 100644 --- a/src/test/compile-fail/lint-type-limits.rs +++ b/src/test/compile-fail/lint-type-limits.rs @@ -32,4 +32,3 @@ fn qux() { i += 1; } } - diff --git a/src/test/compile-fail/liveness-if-no-else.rs b/src/test/compile-fail/liveness-if-no-else.rs index e37ee5bd4d4..22b1b5edbac 100644 --- a/src/test/compile-fail/liveness-if-no-else.rs +++ b/src/test/compile-fail/liveness-if-no-else.rs @@ -11,6 +11,6 @@ fn foo(x: int) { debug!(x); } fn main() { - let x: int; if 1 > 2 { x = 10; } - foo(x); //~ ERROR use of possibly uninitialized variable: `x` + let x: int; if 1 > 2 { x = 10; } + foo(x); //~ ERROR use of possibly uninitialized variable: `x` } diff --git a/src/test/compile-fail/liveness-return.rs b/src/test/compile-fail/liveness-return.rs index 12f7aa434cc..6558bc57968 100644 --- a/src/test/compile-fail/liveness-return.rs +++ b/src/test/compile-fail/liveness-return.rs @@ -9,8 +9,8 @@ // except according to those terms. fn f() -> int { - let x: int; - return x; //~ ERROR use of possibly uninitialized variable: `x` + let x: int; + return x; //~ ERROR use of possibly uninitialized variable: `x` } fn main() { f(); } diff --git a/src/test/compile-fail/liveness-uninit-after-item.rs b/src/test/compile-fail/liveness-uninit-after-item.rs index b3ab0053888..a828b1d6b9f 100644 --- a/src/test/compile-fail/liveness-uninit-after-item.rs +++ b/src/test/compile-fail/liveness-uninit-after-item.rs @@ -13,4 +13,3 @@ fn main() { fn baz(_x: int) { } baz(bar); //~ ERROR use of possibly uninitialized variable: `bar` } - diff --git a/src/test/compile-fail/liveness-uninit.rs b/src/test/compile-fail/liveness-uninit.rs index 8797132fd50..a360f8e85a6 100644 --- a/src/test/compile-fail/liveness-uninit.rs +++ b/src/test/compile-fail/liveness-uninit.rs @@ -11,6 +11,6 @@ fn foo(x: int) { debug!(x); } fn main() { - let x: int; - foo(x); //~ ERROR use of possibly uninitialized variable: `x` + let x: int; + foo(x); //~ ERROR use of possibly uninitialized variable: `x` } diff --git a/src/test/compile-fail/macro-with-seps-err-msg.rs b/src/test/compile-fail/macro-with-seps-err-msg.rs index 74c040238ac..95250e36b86 100644 --- a/src/test/compile-fail/macro-with-seps-err-msg.rs +++ b/src/test/compile-fail/macro-with-seps-err-msg.rs @@ -13,5 +13,3 @@ fn main() { globnar::brotz!(); } - - diff --git a/src/test/compile-fail/missing-derivable-attr.rs b/src/test/compile-fail/missing-derivable-attr.rs index 67cf67bfa5a..eb27d51061f 100644 --- a/src/test/compile-fail/missing-derivable-attr.rs +++ b/src/test/compile-fail/missing-derivable-attr.rs @@ -24,4 +24,3 @@ impl MyEq for A; //~ ERROR missing method fn main() { } - diff --git a/src/test/compile-fail/missing-return.rs b/src/test/compile-fail/missing-return.rs index c0007d2bee8..1dc817cc6e6 100644 --- a/src/test/compile-fail/missing-return.rs +++ b/src/test/compile-fail/missing-return.rs @@ -13,4 +13,3 @@ fn f() -> int { } fn main() { f(); } - diff --git a/src/test/compile-fail/moves-based-on-type-block-bad.rs b/src/test/compile-fail/moves-based-on-type-block-bad.rs index 020dadfc96c..67eb06ab424 100644 --- a/src/test/compile-fail/moves-based-on-type-block-bad.rs +++ b/src/test/compile-fail/moves-based-on-type-block-bad.rs @@ -24,4 +24,3 @@ fn main() { } } } - diff --git a/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs b/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs index 57829e72674..6dce011ddc8 100644 --- a/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs +++ b/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs @@ -5,4 +5,3 @@ fn main() { } io::println(x); //~ ERROR use of moved value } - diff --git a/src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs b/src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs index bee9596df72..2b9291ce328 100644 --- a/src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs +++ b/src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs @@ -29,4 +29,3 @@ fn consume(v: ~List) -> int { } fn main() {} - diff --git a/src/test/compile-fail/no-capture-arc.rs b/src/test/compile-fail/no-capture-arc.rs index da75dfd0106..2c8c98ad5d6 100644 --- a/src/test/compile-fail/no-capture-arc.rs +++ b/src/test/compile-fail/no-capture-arc.rs @@ -16,7 +16,7 @@ use std::arc; fn main() { let v = ~[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; let arc_v = arc::ARC(v); - + do task::spawn() { let v = *arc::get(&arc_v); assert!(v[3] == 4); diff --git a/src/test/compile-fail/noexporttypeexe.rs b/src/test/compile-fail/noexporttypeexe.rs index 8d9796c7c41..95428568e4c 100644 --- a/src/test/compile-fail/noexporttypeexe.rs +++ b/src/test/compile-fail/noexporttypeexe.rs @@ -20,4 +20,3 @@ fn main() { let x: int = noexporttypelib::foo(); //~^ ERROR expected `int` but found `core::option::Option` } - diff --git a/src/test/compile-fail/non-exhaustive-match-nested.rs b/src/test/compile-fail/non-exhaustive-match-nested.rs index 4d1db362376..34fe6b0f678 100644 --- a/src/test/compile-fail/non-exhaustive-match-nested.rs +++ b/src/test/compile-fail/non-exhaustive-match-nested.rs @@ -20,4 +20,3 @@ fn main() { b => { fail!(~"goodbye"); } } } - diff --git a/src/test/compile-fail/once-fn-subtyping.rs b/src/test/compile-fail/once-fn-subtyping.rs index 00009c706e3..178c04dfc79 100644 --- a/src/test/compile-fail/once-fn-subtyping.rs +++ b/src/test/compile-fail/once-fn-subtyping.rs @@ -14,4 +14,3 @@ fn main() { let h: &fn() = ||(); let i: &once fn() = h; // ok } - diff --git a/src/test/compile-fail/private-impl-method.rs b/src/test/compile-fail/private-impl-method.rs index 74bdcdc7f82..a6728f82ec3 100644 --- a/src/test/compile-fail/private-impl-method.rs +++ b/src/test/compile-fail/private-impl-method.rs @@ -22,4 +22,3 @@ fn main() { let s = a::Foo { x: 1 }; s.foo(); //~ ERROR method `foo` is private } - diff --git a/src/test/compile-fail/private-item-simple.rs b/src/test/compile-fail/private-item-simple.rs index e8038df188b..8776739db2d 100644 --- a/src/test/compile-fail/private-item-simple.rs +++ b/src/test/compile-fail/private-item-simple.rs @@ -15,4 +15,3 @@ mod a { fn main() { a::f(); //~ ERROR unresolved name } - diff --git a/src/test/compile-fail/private-method-inherited.rs b/src/test/compile-fail/private-method-inherited.rs index 7b64623e16c..bc27027e886 100644 --- a/src/test/compile-fail/private-method-inherited.rs +++ b/src/test/compile-fail/private-method-inherited.rs @@ -12,4 +12,3 @@ fn main() { let x = a::Foo; x.f(); //~ ERROR method `f` is private } - diff --git a/src/test/compile-fail/private-struct-field-ctor.rs b/src/test/compile-fail/private-struct-field-ctor.rs index 43e7427dd74..7ab28d72965 100644 --- a/src/test/compile-fail/private-struct-field-ctor.rs +++ b/src/test/compile-fail/private-struct-field-ctor.rs @@ -17,4 +17,3 @@ mod a { fn main() { let s = a::Foo { x: 1 }; //~ ERROR field `x` is private } - diff --git a/src/test/compile-fail/private-struct-field-pattern.rs b/src/test/compile-fail/private-struct-field-pattern.rs index 864c9bd98d7..6f524a8eaa4 100644 --- a/src/test/compile-fail/private-struct-field-pattern.rs +++ b/src/test/compile-fail/private-struct-field-pattern.rs @@ -25,4 +25,3 @@ fn main() { Foo { x: _ } => {} //~ ERROR field `x` is private } } - diff --git a/src/test/compile-fail/qquote-1.rs b/src/test/compile-fail/qquote-1.rs index eda207f711d..4710d9dee45 100644 --- a/src/test/compile-fail/qquote-1.rs +++ b/src/test/compile-fail/qquote-1.rs @@ -65,4 +65,3 @@ fn main() { fn check_pp(expr: T, f: &fn(pprust::ps, T), expect: str) { fail!(); } - diff --git a/src/test/compile-fail/qquote-2.rs b/src/test/compile-fail/qquote-2.rs index c6690534008..d3773256105 100644 --- a/src/test/compile-fail/qquote-2.rs +++ b/src/test/compile-fail/qquote-2.rs @@ -60,4 +60,3 @@ fn main() { fn check_pp(expr: T, f: &fn(pprust::ps, T), expect: str) { fail!(); } - diff --git a/src/test/compile-fail/refutable-pattern-in-fn-arg.rs b/src/test/compile-fail/refutable-pattern-in-fn-arg.rs index 5e157c1bd7b..957925709e1 100644 --- a/src/test/compile-fail/refutable-pattern-in-fn-arg.rs +++ b/src/test/compile-fail/refutable-pattern-in-fn-arg.rs @@ -12,4 +12,3 @@ fn main() { let f = |3: int| io::println("hello"); //~ ERROR refutable pattern f(4); } - diff --git a/src/test/compile-fail/regions-addr-of-self.rs b/src/test/compile-fail/regions-addr-of-self.rs index 732d946bf9e..f96ef639e75 100644 --- a/src/test/compile-fail/regions-addr-of-self.rs +++ b/src/test/compile-fail/regions-addr-of-self.rs @@ -35,4 +35,3 @@ fn main() { d.chase_cat(); debug!("cats_chased: %u", d.cats_chased); } - diff --git a/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs b/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs index a8b7ae1b9c8..6ee0216655e 100644 --- a/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs +++ b/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs @@ -24,4 +24,3 @@ fn foo(p: @point) -> &int { } fn main() {} - diff --git a/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs b/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs index bf8f227b573..602f5dc6983 100644 --- a/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs +++ b/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs @@ -15,8 +15,8 @@ fn foo(cond: &fn() -> bool, box: &fn() -> @int) { loop { let x = box(); - // Here we complain because the resulting region - // of this borrow is the fn body as a whole. + // Here we complain because the resulting region + // of this borrow is the fn body as a whole. y = borrow(x); //~ ERROR illegal borrow: cannot root managed value long enough assert!(*x == *y); diff --git a/src/test/compile-fail/regions-ret.rs b/src/test/compile-fail/regions-ret.rs index be7b28f6ef4..cf7cb175bb8 100644 --- a/src/test/compile-fail/regions-ret.rs +++ b/src/test/compile-fail/regions-ret.rs @@ -14,4 +14,3 @@ fn f<'a>(_x : &'a int) -> &'a int { fn main() { } - diff --git a/src/test/compile-fail/repeat-to-run-dtor-twice.rs b/src/test/compile-fail/repeat-to-run-dtor-twice.rs index 18bdb564441..e1e1e2313f4 100644 --- a/src/test/compile-fail/repeat-to-run-dtor-twice.rs +++ b/src/test/compile-fail/repeat-to-run-dtor-twice.rs @@ -26,4 +26,3 @@ fn main() { let a = Foo { x: 3 }; let _ = [ a, ..5 ]; //~ ERROR copying a value of non-copyable type } - diff --git a/src/test/compile-fail/static-method-privacy.rs b/src/test/compile-fail/static-method-privacy.rs index 50df4f04971..0fd82b5ace3 100644 --- a/src/test/compile-fail/static-method-privacy.rs +++ b/src/test/compile-fail/static-method-privacy.rs @@ -8,4 +8,3 @@ mod a { fn main() { let _ = a::S::new(); //~ ERROR function `new` is private } - diff --git a/src/test/compile-fail/static-region-bound.rs b/src/test/compile-fail/static-region-bound.rs index 500a5b0c8bc..ada3aebb2f4 100644 --- a/src/test/compile-fail/static-region-bound.rs +++ b/src/test/compile-fail/static-region-bound.rs @@ -6,4 +6,3 @@ fn main() { let x = &3; f(x); //~ ERROR instantiating a type parameter with an incompatible type } - diff --git a/src/test/compile-fail/struct-like-enum-nonexhaustive.rs b/src/test/compile-fail/struct-like-enum-nonexhaustive.rs index 52a61628c35..91709e2ea7d 100644 --- a/src/test/compile-fail/struct-like-enum-nonexhaustive.rs +++ b/src/test/compile-fail/struct-like-enum-nonexhaustive.rs @@ -20,5 +20,3 @@ fn main() { B { x: None } => {} } } - - diff --git a/src/test/compile-fail/super-at-top-level.rs b/src/test/compile-fail/super-at-top-level.rs index 21b9e5292b1..f1064a62905 100644 --- a/src/test/compile-fail/super-at-top-level.rs +++ b/src/test/compile-fail/super-at-top-level.rs @@ -2,6 +2,4 @@ use super::f; //~ ERROR unresolved name //~^ ERROR failed to resolve import fn main() { - } - diff --git a/src/test/compile-fail/trait-impl-method-mismatch.rs b/src/test/compile-fail/trait-impl-method-mismatch.rs index 7f4c227d2d0..54fa62f7977 100644 --- a/src/test/compile-fail/trait-impl-method-mismatch.rs +++ b/src/test/compile-fail/trait-impl-method-mismatch.rs @@ -19,7 +19,3 @@ impl Mumbo for uint { } fn main() {} - - - - diff --git a/src/test/compile-fail/trait-inheritance-missing-requirement.rs b/src/test/compile-fail/trait-inheritance-missing-requirement.rs index a341c242611..5968c296e13 100644 --- a/src/test/compile-fail/trait-inheritance-missing-requirement.rs +++ b/src/test/compile-fail/trait-inheritance-missing-requirement.rs @@ -30,4 +30,3 @@ impl Bar for A { fn main() { } - diff --git a/src/test/compile-fail/tuple-struct-nonexhaustive.rs b/src/test/compile-fail/tuple-struct-nonexhaustive.rs index 7cfdab2e96d..de28a06abab 100644 --- a/src/test/compile-fail/tuple-struct-nonexhaustive.rs +++ b/src/test/compile-fail/tuple-struct-nonexhaustive.rs @@ -17,5 +17,3 @@ fn main() { Foo(2, b) => io::println(fmt!("%d", b)) } } - - diff --git a/src/test/compile-fail/tutorial-suffix-inference-test.rs b/src/test/compile-fail/tutorial-suffix-inference-test.rs index c68af84b95b..d92aa8d640a 100644 --- a/src/test/compile-fail/tutorial-suffix-inference-test.rs +++ b/src/test/compile-fail/tutorial-suffix-inference-test.rs @@ -22,11 +22,11 @@ fn main() { //~^ ERROR mismatched types: expected `u16` but found `i32` let a = 3i; - + fn identity_i(n: int) -> int { n } identity_i(a); // ok - identity_u16(a); + identity_u16(a); //~^ ERROR mismatched types: expected `u16` but found `int` } diff --git a/src/test/compile-fail/unique-object-noncopyable.rs b/src/test/compile-fail/unique-object-noncopyable.rs index edc8a47822d..95945b0b5ba 100644 --- a/src/test/compile-fail/unique-object-noncopyable.rs +++ b/src/test/compile-fail/unique-object-noncopyable.rs @@ -31,4 +31,3 @@ fn main() { let y: ~Foo = x as ~Foo; let _z = copy y; //~ ERROR copying a value of non-copyable type } - diff --git a/src/test/compile-fail/use-after-move-based-on-type.rs b/src/test/compile-fail/use-after-move-based-on-type.rs index 6c268c5e13c..3d176bb339d 100644 --- a/src/test/compile-fail/use-after-move-based-on-type.rs +++ b/src/test/compile-fail/use-after-move-based-on-type.rs @@ -13,4 +13,3 @@ fn main() { let _y = x; io::println(x); //~ ERROR use of moved value } - diff --git a/src/test/compile-fail/use-after-move-self-based-on-type.rs b/src/test/compile-fail/use-after-move-self-based-on-type.rs index b0a2bc8ec12..627b8924b67 100644 --- a/src/test/compile-fail/use-after-move-self-based-on-type.rs +++ b/src/test/compile-fail/use-after-move-self-based-on-type.rs @@ -19,4 +19,3 @@ fn main() { let x = S { x: 1 }; io::println(x.foo().to_str()); } - diff --git a/src/test/compile-fail/use-after-move-self.rs b/src/test/compile-fail/use-after-move-self.rs index 3eded9fd4f3..11f37df4541 100644 --- a/src/test/compile-fail/use-after-move-self.rs +++ b/src/test/compile-fail/use-after-move-self.rs @@ -15,4 +15,3 @@ fn main() { let x = S { x: ~1 }; io::println(x.foo().to_str()); } - diff --git a/src/test/compile-fail/view-items-at-top.rs b/src/test/compile-fail/view-items-at-top.rs index a637836320d..023be703cca 100644 --- a/src/test/compile-fail/view-items-at-top.rs +++ b/src/test/compile-fail/view-items-at-top.rs @@ -19,4 +19,3 @@ use std::net; //~ ERROR view items must be declared at the top fn main() { } - diff --git a/src/test/compile-fail/while-type-error.rs b/src/test/compile-fail/while-type-error.rs index f9d3dce7508..ecab746373a 100644 --- a/src/test/compile-fail/while-type-error.rs +++ b/src/test/compile-fail/while-type-error.rs @@ -11,4 +11,3 @@ // error-pattern: mismatched types fn main() { while main { } } - diff --git a/src/test/compile-fail/xc-private-method.rs b/src/test/compile-fail/xc-private-method.rs index d194820df94..e8777a0a9f2 100644 --- a/src/test/compile-fail/xc-private-method.rs +++ b/src/test/compile-fail/xc-private-method.rs @@ -6,4 +6,3 @@ extern mod xc_private_method_lib; fn main() { let _ = xc_private_method_lib::Foo::new(); //~ ERROR function `new` is private } - diff --git a/src/test/pretty/doc-comments.rs b/src/test/pretty/doc-comments.rs index a866afd2405..45e242c0ca0 100644 --- a/src/test/pretty/doc-comments.rs +++ b/src/test/pretty/doc-comments.rs @@ -22,7 +22,7 @@ fn b() { ////////////////////////////////// // some single-line non-doc comment preceded by a separator -////////////////////////////////// +////////////////////////////////// /// some single-line outer-docs preceded by a separator /// (and trailing whitespaces) fn c() { } diff --git a/src/test/run-fail/assert-as-macro.rs b/src/test/run-fail/assert-as-macro.rs index 07813b91e57..f715e21f781 100644 --- a/src/test/run-fail/assert-as-macro.rs +++ b/src/test/run-fail/assert-as-macro.rs @@ -3,4 +3,3 @@ fn main() { assert!(1 == 2); } - diff --git a/src/test/run-fail/borrowck-wg-fail-3.rs b/src/test/run-fail/borrowck-wg-fail-3.rs index ad4c7942121..b239bfc3b31 100644 --- a/src/test/run-fail/borrowck-wg-fail-3.rs +++ b/src/test/run-fail/borrowck-wg-fail-3.rs @@ -5,4 +5,3 @@ fn main() { let y: &mut int = x; *x = 5; } - diff --git a/src/test/run-fail/borrowck-wg-fail.rs b/src/test/run-fail/borrowck-wg-fail.rs index d393832c6e8..93e7f9275b6 100644 --- a/src/test/run-fail/borrowck-wg-fail.rs +++ b/src/test/run-fail/borrowck-wg-fail.rs @@ -10,4 +10,3 @@ fn main() { let x = @mut 3; f(x, x); } - diff --git a/src/test/run-fail/unwind-resource-fail3.rs b/src/test/run-fail/unwind-resource-fail3.rs index d3ba5737b71..bfbad0b5aea 100644 --- a/src/test/run-fail/unwind-resource-fail3.rs +++ b/src/test/run-fail/unwind-resource-fail3.rs @@ -14,7 +14,7 @@ struct faily_box { i: @int } // What happens to the box pointer owned by this class? - + fn faily_box(i: @int) -> faily_box { faily_box { i: i } } #[unsafe_destructor] diff --git a/src/test/run-pass-fulldeps/qquote.rs b/src/test/run-pass-fulldeps/qquote.rs index 9bfe29a5e8e..284195f3f04 100644 --- a/src/test/run-pass-fulldeps/qquote.rs +++ b/src/test/run-pass-fulldeps/qquote.rs @@ -85,4 +85,3 @@ fn check_pp(cx: fake_ext_ctxt, assert!(s == expect); } } - diff --git a/src/test/run-pass-fulldeps/quote-tokens.rs b/src/test/run-pass-fulldeps/quote-tokens.rs index ccee163eafe..3ec54955229 100644 --- a/src/test/run-pass-fulldeps/quote-tokens.rs +++ b/src/test/run-pass-fulldeps/quote-tokens.rs @@ -27,4 +27,3 @@ fn syntax_extension(ext_cx: @ext_ctxt) { fn main() { } - diff --git a/src/test/run-pass/anon-trait-static-method.rs b/src/test/run-pass/anon-trait-static-method.rs index 8e11786786f..91bbbf5c0a0 100644 --- a/src/test/run-pass/anon-trait-static-method.rs +++ b/src/test/run-pass/anon-trait-static-method.rs @@ -22,4 +22,3 @@ pub fn main() { let x = Foo::new(); io::println(x.x.to_str()); } - diff --git a/src/test/run-pass/anon_trait_static_method_exe.rs b/src/test/run-pass/anon_trait_static_method_exe.rs index 5d8b7983688..1baeca00083 100644 --- a/src/test/run-pass/anon_trait_static_method_exe.rs +++ b/src/test/run-pass/anon_trait_static_method_exe.rs @@ -18,6 +18,3 @@ pub fn main() { let x = Foo::new(); io::println(x.x.to_str()); } - - - diff --git a/src/test/run-pass/auto-ref-newtype.rs b/src/test/run-pass/auto-ref-newtype.rs index bac6d1aa740..a9fca0ccb15 100644 --- a/src/test/run-pass/auto-ref-newtype.rs +++ b/src/test/run-pass/auto-ref-newtype.rs @@ -21,4 +21,3 @@ pub fn main() { let m = Foo(3); assert!(m.len() == 3); } - diff --git a/src/test/run-pass/auto-ref.rs b/src/test/run-pass/auto-ref.rs index f7c0f513a9d..ee250b97219 100644 --- a/src/test/run-pass/auto-ref.rs +++ b/src/test/run-pass/auto-ref.rs @@ -26,4 +26,3 @@ pub fn main() { let x = Foo { x: 3 }; x.printme(); } - diff --git a/src/test/run-pass/autoderef-and-borrow-method-receiver.rs b/src/test/run-pass/autoderef-and-borrow-method-receiver.rs index 883cffa792b..2bc6df47030 100644 --- a/src/test/run-pass/autoderef-and-borrow-method-receiver.rs +++ b/src/test/run-pass/autoderef-and-borrow-method-receiver.rs @@ -22,4 +22,3 @@ fn g(x: &mut Foo) { pub fn main() { } - diff --git a/src/test/run-pass/bare-static-string.rs b/src/test/run-pass/bare-static-string.rs index d8015f0b92c..6208a9c3cc3 100644 --- a/src/test/run-pass/bare-static-string.rs +++ b/src/test/run-pass/bare-static-string.rs @@ -12,4 +12,3 @@ pub fn main() { let x: &'static str = "foo"; io::println(x); } - diff --git a/src/test/run-pass/binops.rs b/src/test/run-pass/binops.rs index e7624c9e3b9..e755a34f058 100644 --- a/src/test/run-pass/binops.rs +++ b/src/test/run-pass/binops.rs @@ -104,7 +104,7 @@ fn p(x: int, y: int) -> p { fn test_class() { let mut q = p(1, 2); let mut r = p(1, 2); - + unsafe { error!("q = %x, r = %x", (::core::cast::transmute::<*p, uint>(&q)), diff --git a/src/test/run-pass/block-arg-in-parentheses.rs b/src/test/run-pass/block-arg-in-parentheses.rs index ce0b85f414b..ad53bd22754 100644 --- a/src/test/run-pass/block-arg-in-parentheses.rs +++ b/src/test/run-pass/block-arg-in-parentheses.rs @@ -33,4 +33,3 @@ pub fn main() { assert!(w_paren2(~[0, 1, 2, 3]) == -4); assert!(w_ret(~[0, 1, 2, 3]) == -4); } - diff --git a/src/test/run-pass/borrow-by-val-method-receiver.rs b/src/test/run-pass/borrow-by-val-method-receiver.rs index fdb51124f0e..fb4316ca1f5 100644 --- a/src/test/run-pass/borrow-by-val-method-receiver.rs +++ b/src/test/run-pass/borrow-by-val-method-receiver.rs @@ -20,4 +20,3 @@ pub fn main() { let items = ~[ 3, 5, 1, 2, 4 ]; items.foo(); } - diff --git a/src/test/run-pass/borrowck-wg-simple.rs b/src/test/run-pass/borrowck-wg-simple.rs index adf2403ec63..f28b0e4c4ec 100644 --- a/src/test/run-pass/borrowck-wg-simple.rs +++ b/src/test/run-pass/borrowck-wg-simple.rs @@ -6,4 +6,3 @@ pub fn main() { let x = @mut 3; f(x); } - diff --git a/src/test/run-pass/boxed-trait-with-vstore.rs b/src/test/run-pass/boxed-trait-with-vstore.rs index 1aac86238dc..1313a17f81d 100644 --- a/src/test/run-pass/boxed-trait-with-vstore.rs +++ b/src/test/run-pass/boxed-trait-with-vstore.rs @@ -22,4 +22,3 @@ pub fn main() { let x = @3 as @Foo; x.foo(); } - diff --git a/src/test/run-pass/break.rs b/src/test/run-pass/break.rs index b3f524c0ad7..a182dcf2ca0 100644 --- a/src/test/run-pass/break.rs +++ b/src/test/run-pass/break.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - pub fn main() { let mut i = 0; while i < 20 { i += 1; if i == 10 { break; } } @@ -22,8 +20,8 @@ pub fn main() { i = 0; while i < 10 { i += 1; if i % 2 == 0 { loop; } assert!((i % 2 != 0)); } i = 0; - loop { - i += 1; if i % 2 == 0 { loop; } assert!((i % 2 != 0)); + loop { + i += 1; if i % 2 == 0 { loop; } assert!((i % 2 != 0)); if i >= 10 { break; } } for vec::each(~[1, 2, 3, 4, 5, 6]) |x| { diff --git a/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs b/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs index 68bc567cf51..76f4e3b68f7 100644 --- a/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs +++ b/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs @@ -24,4 +24,3 @@ pub fn main() { let nyan : @ToStr = @cat(0u, 2, ~"nyan") as @ToStr; print_out(nyan, ~"nyan"); } - diff --git a/src/test/run-pass/class-impl-parameterized-trait.rs b/src/test/run-pass/class-impl-parameterized-trait.rs index 53ae0021a91..04784b5c515 100644 --- a/src/test/run-pass/class-impl-parameterized-trait.rs +++ b/src/test/run-pass/class-impl-parameterized-trait.rs @@ -48,7 +48,7 @@ class cat : map { } fn size() -> uint { self.meows as uint } - fn insert(+k: int, +v: bool) -> bool { + fn insert(+k: int, +v: bool) -> bool { if v { self.meows += k; } else { self.meows -= k; }; true } diff --git a/src/test/run-pass/cleanup-copy-mode.rs b/src/test/run-pass/cleanup-copy-mode.rs index 41f76b1b4f2..b334f32f344 100644 --- a/src/test/run-pass/cleanup-copy-mode.rs +++ b/src/test/run-pass/cleanup-copy-mode.rs @@ -16,4 +16,3 @@ pub fn main() { adder(@2, failer()); () }))); } - diff --git a/src/test/run-pass/clone-with-exterior.rs b/src/test/run-pass/clone-with-exterior.rs index 57c4f91142d..ae2983b1594 100644 --- a/src/test/run-pass/clone-with-exterior.rs +++ b/src/test/run-pass/clone-with-exterior.rs @@ -18,7 +18,7 @@ struct Pair { pub fn main() { let z = ~Pair { a : 10, b : 12}; - + let f: ~fn() = || { assert!((z.a == 10)); assert!((z.b == 12)); diff --git a/src/test/run-pass/conditional-compile.rs b/src/test/run-pass/conditional-compile.rs index 609bfe7a4cb..73fdb219c19 100644 --- a/src/test/run-pass/conditional-compile.rs +++ b/src/test/run-pass/conditional-compile.rs @@ -27,7 +27,7 @@ mod rustrt { // module was translated pub fn bogus(); } - + #[abi = "cdecl"] pub extern {} } diff --git a/src/test/run-pass/const-enum-vec-index.rs b/src/test/run-pass/const-enum-vec-index.rs index 01bab077832..4c81eaae1d8 100644 --- a/src/test/run-pass/const-enum-vec-index.rs +++ b/src/test/run-pass/const-enum-vec-index.rs @@ -14,7 +14,7 @@ static C0: E = C[0]; static C1: E = C[1]; pub fn main() { - match C0 { + match C0 { V0 => (), _ => fail!() } diff --git a/src/test/run-pass/const-enum-vec-ptr.rs b/src/test/run-pass/const-enum-vec-ptr.rs index 8615356965e..95c4ed836c7 100644 --- a/src/test/run-pass/const-enum-vec-ptr.rs +++ b/src/test/run-pass/const-enum-vec-ptr.rs @@ -16,7 +16,7 @@ pub fn main() { V1(n) => assert!(n == 0xDEADBEE), _ => fail!() } - match C[2] { + match C[2] { V0 => (), _ => fail!() } diff --git a/src/test/run-pass/const-enum-vector.rs b/src/test/run-pass/const-enum-vector.rs index 7ae2c5a2fee..3dc5b918f7f 100644 --- a/src/test/run-pass/const-enum-vector.rs +++ b/src/test/run-pass/const-enum-vector.rs @@ -16,7 +16,7 @@ pub fn main() { V1(n) => assert!(n == 0xDEADBEE), _ => fail!() } - match C[2] { + match C[2] { V0 => (), _ => fail!() } diff --git a/src/test/run-pass/const-expr-in-fixed-length-vec.rs b/src/test/run-pass/const-expr-in-fixed-length-vec.rs index c593fd39aaa..48b41d04633 100644 --- a/src/test/run-pass/const-expr-in-fixed-length-vec.rs +++ b/src/test/run-pass/const-expr-in-fixed-length-vec.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Check that constant expressions can be used for declaring the +// Check that constant expressions can be used for declaring the // type of a fixed length vector. pub fn main() { diff --git a/src/test/run-pass/const-expr-in-vec-repeat.rs b/src/test/run-pass/const-expr-in-vec-repeat.rs index be54c6eb7be..f10cef520ad 100644 --- a/src/test/run-pass/const-expr-in-vec-repeat.rs +++ b/src/test/run-pass/const-expr-in-vec-repeat.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Check that constant expressions can be used in vec repeat syntax. +// Check that constant expressions can be used in vec repeat syntax. pub fn main() { diff --git a/src/test/run-pass/const-tuple-struct.rs b/src/test/run-pass/const-tuple-struct.rs index a68e12b7b10..828c20912a1 100644 --- a/src/test/run-pass/const-tuple-struct.rs +++ b/src/test/run-pass/const-tuple-struct.rs @@ -20,4 +20,3 @@ pub fn main() { } } } - diff --git a/src/test/run-pass/const-unit-struct.rs b/src/test/run-pass/const-unit-struct.rs index b4acde098ba..7e6d9f0bee9 100644 --- a/src/test/run-pass/const-unit-struct.rs +++ b/src/test/run-pass/const-unit-struct.rs @@ -17,4 +17,3 @@ pub fn main() { Foo => {} } } - diff --git a/src/test/run-pass/const-vec-syntax.rs b/src/test/run-pass/const-vec-syntax.rs index c3e882ac04f..625f6ec30cc 100644 --- a/src/test/run-pass/const-vec-syntax.rs +++ b/src/test/run-pass/const-vec-syntax.rs @@ -14,4 +14,3 @@ pub fn main() { let v = [ 1, 2, 3 ]; f(v); } - diff --git a/src/test/run-pass/consts-in-patterns.rs b/src/test/run-pass/consts-in-patterns.rs index 408c0e612f4..c0520cf737f 100644 --- a/src/test/run-pass/consts-in-patterns.rs +++ b/src/test/run-pass/consts-in-patterns.rs @@ -20,4 +20,3 @@ pub fn main() { }; assert!(y == 2); } - diff --git a/src/test/run-pass/cycle-collection.rs b/src/test/run-pass/cycle-collection.rs index 0512b8a1267..0e9be022113 100644 --- a/src/test/run-pass/cycle-collection.rs +++ b/src/test/run-pass/cycle-collection.rs @@ -21,4 +21,3 @@ fn f() { pub fn main() { f(); } - diff --git a/src/test/run-pass/default-method-simple.rs b/src/test/run-pass/default-method-simple.rs index 62b29d4e4eb..3f44f3f1ef8 100644 --- a/src/test/run-pass/default-method-simple.rs +++ b/src/test/run-pass/default-method-simple.rs @@ -32,4 +32,3 @@ pub fn main() { let a = A { x: 1 }; a.f(); } - diff --git a/src/test/run-pass/deriving-clone-enum.rs b/src/test/run-pass/deriving-clone-enum.rs index 6caceeb2d70..969e1fb5dd6 100644 --- a/src/test/run-pass/deriving-clone-enum.rs +++ b/src/test/run-pass/deriving-clone-enum.rs @@ -16,4 +16,3 @@ enum E { } pub fn main() {} - diff --git a/src/test/run-pass/deriving-clone-generic-enum.rs b/src/test/run-pass/deriving-clone-generic-enum.rs index a868db2425c..23841017e93 100644 --- a/src/test/run-pass/deriving-clone-generic-enum.rs +++ b/src/test/run-pass/deriving-clone-generic-enum.rs @@ -6,4 +6,3 @@ enum E { } fn main() {} - diff --git a/src/test/run-pass/deriving-clone-generic-struct.rs b/src/test/run-pass/deriving-clone-generic-struct.rs index b157cd321cf..0a7a5a3aa75 100644 --- a/src/test/run-pass/deriving-clone-generic-struct.rs +++ b/src/test/run-pass/deriving-clone-generic-struct.rs @@ -16,4 +16,3 @@ struct S { } pub fn main() {} - diff --git a/src/test/run-pass/deriving-clone-generic-tuple-struct.rs b/src/test/run-pass/deriving-clone-generic-tuple-struct.rs index aeaa9ed726d..d6a69e8e6ac 100644 --- a/src/test/run-pass/deriving-clone-generic-tuple-struct.rs +++ b/src/test/run-pass/deriving-clone-generic-tuple-struct.rs @@ -2,4 +2,3 @@ struct S(T, ()); fn main() {} - diff --git a/src/test/run-pass/deriving-clone-tuple-struct.rs b/src/test/run-pass/deriving-clone-tuple-struct.rs index c534883f600..1e5c8c80f8c 100644 --- a/src/test/run-pass/deriving-clone-tuple-struct.rs +++ b/src/test/run-pass/deriving-clone-tuple-struct.rs @@ -12,4 +12,3 @@ struct S((), ()); pub fn main() {} - diff --git a/src/test/run-pass/deriving-via-extension-c-enum.rs b/src/test/run-pass/deriving-via-extension-c-enum.rs index 67893ae9c1e..81c4ce013f2 100644 --- a/src/test/run-pass/deriving-via-extension-c-enum.rs +++ b/src/test/run-pass/deriving-via-extension-c-enum.rs @@ -23,4 +23,3 @@ pub fn main() { assert!(a.eq(&b)); assert!(!a.ne(&b)); } - diff --git a/src/test/run-pass/deriving-via-extension-enum.rs b/src/test/run-pass/deriving-via-extension-enum.rs index 7481bae508b..fac0d402a38 100644 --- a/src/test/run-pass/deriving-via-extension-enum.rs +++ b/src/test/run-pass/deriving-via-extension-enum.rs @@ -22,4 +22,3 @@ pub fn main() { assert!(a.eq(&b)); assert!(!a.ne(&b)); } - diff --git a/src/test/run-pass/deriving-via-extension-iter-bytes-enum.rs b/src/test/run-pass/deriving-via-extension-iter-bytes-enum.rs index 5ceb8c48750..b08117b71fa 100644 --- a/src/test/run-pass/deriving-via-extension-iter-bytes-enum.rs +++ b/src/test/run-pass/deriving-via-extension-iter-bytes-enum.rs @@ -25,4 +25,3 @@ enum A { } pub fn main(){} - diff --git a/src/test/run-pass/deriving-via-extension-iter-bytes-struct.rs b/src/test/run-pass/deriving-via-extension-iter-bytes-struct.rs index 9f18cb6ac58..8369d12ecdd 100644 --- a/src/test/run-pass/deriving-via-extension-iter-bytes-struct.rs +++ b/src/test/run-pass/deriving-via-extension-iter-bytes-struct.rs @@ -18,5 +18,3 @@ struct Foo { } pub fn main() {} - - diff --git a/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs b/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs index 712767efacf..4ef8fb6b5d9 100644 --- a/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs +++ b/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs @@ -9,4 +9,3 @@ pub fn main() { assert!(x == x); assert!(!(x != x)); } - diff --git a/src/test/run-pass/deriving-via-extension-struct.rs b/src/test/run-pass/deriving-via-extension-struct.rs index 1e004d1a8c0..c0e7ee36b16 100644 --- a/src/test/run-pass/deriving-via-extension-struct.rs +++ b/src/test/run-pass/deriving-via-extension-struct.rs @@ -23,4 +23,3 @@ pub fn main() { assert!(a.eq(&b)); assert!(!a.ne(&b)); } - diff --git a/src/test/run-pass/deriving-via-extension-type-params.rs b/src/test/run-pass/deriving-via-extension-type-params.rs index f310643f943..85a89c62989 100644 --- a/src/test/run-pass/deriving-via-extension-type-params.rs +++ b/src/test/run-pass/deriving-via-extension-type-params.rs @@ -26,4 +26,3 @@ pub fn main() { assert!(a.eq(&b)); assert!(!a.ne(&b)); } - diff --git a/src/test/run-pass/drop-trait-generic.rs b/src/test/run-pass/drop-trait-generic.rs index 21b85084117..65c3faac2b3 100644 --- a/src/test/run-pass/drop-trait-generic.rs +++ b/src/test/run-pass/drop-trait-generic.rs @@ -22,4 +22,3 @@ impl ::core::ops::Drop for S { pub fn main() { let x = S { x: 1 }; } - diff --git a/src/test/run-pass/drop-trait.rs b/src/test/run-pass/drop-trait.rs index 3eddda376a8..b516c6f6de4 100644 --- a/src/test/run-pass/drop-trait.rs +++ b/src/test/run-pass/drop-trait.rs @@ -21,4 +21,3 @@ impl Drop for Foo { pub fn main() { let x: Foo = Foo { x: 3 }; } - diff --git a/src/test/run-pass/enum-discrim-range-overflow.rs b/src/test/run-pass/enum-discrim-range-overflow.rs index a6806fba142..37e457d547b 100644 --- a/src/test/run-pass/enum-discrim-range-overflow.rs +++ b/src/test/run-pass/enum-discrim-range-overflow.rs @@ -9,23 +9,23 @@ // except according to those terms. pub enum E64 { - H64 = 0x7FFF_FFFF_FFFF_FFFF, - L64 = 0x8000_0000_0000_0000 + H64 = 0x7FFF_FFFF_FFFF_FFFF, + L64 = 0x8000_0000_0000_0000 } pub enum E32 { - H32 = 0x7FFF_FFFF, - L32 = 0x8000_0000 + H32 = 0x7FFF_FFFF, + L32 = 0x8000_0000 } pub fn f(e64: E64, e32: E32) -> (bool,bool) { - (match e64 { - H64 => true, - L64 => false - }, - match e32 { - H32 => true, - L32 => false - }) + (match e64 { + H64 => true, + L64 => false + }, + match e32 { + H32 => true, + L32 => false + }) } pub fn main() { } diff --git a/src/test/run-pass/enum-disr-val-pretty.rs b/src/test/run-pass/enum-disr-val-pretty.rs index 39a807789ec..2c61351cf44 100644 --- a/src/test/run-pass/enum-disr-val-pretty.rs +++ b/src/test/run-pass/enum-disr-val-pretty.rs @@ -23,4 +23,3 @@ fn test_color(color: color, val: int, name: ~str) { assert!(color as int == val); assert!(color as float == val as float); } - diff --git a/src/test/run-pass/enum-export-inheritance.rs b/src/test/run-pass/enum-export-inheritance.rs index c3beebdb8ae..49823155043 100644 --- a/src/test/run-pass/enum-export-inheritance.rs +++ b/src/test/run-pass/enum-export-inheritance.rs @@ -19,4 +19,3 @@ mod a { pub fn main() { let x = a::Bar; } - diff --git a/src/test/run-pass/enum-nullable-simplifycfg-misopt.rs b/src/test/run-pass/enum-nullable-simplifycfg-misopt.rs index b5cf15f3b38..4764dbb9417 100644 --- a/src/test/run-pass/enum-nullable-simplifycfg-misopt.rs +++ b/src/test/run-pass/enum-nullable-simplifycfg-misopt.rs @@ -17,8 +17,8 @@ enum List { Nil, Cons(X, @List) } pub fn main() { match Cons(10, @Nil) { - Cons(10, _) => {} - Nil => {} - _ => fail!() + Cons(10, _) => {} + Nil => {} + _ => fail!() } } diff --git a/src/test/run-pass/explicit-self-generic.rs b/src/test/run-pass/explicit-self-generic.rs index 1a2a8cab303..ac19592accf 100644 --- a/src/test/run-pass/explicit-self-generic.rs +++ b/src/test/run-pass/explicit-self-generic.rs @@ -40,4 +40,3 @@ pub fn main() { let mut m = ~linear_map::<(),()>(); assert!(m.len() == 0); } - diff --git a/src/test/run-pass/explicit-self-objects-box.rs b/src/test/run-pass/explicit-self-objects-box.rs index 105aad03083..12a1780e029 100644 --- a/src/test/run-pass/explicit-self-objects-box.rs +++ b/src/test/run-pass/explicit-self-objects-box.rs @@ -30,5 +30,3 @@ pub fn main() { y.f(); y.f(); } - - diff --git a/src/test/run-pass/explicit-self-objects-simple.rs b/src/test/run-pass/explicit-self-objects-simple.rs index de2926b0e7e..814365a8354 100644 --- a/src/test/run-pass/explicit-self-objects-simple.rs +++ b/src/test/run-pass/explicit-self-objects-simple.rs @@ -27,5 +27,3 @@ pub fn main() { let y = x as @Foo; y.f(); } - - diff --git a/src/test/run-pass/explicit-self-objects-uniq.rs b/src/test/run-pass/explicit-self-objects-uniq.rs index e99a6bbedc0..dadf53fb9bc 100644 --- a/src/test/run-pass/explicit-self-objects-uniq.rs +++ b/src/test/run-pass/explicit-self-objects-uniq.rs @@ -27,5 +27,3 @@ pub fn main() { let y = x as ~Foo; y.f(); } - - diff --git a/src/test/run-pass/explicit_self_xcrate_exe.rs b/src/test/run-pass/explicit_self_xcrate_exe.rs index e217e6ebd41..6f6520e8040 100644 --- a/src/test/run-pass/explicit_self_xcrate_exe.rs +++ b/src/test/run-pass/explicit_self_xcrate_exe.rs @@ -18,4 +18,3 @@ pub fn main() { let x = Bar { x: ~"hello" }; x.f(); } - diff --git a/src/test/run-pass/expr-repeat-vstore.rs b/src/test/run-pass/expr-repeat-vstore.rs index 972b2763b1b..e48abc57534 100644 --- a/src/test/run-pass/expr-repeat-vstore.rs +++ b/src/test/run-pass/expr-repeat-vstore.rs @@ -20,4 +20,3 @@ fn main() { println((copy v[3]).to_str()); println((copy v[4]).to_str()); } - diff --git a/src/test/run-pass/extern-mod-abi.rs b/src/test/run-pass/extern-mod-abi.rs index 7eada51b7c7..84fd1b40bf7 100644 --- a/src/test/run-pass/extern-mod-abi.rs +++ b/src/test/run-pass/extern-mod-abi.rs @@ -13,4 +13,3 @@ extern "C" { } pub fn main() {} - diff --git a/src/test/run-pass/extern-mod-ordering-exe.rs b/src/test/run-pass/extern-mod-ordering-exe.rs index b60302277b3..5836245ff78 100644 --- a/src/test/run-pass/extern-mod-ordering-exe.rs +++ b/src/test/run-pass/extern-mod-ordering-exe.rs @@ -8,4 +8,3 @@ use extern_mod_ordering_lib::extern_mod_ordering_lib; fn main() { extern_mod_ordering_lib::f(); } - diff --git a/src/test/run-pass/extern-mod-syntax.rs b/src/test/run-pass/extern-mod-syntax.rs index b6b2e004263..c98b5ebc238 100644 --- a/src/test/run-pass/extern-mod-syntax.rs +++ b/src/test/run-pass/extern-mod-syntax.rs @@ -16,4 +16,3 @@ use std::json::Object; pub fn main() { io::println("Hello world!"); } - diff --git a/src/test/run-pass/extern-pass-TwoU16s.rs b/src/test/run-pass/extern-pass-TwoU16s.rs index f0343c4d2a2..ec65cbb5670 100644 --- a/src/test/run-pass/extern-pass-TwoU16s.rs +++ b/src/test/run-pass/extern-pass-TwoU16s.rs @@ -29,4 +29,3 @@ pub fn main() { assert!(x == y); } } - diff --git a/src/test/run-pass/extern-pass-TwoU32s.rs b/src/test/run-pass/extern-pass-TwoU32s.rs index 16d14a96cfe..6ac5967c54f 100644 --- a/src/test/run-pass/extern-pass-TwoU32s.rs +++ b/src/test/run-pass/extern-pass-TwoU32s.rs @@ -27,4 +27,3 @@ pub fn main() { assert!(x == y); } } - diff --git a/src/test/run-pass/extern-pass-TwoU64s-ref.rs b/src/test/run-pass/extern-pass-TwoU64s-ref.rs index 56d3f8ebbff..2b18dba90f7 100644 --- a/src/test/run-pass/extern-pass-TwoU64s-ref.rs +++ b/src/test/run-pass/extern-pass-TwoU64s-ref.rs @@ -26,4 +26,3 @@ pub fn main() { assert!(x == y); } } - diff --git a/src/test/run-pass/extern-pass-TwoU64s.rs b/src/test/run-pass/extern-pass-TwoU64s.rs index 24dd3db8aca..3a1f4a51238 100644 --- a/src/test/run-pass/extern-pass-TwoU64s.rs +++ b/src/test/run-pass/extern-pass-TwoU64s.rs @@ -31,4 +31,3 @@ pub fn main() { assert!(x == y); } } - diff --git a/src/test/run-pass/extern-pass-TwoU8s.rs b/src/test/run-pass/extern-pass-TwoU8s.rs index 213e9a68a7f..7d08b436908 100644 --- a/src/test/run-pass/extern-pass-TwoU8s.rs +++ b/src/test/run-pass/extern-pass-TwoU8s.rs @@ -29,4 +29,3 @@ pub fn main() { assert!(x == y); } } - diff --git a/src/test/run-pass/extern-pass-char.rs b/src/test/run-pass/extern-pass-char.rs index f4fa6bde392..645396e5a98 100644 --- a/src/test/run-pass/extern-pass-char.rs +++ b/src/test/run-pass/extern-pass-char.rs @@ -19,4 +19,3 @@ pub fn main() { assert!(22_u8 == rust_dbg_extern_identity_u8(22_u8)); } } - diff --git a/src/test/run-pass/extern-pass-double.rs b/src/test/run-pass/extern-pass-double.rs index 4e16acb4ad5..3a6dd26a9dc 100644 --- a/src/test/run-pass/extern-pass-double.rs +++ b/src/test/run-pass/extern-pass-double.rs @@ -17,4 +17,3 @@ pub fn main() { assert!(22.0_f64 == rust_dbg_extern_identity_double(22.0_f64)); } } - diff --git a/src/test/run-pass/extern-pass-u32.rs b/src/test/run-pass/extern-pass-u32.rs index 14d05f82177..19c4d6e1539 100644 --- a/src/test/run-pass/extern-pass-u32.rs +++ b/src/test/run-pass/extern-pass-u32.rs @@ -19,4 +19,3 @@ pub fn main() { assert!(22_u32 == rust_dbg_extern_identity_u32(22_u32)); } } - diff --git a/src/test/run-pass/extern-pass-u64.rs b/src/test/run-pass/extern-pass-u64.rs index 2b5a03a4d71..cce66999922 100644 --- a/src/test/run-pass/extern-pass-u64.rs +++ b/src/test/run-pass/extern-pass-u64.rs @@ -19,4 +19,3 @@ pub fn main() { assert!(22_u64 == rust_dbg_extern_identity_u64(22_u64)); } } - diff --git a/src/test/run-pass/extern-pub.rs b/src/test/run-pass/extern-pub.rs index 9bfeec8c7d6..f9b0ccbb548 100644 --- a/src/test/run-pass/extern-pub.rs +++ b/src/test/run-pass/extern-pub.rs @@ -6,5 +6,3 @@ extern { pub fn main() { } - - diff --git a/src/test/run-pass/fat-arrow-alt.rs b/src/test/run-pass/fat-arrow-alt.rs index 4b8b552bfae..f6b49960fad 100644 --- a/src/test/run-pass/fat-arrow-alt.rs +++ b/src/test/run-pass/fat-arrow-alt.rs @@ -23,4 +23,3 @@ pub fn main() { blue => { 3 } }); } - diff --git a/src/test/run-pass/fixed_length_copy.rs b/src/test/run-pass/fixed_length_copy.rs index 5daa525d9b1..7ee3f5173b0 100644 --- a/src/test/run-pass/fixed_length_copy.rs +++ b/src/test/run-pass/fixed_length_copy.rs @@ -10,7 +10,7 @@ // error on implicit copies to check fixed length vectors -// are implicitly copyable +// are implicitly copyable #[deny(implicit_copies)] pub fn main() { let arr = [1,2,3]; diff --git a/src/test/run-pass/float-literal-inference.rs b/src/test/run-pass/float-literal-inference.rs index 2b59d7bfcee..a5246eef0b0 100644 --- a/src/test/run-pass/float-literal-inference.rs +++ b/src/test/run-pass/float-literal-inference.rs @@ -20,4 +20,3 @@ pub fn main() { let z = S { z: 1.0 }; io::println(z.z.to_str()); } - diff --git a/src/test/run-pass/fn-pattern-expected-type-2.rs b/src/test/run-pass/fn-pattern-expected-type-2.rs index f9bf9b5915e..501bd81d558 100644 --- a/src/test/run-pass/fn-pattern-expected-type-2.rs +++ b/src/test/run-pass/fn-pattern-expected-type-2.rs @@ -15,4 +15,3 @@ pub fn main() { io::println(x.to_str()); } } - diff --git a/src/test/run-pass/fn-pattern-expected-type.rs b/src/test/run-pass/fn-pattern-expected-type.rs index dc3f33a1991..f3949a0f43b 100644 --- a/src/test/run-pass/fn-pattern-expected-type.rs +++ b/src/test/run-pass/fn-pattern-expected-type.rs @@ -15,4 +15,3 @@ pub fn main() { }; f((1, 2)); } - diff --git a/src/test/run-pass/foreign-mod-unused-const.rs b/src/test/run-pass/foreign-mod-unused-const.rs index 430da7a3f60..4909e9d7e56 100644 --- a/src/test/run-pass/foreign-mod-unused-const.rs +++ b/src/test/run-pass/foreign-mod-unused-const.rs @@ -17,4 +17,3 @@ mod foo { pub fn main() { } - diff --git a/src/test/run-pass/functional-struct-update.rs b/src/test/run-pass/functional-struct-update.rs index f1db6db417a..297b5e78a92 100644 --- a/src/test/run-pass/functional-struct-update.rs +++ b/src/test/run-pass/functional-struct-update.rs @@ -18,4 +18,3 @@ pub fn main() { let c = Foo { x: 4, .. a}; io::println(fmt!("%?", c)); } - diff --git a/src/test/run-pass/generic-ivec-leak.rs b/src/test/run-pass/generic-ivec-leak.rs index 8d9b0fa6ddb..ac6e3e1a69a 100644 --- a/src/test/run-pass/generic-ivec-leak.rs +++ b/src/test/run-pass/generic-ivec-leak.rs @@ -11,4 +11,3 @@ enum wrapper { wrapped(T), } pub fn main() { let w = wrapped(~[1, 2, 3, 4, 5]); } - diff --git a/src/test/run-pass/generic-ivec.rs b/src/test/run-pass/generic-ivec.rs index 031821d9909..2a288c8abbf 100644 --- a/src/test/run-pass/generic-ivec.rs +++ b/src/test/run-pass/generic-ivec.rs @@ -10,4 +10,3 @@ fn f(v: @T) { } pub fn main() { f(@~[1, 2, 3, 4, 5]); } - diff --git a/src/test/run-pass/generic-newtype-struct.rs b/src/test/run-pass/generic-newtype-struct.rs index 7c7d73eda10..cf4279d67b8 100644 --- a/src/test/run-pass/generic-newtype-struct.rs +++ b/src/test/run-pass/generic-newtype-struct.rs @@ -4,4 +4,3 @@ pub fn main() { let s = S(2i); io::println(s.to_str()); } - diff --git a/src/test/run-pass/generic-object.rs b/src/test/run-pass/generic-object.rs index ebfc362c72c..54ae2c58e42 100644 --- a/src/test/run-pass/generic-object.rs +++ b/src/test/run-pass/generic-object.rs @@ -27,4 +27,3 @@ pub fn main() { let y = x as @Foo; assert!(y.get() == 1); } - diff --git a/src/test/run-pass/global-scope.rs b/src/test/run-pass/global-scope.rs index 3dd912dea9a..9b292a325c0 100644 --- a/src/test/run-pass/global-scope.rs +++ b/src/test/run-pass/global-scope.rs @@ -18,4 +18,3 @@ pub mod foo { } pub fn main() { return foo::g(); } - diff --git a/src/test/run-pass/impl-privacy-xc-1.rs b/src/test/run-pass/impl-privacy-xc-1.rs index df001c7ab21..19d3caf818d 100644 --- a/src/test/run-pass/impl-privacy-xc-1.rs +++ b/src/test/run-pass/impl-privacy-xc-1.rs @@ -7,4 +7,3 @@ pub fn main() { let fish = impl_privacy_xc_1::Fish { x: 1 }; fish.swim(); } - diff --git a/src/test/run-pass/impl-privacy-xc-2.rs b/src/test/run-pass/impl-privacy-xc-2.rs index 69bd31ab766..74d9a34e161 100644 --- a/src/test/run-pass/impl-privacy-xc-2.rs +++ b/src/test/run-pass/impl-privacy-xc-2.rs @@ -8,4 +8,3 @@ pub fn main() { let fish2 = impl_privacy_xc_2::Fish { x: 2 }; io::println(if fish1.eq(&fish2) { "yes" } else { "no " }); } - diff --git a/src/test/run-pass/infinite-loops.rs b/src/test/run-pass/infinite-loops.rs index 611a4b9ccab..b2ed6d95c20 100644 --- a/src/test/run-pass/infinite-loops.rs +++ b/src/test/run-pass/infinite-loops.rs @@ -21,9 +21,9 @@ fn loopy(n: int) { loop { } } -pub fn main() { +pub fn main() { // Commenting this out, as this will hang forever otherwise. // Even after seeing the comment above, I'm not sure what the // intention of this test is. - // do spawn { loopy(5) }; + // do spawn { loopy(5) }; } diff --git a/src/test/run-pass/instantiable.rs b/src/test/run-pass/instantiable.rs index c140a66ffe4..2173bae85e1 100644 --- a/src/test/run-pass/instantiable.rs +++ b/src/test/run-pass/instantiable.rs @@ -18,4 +18,3 @@ struct X { x: uint, nxt: *foo } pub fn main() { let x = foo(X {x: 0, nxt: ptr::null()}); } - diff --git a/src/test/run-pass/int-conversion-coherence.rs b/src/test/run-pass/int-conversion-coherence.rs index 235fab107e7..ef2a84da219 100644 --- a/src/test/run-pass/int-conversion-coherence.rs +++ b/src/test/run-pass/int-conversion-coherence.rs @@ -23,4 +23,3 @@ impl foo of plus for int { fn plus() -> int { self + 10 } } pub fn main() { assert!(10.plus() == 20); } - diff --git a/src/test/run-pass/intrinsics-integer.rs b/src/test/run-pass/intrinsics-integer.rs index b96ea8cbb7b..1a0d97a5c5b 100644 --- a/src/test/run-pass/intrinsics-integer.rs +++ b/src/test/run-pass/intrinsics-integer.rs @@ -89,7 +89,7 @@ pub fn main() { assert!((cttz16(-1i16) == 0i16)); assert!((cttz32(-1i32) == 0i32)); assert!((cttz64(-1i64) == 0i64)); - + assert!((cttz8(0i8) == 8i8)); assert!((cttz16(0i16) == 16i16)); assert!((cttz32(0i32) == 32i32)); diff --git a/src/test/run-pass/intrinsics-math.rs b/src/test/run-pass/intrinsics-math.rs index 60e32a56ee5..6f9179bc89d 100644 --- a/src/test/run-pass/intrinsics-math.rs +++ b/src/test/run-pass/intrinsics-math.rs @@ -83,7 +83,7 @@ pub fn main() { assert!((log2f32(8f32).fuzzy_eq(&3f32))); assert!((log2f64(f64::consts::e).fuzzy_eq(&f64::consts::log2_e))); - + assert!((fmaf32(1.0f32, 2.0f32, 5.0f32).fuzzy_eq(&7.0f32))); assert!((fmaf64(0.0f64, -2.0f64, f64::consts::e).fuzzy_eq(&f64::consts::e))); @@ -97,7 +97,7 @@ pub fn main() { // undefined reference to llvm.ceil.f32/64 //assert!((ceilf32(-2.3f32) == -2.0f32)); //assert!((ceilf64(3.8f64) == 4.0f64)); - + // Causes linker error // undefined reference to llvm.trunc.f32/64 //assert!((truncf32(0.1f32) == 0.0f32)); diff --git a/src/test/run-pass/issue-1516.rs b/src/test/run-pass/issue-1516.rs index 33be716cc5f..fe3feeb3dbf 100644 --- a/src/test/run-pass/issue-1516.rs +++ b/src/test/run-pass/issue-1516.rs @@ -10,4 +10,3 @@ // xfail-test pub fn main() { let early_error: @fn(str) -> ! = {|msg| fail!() }; } - diff --git a/src/test/run-pass/issue-2185.rs b/src/test/run-pass/issue-2185.rs index 8a553784c5e..5b320ddc06b 100644 --- a/src/test/run-pass/issue-2185.rs +++ b/src/test/run-pass/issue-2185.rs @@ -15,7 +15,7 @@ // notes on this test case: // On Thu, Apr 18, 2013 at 6:30 PM, John Clements wrote: // the "issue-2185.rs" test was xfailed with a ref to #2263. Issue #2263 is now fixed, so I tried it again, and after adding some &self parameters, I got this error: -// +// // Running /usr/local/bin/rustc: // issue-2185.rs:24:0: 26:1 error: conflicting implementations for a trait // issue-2185.rs:24 impl iterable for @fn(&fn(uint)) { @@ -25,7 +25,7 @@ // issue-2185.rs:20 impl iterable for @fn(&fn(A)) { // issue-2185.rs:21 fn iter(&self, blk: &fn(A)) { self(blk); } // issue-2185.rs:22 } -// +// // … so it looks like it's just not possible to implement both the generic iterable and iterable for the type iterable. Is it okay if I just remove this test? // // but Niko responded: diff --git a/src/test/run-pass/issue-2216.rs b/src/test/run-pass/issue-2216.rs index 98965cb6d91..c3a2a4c0b7e 100644 --- a/src/test/run-pass/issue-2216.rs +++ b/src/test/run-pass/issue-2216.rs @@ -10,7 +10,7 @@ pub fn main() { let mut x = 0; - + 'foo: loop { 'bar: loop { 'quux: loop { diff --git a/src/test/run-pass/issue-2526-a.rs b/src/test/run-pass/issue-2526-a.rs index c91b5dd303c..39ce74947e9 100644 --- a/src/test/run-pass/issue-2526-a.rs +++ b/src/test/run-pass/issue-2526-a.rs @@ -15,4 +15,3 @@ extern mod issue_2526; use issue_2526::*; pub fn main() {} - diff --git a/src/test/run-pass/issue-2734.rs b/src/test/run-pass/issue-2734.rs index 7125e89287c..319146d0a81 100644 --- a/src/test/run-pass/issue-2734.rs +++ b/src/test/run-pass/issue-2734.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait hax { } -impl hax for A { } +trait hax { } +impl hax for A { } fn perform_hax(x: @T) -> @hax { @x as @hax diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs index ef7fd691577..77cc6b3e1b5 100644 --- a/src/test/run-pass/issue-2904.rs +++ b/src/test/run-pass/issue-2904.rs @@ -37,7 +37,7 @@ impl to_str::ToStr for square { closed_lift => { ~"L" } open_lift => { ~"O" } earth => { ~"." } - empty => { ~" " } + empty => { ~" " } } } } diff --git a/src/test/run-pass/issue-3176.rs b/src/test/run-pass/issue-3176.rs index 03b1c127c55..55d62a5bf8e 100644 --- a/src/test/run-pass/issue-3176.rs +++ b/src/test/run-pass/issue-3176.rs @@ -20,7 +20,7 @@ pub fn main() { p2.recv(); error!("sibling fails"); fail!(); - } + } let (p3,c3) = comm::stream(); c.send(c3); c2.send(()); @@ -28,7 +28,7 @@ pub fn main() { let (p, c) = comm::stream(); (p, p3).select(); c.send(()); - }; + }; error!("parent tries"); assert!(!p.recv().try_send(())); error!("all done!"); diff --git a/src/test/run-pass/issue-3250.rs b/src/test/run-pass/issue-3250.rs index a563544b5c7..0a93b89a94d 100644 --- a/src/test/run-pass/issue-3250.rs +++ b/src/test/run-pass/issue-3250.rs @@ -2,6 +2,4 @@ type t = (uint, uint); - - pub fn main() { } diff --git a/src/test/run-pass/issue-3429.rs b/src/test/run-pass/issue-3429.rs index 67877795cc0..7bfb928e86d 100644 --- a/src/test/run-pass/issue-3429.rs +++ b/src/test/run-pass/issue-3429.rs @@ -13,4 +13,3 @@ pub fn main() { let y: @fn() -> int = || x; let z = y(); } - diff --git a/src/test/run-pass/issue-3461.rs b/src/test/run-pass/issue-3461.rs index 4c4144f28e8..dae35d7237b 100644 --- a/src/test/run-pass/issue-3461.rs +++ b/src/test/run-pass/issue-3461.rs @@ -12,6 +12,6 @@ pub fn main() { fn foo() { } - + let bar: ~fn() = ~foo; } diff --git a/src/test/run-pass/issue-3556.rs b/src/test/run-pass/issue-3556.rs index 703dcd54f0a..ff2fa80102b 100644 --- a/src/test/run-pass/issue-3556.rs +++ b/src/test/run-pass/issue-3556.rs @@ -10,7 +10,7 @@ extern mod std; use core::io::WriterUtil; - + enum Token { Text(@~str), ETag(@~[~str], @~str), @@ -19,7 +19,7 @@ enum Token { IncompleteSection(@~[~str], bool, @~str, bool), Partial(@~str, @~str, @~str), } - + fn check_strs(actual: &str, expected: &str) -> bool { if actual != expected @@ -29,12 +29,12 @@ fn check_strs(actual: &str, expected: &str) -> bool } return true; } - + pub fn main() { // assert!(check_strs(fmt!("%?", Text(@~"foo")), "Text(@~\"foo\")")); // assert!(check_strs(fmt!("%?", ETag(@~[~"foo"], @~"bar")), "ETag(@~[ ~\"foo\" ], @~\"bar\")")); - + let t = Text(@~"foo"); let u = Section(@~[~"alpha"], true, @~[t], @~"foo", @~"foo", @~"foo", @~"foo", @~"foo"); let v = fmt!("%?", u); // this is the line that causes the seg fault diff --git a/src/test/run-pass/issue-3563-3.rs b/src/test/run-pass/issue-3563-3.rs index 9b7ab67c1a3..96925a97a10 100644 --- a/src/test/run-pass/issue-3563-3.rs +++ b/src/test/run-pass/issue-3563-3.rs @@ -62,7 +62,7 @@ impl Drop for AsciiArt { // It's common to define a constructor sort of function to create struct instances. // If there is a canonical constructor it is typically named the same as the type. -// Other constructor sort of functions are typically named from_foo, from_bar, etc. +// Other constructor sort of functions are typically named from_foo, from_bar, etc. fn AsciiArt(width: uint, height: uint, fill: char) -> AsciiArt { // Use an anonymous function to build a vector of vectors containing @@ -72,7 +72,7 @@ fn AsciiArt(width: uint, height: uint, fill: char) -> AsciiArt { for height.times { - let mut line = ~[]; + let mut line = ~[]; vec::grow_set(&mut line, width-1, &'.', '.'); push(line); } @@ -208,4 +208,3 @@ pub fn main() { test_add_pt(); test_shapes(); } - diff --git a/src/test/run-pass/issue-3609.rs b/src/test/run-pass/issue-3609.rs index fc6ceb4130f..6c26ac3f65e 100644 --- a/src/test/run-pass/issue-3609.rs +++ b/src/test/run-pass/issue-3609.rs @@ -24,4 +24,3 @@ fn foo(name: ~str, samples_chan: Chan) { } pub fn main() {} - diff --git a/src/test/run-pass/issue-3860.rs b/src/test/run-pass/issue-3860.rs index 46aa7187c9a..778b2b72b13 100644 --- a/src/test/run-pass/issue-3860.rs +++ b/src/test/run-pass/issue-3860.rs @@ -19,6 +19,6 @@ pub impl Foo { pub fn main() { let mut x = @mut Foo { x: 3 }; // Neither of the next two lines should cause an error - let _ = x.stuff(); + let _ = x.stuff(); x.stuff(); } diff --git a/src/test/run-pass/issue-3895.rs b/src/test/run-pass/issue-3895.rs index d3820c1e547..388e09ddb3e 100644 --- a/src/test/run-pass/issue-3895.rs +++ b/src/test/run-pass/issue-3895.rs @@ -11,7 +11,7 @@ // xfail-test pub fn main() { enum State { BadChar, BadSyntax } - + match BadChar { _ if true => BadChar, BadChar | BadSyntax => fail!() , diff --git a/src/test/run-pass/issue-3979-2.rs b/src/test/run-pass/issue-3979-2.rs index c485590f4aa..a04e3510802 100644 --- a/src/test/run-pass/issue-3979-2.rs +++ b/src/test/run-pass/issue-3979-2.rs @@ -24,4 +24,3 @@ trait C: B { } pub fn main() {} - diff --git a/src/test/run-pass/issue-4241.rs b/src/test/run-pass/issue-4241.rs index 18bc471afab..e5905e7a5be 100644 --- a/src/test/run-pass/issue-4241.rs +++ b/src/test/run-pass/issue-4241.rs @@ -55,7 +55,7 @@ priv fn parse_list(len: uint, io: @io::Reader) -> Result { priv fn chop(s: ~str) -> ~str { s.slice(0, s.len() - 1).to_owned() } - + priv fn parse_bulk(io: @io::Reader) -> Result { match int::from_str(chop(io.read_line())) { None => fail!(), diff --git a/src/test/run-pass/issue-4875.rs b/src/test/run-pass/issue-4875.rs index 51c23e76808..81947791881 100644 --- a/src/test/run-pass/issue-4875.rs +++ b/src/test/run-pass/issue-4875.rs @@ -19,4 +19,3 @@ fn foo(Foo{_}: Foo) { pub fn main() { } - diff --git a/src/test/run-pass/issue-868.rs b/src/test/run-pass/issue-868.rs index 16e8fa18c2a..2a82f559d54 100644 --- a/src/test/run-pass/issue-868.rs +++ b/src/test/run-pass/issue-868.rs @@ -22,4 +22,3 @@ pub fn main() { let _ = f(||{}); let _ = (||{}); } - diff --git a/src/test/run-pass/issue_3136_b.rs b/src/test/run-pass/issue_3136_b.rs index c5b6b6b220c..b1d28a1eb67 100644 --- a/src/test/run-pass/issue_3136_b.rs +++ b/src/test/run-pass/issue_3136_b.rs @@ -13,4 +13,3 @@ extern mod issue_3136_a; pub fn main() {} - diff --git a/src/test/run-pass/ivec-add.rs b/src/test/run-pass/ivec-add.rs index 1b9e818421e..bd58ae65651 100644 --- a/src/test/run-pass/ivec-add.rs +++ b/src/test/run-pass/ivec-add.rs @@ -21,4 +21,3 @@ pub fn main() { assert!((d[0] == 1)); assert!((d[1] == 1)); } - diff --git a/src/test/run-pass/ivec-pass-by-value.rs b/src/test/run-pass/ivec-pass-by-value.rs index 756f38196fd..3a3b5746b9d 100644 --- a/src/test/run-pass/ivec-pass-by-value.rs +++ b/src/test/run-pass/ivec-pass-by-value.rs @@ -10,4 +10,3 @@ fn f(a: ~[int]) { } pub fn main() { f(~[1, 2, 3, 4, 5]); } - diff --git a/src/test/run-pass/labeled-break.rs b/src/test/run-pass/labeled-break.rs index 06ca401a136..32cd7f0c7f8 100644 --- a/src/test/run-pass/labeled-break.rs +++ b/src/test/run-pass/labeled-break.rs @@ -18,4 +18,3 @@ pub fn main() { } } } - diff --git a/src/test/run-pass/let-assignability.rs b/src/test/run-pass/let-assignability.rs index 51fa84613ca..0afc3ee87e0 100644 --- a/src/test/run-pass/let-assignability.rs +++ b/src/test/run-pass/let-assignability.rs @@ -17,4 +17,3 @@ fn f() { pub fn main() { f(); } - diff --git a/src/test/run-pass/liveness-assign-imm-local-after-loop.rs b/src/test/run-pass/liveness-assign-imm-local-after-loop.rs index f352a2b5273..5d59c4c1471 100644 --- a/src/test/run-pass/liveness-assign-imm-local-after-loop.rs +++ b/src/test/run-pass/liveness-assign-imm-local-after-loop.rs @@ -16,5 +16,5 @@ fn test(cond: bool) { } pub fn main() { - // note: don't call test()... :) + // note: don't call test()... :) } diff --git a/src/test/run-pass/log-linearized.rs b/src/test/run-pass/log-linearized.rs index 919c53e0330..0f388489000 100644 --- a/src/test/run-pass/log-linearized.rs +++ b/src/test/run-pass/log-linearized.rs @@ -32,4 +32,3 @@ fn f() { pub fn main() { f::(); } - diff --git a/src/test/run-pass/max-min-classes.rs b/src/test/run-pass/max-min-classes.rs index 58dcb24edf9..d986d7e676a 100644 --- a/src/test/run-pass/max-min-classes.rs +++ b/src/test/run-pass/max-min-classes.rs @@ -37,4 +37,3 @@ pub fn main() { let foo = Foo(3, 20); io::println(fmt!("%d %d", foo.sum(), foo.product())); } - diff --git a/src/test/run-pass/module-qualified-struct-destructure.rs b/src/test/run-pass/module-qualified-struct-destructure.rs index 6fb6d21f13f..87c854d32be 100644 --- a/src/test/run-pass/module-qualified-struct-destructure.rs +++ b/src/test/run-pass/module-qualified-struct-destructure.rs @@ -19,4 +19,3 @@ pub fn main() { let x = m::S { x: 1, y: 2 }; let m::S { x: a, y: b } = x; } - diff --git a/src/test/run-pass/move-self.rs b/src/test/run-pass/move-self.rs index d8464695728..4ed1faf65b6 100644 --- a/src/test/run-pass/move-self.rs +++ b/src/test/run-pass/move-self.rs @@ -16,4 +16,3 @@ pub fn main() { let x = S { x: ~"Hello!" }; x.foo(); } - diff --git a/src/test/run-pass/moves-based-on-type-capture-clause.rs b/src/test/run-pass/moves-based-on-type-capture-clause.rs index 2f427ca48aa..26d4773d961 100644 --- a/src/test/run-pass/moves-based-on-type-capture-clause.rs +++ b/src/test/run-pass/moves-based-on-type-capture-clause.rs @@ -4,4 +4,3 @@ pub fn main() { io::println(x); } } - diff --git a/src/test/run-pass/multiple-trait-bounds.rs b/src/test/run-pass/multiple-trait-bounds.rs index 3c6559b9c0d..cdfa93d3094 100644 --- a/src/test/run-pass/multiple-trait-bounds.rs +++ b/src/test/run-pass/multiple-trait-bounds.rs @@ -4,4 +4,3 @@ fn f(_: T) { pub fn main() { f(3); } - diff --git a/src/test/run-pass/mut-vstore-expr.rs b/src/test/run-pass/mut-vstore-expr.rs index 0ababc43c3f..fa6dde5b3ef 100644 --- a/src/test/run-pass/mut-vstore-expr.rs +++ b/src/test/run-pass/mut-vstore-expr.rs @@ -11,4 +11,3 @@ pub fn main() { let x: &mut [int] = &mut [ 1, 2, 3 ]; } - diff --git a/src/test/run-pass/nested-class.rs b/src/test/run-pass/nested-class.rs index 44348223b60..83820f87d50 100644 --- a/src/test/run-pass/nested-class.rs +++ b/src/test/run-pass/nested-class.rs @@ -9,14 +9,13 @@ // except according to those terms. pub fn main() { - - struct b { - i: int, - } + struct b { + i: int, + } - pub impl b { - fn do_stuff(&self) -> int { return 37; } - } + pub impl b { + fn do_stuff(&self) -> int { return 37; } + } fn b(i:int) -> b { b { @@ -24,10 +23,9 @@ pub fn main() { } } - // fn b(x:int) -> int { fail!(); } + // fn b(x:int) -> int { fail!(); } - let z = b(42); - assert!((z.i == 42)); - assert!((z.do_stuff() == 37)); - + let z = b(42); + assert!((z.i == 42)); + assert!((z.do_stuff() == 37)); } diff --git a/src/test/run-pass/new-impl-syntax.rs b/src/test/run-pass/new-impl-syntax.rs index 12b41fc9148..2603353f0cf 100644 --- a/src/test/run-pass/new-impl-syntax.rs +++ b/src/test/run-pass/new-impl-syntax.rs @@ -23,4 +23,3 @@ pub fn main() { io::println(Thingy { x: 1, y: 2 }.to_str()); io::println(PolymorphicThingy { x: Thingy { x: 1, y: 2 } }.to_str()); } - diff --git a/src/test/run-pass/new-import-syntax.rs b/src/test/run-pass/new-import-syntax.rs index 267f365c713..1390ae5f7eb 100644 --- a/src/test/run-pass/new-import-syntax.rs +++ b/src/test/run-pass/new-import-syntax.rs @@ -13,4 +13,3 @@ use core::io::println; pub fn main() { println("Hello world!"); } - diff --git a/src/test/run-pass/new-style-constants.rs b/src/test/run-pass/new-style-constants.rs index 9a319ea6a5c..6fe4a88d071 100644 --- a/src/test/run-pass/new-style-constants.rs +++ b/src/test/run-pass/new-style-constants.rs @@ -15,4 +15,3 @@ static FOO: int = 3; pub fn main() { println(fmt!("%d", FOO)); } - diff --git a/src/test/run-pass/new-style-fixed-length-vec.rs b/src/test/run-pass/new-style-fixed-length-vec.rs index 5d37a42af42..6eea23f6b2b 100644 --- a/src/test/run-pass/new-style-fixed-length-vec.rs +++ b/src/test/run-pass/new-style-fixed-length-vec.rs @@ -15,6 +15,3 @@ static FOO: [int, ..3] = [1, 2, 3]; pub fn main() { println(fmt!("%d %d %d", FOO[0], FOO[1], FOO[2])); } - - - diff --git a/src/test/run-pass/new-vstore-mut-box-syntax.rs b/src/test/run-pass/new-vstore-mut-box-syntax.rs index 971e870d1f8..63569c71982 100644 --- a/src/test/run-pass/new-vstore-mut-box-syntax.rs +++ b/src/test/run-pass/new-vstore-mut-box-syntax.rs @@ -12,4 +12,3 @@ pub fn main() { let x: @mut [int] = @mut [ 1, 2, 3 ]; } - diff --git a/src/test/run-pass/newtype-struct-with-dtor.rs b/src/test/run-pass/newtype-struct-with-dtor.rs index b33bfa0388a..eb3b74553b7 100644 --- a/src/test/run-pass/newtype-struct-with-dtor.rs +++ b/src/test/run-pass/newtype-struct-with-dtor.rs @@ -13,5 +13,3 @@ impl Drop for Fd { pub fn main() { } - - diff --git a/src/test/run-pass/newtype-struct-xc-2.rs b/src/test/run-pass/newtype-struct-xc-2.rs index 1fca01f7373..cedf1d42c3d 100644 --- a/src/test/run-pass/newtype-struct-xc-2.rs +++ b/src/test/run-pass/newtype-struct-xc-2.rs @@ -11,4 +11,3 @@ fn f() -> Au { pub fn main() { let _ = f(); } - diff --git a/src/test/run-pass/newtype-struct-xc.rs b/src/test/run-pass/newtype-struct-xc.rs index 49ce618e37b..2280b335f3f 100644 --- a/src/test/run-pass/newtype-struct-xc.rs +++ b/src/test/run-pass/newtype-struct-xc.rs @@ -6,4 +6,3 @@ extern mod newtype_struct_xc; pub fn main() { let _ = newtype_struct_xc::Au(2); } - diff --git a/src/test/run-pass/nullable-pointer-iotareduction.rs b/src/test/run-pass/nullable-pointer-iotareduction.rs index 0c4d297403c..206381bcef7 100644 --- a/src/test/run-pass/nullable-pointer-iotareduction.rs +++ b/src/test/run-pass/nullable-pointer-iotareduction.rs @@ -20,7 +20,7 @@ use core::{option, cast}; enum E { Thing(int, T), Nothing((), ((), ()), [i8, ..0]) } impl E { - fn is_none(&self) -> bool { + fn is_none(&self) -> bool { match *self { Thing(*) => false, Nothing(*) => true diff --git a/src/test/run-pass/one-tuple.rs b/src/test/run-pass/one-tuple.rs index 2efa0b98b6a..eb32e7cda1a 100644 --- a/src/test/run-pass/one-tuple.rs +++ b/src/test/run-pass/one-tuple.rs @@ -21,4 +21,3 @@ pub fn main() { let (y,) = x; assert!(y == 'd'); } - diff --git a/src/test/run-pass/pattern-in-closure.rs b/src/test/run-pass/pattern-in-closure.rs index 7194fca519b..08c749235c2 100644 --- a/src/test/run-pass/pattern-in-closure.rs +++ b/src/test/run-pass/pattern-in-closure.rs @@ -19,4 +19,3 @@ pub fn main() { f((2, 3)); g(Foo { x: 1, y: 2 }); } - diff --git a/src/test/run-pass/pipe-detect-term.rs b/src/test/run-pass/pipe-detect-term.rs index bd0ffa64590..55e43075204 100644 --- a/src/test/run-pass/pipe-detect-term.rs +++ b/src/test/run-pass/pipe-detect-term.rs @@ -29,7 +29,7 @@ proto! oneshot ( pub fn main() { let iotask = &uv::global_loop::get(); - + let (chan, port) = oneshot::init(); let port = Cell(port); do spawn { @@ -48,7 +48,7 @@ pub fn main() { fn failtest() { let (c, p) = oneshot::init(); - do task::spawn_with(c) |_c| { + do task::spawn_with(c) |_c| { fail!(); } diff --git a/src/test/run-pass/pipe-pingpong-bounded.rs b/src/test/run-pass/pipe-pingpong-bounded.rs index 6d82663d195..69d87804b42 100644 --- a/src/test/run-pass/pipe-pingpong-bounded.rs +++ b/src/test/run-pass/pipe-pingpong-bounded.rs @@ -99,7 +99,7 @@ mod test { let pong(_chan) = recv(chan); error!("Received pong"); } - + pub fn server(+chan: ::pingpong::server::ping) { use pingpong::server; diff --git a/src/test/run-pass/pipe-pingpong-proto.rs b/src/test/run-pass/pipe-pingpong-proto.rs index 65a5672941f..d1198f3611d 100644 --- a/src/test/run-pass/pipe-pingpong-proto.rs +++ b/src/test/run-pass/pipe-pingpong-proto.rs @@ -37,7 +37,7 @@ mod test { let pong(_chan) = recv(chan); error!(~"Received pong"); } - + pub fn server(+chan: ::pingpong::server::ping) { use pingpong::server; diff --git a/src/test/run-pass/pipe-select.rs b/src/test/run-pass/pipe-select.rs index 12d60c9d6ab..8782f6f6ebd 100644 --- a/src/test/run-pass/pipe-select.rs +++ b/src/test/run-pass/pipe-select.rs @@ -55,8 +55,8 @@ pub fn main() { use stream::client::*; let iotask = &uv::global_loop::get(); - - let c = spawn_service(stream::init, |p| { + + let c = spawn_service(stream::init, |p| { error!("waiting for pipes"); let stream::send(x, p) = recv(p); error!("got pipes"); @@ -86,7 +86,7 @@ pub fn main() { let (_c2, p2) = oneshot::init(); let c = send(c, (p1, p2)); - + sleep(iotask, 100); signal(c1); diff --git a/src/test/run-pass/pipe-sleep.rs b/src/test/run-pass/pipe-sleep.rs index 86ffc96e89a..da49a4303a6 100644 --- a/src/test/run-pass/pipe-sleep.rs +++ b/src/test/run-pass/pipe-sleep.rs @@ -55,6 +55,6 @@ pub fn main() { let iotask = &uv::global_loop::get(); sleep(iotask, 500); - + signal(c); } diff --git a/src/test/run-pass/pub-use-xcrate.rs b/src/test/run-pass/pub-use-xcrate.rs index 03004e5e475..74ae81e63e2 100644 --- a/src/test/run-pass/pub-use-xcrate.rs +++ b/src/test/run-pass/pub-use-xcrate.rs @@ -21,4 +21,3 @@ pub fn main() { name: 0 }; } - diff --git a/src/test/run-pass/pub_use_mods_xcrate_exe.rs b/src/test/run-pass/pub_use_mods_xcrate_exe.rs index 1d60cab3a82..953a99e1fd5 100644 --- a/src/test/run-pass/pub_use_mods_xcrate_exe.rs +++ b/src/test/run-pass/pub_use_mods_xcrate_exe.rs @@ -15,4 +15,3 @@ extern mod pub_use_mods_xcrate; use pub_use_mods_xcrate::a::c; pub fn main(){} - diff --git a/src/test/run-pass/reexport-star.rs b/src/test/run-pass/reexport-star.rs index 3b9fe688d4d..3cc250b1707 100644 --- a/src/test/run-pass/reexport-star.rs +++ b/src/test/run-pass/reexport-star.rs @@ -25,4 +25,3 @@ pub fn main() { b::f(); b::g(); } - diff --git a/src/test/run-pass/regions-addr-of-interior-of-unique-box.rs b/src/test/run-pass/regions-addr-of-interior-of-unique-box.rs index 1fb9c126e74..7efe62236f3 100644 --- a/src/test/run-pass/regions-addr-of-interior-of-unique-box.rs +++ b/src/test/run-pass/regions-addr-of-interior-of-unique-box.rs @@ -26,4 +26,3 @@ fn get_x<'r>(x: &'r Character) -> &'r int { pub fn main() { } - diff --git a/src/test/run-pass/regions-addr-of-ret.rs b/src/test/run-pass/regions-addr-of-ret.rs index a9c65d01295..9e19618f332 100644 --- a/src/test/run-pass/regions-addr-of-ret.rs +++ b/src/test/run-pass/regions-addr-of-ret.rs @@ -16,4 +16,3 @@ pub fn main() { let three = &3; error!(fmt!("%d", *f(three))); } - diff --git a/src/test/run-pass/regions-fn-subtyping-2.rs b/src/test/run-pass/regions-fn-subtyping-2.rs index a660b9c9ee2..ef8d9970c2b 100644 --- a/src/test/run-pass/regions-fn-subtyping-2.rs +++ b/src/test/run-pass/regions-fn-subtyping-2.rs @@ -19,10 +19,8 @@ fn has_same_region(f: &fn<'a>(x: &'a int, g: &fn(y: &'a int))) { wants_same_region(f); } -fn wants_same_region(_f: &fn<'b>(x: &'b int, g: &fn(y: &'b int))) { +fn wants_same_region(_f: &fn<'b>(x: &'b int, g: &fn(y: &'b int))) { } pub fn main() { } - - diff --git a/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs b/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs index ee2682ff4ab..39da08de6df 100644 --- a/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs +++ b/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs @@ -13,15 +13,15 @@ pub fn main() { for uint::range(0, 3) |i| { // ensure that the borrow in this alt - // does not inferfere with the swap - // below. note that it would it you - // naively borrowed &x for the lifetime - // of the variable x, as we once did + // does not inferfere with the swap + // below. note that it would it you + // naively borrowed &x for the lifetime + // of the variable x, as we once did match i { - i => { - let y = &x; - assert!(i < *y); - } + i => { + let y = &x; + assert!(i < *y); + } } let mut y = 4; y <-> x; diff --git a/src/test/run-pass/regions-infer-borrow-scope-view.rs b/src/test/run-pass/regions-infer-borrow-scope-view.rs index 9358ea8a777..8f7452f2d06 100644 --- a/src/test/run-pass/regions-infer-borrow-scope-view.rs +++ b/src/test/run-pass/regions-infer-borrow-scope-view.rs @@ -16,4 +16,3 @@ pub fn main() { let y = view(x); assert!((v[0] == x[0]) && (v[0] == y[0])); } - diff --git a/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs b/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs index 08c54c790b1..73535f52043 100644 --- a/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs +++ b/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs @@ -15,6 +15,6 @@ pub fn main() { loop { let y = borrow(x); assert!(*x == *y); - break; + break; } } diff --git a/src/test/run-pass/regions-infer-borrow-scope.rs b/src/test/run-pass/regions-infer-borrow-scope.rs index e06a2fea1c1..61b9000aea3 100644 --- a/src/test/run-pass/regions-infer-borrow-scope.rs +++ b/src/test/run-pass/regions-infer-borrow-scope.rs @@ -19,4 +19,3 @@ pub fn main() { let xc = x_coord(p); assert!(*xc == 3); } - diff --git a/src/test/run-pass/regions-mock-trans-impls.rs b/src/test/run-pass/regions-mock-trans-impls.rs index e9163505748..d54aae7bb63 100644 --- a/src/test/run-pass/regions-mock-trans-impls.rs +++ b/src/test/run-pass/regions-mock-trans-impls.rs @@ -52,4 +52,3 @@ pub fn main() { let mut ccx = Ccx { x: 0 }; f(&mut ccx); } - diff --git a/src/test/run-pass/regions-mock-trans.rs b/src/test/run-pass/regions-mock-trans.rs index c46e41ab0eb..0ea6f852a89 100644 --- a/src/test/run-pass/regions-mock-trans.rs +++ b/src/test/run-pass/regions-mock-trans.rs @@ -52,4 +52,3 @@ pub fn main() { let ccx = Ccx { x: 0 }; f(&ccx); } - diff --git a/src/test/run-pass/regions-self-impls.rs b/src/test/run-pass/regions-self-impls.rs index 2f4eefe5243..c43fd0db566 100644 --- a/src/test/run-pass/regions-self-impls.rs +++ b/src/test/run-pass/regions-self-impls.rs @@ -25,4 +25,3 @@ pub fn main() { debug!(*clam.get_chowder()); clam.get_chowder(); } - diff --git a/src/test/run-pass/regions-self-in-enums.rs b/src/test/run-pass/regions-self-in-enums.rs index 78045e5e5d4..5f8b9ee3332 100644 --- a/src/test/run-pass/regions-self-in-enums.rs +++ b/src/test/run-pass/regions-self-in-enums.rs @@ -21,4 +21,3 @@ pub fn main() { } debug!(*z); } - diff --git a/src/test/run-pass/regions-simple.rs b/src/test/run-pass/regions-simple.rs index f7a50e6b114..436fede4dc1 100644 --- a/src/test/run-pass/regions-simple.rs +++ b/src/test/run-pass/regions-simple.rs @@ -14,5 +14,3 @@ pub fn main() { *y = 5; debug!(*y); } - - diff --git a/src/test/run-pass/repeated-vector-syntax.rs b/src/test/run-pass/repeated-vector-syntax.rs index a22384a6b53..f3d6c1640d8 100644 --- a/src/test/run-pass/repeated-vector-syntax.rs +++ b/src/test/run-pass/repeated-vector-syntax.rs @@ -21,4 +21,3 @@ pub fn main() { error!("%?", x); error!("%?", y); } - diff --git a/src/test/run-pass/resource-cycle.rs b/src/test/run-pass/resource-cycle.rs index fdb8c2a496c..f498553834a 100644 --- a/src/test/run-pass/resource-cycle.rs +++ b/src/test/run-pass/resource-cycle.rs @@ -57,7 +57,7 @@ pub fn main() { debug!("r = %x", cast::transmute::<*r, uint>(&rs)); rs } }); - + debug!("x1 = %x, x1.r = %x", cast::transmute::<@mut t, uint>(x1), cast::transmute::<*r, uint>(&x1.r)); @@ -70,7 +70,7 @@ pub fn main() { rs } }); - + debug!("x2 = %x, x2.r = %x", cast::transmute::<@mut t, uint>(x2), cast::transmute::<*r, uint>(&(x2.r))); diff --git a/src/test/run-pass/resource-cycle3.rs b/src/test/run-pass/resource-cycle3.rs index 0d699a6e49b..ef713724778 100644 --- a/src/test/run-pass/resource-cycle3.rs +++ b/src/test/run-pass/resource-cycle3.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// same as resource-cycle2, but be sure to give r multiple fields... +// same as resource-cycle2, but be sure to give r multiple fields... // Don't leak the unique pointers @@ -50,7 +50,7 @@ struct Node { r: R } -pub fn main() { +pub fn main() { unsafe { let i1 = ~0xA; let i1p = cast::transmute_copy(&i1); diff --git a/src/test/run-pass/self-type-param.rs b/src/test/run-pass/self-type-param.rs index 0af19796804..d90ec51bedf 100644 --- a/src/test/run-pass/self-type-param.rs +++ b/src/test/run-pass/self-type-param.rs @@ -13,4 +13,3 @@ impl MyTrait for S { } pub fn main() {} - diff --git a/src/test/run-pass/static-methods-in-traits.rs b/src/test/run-pass/static-methods-in-traits.rs index d171434aa48..42d0f02d642 100644 --- a/src/test/run-pass/static-methods-in-traits.rs +++ b/src/test/run-pass/static-methods-in-traits.rs @@ -9,27 +9,26 @@ // except according to those terms. mod a { - pub trait Foo { - pub fn foo() -> Self; - } + pub trait Foo { + pub fn foo() -> Self; + } - impl Foo for int { - pub fn foo() -> int { - 3 - } - } - - impl Foo for uint { - pub fn foo() -> uint { - 5u - } - } + impl Foo for int { + pub fn foo() -> int { + 3 + } + } + + impl Foo for uint { + pub fn foo() -> uint { + 5u + } + } } pub fn main() { - let x: int = a::Foo::foo(); - let y: uint = a::Foo::foo(); - assert!(x == 3); - assert!(y == 5); + let x: int = a::Foo::foo(); + let y: uint = a::Foo::foo(); + assert!(x == 3); + assert!(y == 5); } - diff --git a/src/test/run-pass/struct-deref.rs b/src/test/run-pass/struct-deref.rs index f71bc06a1cf..a52a2851689 100644 --- a/src/test/run-pass/struct-deref.rs +++ b/src/test/run-pass/struct-deref.rs @@ -14,4 +14,3 @@ pub fn main() { let x: Foo = Foo(2); assert!(*x == 2); } - diff --git a/src/test/run-pass/struct-field-assignability.rs b/src/test/run-pass/struct-field-assignability.rs index 1e13c7b86bf..0aca1a3d05f 100644 --- a/src/test/run-pass/struct-field-assignability.rs +++ b/src/test/run-pass/struct-field-assignability.rs @@ -6,4 +6,3 @@ pub fn main() { let f = Foo { x: @3 }; assert!(*f.x == 3); } - diff --git a/src/test/run-pass/struct-like-variant-construct.rs b/src/test/run-pass/struct-like-variant-construct.rs index 0d14d90c1f1..bc2dce680c9 100644 --- a/src/test/run-pass/struct-like-variant-construct.rs +++ b/src/test/run-pass/struct-like-variant-construct.rs @@ -22,4 +22,3 @@ enum Foo { pub fn main() { let x = Bar { a: 2, b: 3 }; } - diff --git a/src/test/run-pass/struct-like-variant-match.rs b/src/test/run-pass/struct-like-variant-match.rs index 3158d2836dd..64a75ddab22 100644 --- a/src/test/run-pass/struct-like-variant-match.rs +++ b/src/test/run-pass/struct-like-variant-match.rs @@ -38,4 +38,3 @@ pub fn main() { let y = Baz { x: 1.0, y: 2.0 }; f(&y); } - diff --git a/src/test/run-pass/struct-pattern-matching.rs b/src/test/run-pass/struct-pattern-matching.rs index 1d7bcb2585f..1bda2d2412d 100644 --- a/src/test/run-pass/struct-pattern-matching.rs +++ b/src/test/run-pass/struct-pattern-matching.rs @@ -19,6 +19,3 @@ pub fn main() { Foo { x: x, y: y } => io::println(fmt!("yes, %d, %d", x, y)) } } - - - diff --git a/src/test/run-pass/super.rs b/src/test/run-pass/super.rs index 2fe0696b2f2..b5eb6e85045 100644 --- a/src/test/run-pass/super.rs +++ b/src/test/run-pass/super.rs @@ -9,4 +9,3 @@ pub mod a { pub fn main() { } - diff --git a/src/test/run-pass/tag-disr-val-shape.rs b/src/test/run-pass/tag-disr-val-shape.rs index 50ab17fdeea..dd78dff0d6e 100644 --- a/src/test/run-pass/tag-disr-val-shape.rs +++ b/src/test/run-pass/tag-disr-val-shape.rs @@ -23,4 +23,3 @@ pub fn main() { assert!(~"green" == fmt!("%?", green)); assert!(~"white" == fmt!("%?", white)); } - diff --git a/src/test/run-pass/tag-variant-disr-val.rs b/src/test/run-pass/tag-variant-disr-val.rs index 0806f1ea92a..d4eadd366de 100644 --- a/src/test/run-pass/tag-variant-disr-val.rs +++ b/src/test/run-pass/tag-variant-disr-val.rs @@ -69,5 +69,3 @@ fn get_color_if(color: color) -> ~str { else if color == orange {~"orange"} else {~"unknown"} } - - diff --git a/src/test/run-pass/threads.rs b/src/test/run-pass/threads.rs index f736ded3db2..288a23b855b 100644 --- a/src/test/run-pass/threads.rs +++ b/src/test/run-pass/threads.rs @@ -19,4 +19,3 @@ pub fn main() { } fn child(&&x: int) { debug!(x); } - diff --git a/src/test/run-pass/trait-composition-trivial.rs b/src/test/run-pass/trait-composition-trivial.rs index 328c0b6888c..de130bf1b41 100644 --- a/src/test/run-pass/trait-composition-trivial.rs +++ b/src/test/run-pass/trait-composition-trivial.rs @@ -17,5 +17,3 @@ trait Bar : Foo { } pub fn main() {} - - diff --git a/src/test/run-pass/trait-inheritance-auto-xc-2.rs b/src/test/run-pass/trait-inheritance-auto-xc-2.rs index 446dd4b3d8e..996f55d4019 100644 --- a/src/test/run-pass/trait-inheritance-auto-xc-2.rs +++ b/src/test/run-pass/trait-inheritance-auto-xc-2.rs @@ -30,4 +30,3 @@ pub fn main() { let a = &A { x: 3 }; f(a); } - diff --git a/src/test/run-pass/trait-inheritance-auto-xc.rs b/src/test/run-pass/trait-inheritance-auto-xc.rs index 03287809a9b..3af8d606bf4 100644 --- a/src/test/run-pass/trait-inheritance-auto-xc.rs +++ b/src/test/run-pass/trait-inheritance-auto-xc.rs @@ -31,4 +31,3 @@ pub fn main() { let a = &A { x: 3 }; f(a); } - diff --git a/src/test/run-pass/trait-inheritance-auto.rs b/src/test/run-pass/trait-inheritance-auto.rs index b74064591d3..fb97dd5e774 100644 --- a/src/test/run-pass/trait-inheritance-auto.rs +++ b/src/test/run-pass/trait-inheritance-auto.rs @@ -34,4 +34,3 @@ pub fn main() { let a = &A { x: 3 }; f(a); } - diff --git a/src/test/run-pass/trait-inheritance-call-bound-inherited.rs b/src/test/run-pass/trait-inheritance-call-bound-inherited.rs index 26b96f93326..805c9655d81 100644 --- a/src/test/run-pass/trait-inheritance-call-bound-inherited.rs +++ b/src/test/run-pass/trait-inheritance-call-bound-inherited.rs @@ -25,4 +25,3 @@ pub fn main() { let a = &A { x: 3 }; assert!(gg(a) == 10); } - diff --git a/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs b/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs index 5e612bbca64..0b35fd90bbd 100644 --- a/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs +++ b/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs @@ -28,4 +28,3 @@ pub fn main() { let a = &A { x: 3 }; assert!(gg(a) == 10); } - diff --git a/src/test/run-pass/trait-inheritance-cast-without-call-to-supertrait.rs b/src/test/run-pass/trait-inheritance-cast-without-call-to-supertrait.rs index 6efd854e01b..df9cc4fb8b6 100644 --- a/src/test/run-pass/trait-inheritance-cast-without-call-to-supertrait.rs +++ b/src/test/run-pass/trait-inheritance-cast-without-call-to-supertrait.rs @@ -38,4 +38,3 @@ pub fn main() { assert!(afoo.f() == 10); assert!(abar.g() == 20); } - diff --git a/src/test/run-pass/trait-inheritance-cast.rs b/src/test/run-pass/trait-inheritance-cast.rs index 02382797797..75c121e10b0 100644 --- a/src/test/run-pass/trait-inheritance-cast.rs +++ b/src/test/run-pass/trait-inheritance-cast.rs @@ -40,4 +40,3 @@ pub fn main() { assert!(abar.g() == 20); assert!(abar.f() == 10); } - diff --git a/src/test/run-pass/trait-inheritance-cross-trait-call-xc.rs b/src/test/run-pass/trait-inheritance-cross-trait-call-xc.rs index 3c1bf2035aa..976c9a02439 100644 --- a/src/test/run-pass/trait-inheritance-cross-trait-call-xc.rs +++ b/src/test/run-pass/trait-inheritance-cross-trait-call-xc.rs @@ -27,4 +27,3 @@ pub fn main() { let a = &aux::A { x: 3 }; assert!(a.g() == 10); } - diff --git a/src/test/run-pass/trait-inheritance-cross-trait-call.rs b/src/test/run-pass/trait-inheritance-cross-trait-call.rs index 997f13d0e5e..20dac16b492 100644 --- a/src/test/run-pass/trait-inheritance-cross-trait-call.rs +++ b/src/test/run-pass/trait-inheritance-cross-trait-call.rs @@ -24,4 +24,3 @@ pub fn main() { let a = &A { x: 3 }; assert!(a.g() == 10); } - diff --git a/src/test/run-pass/trait-inheritance-overloading-simple.rs b/src/test/run-pass/trait-inheritance-overloading-simple.rs index 711571e8c64..3a1c3716df4 100644 --- a/src/test/run-pass/trait-inheritance-overloading-simple.rs +++ b/src/test/run-pass/trait-inheritance-overloading-simple.rs @@ -32,4 +32,3 @@ pub fn main() { assert!(x != y); assert!(x == z); } - diff --git a/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs b/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs index 9f745db7638..d89852e2b05 100644 --- a/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs +++ b/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs @@ -27,4 +27,3 @@ pub fn main() { assert!(b == mi(-2)); assert!(c == mi(15)); } - diff --git a/src/test/run-pass/trait-inheritance-overloading.rs b/src/test/run-pass/trait-inheritance-overloading.rs index 5b68aff269e..e58ec24f1b7 100644 --- a/src/test/run-pass/trait-inheritance-overloading.rs +++ b/src/test/run-pass/trait-inheritance-overloading.rs @@ -46,4 +46,3 @@ pub fn main() { assert!(b == mi(-2)); assert!(c == mi(15)); } - diff --git a/src/test/run-pass/trait-inheritance-self.rs b/src/test/run-pass/trait-inheritance-self.rs index 02ed518ff65..5eb87b7a96b 100644 --- a/src/test/run-pass/trait-inheritance-self.rs +++ b/src/test/run-pass/trait-inheritance-self.rs @@ -26,4 +26,3 @@ pub fn main() { let s = S { x: 1 }; s.g(); } - diff --git a/src/test/run-pass/trait-inheritance-simple.rs b/src/test/run-pass/trait-inheritance-simple.rs index 779dfb65944..2da1f02779e 100644 --- a/src/test/run-pass/trait-inheritance-simple.rs +++ b/src/test/run-pass/trait-inheritance-simple.rs @@ -29,4 +29,3 @@ pub fn main() { assert!(ff(a) == 10); assert!(gg(a) == 20); } - diff --git a/src/test/run-pass/trait-inheritance-subst.rs b/src/test/run-pass/trait-inheritance-subst.rs index 22efdabec83..479f293a396 100644 --- a/src/test/run-pass/trait-inheritance-subst.rs +++ b/src/test/run-pass/trait-inheritance-subst.rs @@ -33,4 +33,3 @@ pub fn main() { let z = f(x, y); assert!(z.val == 8) } - diff --git a/src/test/run-pass/trait-inheritance-subst2.rs b/src/test/run-pass/trait-inheritance-subst2.rs index 4f3b808f8eb..5d1741a45f3 100644 --- a/src/test/run-pass/trait-inheritance-subst2.rs +++ b/src/test/run-pass/trait-inheritance-subst2.rs @@ -43,4 +43,3 @@ pub fn main() { let z = f(x, y); assert!(z.val == 13); } - diff --git a/src/test/run-pass/trait-inheritance2.rs b/src/test/run-pass/trait-inheritance2.rs index 5d6913d4146..adb7ab018d6 100644 --- a/src/test/run-pass/trait-inheritance2.rs +++ b/src/test/run-pass/trait-inheritance2.rs @@ -31,4 +31,3 @@ pub fn main() { let a = &A { x: 3 }; f(a); } - diff --git a/src/test/run-pass/trait-region-pointer-simple.rs b/src/test/run-pass/trait-region-pointer-simple.rs index 285b0e65daf..a2742828a1b 100644 --- a/src/test/run-pass/trait-region-pointer-simple.rs +++ b/src/test/run-pass/trait-region-pointer-simple.rs @@ -28,4 +28,3 @@ pub fn main() { let b = (&a) as &Foo; assert!(b.f() == 3); } - diff --git a/src/test/run-pass/trait-static-method-overwriting.rs b/src/test/run-pass/trait-static-method-overwriting.rs index a8a579422a3..86ebc5356eb 100644 --- a/src/test/run-pass/trait-static-method-overwriting.rs +++ b/src/test/run-pass/trait-static-method-overwriting.rs @@ -21,7 +21,7 @@ mod base { impl ::base::HasNew for Foo { fn new() -> Foo { - unsafe { io::println("Foo"); } + unsafe { io::println("Foo"); } Foo { dummy: () } } } @@ -32,7 +32,7 @@ mod base { impl ::base::HasNew for Bar { fn new() -> Bar { - unsafe { io::println("Bar"); } + unsafe { io::println("Bar"); } Bar { dummy: () } } } @@ -40,5 +40,5 @@ mod base { pub fn main() { let f: base::Foo = base::HasNew::new::(); - let b: base::Bar = base::HasNew::new::(); + let b: base::Bar = base::HasNew::new::(); } diff --git a/src/test/run-pass/traits.rs b/src/test/run-pass/traits.rs index c4ec15ff273..ba3e8e082b3 100644 --- a/src/test/run-pass/traits.rs +++ b/src/test/run-pass/traits.rs @@ -53,4 +53,3 @@ impl Ord for int { self == (*a) } } - diff --git a/src/test/run-pass/tuple-struct-construct.rs b/src/test/run-pass/tuple-struct-construct.rs index ea410093c4b..c5ea3e14d39 100644 --- a/src/test/run-pass/tuple-struct-construct.rs +++ b/src/test/run-pass/tuple-struct-construct.rs @@ -14,4 +14,3 @@ pub fn main() { let x = Foo(1, 2); io::println(fmt!("%?", x)); } - diff --git a/src/test/run-pass/tuple-struct-destructuring.rs b/src/test/run-pass/tuple-struct-destructuring.rs index 7e6b9570def..1cb944da040 100644 --- a/src/test/run-pass/tuple-struct-destructuring.rs +++ b/src/test/run-pass/tuple-struct-destructuring.rs @@ -17,4 +17,3 @@ pub fn main() { assert!(y == 1); assert!(z == 2); } - diff --git a/src/test/run-pass/tuple-struct-matching.rs b/src/test/run-pass/tuple-struct-matching.rs index 405616f9b1f..e3cbd1201c1 100644 --- a/src/test/run-pass/tuple-struct-matching.rs +++ b/src/test/run-pass/tuple-struct-matching.rs @@ -20,4 +20,3 @@ pub fn main() { } } } - diff --git a/src/test/run-pass/tuple-struct-trivial.rs b/src/test/run-pass/tuple-struct-trivial.rs index 8ddc04a186f..c6c32cf49c6 100644 --- a/src/test/run-pass/tuple-struct-trivial.rs +++ b/src/test/run-pass/tuple-struct-trivial.rs @@ -14,4 +14,3 @@ struct Foo(int, int, int); pub fn main() { } - diff --git a/src/test/run-pass/typeclasses-eq-example-static.rs b/src/test/run-pass/typeclasses-eq-example-static.rs index 9c5f8c3218a..c14dd0471f9 100644 --- a/src/test/run-pass/typeclasses-eq-example-static.rs +++ b/src/test/run-pass/typeclasses-eq-example-static.rs @@ -38,7 +38,7 @@ impl Equal for ColorTree { fn isEq(a: ColorTree, b: ColorTree) -> bool { match (a, b) { (leaf(x), leaf(y)) => { Equal::isEq(x, y) } - (branch(l1, r1), branch(l2, r2)) => { + (branch(l1, r1), branch(l2, r2)) => { Equal::isEq(*l1, *l2) && Equal::isEq(*r1, *r2) } _ => { false } diff --git a/src/test/run-pass/typeclasses-eq-example.rs b/src/test/run-pass/typeclasses-eq-example.rs index 51c19cef50a..18a68bc1c34 100644 --- a/src/test/run-pass/typeclasses-eq-example.rs +++ b/src/test/run-pass/typeclasses-eq-example.rs @@ -37,7 +37,7 @@ impl Equal for ColorTree { fn isEq(&self, a: ColorTree) -> bool { match (*self, a) { (leaf(x), leaf(y)) => { x.isEq(y) } - (branch(l1, r1), branch(l2, r2)) => { + (branch(l1, r1), branch(l2, r2)) => { (*l1).isEq(*l2) && (*r1).isEq(*r2) } _ => { false } diff --git a/src/test/run-pass/unique-object.rs b/src/test/run-pass/unique-object.rs index 1cf4cf09b81..5e0954969ef 100644 --- a/src/test/run-pass/unique-object.rs +++ b/src/test/run-pass/unique-object.rs @@ -27,4 +27,3 @@ pub fn main() { let y = x as ~Foo; assert!(y.f() == 10); } - diff --git a/src/test/run-pass/unit-like-struct.rs b/src/test/run-pass/unit-like-struct.rs index 837bfa50b8e..1b81015b029 100644 --- a/src/test/run-pass/unit-like-struct.rs +++ b/src/test/run-pass/unit-like-struct.rs @@ -16,4 +16,3 @@ pub fn main() { Foo => { io::println("hi"); } } } - diff --git a/src/test/run-pass/unsafe-pointer-assignability.rs b/src/test/run-pass/unsafe-pointer-assignability.rs index 05c9cd8a574..f19558fbb1d 100644 --- a/src/test/run-pass/unsafe-pointer-assignability.rs +++ b/src/test/run-pass/unsafe-pointer-assignability.rs @@ -17,6 +17,3 @@ fn f(x: *int) { pub fn main() { f(&3); } - - - diff --git a/src/test/run-pass/vec-fixed-length.rs b/src/test/run-pass/vec-fixed-length.rs index 5ce1b04dbe9..2c4add63e8b 100644 --- a/src/test/run-pass/vec-fixed-length.rs +++ b/src/test/run-pass/vec-fixed-length.rs @@ -12,4 +12,3 @@ pub fn main() { let x: [int, ..4] = [1, 2, 3, 4]; io::println(fmt!("%d", x[0])); } - -- cgit 1.4.1-3-g733a5 From 8081e8debf63726865e869aaacbd040755285a51 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sat, 4 May 2013 14:25:41 -0700 Subject: Register snapshots --- src/libcore/cast.rs | 46 -- src/libcore/container.rs | 36 - src/libcore/core.rc | 3 - src/libcore/hashmap.rs | 168 ---- src/libcore/num/f32.rs | 7 +- src/libcore/num/f64.rs | 6 +- src/libcore/num/float.rs | 7 +- src/libcore/num/int-template.rs | 7 +- src/libcore/num/num.rs | 23 +- src/libcore/num/strconv.rs | 7 - src/libcore/num/uint-template.rs | 7 +- src/libcore/ops.rs | 6 - src/libcore/option.rs | 104 --- src/libcore/prelude.rs | 3 - src/libcore/reflect.rs | 33 +- src/libcore/repr.rs | 111 +-- src/libcore/result.rs | 7 - src/libcore/rt/io/mod.rs | 3 - src/libcore/rt/mod.rs | 21 - src/libcore/rt/rtio.rs | 5 - src/libcore/rt/uvio.rs | 16 - src/libcore/stackwalk.rs | 3 - src/libcore/sys.rs | 22 - src/libcore/trie.rs | 95 --- src/libcore/tuple.rs | 28 - src/libcore/unstable/intrinsics.rs | 4 - src/libcore/unstable/lang.rs | 47 -- src/libcore/vec.rs | 226 ------ src/librustc/metadata/decoder.rs | 8 - src/librustc/metadata/encoder.rs | 1536 +++--------------------------------- src/librustc/middle/astencode.rs | 774 ------------------ src/libstd/arena.rs | 59 -- src/libstd/deque.rs | 122 --- src/libstd/ebml.rs | 539 ------------- src/libstd/flatpipes.rs | 25 - src/libstd/future.rs | 29 - src/libstd/json.rs | 631 --------------- src/libstd/priority_queue.rs | 16 - src/libstd/serialize.rs | 990 +---------------------- src/libstd/smallintmap.rs | 77 -- src/libstd/std.rc | 4 - src/libstd/workcache.rs | 45 -- src/libsyntax/ast.rs | 31 - src/libsyntax/codemap.rs | 15 - src/libsyntax/ext/base.rs | 11 - src/libsyntax/opt_vec.rs | 9 - src/snapshots.txt | 8 + 47 files changed, 138 insertions(+), 5842 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/libcore/cast.rs b/src/libcore/cast.rs index 22f31d52d2d..96e1c3bd124 100644 --- a/src/libcore/cast.rs +++ b/src/libcore/cast.rs @@ -10,9 +10,7 @@ //! Unsafe casting functions -#[cfg(not(stage0))] use sys; -#[cfg(not(stage0))] use unstable; pub mod rusti { @@ -21,35 +19,11 @@ pub mod rusti { pub extern "rust-intrinsic" { fn forget(+x: T); - #[cfg(stage0)] - fn reinterpret_cast(&&e: T) -> U; - - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn transmute(e: T) -> U; } } /// Casts the value at `src` to U. The two types must have the same length. -#[inline(always)] -#[cfg(stage0)] -pub unsafe fn reinterpret_cast(src: &T) -> U { - rusti::reinterpret_cast(*src) -} - -/// Unsafely copies and casts the value at `src` to U, even if the value is -/// noncopyable. The two types must have the same length. -#[inline(always)] -#[cfg(stage0)] -pub unsafe fn transmute_copy(src: &T) -> U { - rusti::reinterpret_cast(*src) -} - -#[inline(always)] -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] pub unsafe fn transmute_copy(src: &T) -> U { let mut dest: U = unstable::intrinsics::init(); { @@ -90,17 +64,6 @@ pub unsafe fn bump_box_refcount(t: @T) { forget(t); } * assert!(transmute("L") == ~[76u8, 0u8]); */ #[inline(always)] -#[cfg(stage0)] -pub unsafe fn transmute(thing: L) -> G { - let newthing: G = reinterpret_cast(&thing); - forget(thing); - newthing -} - -#[inline(always)] -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] pub unsafe fn transmute(thing: L) -> G { rusti::transmute(thing) } @@ -161,15 +124,6 @@ mod tests { use cast::{bump_box_refcount, transmute}; #[test] - #[cfg(stage0)] - fn test_reinterpret_cast() { - assert!(1u == unsafe { ::cast::reinterpret_cast(&1) }); - } - - #[test] - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn test_transmute_copy() { assert!(1u == unsafe { ::cast::transmute_copy(&1) }); } diff --git a/src/libcore/container.rs b/src/libcore/container.rs index 88c78aebfc5..00ea4a93221 100644 --- a/src/libcore/container.rs +++ b/src/libcore/container.rs @@ -25,42 +25,6 @@ pub trait Mutable: Container { fn clear(&mut self); } -#[cfg(stage0)] -pub trait Map: Mutable { - /// Return true if the map contains a value for the specified key - fn contains_key(&self, key: &K) -> bool; - - // Visits all keys and values - fn each(&self, f: &fn(&K, &V) -> bool); - - /// Visit all keys - fn each_key(&self, f: &fn(&K) -> bool); - - /// Visit all values - fn each_value(&self, f: &fn(&V) -> bool); - - /// Iterate over the map and mutate the contained values - fn mutate_values(&mut self, f: &fn(&K, &mut V) -> bool); - - /// Return a reference to the value corresponding to the key - fn find(&self, key: &K) -> Option<&'self V>; - - /// Return a mutable reference to the value corresponding to the key - fn find_mut(&mut self, key: &K) -> Option<&'self mut V>; - - /// Insert a key-value pair into the map. An existing value for a - /// key is replaced by the new value. Return true if the key did - /// not already exist in the map. - fn insert(&mut self, key: K, value: V) -> bool; - - /// Remove a key-value pair from the map. Return true if the key - /// was present in the map, otherwise false. - fn remove(&mut self, key: &K) -> bool; -} - -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] pub trait Map: Mutable { /// Return true if the map contains a value for the specified key fn contains_key(&self, key: &K) -> bool; diff --git a/src/libcore/core.rc b/src/libcore/core.rc index 75ef8ee0cbd..9672bf887ca 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -74,9 +74,6 @@ they contained the following prologue: pub use kinds::{Const, Copy, Owned, Durable}; pub use ops::{Drop}; -#[cfg(stage0)] -pub use ops::{Add, Sub, Mul, Div, Modulo, Neg, Not}; -#[cfg(not(stage0))] pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not}; pub use ops::{BitAnd, BitOr, BitXor}; pub use ops::{Shl, Shr, Index}; diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index 9b82a8dad05..392ad38e209 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -184,18 +184,6 @@ priv impl HashMap { } } - #[cfg(stage0)] - #[inline(always)] - fn value_for_bucket(&self, idx: uint) -> &'self V { - match self.buckets[idx] { - Some(ref bkt) => &bkt.value, - None => fail!(~"HashMap::find: internal logic error"), - } - } - - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] #[inline(always)] fn value_for_bucket<'a>(&'a self, idx: uint) -> &'a V { match self.buckets[idx] { @@ -204,18 +192,6 @@ priv impl HashMap { } } - #[cfg(stage0)] - #[inline(always)] - fn mut_value_for_bucket(&mut self, idx: uint) -> &'self mut V { - match self.buckets[idx] { - Some(ref mut bkt) => &mut bkt.value, - None => unreachable() - } - } - - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] #[inline(always)] fn mut_value_for_bucket<'a>(&'a mut self, idx: uint) -> &'a mut V { match self.buckets[idx] { @@ -329,21 +305,6 @@ impl Map for HashMap { } /// Visit all key-value pairs - #[cfg(stage0)] - fn each(&self, blk: &fn(&'self K, &'self V) -> bool) { - for uint::range(0, self.buckets.len()) |i| { - for self.buckets[i].each |bucket| { - if !blk(&bucket.key, &bucket.value) { - return; - } - } - } - } - - /// Visit all key-value pairs - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn each<'a>(&'a self, blk: &fn(&'a K, &'a V) -> bool) { for uint::range(0, self.buckets.len()) |i| { for self.buckets[i].each |bucket| { @@ -360,15 +321,6 @@ impl Map for HashMap { } /// Visit all values - #[cfg(stage0)] - fn each_value(&self, blk: &fn(v: &V) -> bool) { - self.each(|_, v| blk(v)) - } - - /// Visit all values - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn each_value<'a>(&'a self, blk: &fn(v: &'a V) -> bool) { self.each(|_, v| blk(v)) } @@ -386,18 +338,6 @@ impl Map for HashMap { } /// Return a reference to the value corresponding to the key - #[cfg(stage0)] - fn find(&self, k: &K) -> Option<&'self V> { - match self.bucket_for_key(k) { - FoundEntry(idx) => Some(self.value_for_bucket(idx)), - TableFull | FoundHole(_) => None, - } - } - - /// Return a reference to the value corresponding to the key - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn find<'a>(&'a self, k: &K) -> Option<&'a V> { match self.bucket_for_key(k) { FoundEntry(idx) => Some(self.value_for_bucket(idx)), @@ -406,21 +346,6 @@ impl Map for HashMap { } /// Return a mutable reference to the value corresponding to the key - #[cfg(stage0)] - fn find_mut(&mut self, k: &K) -> Option<&'self mut V> { - let idx = match self.bucket_for_key(k) { - FoundEntry(idx) => idx, - TableFull | FoundHole(_) => return None - }; - unsafe { // FIXME(#4903)---requires flow-sensitive borrow checker - Some(::cast::transmute_mut_region(self.mut_value_for_bucket(idx))) - } - } - - /// Return a mutable reference to the value corresponding to the key - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn find_mut<'a>(&'a mut self, k: &K) -> Option<&'a mut V> { let idx = match self.bucket_for_key(k) { FoundEntry(idx) => idx, @@ -503,40 +428,6 @@ pub impl HashMap { /// Return the value corresponding to the key in the map, or insert /// and return the value if it doesn't exist. - #[cfg(stage0)] - fn find_or_insert(&mut self, k: K, v: V) -> &'self V { - if self.size >= self.resize_at { - // n.b.: We could also do this after searching, so - // that we do not resize if this call to insert is - // simply going to update a key in place. My sense - // though is that it's worse to have to search through - // buckets to find the right spot twice than to just - // resize in this corner case. - self.expand(); - } - - let hash = k.hash_keyed(self.k0, self.k1) as uint; - let idx = match self.bucket_for_key_with_hash(hash, &k) { - TableFull => fail!(~"Internal logic error"), - FoundEntry(idx) => idx, - FoundHole(idx) => { - self.buckets[idx] = Some(Bucket{hash: hash, key: k, - value: v}); - self.size += 1; - idx - }, - }; - - unsafe { // FIXME(#4903)---requires flow-sensitive borrow checker - ::cast::transmute_region(self.value_for_bucket(idx)) - } - } - - /// Return the value corresponding to the key in the map, or insert - /// and return the value if it doesn't exist. - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn find_or_insert<'a>(&'a mut self, k: K, v: V) -> &'a V { if self.size >= self.resize_at { // n.b.: We could also do this after searching, so @@ -567,41 +458,6 @@ pub impl HashMap { /// Return the value corresponding to the key in the map, or create, /// insert, and return a new value if it doesn't exist. - #[cfg(stage0)] - fn find_or_insert_with(&mut self, k: K, f: &fn(&K) -> V) -> &'self V { - if self.size >= self.resize_at { - // n.b.: We could also do this after searching, so - // that we do not resize if this call to insert is - // simply going to update a key in place. My sense - // though is that it's worse to have to search through - // buckets to find the right spot twice than to just - // resize in this corner case. - self.expand(); - } - - let hash = k.hash_keyed(self.k0, self.k1) as uint; - let idx = match self.bucket_for_key_with_hash(hash, &k) { - TableFull => fail!(~"Internal logic error"), - FoundEntry(idx) => idx, - FoundHole(idx) => { - let v = f(&k); - self.buckets[idx] = Some(Bucket{hash: hash, key: k, - value: v}); - self.size += 1; - idx - }, - }; - - unsafe { // FIXME(#4903)---requires flow-sensitive borrow checker - ::cast::transmute_region(self.value_for_bucket(idx)) - } - } - - /// Return the value corresponding to the key in the map, or create, - /// insert, and return a new value if it doesn't exist. - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn find_or_insert_with<'a>(&'a mut self, k: K, f: &fn(&K) -> V) -> &'a V { if self.size >= self.resize_at { // n.b.: We could also do this after searching, so @@ -647,17 +503,6 @@ pub impl HashMap { } } - #[cfg(stage0)] - fn get(&self, k: &K) -> &'self V { - match self.find(k) { - Some(v) => v, - None => fail!(fmt!("No entry found for key: %?", k)), - } - } - - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn get<'a>(&'a self, k: &K) -> &'a V { match self.find(k) { Some(v) => v, @@ -676,19 +521,6 @@ pub impl HashMap { /// Return the value corresponding to the key in the map, using /// equivalence - #[cfg(stage0)] - fn find_equiv>(&self, k: &Q) -> Option<&'self V> { - match self.bucket_for_key_equiv(k) { - FoundEntry(idx) => Some(self.value_for_bucket(idx)), - TableFull | FoundHole(_) => None, - } - } - - /// Return the value corresponding to the key in the map, using - /// equivalence - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn find_equiv<'a, Q:Hash + Equiv>(&'a self, k: &Q) -> Option<&'a V> { match self.bucket_for_key_equiv(k) { FoundEntry(idx) => Some(self.value_for_bucket(idx)), diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 1b4c679ea07..416ec2069b5 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -284,12 +284,7 @@ impl Div for f32 { fn div(&self, other: &f32) -> f32 { *self / *other } } -#[cfg(stage0,notest)] -impl Modulo for f32 { - #[inline(always)] - fn modulo(&self, other: &f32) -> f32 { *self % *other } -} -#[cfg(not(stage0),notest)] +#[cfg(notest)] impl Rem for f32 { #[inline(always)] fn rem(&self, other: &f32) -> f32 { *self % *other } diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index 0f7647fa868..6e09ca61a7d 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -299,11 +299,7 @@ impl Mul for f64 { impl Div for f64 { fn div(&self, other: &f64) -> f64 { *self / *other } } -#[cfg(stage0,notest)] -impl Modulo for f64 { - fn modulo(&self, other: &f64) -> f64 { *self % *other } -} -#[cfg(not(stage0),notest)] +#[cfg(notest)] impl Rem for f64 { #[inline(always)] fn rem(&self, other: &f64) -> f64 { *self % *other } diff --git a/src/libcore/num/float.rs b/src/libcore/num/float.rs index 16bb2aa1286..da9d03f6a7b 100644 --- a/src/libcore/num/float.rs +++ b/src/libcore/num/float.rs @@ -697,12 +697,7 @@ impl Div for float { fn div(&self, other: &float) -> float { *self / *other } } -#[cfg(stage0,notest)] -impl Modulo for float { - #[inline(always)] - fn modulo(&self, other: &float) -> float { *self % *other } -} -#[cfg(not(stage0),notest)] +#[cfg(notest)] impl Rem for float { #[inline(always)] fn rem(&self, other: &float) -> float { *self % *other } diff --git a/src/libcore/num/int-template.rs b/src/libcore/num/int-template.rs index 090e0256abf..95c187a7be2 100644 --- a/src/libcore/num/int-template.rs +++ b/src/libcore/num/int-template.rs @@ -224,12 +224,7 @@ impl Div for T { fn div(&self, other: &T) -> T { *self / *other } } -#[cfg(stage0,notest)] -impl Modulo for T { - #[inline(always)] - fn modulo(&self, other: &T) -> T { *self % *other } -} -#[cfg(not(stage0),notest)] +#[cfg(notest)] impl Rem for T { /// /// Returns the integer remainder after division, satisfying: diff --git a/src/libcore/num/num.rs b/src/libcore/num/num.rs index b8f47db7d12..1a59a069df7 100644 --- a/src/libcore/num/num.rs +++ b/src/libcore/num/num.rs @@ -10,11 +10,6 @@ //! An interface for numeric types use cmp::{Eq, Ord}; -#[cfg(stage0)] -use ops::{Add, Sub, Mul, Div, Neg}; -#[cfg(stage0)] -use Rem = ops::Modulo; -#[cfg(not(stage0))] use ops::{Add, Sub, Mul, Div, Rem, Neg}; use ops::{Not, BitAnd, BitOr, BitXor, Shl, Shr}; use option::Option; @@ -391,23 +386,7 @@ pub fn pow_with_uint+Mul>( } /// Helper function for testing numeric operations -#[cfg(stage0,test)] -pub fn test_num(ten: T, two: T) { - assert_eq!(ten.add(&two), cast(12)); - assert_eq!(ten.sub(&two), cast(8)); - assert_eq!(ten.mul(&two), cast(20)); - assert_eq!(ten.div(&two), cast(5)); - assert_eq!(ten.modulo(&two), cast(0)); - - assert_eq!(ten.add(&two), ten + two); - assert_eq!(ten.sub(&two), ten - two); - assert_eq!(ten.mul(&two), ten * two); - assert_eq!(ten.div(&two), ten / two); - assert_eq!(ten.modulo(&two), ten % two); -} -#[cfg(stage1,test)] -#[cfg(stage2,test)] -#[cfg(stage3,test)] +#[cfg(test)] pub fn test_num(ten: T, two: T) { assert_eq!(ten.add(&two), cast(12)); assert_eq!(ten.sub(&two), cast(8)); diff --git a/src/libcore/num/strconv.rs b/src/libcore/num/strconv.rs index 68e3b407a8b..c16a29f8295 100644 --- a/src/libcore/num/strconv.rs +++ b/src/libcore/num/strconv.rs @@ -9,13 +9,6 @@ // except according to those terms. use core::cmp::{Ord, Eq}; -#[cfg(stage0)] -use ops::{Add, Sub, Mul, Div, Neg}; -#[cfg(stage0)] -use Rem = ops::Modulo; -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] use ops::{Add, Sub, Mul, Div, Rem, Neg}; use option::{None, Option, Some}; use char; diff --git a/src/libcore/num/uint-template.rs b/src/libcore/num/uint-template.rs index 379c1834543..6d0f1fe1fc7 100644 --- a/src/libcore/num/uint-template.rs +++ b/src/libcore/num/uint-template.rs @@ -171,12 +171,7 @@ impl Div for T { fn div(&self, other: &T) -> T { *self / *other } } -#[cfg(stage0,notest)] -impl Modulo for T { - #[inline(always)] - fn modulo(&self, other: &T) -> T { *self % *other } -} -#[cfg(not(stage0),notest)] +#[cfg(notest)] impl Rem for T { #[inline(always)] fn rem(&self, other: &T) -> T { *self % *other } diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 5ba860c89c9..47ff45be687 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -35,13 +35,7 @@ pub trait Div { fn div(&self, rhs: &RHS) -> Result; } -#[lang="modulo"] -#[cfg(stage0)] -pub trait Modulo { - fn modulo(&self, rhs: &RHS) -> Result; -} #[lang="rem"] -#[cfg(not(stage0))] pub trait Rem { fn rem(&self, rhs: &RHS) -> Result; } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 47ec1fabcb8..b7c51147fba 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -100,16 +100,6 @@ impl> Add, Option> for Option { impl BaseIter for Option { /// Performs an operation on the contained value by reference - #[cfg(stage0)] - #[inline(always)] - fn each(&self, f: &fn(x: &'self T) -> bool) { - match *self { None => (), Some(ref t) => { f(t); } } - } - - /// Performs an operation on the contained value by reference - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] #[inline(always)] fn each<'a>(&'a self, f: &fn(x: &'a T) -> bool) { match *self { None => (), Some(ref t) => { f(t); } } @@ -122,15 +112,6 @@ impl BaseIter for Option { } impl MutableIter for Option { - #[cfg(stage0)] - #[inline(always)] - fn each_mut(&mut self, f: &fn(&'self mut T) -> bool) { - match *self { None => (), Some(ref mut t) => { f(t); } } - } - - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] #[inline(always)] fn each_mut<'a>(&'a mut self, f: &fn(&'a mut T) -> bool) { match *self { None => (), Some(ref mut t) => { f(t); } } @@ -200,35 +181,12 @@ pub impl Option { * Update an optional value by optionally running its content by reference * through a function that returns an option. */ - #[cfg(stage0)] - #[inline(always)] - fn chain_ref(&self, f: &fn(x: &'self T) -> Option) -> Option { - match *self { Some(ref x) => f(x), None => None } - } - - /** - * Update an optional value by optionally running its content by reference - * through a function that returns an option. - */ - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] #[inline(always)] fn chain_ref<'a, U>(&'a self, f: &fn(x: &'a T) -> Option) -> Option { match *self { Some(ref x) => f(x), None => None } } /// Maps a `some` value from one type to another by reference - #[cfg(stage0)] - #[inline(always)] - fn map(&self, f: &fn(&'self T) -> U) -> Option { - match *self { Some(ref x) => Some(f(x)), None => None } - } - - /// Maps a `some` value from one type to another by reference - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] #[inline(always)] fn map<'a, U>(&self, f: &fn(&'a T) -> U) -> Option { match *self { Some(ref x) => Some(f(x)), None => None } @@ -242,16 +200,6 @@ pub impl Option { } /// Applies a function to the contained value or returns a default - #[cfg(stage0)] - #[inline(always)] - fn map_default(&self, def: U, f: &fn(&'self T) -> U) -> U { - match *self { None => def, Some(ref t) => f(t) } - } - - /// Applies a function to the contained value or returns a default - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] #[inline(always)] fn map_default<'a, U>(&'a self, def: U, f: &fn(&'a T) -> U) -> U { match *self { None => def, Some(ref t) => f(t) } @@ -295,32 +243,6 @@ pub impl Option { case explicitly. */ #[inline(always)] - #[cfg(stage0)] - fn get_ref(&self) -> &'self T { - match *self { - Some(ref x) => x, - None => fail!(~"option::get_ref none") - } - } - - /** - Gets an immutable reference to the value inside an option. - - # Failure - - Fails if the value equals `None` - - # Safety note - - In general, because this function may fail, its use is discouraged - (calling `get` on `None` is akin to dereferencing a null pointer). - Instead, prefer to use pattern matching and handle the `None` - case explicitly. - */ - #[inline(always)] - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn get_ref<'a>(&'a self) -> &'a T { match *self { Some(ref x) => x, @@ -343,32 +265,6 @@ pub impl Option { case explicitly. */ #[inline(always)] - #[cfg(stage0)] - fn get_mut_ref(&mut self) -> &'self mut T { - match *self { - Some(ref mut x) => x, - None => fail!(~"option::get_mut_ref none") - } - } - - /** - Gets a mutable reference to the value inside an option. - - # Failure - - Fails if the value equals `None` - - # Safety note - - In general, because this function may fail, its use is discouraged - (calling `get` on `None` is akin to dereferencing a null pointer). - Instead, prefer to use pattern matching and handle the `None` - case explicitly. - */ - #[inline(always)] - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn get_mut_ref<'a>(&'a mut self) -> &'a mut T { match *self { Some(ref mut x) => x, diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs index 0dad9fc91d4..42401ae5a1f 100644 --- a/src/libcore/prelude.rs +++ b/src/libcore/prelude.rs @@ -14,9 +14,6 @@ pub use either::{Either, Left, Right}; pub use kinds::{Const, Copy, Owned, Durable}; -#[cfg(stage0)] -pub use ops::{Add, Sub, Mul, Div, Modulo, Neg, Not}; -#[cfg(not(stage0))] pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not}; pub use ops::{BitAnd, BitOr, BitXor}; pub use ops::{Drop}; diff --git a/src/libcore/reflect.rs b/src/libcore/reflect.rs index 9a0526b4351..47de360f589 100644 --- a/src/libcore/reflect.rs +++ b/src/libcore/reflect.rs @@ -15,7 +15,7 @@ Runtime type reflection */ use intrinsic::{TyDesc, TyVisitor}; -#[cfg(not(stage0))] use intrinsic::Opaque; +use intrinsic::Opaque; use libc::c_void; use sys; use vec; @@ -394,17 +394,6 @@ impl TyVisitor for MovePtrAdaptor { true } - #[cfg(stage0)] - fn visit_enter_enum(&self, n_variants: uint, sz: uint, align: uint) - -> bool { - self.align(align); - if ! self.inner.visit_enter_enum(n_variants, sz, align) { - return false; - } - true - } - - #[cfg(not(stage0))] fn visit_enter_enum(&self, n_variants: uint, get_disr: extern unsafe fn(ptr: *Opaque) -> int, sz: uint, align: uint) @@ -428,15 +417,6 @@ impl TyVisitor for MovePtrAdaptor { true } - #[cfg(stage0)] - fn visit_enum_variant_field(&self, i: uint, inner: *TyDesc) -> bool { - unsafe { self.align((*inner).align); } - if ! self.inner.visit_enum_variant_field(i, inner) { return false; } - unsafe { self.bump((*inner).size); } - true - } - - #[cfg(not(stage0))] fn visit_enum_variant_field(&self, i: uint, offset: uint, inner: *TyDesc) -> bool { self.inner.push_ptr(); self.bump(offset); @@ -457,17 +437,6 @@ impl TyVisitor for MovePtrAdaptor { true } - #[cfg(stage0)] - fn visit_leave_enum(&self, n_variants: uint, sz: uint, align: uint) - -> bool { - if ! self.inner.visit_leave_enum(n_variants, sz, align) { - return false; - } - self.bump(sz); - true - } - - #[cfg(not(stage0))] fn visit_leave_enum(&self, n_variants: uint, get_disr: extern unsafe fn(ptr: *Opaque) -> int, sz: uint, align: uint) -> bool { diff --git a/src/libcore/repr.rs b/src/libcore/repr.rs index 29b8400706c..3d525993259 100644 --- a/src/libcore/repr.rs +++ b/src/libcore/repr.rs @@ -18,12 +18,11 @@ use cast::transmute; use char; use intrinsic; use intrinsic::{TyDesc, TyVisitor, visit_tydesc}; -#[cfg(not(stage0))] use intrinsic::Opaque; +use intrinsic::Opaque; use io::{Writer, WriterUtil}; use libc::c_void; use managed; use ptr; -#[cfg(stage0)] use sys; use reflect; use reflect::{MovePtr, align}; use to_str::ToStr; @@ -138,14 +137,6 @@ impl Repr for char { // New implementation using reflect::MovePtr -#[cfg(stage0)] -enum VariantState { - Degenerate, - TagMatch, - TagMismatch, -} - -#[cfg(not(stage0))] enum VariantState { SearchingFor(int), Matched, @@ -190,18 +181,6 @@ pub impl ReprVisitor { true } - #[cfg(stage0)] #[inline(always)] - fn bump(&self, sz: uint) { - do self.move_ptr() |p| { - ((p as uint) + sz) as *c_void - }; - } - - #[cfg(stage0)] #[inline(always)] - fn bump_past(&self) { - self.bump(sys::size_of::()); - } - #[inline(always)] fn visit_inner(&self, inner: *TyDesc) -> bool { self.visit_ptr_inner(self.ptr, inner) @@ -467,18 +446,6 @@ impl TyVisitor for ReprVisitor { true } - #[cfg(stage0)] - fn visit_enter_enum(&self, n_variants: uint, - _sz: uint, _align: uint) -> bool { - if n_variants == 1 { - self.var_stk.push(Degenerate) - } else { - self.var_stk.push(TagMatch) - } - true - } - - #[cfg(not(stage0))] fn visit_enter_enum(&self, _n_variants: uint, get_disr: extern unsafe fn(ptr: *Opaque) -> int, _sz: uint, _align: uint) -> bool { @@ -487,40 +454,6 @@ impl TyVisitor for ReprVisitor { true } - #[cfg(stage0)] - fn visit_enter_enum_variant(&self, _variant: uint, - disr_val: int, - n_fields: uint, - name: &str) -> bool { - let mut write = false; - match self.var_stk.pop() { - Degenerate => { - write = true; - self.var_stk.push(Degenerate); - } - TagMatch | TagMismatch => { - do self.get::() |t| { - if disr_val == *t { - write = true; - self.var_stk.push(TagMatch); - } else { - self.var_stk.push(TagMismatch); - } - }; - self.bump_past::(); - } - } - - if write { - self.writer.write_str(name); - if n_fields > 0 { - self.writer.write_char('('); - } - } - true - } - - #[cfg(not(stage0))] fn visit_enter_enum_variant(&self, _variant: uint, disr_val: int, n_fields: uint, @@ -549,23 +482,6 @@ impl TyVisitor for ReprVisitor { true } - #[cfg(stage0)] - fn visit_enum_variant_field(&self, i: uint, inner: *TyDesc) -> bool { - match self.var_stk[vec::uniq_len(&const self.var_stk) - 1] { - Degenerate | TagMatch => { - if i != 0 { - self.writer.write_str(", "); - } - if ! self.visit_inner(inner) { - return false; - } - } - TagMismatch => () - } - true - } - - #[cfg(not(stage0))] fn visit_enum_variant_field(&self, i: uint, _offset: uint, inner: *TyDesc) -> bool { match self.var_stk[vec::uniq_len(&const self.var_stk) - 1] { Matched => { @@ -581,23 +497,6 @@ impl TyVisitor for ReprVisitor { true } - #[cfg(stage0)] - fn visit_leave_enum_variant(&self, _variant: uint, - _disr_val: int, - n_fields: uint, - _name: &str) -> bool { - match self.var_stk[vec::uniq_len(&const self.var_stk) - 1] { - Degenerate | TagMatch => { - if n_fields > 0 { - self.writer.write_char(')'); - } - } - TagMismatch => () - } - true - } - - #[cfg(not(stage0))] fn visit_leave_enum_variant(&self, _variant: uint, _disr_val: int, n_fields: uint, @@ -613,14 +512,6 @@ impl TyVisitor for ReprVisitor { true } - #[cfg(stage0)] - fn visit_leave_enum(&self, _n_variants: uint, - _sz: uint, _align: uint) -> bool { - self.var_stk.pop(); - true - } - - #[cfg(not(stage0))] fn visit_leave_enum(&self, _n_variants: uint, _get_disr: extern unsafe fn(ptr: *Opaque) -> int, _sz: uint, _align: uint) -> bool { diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 9171c5167bc..17cc07c660d 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -226,13 +226,6 @@ pub fn map_err(res: &Result, op: &fn(&E) -> F) } pub impl Result { - #[cfg(stage0)] - #[inline(always)] - fn get_ref(&self) -> &'self T { get_ref(self) } - - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] #[inline(always)] fn get_ref<'a>(&'a self) -> &'a T { get_ref(self) } diff --git a/src/libcore/rt/io/mod.rs b/src/libcore/rt/io/mod.rs index ced4ba0ee23..97b3ee3e30e 100644 --- a/src/libcore/rt/io/mod.rs +++ b/src/libcore/rt/io/mod.rs @@ -275,7 +275,6 @@ pub mod net { } /// Readers and Writers for memory buffers and strings. -#[cfg(not(stage0))] // XXX Using unsnapshotted features pub mod mem; /// Non-blocking access to stdin, stdout, stderr @@ -286,11 +285,9 @@ pub mod stdio; mod option; /// Basic stream compression. XXX: Belongs with other flate code -#[cfg(not(stage0))] // XXX Using unsnapshotted features pub mod flate; /// Interop between byte streams and pipes. Not sure where it belongs -#[cfg(not(stage0))] // XXX " pub mod comm_adapters; /// Extension traits diff --git a/src/libcore/rt/mod.rs b/src/libcore/rt/mod.rs index 56ed7dc95b6..a072fccd33d 100644 --- a/src/libcore/rt/mod.rs +++ b/src/libcore/rt/mod.rs @@ -37,27 +37,6 @@ mod local_heap; #[cfg(test)] pub mod test; -#[cfg(stage0)] -pub fn start(main: *u8, _argc: int, _argv: *c_char, _crate_map: *u8) -> int { - use self::sched::{Scheduler, Task}; - use self::uvio::UvEventLoop; - - let loop_ = ~UvEventLoop::new(); - let mut sched = ~Scheduler::new(loop_); - let main_task = ~do Task::new(&mut sched.stack_pool) { - // XXX: Can't call a C function pointer from Rust yet - unsafe { rust_call_nullary_fn(main) }; - }; - sched.task_queue.push_back(main_task); - sched.run(); - return 0; - - extern { - fn rust_call_nullary_fn(f: *u8); - } -} - -#[cfg(not(stage0))] pub fn start(main: *u8, _argc: int, _argv: **c_char, _crate_map: *u8) -> int { use self::sched::{Scheduler, Task}; use self::uvio::UvEventLoop; diff --git a/src/libcore/rt/rtio.rs b/src/libcore/rt/rtio.rs index 66eb79ba6ae..fd64438c61b 100644 --- a/src/libcore/rt/rtio.rs +++ b/src/libcore/rt/rtio.rs @@ -24,11 +24,6 @@ pub trait EventLoop { fn run(&mut self); fn callback(&mut self, ~fn()); /// The asynchronous I/O services. Not all event loops may provide one - #[cfg(stage0)] - fn io(&mut self) -> Option<&'self mut IoFactoryObject>; - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn io<'a>(&'a mut self) -> Option<&'a mut IoFactoryObject>; } diff --git a/src/libcore/rt/uvio.rs b/src/libcore/rt/uvio.rs index 94f8c0bf707..ab8aea2b63c 100644 --- a/src/libcore/rt/uvio.rs +++ b/src/libcore/rt/uvio.rs @@ -68,14 +68,6 @@ impl EventLoop for UvEventLoop { } } - #[cfg(stage0)] - fn io(&mut self) -> Option<&'self mut IoFactoryObject> { - Some(&mut self.uvio) - } - - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn io<'a>(&'a mut self) -> Option<&'a mut IoFactoryObject> { Some(&mut self.uvio) } @@ -98,14 +90,6 @@ fn test_callback_run_once() { pub struct UvIoFactory(Loop); pub impl UvIoFactory { - #[cfg(stage0)] - fn uv_loop(&mut self) -> &'self mut Loop { - match self { &UvIoFactory(ref mut ptr) => ptr } - } - - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn uv_loop<'a>(&'a mut self) -> &'a mut Loop { match self { &UvIoFactory(ref mut ptr) => ptr } } diff --git a/src/libcore/stackwalk.rs b/src/libcore/stackwalk.rs index 272bdca8654..987d4064ab9 100644 --- a/src/libcore/stackwalk.rs +++ b/src/libcore/stackwalk.rs @@ -93,9 +93,6 @@ pub mod rustrt { pub mod rusti { #[abi = "rust-intrinsic"] pub extern "rust-intrinsic" { - #[cfg(stage0)] - pub fn frame_address(f: &once fn(x: *u8)); - #[cfg(not(stage0))] pub fn frame_address(+f: &once fn(x: *u8)); } } diff --git a/src/libcore/sys.rs b/src/libcore/sys.rs index dd366048834..4eca7ebbb37 100644 --- a/src/libcore/sys.rs +++ b/src/libcore/sys.rs @@ -200,21 +200,6 @@ impl FailWithCause for &'static str { } } -// NOTE: remove function after snapshot -#[cfg(stage0)] -pub fn begin_unwind(msg: ~str, file: ~str, line: uint) -> ! { - - do str::as_buf(msg) |msg_buf, _msg_len| { - do str::as_buf(file) |file_buf, _file_len| { - unsafe { - let msg_buf = cast::transmute(msg_buf); - let file_buf = cast::transmute(file_buf); - begin_unwind_(msg_buf, file_buf, line as libc::size_t) - } - } - } -} - // FIXME #4427: Temporary until rt::rt_fail_ goes away pub fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! { use rt::{context, OldTaskContext}; @@ -242,13 +227,6 @@ pub fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! { } } -// NOTE: remove function after snapshot -#[cfg(stage0)] -pub fn fail_assert(msg: &str, file: &str, line: uint) -> ! { - let (msg, file) = (msg.to_owned(), file.to_owned()); - begin_unwind(~"assertion failed: " + msg, file, line) -} - #[cfg(test)] mod tests { use cast; diff --git a/src/libcore/trie.rs b/src/libcore/trie.rs index f4e9ddbdd90..f0756be9944 100644 --- a/src/libcore/trie.rs +++ b/src/libcore/trie.rs @@ -56,16 +56,6 @@ impl Map for TrieMap { /// Visit all key-value pairs in order #[inline(always)] - #[cfg(stage0)] - fn each(&self, f: &fn(&uint, &'self T) -> bool) { - self.root.each(f); - } - - /// Visit all key-value pairs in order - #[inline(always)] - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn each<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) { self.root.each(f); } @@ -78,16 +68,6 @@ impl Map for TrieMap { /// Visit all values in order #[inline(always)] - #[cfg(stage0)] - fn each_value(&self, f: &fn(&T) -> bool) { - self.each(|_, v| f(v)) - } - - /// Visit all values in order - #[inline(always)] - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn each_value<'a>(&'a self, f: &fn(&'a T) -> bool) { self.each(|_, v| f(v)) } @@ -99,31 +79,6 @@ impl Map for TrieMap { } /// Return a reference to the value corresponding to the key - #[cfg(stage0)] - #[inline(hint)] - fn find(&self, key: &uint) -> Option<&'self T> { - let mut node: &'self TrieNode = &self.root; - let mut idx = 0; - loop { - match node.children[chunk(*key, idx)] { - Internal(ref x) => node = &**x, - External(stored, ref value) => { - if stored == *key { - return Some(value) - } else { - return None - } - } - Nothing => return None - } - idx += 1; - } - } - - /// Return a reference to the value corresponding to the key - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] #[inline(hint)] fn find<'a>(&'a self, key: &uint) -> Option<&'a T> { let mut node: &'a TrieNode = &self.root; @@ -145,16 +100,6 @@ impl Map for TrieMap { } /// Return a mutable reference to the value corresponding to the key - #[cfg(stage0)] - #[inline(always)] - fn find_mut(&mut self, key: &uint) -> Option<&'self mut T> { - find_mut(&mut self.root.children[chunk(*key, 0)], *key, 1) - } - - /// Return a mutable reference to the value corresponding to the key - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] #[inline(always)] fn find_mut<'a>(&'a mut self, key: &uint) -> Option<&'a mut T> { find_mut(&mut self.root.children[chunk(*key, 0)], *key, 1) @@ -193,16 +138,6 @@ pub impl TrieMap { /// Visit all key-value pairs in reverse order #[inline(always)] - #[cfg(stage0)] - fn each_reverse(&self, f: &fn(&uint, &'self T) -> bool) { - self.root.each_reverse(f); - } - - /// Visit all key-value pairs in reverse order - #[inline(always)] - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn each_reverse<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) { self.root.each_reverse(f); } @@ -298,21 +233,6 @@ impl TrieNode { } impl TrieNode { - #[cfg(stage0)] - fn each(&self, f: &fn(&uint, &'self T) -> bool) -> bool { - for uint::range(0, self.children.len()) |idx| { - match self.children[idx] { - Internal(ref x) => if !x.each(f) { return false }, - External(k, ref v) => if !f(&k, v) { return false }, - Nothing => () - } - } - true - } - - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn each<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) -> bool { for uint::range(0, self.children.len()) |idx| { match self.children[idx] { @@ -324,21 +244,6 @@ impl TrieNode { true } - #[cfg(stage0)] - fn each_reverse(&self, f: &fn(&uint, &'self T) -> bool) -> bool { - for uint::range_rev(self.children.len(), 0) |idx| { - match self.children[idx - 1] { - Internal(ref x) => if !x.each_reverse(f) { return false }, - External(k, ref v) => if !f(&k, v) { return false }, - Nothing => () - } - } - true - } - - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn each_reverse<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) -> bool { for uint::range_rev(self.children.len(), 0) |idx| { match self.children[idx - 1] { diff --git a/src/libcore/tuple.rs b/src/libcore/tuple.rs index a2b6f0eb1a7..6da22657906 100644 --- a/src/libcore/tuple.rs +++ b/src/libcore/tuple.rs @@ -56,39 +56,11 @@ impl Clone for (T, U) { } } -#[cfg(stage0)] -pub trait ImmutableTuple { - fn first_ref(&self) -> &'self T; - fn second_ref(&self) -> &'self U; -} - -#[cfg(stage0)] -impl ImmutableTuple for (T, U) { - #[inline(always)] - fn first_ref(&self) -> &'self T { - match *self { - (ref t, _) => t, - } - } - #[inline(always)] - fn second_ref(&self) -> &'self U { - match *self { - (_, ref u) => u, - } - } -} - -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] pub trait ImmutableTuple { fn first_ref<'a>(&'a self) -> &'a T; fn second_ref<'a>(&'a self) -> &'a U; } -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] impl ImmutableTuple for (T, U) { #[inline(always)] fn first_ref<'a>(&'a self) -> &'a T { diff --git a/src/libcore/unstable/intrinsics.rs b/src/libcore/unstable/intrinsics.rs index b58429a10aa..65cfc6ec1fe 100644 --- a/src/libcore/unstable/intrinsics.rs +++ b/src/libcore/unstable/intrinsics.rs @@ -46,10 +46,6 @@ pub extern "rust-intrinsic" { pub fn forget(_: T) -> (); - // XXX: intrinsic uses legacy modes - #[cfg(stage0)] - fn reinterpret_cast(&&src: T) -> U; - pub fn needs_drop() -> bool; // XXX: intrinsic uses legacy modes and has reference to TyDesc diff --git a/src/libcore/unstable/lang.rs b/src/libcore/unstable/lang.rs index 460285bfcfd..7f6faa81012 100644 --- a/src/libcore/unstable/lang.rs +++ b/src/libcore/unstable/lang.rs @@ -17,9 +17,7 @@ use str; use sys; use unstable::exchange_alloc; use cast::transmute; -#[cfg(not(stage0))] use rt::{context, OldTaskContext}; -#[cfg(not(stage0))] use rt::local_services::borrow_local_services; #[allow(non_camel_case_types)] @@ -91,14 +89,6 @@ pub unsafe fn exchange_free(ptr: *c_char) { } #[lang="malloc"] -#[inline(always)] -#[cfg(stage0)] // For some reason this isn't working on windows in stage0 -pub unsafe fn local_malloc(td: *c_char, size: uintptr_t) -> *c_char { - return rustrt::rust_upcall_malloc_noswitch(td, size); -} - -#[lang="malloc"] -#[cfg(not(stage0))] pub unsafe fn local_malloc(td: *c_char, size: uintptr_t) -> *c_char { match context() { OldTaskContext => { @@ -118,17 +108,6 @@ pub unsafe fn local_malloc(td: *c_char, size: uintptr_t) -> *c_char { // inside a landing pad may corrupt the state of the exception handler. If a // problem occurs, call exit instead. #[lang="free"] -#[inline(always)] -#[cfg(stage0)] -pub unsafe fn local_free(ptr: *c_char) { - rustrt::rust_upcall_free_noswitch(ptr); -} - -// NB: Calls to free CANNOT be allowed to fail, as throwing an exception from -// inside a landing pad may corrupt the state of the exception handler. If a -// problem occurs, call exit instead. -#[lang="free"] -#[cfg(not(stage0))] pub unsafe fn local_free(ptr: *c_char) { match context() { OldTaskContext => { @@ -176,32 +155,6 @@ pub unsafe fn strdup_uniq(ptr: *c_uchar, len: uint) -> ~str { } #[lang="start"] -#[cfg(stage0)] -pub fn start(main: *u8, argc: int, argv: *c_char, - crate_map: *u8) -> int { - use libc::getenv; - use rt::start; - - unsafe { - let use_old_rt = do str::as_c_str("RUST_NEWRT") |s| { - getenv(s).is_null() - }; - if use_old_rt { - return rust_start(main as *c_void, argc as c_int, argv, - crate_map as *c_void) as int; - } else { - return start(main, argc, argv, crate_map); - } - } - - extern { - fn rust_start(main: *c_void, argc: c_int, argv: *c_char, - crate_map: *c_void) -> c_int; - } -} - -#[lang="start"] -#[cfg(not(stage0))] pub fn start(main: *u8, argc: int, argv: **c_char, crate_map: *u8) -> int { use libc::getenv; diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 081efe48e1e..6ffb0b30917 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -19,9 +19,6 @@ use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater}; use clone::Clone; use old_iter::BaseIter; use old_iter; -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] use iterator::Iterator; use kinds::Copy; use libc; @@ -1566,16 +1563,6 @@ pub fn each_permutation(v: &[T], put: &fn(ts: &[T]) -> bool) { } } -// see doc below -#[cfg(stage0)] // XXX: lifetimes! -pub fn windowed(n: uint, v: &[T], it: &fn(&[T]) -> bool) { - assert!(1u <= n); - if n > v.len() { return; } - for uint::range(0, v.len() - n + 1) |i| { - if !it(v.slice(i, i+n)) { return } - } -} - /** * Iterate over all contiguous windows of length `n` of the vector `v`. * @@ -1590,9 +1577,6 @@ pub fn windowed(n: uint, v: &[T], it: &fn(&[T]) -> bool) { * ~~~ * */ -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] pub fn windowed<'r, T>(n: uint, v: &'r [T], it: &fn(&'r [T]) -> bool) { assert!(1u <= n); if n > v.len() { return; } @@ -1854,150 +1838,6 @@ impl<'self,T:Copy> CopyableVector for &'self const [T] { } } -#[cfg(stage0)] -pub trait ImmutableVector { - fn slice(&self, start: uint, end: uint) -> &'self [T]; - fn head(&self) -> &'self T; - fn head_opt(&self) -> Option<&'self T>; - fn tail(&self) -> &'self [T]; - fn tailn(&self, n: uint) -> &'self [T]; - fn init(&self) -> &'self [T]; - fn initn(&self, n: uint) -> &'self [T]; - fn last(&self) -> &'self T; - fn last_opt(&self) -> Option<&'self T>; - fn each_reverse(&self, blk: &fn(&T) -> bool); - fn eachi_reverse(&self, blk: &fn(uint, &T) -> bool); - fn foldr(&self, z: U, p: &fn(t: &T, u: U) -> U) -> U; - fn map(&self, f: &fn(t: &T) -> U) -> ~[U]; - fn mapi(&self, f: &fn(uint, t: &T) -> U) -> ~[U]; - fn map_r(&self, f: &fn(x: &T) -> U) -> ~[U]; - fn alli(&self, f: &fn(uint, t: &T) -> bool) -> bool; - fn flat_map(&self, f: &fn(t: &T) -> ~[U]) -> ~[U]; - fn filter_mapped(&self, f: &fn(t: &T) -> Option) -> ~[U]; - unsafe fn unsafe_ref(&self, index: uint) -> *T; -} - -/// Extension methods for vectors -#[cfg(stage0)] -impl<'self,T> ImmutableVector for &'self [T] { - /// Return a slice that points into another slice. - #[inline] - fn slice(&self, start: uint, end: uint) -> &'self [T] { - slice(*self, start, end) - } - - /// Returns the first element of a vector, failing if the vector is empty. - #[inline] - fn head(&self) -> &'self T { head(*self) } - - /// Returns the first element of a vector - #[inline] - fn head_opt(&self) -> Option<&'self T> { head_opt(*self) } - - /// Returns all but the first element of a vector - #[inline] - fn tail(&self) -> &'self [T] { tail(*self) } - - /// Returns all but the first `n' elements of a vector - #[inline] - fn tailn(&self, n: uint) -> &'self [T] { tailn(*self, n) } - - /// Returns all but the last elemnt of a vector - #[inline] - fn init(&self) -> &'self [T] { init(*self) } - - /// Returns all but the last `n' elemnts of a vector - #[inline] - fn initn(&self, n: uint) -> &'self [T] { initn(*self, n) } - - /// Returns the last element of a `v`, failing if the vector is empty. - #[inline] - fn last(&self) -> &'self T { last(*self) } - - /// Returns the last element of a `v`, failing if the vector is empty. - #[inline] - fn last_opt(&self) -> Option<&'self T> { last_opt(*self) } - - /// Iterates over a vector's elements in reverse. - #[inline] - fn each_reverse(&self, blk: &fn(&T) -> bool) { - each_reverse(*self, blk) - } - - /// Iterates over a vector's elements and indices in reverse. - #[inline] - fn eachi_reverse(&self, blk: &fn(uint, &T) -> bool) { - eachi_reverse(*self, blk) - } - - /// Reduce a vector from right to left - #[inline] - fn foldr(&self, z: U, p: &fn(t: &T, u: U) -> U) -> U { - foldr(*self, z, p) - } - - /// Apply a function to each element of a vector and return the results - #[inline] - fn map(&self, f: &fn(t: &T) -> U) -> ~[U] { map(*self, f) } - - /** - * Apply a function to the index and value of each element in the vector - * and return the results - */ - fn mapi(&self, f: &fn(uint, t: &T) -> U) -> ~[U] { - mapi(*self, f) - } - - #[inline] - fn map_r(&self, f: &fn(x: &T) -> U) -> ~[U] { - let mut r = ~[]; - let mut i = 0; - while i < self.len() { - r.push(f(&self[i])); - i += 1; - } - r - } - - /** - * Returns true if the function returns true for all elements. - * - * If the vector is empty, true is returned. - */ - fn alli(&self, f: &fn(uint, t: &T) -> bool) -> bool { - alli(*self, f) - } - /** - * Apply a function to each element of a vector and return a concatenation - * of each result vector - */ - #[inline] - fn flat_map(&self, f: &fn(t: &T) -> ~[U]) -> ~[U] { - flat_map(*self, f) - } - /** - * Apply a function to each element of a vector and return the results - * - * If function `f` returns `none` then that element is excluded from - * the resulting vector. - */ - #[inline] - fn filter_mapped(&self, f: &fn(t: &T) -> Option) -> ~[U] { - filter_mapped(*self, f) - } - - /// Returns a pointer to the element at the given index, without doing - /// bounds checking. - #[inline(always)] - unsafe fn unsafe_ref(&self, index: uint) -> *T { - let (ptr, _): (*T, uint) = transmute(*self); - ptr.offset(index) - } -} - -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] pub trait ImmutableVector<'self, T> { fn slice(&self, start: uint, end: uint) -> &'self [T]; fn iter(self) -> VecIterator<'self, T>; @@ -2022,9 +1862,6 @@ pub trait ImmutableVector<'self, T> { } /// Extension methods for vectors -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] impl<'self,T> ImmutableVector<'self, T> for &'self [T] { /// Return a slice that points into another slice. #[inline] @@ -2634,17 +2471,6 @@ pub mod bytes { // ___________________________________________________________________________ // ITERATION TRAIT METHODS -#[cfg(stage0)] -impl<'self,A> old_iter::BaseIter for &'self [A] { - #[inline(always)] - fn each(&self, blk: &fn(v: &'self A) -> bool) { each(*self, blk) } - #[inline(always)] - fn size_hint(&self) -> Option { Some(self.len()) } -} - -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] impl<'self,A> old_iter::BaseIter for &'self [A] { #[inline(always)] fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) { each(*self, blk) } @@ -2653,18 +2479,6 @@ impl<'self,A> old_iter::BaseIter for &'self [A] { } // FIXME(#4148): This should be redundant -#[cfg(stage0)] -impl old_iter::BaseIter for ~[A] { - #[inline(always)] - fn each(&self, blk: &fn(v: &'self A) -> bool) { each(*self, blk) } - #[inline(always)] - fn size_hint(&self) -> Option { Some(self.len()) } -} - -// FIXME(#4148): This should be redundant -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] impl old_iter::BaseIter for ~[A] { #[inline(always)] fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) { each(*self, blk) } @@ -2673,18 +2487,6 @@ impl old_iter::BaseIter for ~[A] { } // FIXME(#4148): This should be redundant -#[cfg(stage0)] -impl old_iter::BaseIter for @[A] { - #[inline(always)] - fn each(&self, blk: &fn(v: &'self A) -> bool) { each(*self, blk) } - #[inline(always)] - fn size_hint(&self) -> Option { Some(self.len()) } -} - -// FIXME(#4148): This should be redundant -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] impl old_iter::BaseIter for @[A] { #[inline(always)] fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) { each(*self, blk) } @@ -2692,17 +2494,6 @@ impl old_iter::BaseIter for @[A] { fn size_hint(&self) -> Option { Some(self.len()) } } -#[cfg(stage0)] -impl<'self,A> old_iter::MutableIter for &'self mut [A] { - #[inline(always)] - fn each_mut(&mut self, blk: &fn(v: &'self mut A) -> bool) { - each_mut(*self, blk) - } -} - -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] impl<'self,A> old_iter::MutableIter for &'self mut [A] { #[inline(always)] fn each_mut<'a>(&'a mut self, blk: &fn(v: &'a mut A) -> bool) { @@ -2711,17 +2502,6 @@ impl<'self,A> old_iter::MutableIter for &'self mut [A] { } // FIXME(#4148): This should be redundant -#[cfg(stage0)] -impl old_iter::MutableIter for ~[A] { - #[inline(always)] - fn each_mut(&mut self, blk: &fn(v: &'self mut A) -> bool) { - each_mut(*self, blk) - } -} - -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] impl old_iter::MutableIter for ~[A] { #[inline(always)] fn each_mut<'a>(&'a mut self, blk: &fn(v: &'a mut A) -> bool) { @@ -2927,18 +2707,12 @@ impl Clone for ~[A] { } // could be implemented with &[T] with .slice(), but this avoids bounds checks -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] pub struct VecIterator<'self, T> { priv ptr: *T, priv end: *T, priv lifetime: &'self T // FIXME: #5922 } -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] impl<'self, T> Iterator<&'self T> for VecIterator<'self, T> { #[inline] fn next(&mut self) -> Option<&'self T> { diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 1be49528b9e..1347fec5d66 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -272,14 +272,6 @@ fn item_ty_param_defs(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd, @bounds } -#[cfg(stage0)] -fn item_ty_region_param(item: ebml::Doc) -> Option { - reader::maybe_get_doc(item, tag_region_param).map(|doc| { - Decodable::decode(&reader::Decoder(*doc)) - }) -} - -#[cfg(not(stage0))] fn item_ty_region_param(item: ebml::Doc) -> Option { reader::maybe_get_doc(item, tag_region_param).map(|doc| { let mut decoder = reader::Decoder(*doc); diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 77373076137..6a9c564f368 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -42,13 +42,6 @@ use writer = std::ebml::writer; // used by astencode: type abbrev_map = @mut HashMap; -#[cfg(stage0)] -pub type encode_inlined_item = @fn(ecx: @EncodeContext, - ebml_w: &writer::Encoder, - path: &[ast_map::path_elt], - ii: ast::inlined_item); - -#[cfg(not(stage0))] pub type encode_inlined_item = @fn(ecx: @EncodeContext, ebml_w: &mut writer::Encoder, path: &[ast_map::path_elt], @@ -98,27 +91,12 @@ pub fn reachable(ecx: @EncodeContext, id: node_id) -> bool { ecx.reachable.contains(&id) } -#[cfg(stage0)] -fn encode_name(ecx: @EncodeContext, ebml_w: &writer::Encoder, name: ident) { - ebml_w.wr_tagged_str(tag_paths_data_name, *ecx.tcx.sess.str_of(name)); -} - -#[cfg(not(stage0))] fn encode_name(ecx: @EncodeContext, ebml_w: &mut writer::Encoder, name: ident) { ebml_w.wr_tagged_str(tag_paths_data_name, *ecx.tcx.sess.str_of(name)); } -#[cfg(stage0)] -fn encode_impl_type_basename(ecx: @EncodeContext, - ebml_w: &writer::Encoder, - name: ident) { - ebml_w.wr_tagged_str(tag_item_impl_type_basename, - *ecx.tcx.sess.str_of(name)); -} - -#[cfg(not(stage0))] fn encode_impl_type_basename(ecx: @EncodeContext, ebml_w: &mut writer::Encoder, name: ident) { @@ -126,29 +104,10 @@ fn encode_impl_type_basename(ecx: @EncodeContext, *ecx.tcx.sess.str_of(name)); } -#[cfg(stage0)] -pub fn encode_def_id(ebml_w: &writer::Encoder, id: def_id) { - ebml_w.wr_tagged_str(tag_def_id, def_to_str(id)); -} - -#[cfg(not(stage0))] pub fn encode_def_id(ebml_w: &mut writer::Encoder, id: def_id) { ebml_w.wr_tagged_str(tag_def_id, def_to_str(id)); } -#[cfg(stage0)] -fn encode_region_param(ecx: @EncodeContext, - ebml_w: &writer::Encoder, - it: @ast::item) { - let opt_rp = ecx.tcx.region_paramd_items.find(&it.id); - for opt_rp.each |rp| { - do ebml_w.wr_tag(tag_region_param) { - rp.encode(ebml_w); - } - } -} - -#[cfg(not(stage0))] fn encode_region_param(ecx: @EncodeContext, ebml_w: &mut writer::Encoder, it: @ast::item) { @@ -160,18 +119,6 @@ fn encode_region_param(ecx: @EncodeContext, } } -#[cfg(stage0)] -fn encode_mutability(ebml_w: &writer::Encoder, mt: struct_mutability) { - do ebml_w.wr_tag(tag_struct_mut) { - let val = match mt { - struct_immutable => 'a', - struct_mutable => 'm' - }; - ebml_w.writer.write(&[val as u8]); - } -} - -#[cfg(not(stage0))] fn encode_mutability(ebml_w: &mut writer::Encoder, mt: struct_mutability) { ebml_w.start_tag(tag_struct_mut); let val = match mt { @@ -187,24 +134,6 @@ struct entry { pos: uint } -#[cfg(stage0)] -fn add_to_index(ecx: @EncodeContext, - ebml_w: &writer::Encoder, - path: &[ident], - index: &mut ~[entry<~str>], - name: ident) { - let mut full_path = ~[]; - full_path.push_all(path); - full_path.push(name); - index.push( - entry { - val: ast_util::path_name_i(full_path, - ecx.tcx.sess.parse_sess.interner), - pos: ebml_w.writer.tell() - }); -} - -#[cfg(not(stage0))] fn add_to_index(ecx: @EncodeContext, ebml_w: &mut writer::Encoder, path: &[ident], @@ -221,24 +150,6 @@ fn add_to_index(ecx: @EncodeContext, }); } -#[cfg(stage0)] -fn encode_trait_ref(ebml_w: &writer::Encoder, - ecx: @EncodeContext, - trait_ref: &ty::TraitRef, - tag: uint) { - let ty_str_ctxt = @tyencode::ctxt { - diag: ecx.diag, - ds: def_to_str, - tcx: ecx.tcx, - reachable: |a| reachable(ecx, a), - abbrevs: tyencode::ac_use_abbrevs(ecx.type_abbrevs)}; - - ebml_w.start_tag(tag); - tyencode::enc_trait_ref(ebml_w.writer, ty_str_ctxt, trait_ref); - ebml_w.end_tag(); -} - -#[cfg(not(stage0))] fn encode_trait_ref(ebml_w: &mut writer::Encoder, ecx: @EncodeContext, trait_ref: &ty::TraitRef, @@ -256,15 +167,6 @@ fn encode_trait_ref(ebml_w: &mut writer::Encoder, } // Item info table encoding -#[cfg(stage0)] -fn encode_family(ebml_w: &writer::Encoder, c: char) { - ebml_w.start_tag(tag_items_data_item_family); - ebml_w.writer.write(&[c as u8]); - ebml_w.end_tag(); -} - -// Item info table encoding -#[cfg(not(stage0))] fn encode_family(ebml_w: &mut writer::Encoder, c: char) { ebml_w.start_tag(tag_items_data_item_family); ebml_w.writer.write(&[c as u8]); @@ -275,25 +177,6 @@ pub fn def_to_str(did: def_id) -> ~str { fmt!("%d:%d", did.crate, did.node) } -#[cfg(stage0)] -fn encode_ty_type_param_defs(ebml_w: &writer::Encoder, - ecx: @EncodeContext, - params: @~[ty::TypeParameterDef], - tag: uint) { - let ty_str_ctxt = @tyencode::ctxt { - diag: ecx.diag, - ds: def_to_str, - tcx: ecx.tcx, - reachable: |a| reachable(ecx, a), - abbrevs: tyencode::ac_use_abbrevs(ecx.type_abbrevs)}; - for params.each |param| { - ebml_w.start_tag(tag); - tyencode::enc_type_param_def(ebml_w.writer, ty_str_ctxt, param); - ebml_w.end_tag(); - } -} - -#[cfg(not(stage0))] fn encode_ty_type_param_defs(ebml_w: &mut writer::Encoder, ecx: @EncodeContext, params: @~[ty::TypeParameterDef], @@ -311,17 +194,6 @@ fn encode_ty_type_param_defs(ebml_w: &mut writer::Encoder, } } -#[cfg(stage0)] -fn encode_type_param_bounds(ebml_w: &writer::Encoder, - ecx: @EncodeContext, - params: &OptVec) { - let ty_param_defs = - @params.map_to_vec(|param| *ecx.tcx.ty_param_defs.get(¶m.id)); - encode_ty_type_param_defs(ebml_w, ecx, ty_param_defs, - tag_items_data_item_ty_param_bounds); -} - -#[cfg(not(stage0))] fn encode_type_param_bounds(ebml_w: &mut writer::Encoder, ecx: @EncodeContext, params: &OptVec) { @@ -331,32 +203,12 @@ fn encode_type_param_bounds(ebml_w: &mut writer::Encoder, tag_items_data_item_ty_param_bounds); } -#[cfg(stage0)] -fn encode_variant_id(ebml_w: &writer::Encoder, vid: def_id) { - ebml_w.start_tag(tag_items_data_item_variant); - ebml_w.writer.write(str::to_bytes(def_to_str(vid))); - ebml_w.end_tag(); -} - -#[cfg(not(stage0))] fn encode_variant_id(ebml_w: &mut writer::Encoder, vid: def_id) { ebml_w.start_tag(tag_items_data_item_variant); ebml_w.writer.write(str::to_bytes(def_to_str(vid))); ebml_w.end_tag(); } -#[cfg(stage0)] -pub fn write_type(ecx: @EncodeContext, ebml_w: &writer::Encoder, typ: ty::t) { - let ty_str_ctxt = @tyencode::ctxt { - diag: ecx.diag, - ds: def_to_str, - tcx: ecx.tcx, - reachable: |a| reachable(ecx, a), - abbrevs: tyencode::ac_use_abbrevs(ecx.type_abbrevs)}; - tyencode::enc_ty(ebml_w.writer, ty_str_ctxt, typ); -} - -#[cfg(not(stage0))] pub fn write_type(ecx: @EncodeContext, ebml_w: &mut writer::Encoder, typ: ty::t) { @@ -369,20 +221,6 @@ pub fn write_type(ecx: @EncodeContext, tyencode::enc_ty(ebml_w.writer, ty_str_ctxt, typ); } -#[cfg(stage0)] -pub fn write_vstore(ecx: @EncodeContext, - ebml_w: &writer::Encoder, - vstore: ty::vstore) { - let ty_str_ctxt = @tyencode::ctxt { - diag: ecx.diag, - ds: def_to_str, - tcx: ecx.tcx, - reachable: |a| reachable(ecx, a), - abbrevs: tyencode::ac_use_abbrevs(ecx.type_abbrevs)}; - tyencode::enc_vstore(ebml_w.writer, ty_str_ctxt, vstore); -} - -#[cfg(not(stage0))] pub fn write_vstore(ecx: @EncodeContext, ebml_w: &mut writer::Encoder, vstore: ty::vstore) { @@ -395,14 +233,6 @@ pub fn write_vstore(ecx: @EncodeContext, tyencode::enc_vstore(ebml_w.writer, ty_str_ctxt, vstore); } -#[cfg(stage0)] -fn encode_type(ecx: @EncodeContext, ebml_w: &writer::Encoder, typ: ty::t) { - ebml_w.start_tag(tag_items_data_item_type); - write_type(ecx, ebml_w, typ); - ebml_w.end_tag(); -} - -#[cfg(not(stage0))] fn encode_type(ecx: @EncodeContext, ebml_w: &mut writer::Encoder, typ: ty::t) { @@ -411,18 +241,6 @@ fn encode_type(ecx: @EncodeContext, ebml_w.end_tag(); } -#[cfg(stage0)] -fn encode_transformed_self_ty(ecx: @EncodeContext, - ebml_w: &writer::Encoder, - opt_typ: Option) { - for opt_typ.each |&typ| { - ebml_w.start_tag(tag_item_method_transformed_self_ty); - write_type(ecx, ebml_w, typ); - ebml_w.end_tag(); - } -} - -#[cfg(not(stage0))] fn encode_transformed_self_ty(ecx: @EncodeContext, ebml_w: &mut writer::Encoder, opt_typ: Option) { @@ -433,24 +251,6 @@ fn encode_transformed_self_ty(ecx: @EncodeContext, } } -#[cfg(stage0)] -fn encode_method_fty(ecx: @EncodeContext, - ebml_w: &writer::Encoder, - typ: &ty::BareFnTy) { - ebml_w.start_tag(tag_item_method_fty); - - let ty_str_ctxt = @tyencode::ctxt { - diag: ecx.diag, - ds: def_to_str, - tcx: ecx.tcx, - reachable: |a| reachable(ecx, a), - abbrevs: tyencode::ac_use_abbrevs(ecx.type_abbrevs)}; - tyencode::enc_bare_fn_ty(ebml_w.writer, ty_str_ctxt, typ); - - ebml_w.end_tag(); -} - -#[cfg(not(stage0))] fn encode_method_fty(ecx: @EncodeContext, ebml_w: &mut writer::Encoder, typ: &ty::BareFnTy) { @@ -467,23 +267,6 @@ fn encode_method_fty(ecx: @EncodeContext, ebml_w.end_tag(); } -#[cfg(stage0)] -fn encode_symbol(ecx: @EncodeContext, ebml_w: &writer::Encoder, id: node_id) { - ebml_w.start_tag(tag_items_data_item_symbol); - match ecx.item_symbols.find(&id) { - Some(x) => { - debug!("encode_symbol(id=%?, str=%s)", id, *x); - ebml_w.writer.write(str::to_bytes(*x)); - } - None => { - ecx.diag.handler().bug( - fmt!("encode_symbol: id not found %d", id)); - } - } - ebml_w.end_tag(); -} - -#[cfg(not(stage0))] fn encode_symbol(ecx: @EncodeContext, ebml_w: &mut writer::Encoder, id: node_id) { @@ -501,16 +284,6 @@ fn encode_symbol(ecx: @EncodeContext, ebml_w.end_tag(); } -#[cfg(stage0)] -fn encode_discriminant(ecx: @EncodeContext, - ebml_w: &writer::Encoder, - id: node_id) { - ebml_w.start_tag(tag_items_data_item_symbol); - ebml_w.writer.write(str::to_bytes(**ecx.discrim_symbols.get(&id))); - ebml_w.end_tag(); -} - -#[cfg(not(stage0))] fn encode_discriminant(ecx: @EncodeContext, ebml_w: &mut writer::Encoder, id: node_id) { @@ -519,16 +292,6 @@ fn encode_discriminant(ecx: @EncodeContext, ebml_w.end_tag(); } -#[cfg(stage0)] -fn encode_disr_val(_: @EncodeContext, - ebml_w: &writer::Encoder, - disr_val: int) { - ebml_w.start_tag(tag_disr_val); - ebml_w.writer.write(str::to_bytes(int::to_str(disr_val))); - ebml_w.end_tag(); -} - -#[cfg(not(stage0))] fn encode_disr_val(_: @EncodeContext, ebml_w: &mut writer::Encoder, disr_val: int) { @@ -537,65 +300,12 @@ fn encode_disr_val(_: @EncodeContext, ebml_w.end_tag(); } -#[cfg(stage0)] -fn encode_parent_item(ebml_w: &writer::Encoder, id: def_id) { - ebml_w.start_tag(tag_items_data_parent_item); - ebml_w.writer.write(str::to_bytes(def_to_str(id))); - ebml_w.end_tag(); -} - -#[cfg(not(stage0))] fn encode_parent_item(ebml_w: &mut writer::Encoder, id: def_id) { ebml_w.start_tag(tag_items_data_parent_item); ebml_w.writer.write(str::to_bytes(def_to_str(id))); ebml_w.end_tag(); } -#[cfg(stage0)] -fn encode_enum_variant_info(ecx: @EncodeContext, - ebml_w: &writer::Encoder, - id: node_id, - variants: &[variant], - path: &[ast_map::path_elt], - index: @mut ~[entry], - generics: &ast::Generics) { - debug!("encode_enum_variant_info(id=%?)", id); - - let mut disr_val = 0; - let mut i = 0; - let vi = ty::enum_variants(ecx.tcx, - ast::def_id { crate: local_crate, node: id }); - for variants.each |variant| { - index.push(entry {val: variant.node.id, pos: ebml_w.writer.tell()}); - ebml_w.start_tag(tag_items_data_item); - encode_def_id(ebml_w, local_def(variant.node.id)); - encode_family(ebml_w, 'v'); - encode_name(ecx, ebml_w, variant.node.name); - encode_parent_item(ebml_w, local_def(id)); - encode_type(ecx, ebml_w, - node_id_to_type(ecx.tcx, variant.node.id)); - match variant.node.kind { - ast::tuple_variant_kind(ref args) - if args.len() > 0 && generics.ty_params.len() == 0 => { - encode_symbol(ecx, ebml_w, variant.node.id); - } - ast::tuple_variant_kind(_) | ast::struct_variant_kind(_) => {} - } - encode_discriminant(ecx, ebml_w, variant.node.id); - if vi[i].disr_val != disr_val { - encode_disr_val(ecx, ebml_w, vi[i].disr_val); - disr_val = vi[i].disr_val; - } - encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); - encode_path(ecx, ebml_w, path, - ast_map::path_name(variant.node.name)); - ebml_w.end_tag(); - disr_val += 1; - i += 1; - } -} - -#[cfg(not(stage0))] fn encode_enum_variant_info(ecx: @EncodeContext, ebml_w: &mut writer::Encoder, id: node_id, @@ -639,31 +349,6 @@ fn encode_enum_variant_info(ecx: @EncodeContext, } } -#[cfg(stage0)] -fn encode_path(ecx: @EncodeContext, - ebml_w: &writer::Encoder, - path: &[ast_map::path_elt], - name: ast_map::path_elt) { - fn encode_path_elt(ecx: @EncodeContext, ebml_w: &writer::Encoder, - elt: ast_map::path_elt) { - let (tag, name) = match elt { - ast_map::path_mod(name) => (tag_path_elt_mod, name), - ast_map::path_name(name) => (tag_path_elt_name, name) - }; - - ebml_w.wr_tagged_str(tag, *ecx.tcx.sess.str_of(name)); - } - - do ebml_w.wr_tag(tag_path) { - ebml_w.wr_tagged_u32(tag_path_len, (path.len() + 1) as u32); - for path.each |pe| { - encode_path_elt(ecx, ebml_w, *pe); - } - encode_path_elt(ecx, ebml_w, name); - } -} - -#[cfg(not(stage0))] fn encode_path(ecx: @EncodeContext, ebml_w: &mut writer::Encoder, path: &[ast_map::path_elt], @@ -688,9 +373,8 @@ fn encode_path(ecx: @EncodeContext, ebml_w.end_tag(); } -#[cfg(stage0)] fn encode_info_for_mod(ecx: @EncodeContext, - ebml_w: &writer::Encoder, + ebml_w: &mut writer::Encoder, md: &_mod, id: node_id, path: &[ast_map::path_elt], @@ -750,101 +434,15 @@ fn encode_info_for_mod(ecx: @EncodeContext, ebml_w.end_tag(); } -#[cfg(not(stage0))] -fn encode_info_for_mod(ecx: @EncodeContext, - ebml_w: &mut writer::Encoder, - md: &_mod, - id: node_id, - path: &[ast_map::path_elt], - name: ident) { - ebml_w.start_tag(tag_items_data_item); - encode_def_id(ebml_w, local_def(id)); - encode_family(ebml_w, 'm'); - encode_name(ecx, ebml_w, name); - debug!("(encoding info for module) encoding info for module ID %d", id); +fn encode_struct_field_family(ebml_w: &mut writer::Encoder, + visibility: visibility) { + encode_family(ebml_w, match visibility { + public => 'g', + private => 'j', + inherited => 'N' + }); +} - // Encode info about all the module children. - for md.items.each |item| { - match item.node { - item_impl(*) => { - let (ident, did) = (item.ident, item.id); - debug!("(encoding info for module) ... encoding impl %s \ - (%?/%?)", - *ecx.tcx.sess.str_of(ident), - did, - ast_map::node_id_to_str(ecx.tcx.items, did, ecx.tcx - .sess.parse_sess.interner)); - - ebml_w.start_tag(tag_mod_impl); - ebml_w.wr_str(def_to_str(local_def(did))); - ebml_w.end_tag(); - } - _ => {} // FIXME #4573: Encode these too. - } - } - - encode_path(ecx, ebml_w, path, ast_map::path_mod(name)); - - // Encode the reexports of this module. - debug!("(encoding info for module) encoding reexports for %d", id); - match ecx.reexports2.find(&id) { - Some(ref exports) => { - debug!("(encoding info for module) found reexports for %d", id); - for exports.each |exp| { - debug!("(encoding info for module) reexport '%s' for %d", - *exp.name, id); - ebml_w.start_tag(tag_items_data_item_reexport); - ebml_w.start_tag(tag_items_data_item_reexport_def_id); - ebml_w.wr_str(def_to_str(exp.def_id)); - ebml_w.end_tag(); - ebml_w.start_tag(tag_items_data_item_reexport_name); - ebml_w.wr_str(*exp.name); - ebml_w.end_tag(); - ebml_w.end_tag(); - } - } - None => { - debug!("(encoding info for module) found no reexports for %d", - id); - } - } - - ebml_w.end_tag(); -} - -#[cfg(stage0)] -fn encode_struct_field_family(ebml_w: &writer::Encoder, - visibility: visibility) { - encode_family(ebml_w, match visibility { - public => 'g', - private => 'j', - inherited => 'N' - }); -} - -#[cfg(not(stage0))] -fn encode_struct_field_family(ebml_w: &mut writer::Encoder, - visibility: visibility) { - encode_family(ebml_w, match visibility { - public => 'g', - private => 'j', - inherited => 'N' - }); -} - -#[cfg(stage0)] -fn encode_visibility(ebml_w: &writer::Encoder, visibility: visibility) { - ebml_w.start_tag(tag_items_data_item_visibility); - let ch = match visibility { - public => 'y', - private => 'n', - inherited => 'i', - }; - ebml_w.wr_str(str::from_char(ch)); - ebml_w.end_tag(); -} - -#[cfg(not(stage0))] fn encode_visibility(ebml_w: &mut writer::Encoder, visibility: visibility) { ebml_w.start_tag(tag_items_data_item_visibility); let ch = match visibility { @@ -856,52 +454,6 @@ fn encode_visibility(ebml_w: &mut writer::Encoder, visibility: visibility) { ebml_w.end_tag(); } -#[cfg(stage0)] -fn encode_self_type(ebml_w: &writer::Encoder, self_type: ast::self_ty_) { - ebml_w.start_tag(tag_item_trait_method_self_ty); - - // Encode the base self type. - match self_type { - sty_static => { - ebml_w.writer.write(&[ 's' as u8 ]); - } - sty_value => { - ebml_w.writer.write(&[ 'v' as u8 ]); - } - sty_region(_, m) => { - // FIXME(#4846) encode custom lifetime - ebml_w.writer.write(&[ '&' as u8 ]); - encode_mutability(ebml_w, m); - } - sty_box(m) => { - ebml_w.writer.write(&[ '@' as u8 ]); - encode_mutability(ebml_w, m); - } - sty_uniq(m) => { - ebml_w.writer.write(&[ '~' as u8 ]); - encode_mutability(ebml_w, m); - } - } - - ebml_w.end_tag(); - - fn encode_mutability(ebml_w: &writer::Encoder, - m: ast::mutability) { - match m { - m_imm => { - ebml_w.writer.write(&[ 'i' as u8 ]); - } - m_mutbl => { - ebml_w.writer.write(&[ 'm' as u8 ]); - } - m_const => { - ebml_w.writer.write(&[ 'c' as u8 ]); - } - } - } -} - -#[cfg(not(stage0))] fn encode_self_type(ebml_w: &mut writer::Encoder, self_type: ast::self_ty_) { ebml_w.start_tag(tag_item_trait_method_self_ty); @@ -946,14 +498,6 @@ fn encode_self_type(ebml_w: &mut writer::Encoder, self_type: ast::self_ty_) { } } -#[cfg(stage0)] -fn encode_method_sort(ebml_w: &writer::Encoder, sort: char) { - ebml_w.start_tag(tag_item_trait_method_sort); - ebml_w.writer.write(&[ sort as u8 ]); - ebml_w.end_tag(); -} - -#[cfg(not(stage0))] fn encode_method_sort(ebml_w: &mut writer::Encoder, sort: char) { ebml_w.start_tag(tag_item_trait_method_sort); ebml_w.writer.write(&[ sort as u8 ]); @@ -961,47 +505,6 @@ fn encode_method_sort(ebml_w: &mut writer::Encoder, sort: char) { } /* Returns an index of items in this class */ -#[cfg(stage0)] -fn encode_info_for_struct(ecx: @EncodeContext, - ebml_w: &writer::Encoder, - path: &[ast_map::path_elt], - fields: &[@struct_field], - global_index: @mut~[entry]) - -> ~[entry] { - /* Each class has its own index, since different classes - may have fields with the same name */ - let index = @mut ~[]; - let tcx = ecx.tcx; - /* We encode both private and public fields -- need to include - private fields to get the offsets right */ - for fields.each |field| { - let (nm, mt, vis) = match field.node.kind { - named_field(nm, mt, vis) => (nm, mt, vis), - unnamed_field => ( - special_idents::unnamed_field, - struct_immutable, - inherited - ) - }; - - let id = field.node.id; - index.push(entry {val: id, pos: ebml_w.writer.tell()}); - global_index.push(entry {val: id, pos: ebml_w.writer.tell()}); - ebml_w.start_tag(tag_items_data_item); - debug!("encode_info_for_struct: doing %s %d", - *tcx.sess.str_of(nm), id); - encode_struct_field_family(ebml_w, vis); - encode_name(ecx, ebml_w, nm); - encode_path(ecx, ebml_w, path, ast_map::path_name(nm)); - encode_type(ecx, ebml_w, node_id_to_type(tcx, id)); - encode_mutability(ebml_w, mt); - encode_def_id(ebml_w, local_def(id)); - ebml_w.end_tag(); - } - /*bad*/copy *index -} - -#[cfg(not(stage0))] fn encode_info_for_struct(ecx: @EncodeContext, ebml_w: &mut writer::Encoder, path: &[ast_map::path_elt], @@ -1042,37 +545,6 @@ fn encode_info_for_struct(ecx: @EncodeContext, } // This is for encoding info for ctors and dtors -#[cfg(stage0)] -fn encode_info_for_ctor(ecx: @EncodeContext, - ebml_w: &writer::Encoder, - id: node_id, - ident: ident, - path: &[ast_map::path_elt], - item: Option, - generics: &ast::Generics) { - ebml_w.start_tag(tag_items_data_item); - encode_name(ecx, ebml_w, ident); - encode_def_id(ebml_w, local_def(id)); - encode_family(ebml_w, purity_fn_family(ast::impure_fn)); - encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); - let its_ty = node_id_to_type(ecx.tcx, id); - debug!("fn name = %s ty = %s its node id = %d", - *ecx.tcx.sess.str_of(ident), - ty_to_str(ecx.tcx, its_ty), id); - encode_type(ecx, ebml_w, its_ty); - encode_path(ecx, ebml_w, path, ast_map::path_name(ident)); - match item { - Some(it) => { - (ecx.encode_inlined_item)(ecx, ebml_w, path, it); - } - None => { - encode_symbol(ecx, ebml_w, id); - } - } - ebml_w.end_tag(); -} - -#[cfg(not(stage0))] fn encode_info_for_ctor(ecx: @EncodeContext, ebml_w: &mut writer::Encoder, id: node_id, @@ -1094,512 +566,121 @@ fn encode_info_for_ctor(ecx: @EncodeContext, match item { Some(it) => { (ecx.encode_inlined_item)(ecx, ebml_w, path, it); - } - None => { - encode_symbol(ecx, ebml_w, id); - } - } - ebml_w.end_tag(); -} - -#[cfg(stage0)] -fn encode_info_for_struct_ctor(ecx: @EncodeContext, - ebml_w: &writer::Encoder, - path: &[ast_map::path_elt], - name: ast::ident, - ctor_id: node_id, - index: @mut ~[entry]) { - index.push(entry { val: ctor_id, pos: ebml_w.writer.tell() }); - - ebml_w.start_tag(tag_items_data_item); - encode_def_id(ebml_w, local_def(ctor_id)); - encode_family(ebml_w, 'f'); - encode_name(ecx, ebml_w, name); - encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, ctor_id)); - encode_path(ecx, ebml_w, path, ast_map::path_name(name)); - - if ecx.item_symbols.contains_key(&ctor_id) { - encode_symbol(ecx, ebml_w, ctor_id); - } - - ebml_w.end_tag(); -} - -#[cfg(not(stage0))] -fn encode_info_for_struct_ctor(ecx: @EncodeContext, - ebml_w: &mut writer::Encoder, - path: &[ast_map::path_elt], - name: ast::ident, - ctor_id: node_id, - index: @mut ~[entry]) { - index.push(entry { val: ctor_id, pos: ebml_w.writer.tell() }); - - ebml_w.start_tag(tag_items_data_item); - encode_def_id(ebml_w, local_def(ctor_id)); - encode_family(ebml_w, 'f'); - encode_name(ecx, ebml_w, name); - encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, ctor_id)); - encode_path(ecx, ebml_w, path, ast_map::path_name(name)); - - if ecx.item_symbols.contains_key(&ctor_id) { - encode_symbol(ecx, ebml_w, ctor_id); - } - - ebml_w.end_tag(); -} - -#[cfg(stage0)] -fn encode_method_ty_fields(ecx: @EncodeContext, - ebml_w: &writer::Encoder, - method_ty: &ty::method) { - encode_def_id(ebml_w, method_ty.def_id); - encode_name(ecx, ebml_w, method_ty.ident); - encode_ty_type_param_defs(ebml_w, ecx, - method_ty.generics.type_param_defs, - tag_item_method_tps); - encode_transformed_self_ty(ecx, ebml_w, method_ty.transformed_self_ty); - encode_method_fty(ecx, ebml_w, &method_ty.fty); - encode_visibility(ebml_w, method_ty.vis); - encode_self_type(ebml_w, method_ty.self_ty); -} - -#[cfg(not(stage0))] -fn encode_method_ty_fields(ecx: @EncodeContext, - ebml_w: &mut writer::Encoder, - method_ty: &ty::method) { - encode_def_id(ebml_w, method_ty.def_id); - encode_name(ecx, ebml_w, method_ty.ident); - encode_ty_type_param_defs(ebml_w, ecx, - method_ty.generics.type_param_defs, - tag_item_method_tps); - encode_transformed_self_ty(ecx, ebml_w, method_ty.transformed_self_ty); - encode_method_fty(ecx, ebml_w, &method_ty.fty); - encode_visibility(ebml_w, method_ty.vis); - encode_self_type(ebml_w, method_ty.self_ty); -} - -#[cfg(stage0)] -fn encode_info_for_method(ecx: @EncodeContext, - ebml_w: &writer::Encoder, - impl_path: &[ast_map::path_elt], - should_inline: bool, - parent_id: node_id, - m: @method, - owner_generics: &ast::Generics, - method_generics: &ast::Generics) { - debug!("encode_info_for_method: %d %s %u %u", m.id, - *ecx.tcx.sess.str_of(m.ident), - owner_generics.ty_params.len(), - method_generics.ty_params.len()); - ebml_w.start_tag(tag_items_data_item); - - let method_def_id = local_def(m.id); - let method_ty: @ty::method = ty::method(ecx.tcx, method_def_id); - encode_method_ty_fields(ecx, ebml_w, method_ty); - - match m.self_ty.node { - ast::sty_static => { - encode_family(ebml_w, purity_static_method_family(m.purity)); - } - _ => encode_family(ebml_w, purity_fn_family(m.purity)) - } - - let mut combined_ty_params = opt_vec::Empty; - combined_ty_params.push_all(&owner_generics.ty_params); - combined_ty_params.push_all(&method_generics.ty_params); - let len = combined_ty_params.len(); - encode_type_param_bounds(ebml_w, ecx, &combined_ty_params); - - encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, m.id)); - encode_path(ecx, ebml_w, impl_path, ast_map::path_name(m.ident)); - - if len > 0u || should_inline { - (ecx.encode_inlined_item)( - ecx, ebml_w, impl_path, - ii_method(local_def(parent_id), m)); - } else { - encode_symbol(ecx, ebml_w, m.id); - } - - ebml_w.end_tag(); -} - -#[cfg(not(stage0))] -fn encode_info_for_method(ecx: @EncodeContext, - ebml_w: &mut writer::Encoder, - impl_path: &[ast_map::path_elt], - should_inline: bool, - parent_id: node_id, - m: @method, - owner_generics: &ast::Generics, - method_generics: &ast::Generics) { - debug!("encode_info_for_method: %d %s %u %u", m.id, - *ecx.tcx.sess.str_of(m.ident), - owner_generics.ty_params.len(), - method_generics.ty_params.len()); - ebml_w.start_tag(tag_items_data_item); - - let method_def_id = local_def(m.id); - let method_ty: @ty::method = ty::method(ecx.tcx, method_def_id); - encode_method_ty_fields(ecx, ebml_w, method_ty); - - match m.self_ty.node { - ast::sty_static => { - encode_family(ebml_w, purity_static_method_family(m.purity)); - } - _ => encode_family(ebml_w, purity_fn_family(m.purity)) - } - - let mut combined_ty_params = opt_vec::Empty; - combined_ty_params.push_all(&owner_generics.ty_params); - combined_ty_params.push_all(&method_generics.ty_params); - let len = combined_ty_params.len(); - encode_type_param_bounds(ebml_w, ecx, &combined_ty_params); - - encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, m.id)); - encode_path(ecx, ebml_w, impl_path, ast_map::path_name(m.ident)); - - if len > 0u || should_inline { - (ecx.encode_inlined_item)( - ecx, ebml_w, impl_path, - ii_method(local_def(parent_id), m)); - } else { - encode_symbol(ecx, ebml_w, m.id); - } - - ebml_w.end_tag(); -} - -fn purity_fn_family(p: purity) -> char { - match p { - unsafe_fn => 'u', - pure_fn => 'p', - impure_fn => 'f', - extern_fn => 'e' - } -} - -fn purity_static_method_family(p: purity) -> char { - match p { - unsafe_fn => 'U', - pure_fn => 'P', - impure_fn => 'F', - _ => fail!(~"extern fn can't be static") - } -} - - -fn should_inline(attrs: &[attribute]) -> bool { - match attr::find_inline_attr(attrs) { - attr::ia_none | attr::ia_never => false, - attr::ia_hint | attr::ia_always => true - } -} - -#[cfg(stage0)] -fn encode_info_for_item(ecx: @EncodeContext, - ebml_w: &writer::Encoder, - item: @item, - index: @mut ~[entry], - path: &[ast_map::path_elt]) { - let tcx = ecx.tcx; - let must_write = - match item.node { - item_enum(_, _) | item_impl(*) | item_trait(*) | item_struct(*) | - item_mod(*) | item_foreign_mod(*) | item_const(*) => true, - _ => false - }; - if !must_write && !reachable(ecx, item.id) { return; } - - fn add_to_index_(item: @item, ebml_w: &writer::Encoder, - index: @mut ~[entry]) { - index.push(entry { val: item.id, pos: ebml_w.writer.tell() }); - } - let add_to_index: &fn() = || add_to_index_(item, ebml_w, index); - - debug!("encoding info for item at %s", - ecx.tcx.sess.codemap.span_to_str(item.span)); - - match item.node { - item_const(_, _) => { - add_to_index(); - ebml_w.start_tag(tag_items_data_item); - encode_def_id(ebml_w, local_def(item.id)); - encode_family(ebml_w, 'c'); - encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); - encode_symbol(ecx, ebml_w, item.id); - encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); - (ecx.encode_inlined_item)(ecx, ebml_w, path, ii_item(item)); - ebml_w.end_tag(); - } - item_fn(_, purity, _, ref generics, _) => { - add_to_index(); - ebml_w.start_tag(tag_items_data_item); - encode_def_id(ebml_w, local_def(item.id)); - encode_family(ebml_w, purity_fn_family(purity)); - let tps_len = generics.ty_params.len(); - encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); - encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); - encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); - encode_attributes(ebml_w, item.attrs); - if tps_len > 0u || should_inline(item.attrs) { - (ecx.encode_inlined_item)(ecx, ebml_w, path, ii_item(item)); - } else { - encode_symbol(ecx, ebml_w, item.id); - } - ebml_w.end_tag(); - } - item_mod(ref m) => { - add_to_index(); - encode_info_for_mod(ecx, ebml_w, m, item.id, path, item.ident); - } - item_foreign_mod(_) => { - add_to_index(); - ebml_w.start_tag(tag_items_data_item); - encode_def_id(ebml_w, local_def(item.id)); - encode_family(ebml_w, 'n'); - encode_name(ecx, ebml_w, item.ident); - encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); - ebml_w.end_tag(); - } - item_ty(_, ref generics) => { - add_to_index(); - ebml_w.start_tag(tag_items_data_item); - encode_def_id(ebml_w, local_def(item.id)); - encode_family(ebml_w, 'y'); - encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); - encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); - encode_name(ecx, ebml_w, item.ident); - encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); - encode_region_param(ecx, ebml_w, item); - ebml_w.end_tag(); - } - item_enum(ref enum_definition, ref generics) => { - add_to_index(); - do ebml_w.wr_tag(tag_items_data_item) { - encode_def_id(ebml_w, local_def(item.id)); - encode_family(ebml_w, 't'); - encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); - encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); - encode_name(ecx, ebml_w, item.ident); - for (*enum_definition).variants.each |v| { - encode_variant_id(ebml_w, local_def(v.node.id)); - } - (ecx.encode_inlined_item)(ecx, ebml_w, path, ii_item(item)); - encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); - encode_region_param(ecx, ebml_w, item); - } - encode_enum_variant_info(ecx, - ebml_w, - item.id, - (*enum_definition).variants, - path, - index, - generics); - } - item_struct(struct_def, ref generics) => { - /* First, encode the fields - These come first because we need to write them to make - the index, and the index needs to be in the item for the - class itself */ - let idx = encode_info_for_struct(ecx, ebml_w, path, - struct_def.fields, index); - - /* Index the class*/ - add_to_index(); - - /* Now, make an item for the class itself */ - ebml_w.start_tag(tag_items_data_item); - encode_def_id(ebml_w, local_def(item.id)); - encode_family(ebml_w, 'S'); - encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); - encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); - - // If this is a tuple- or enum-like struct, encode the type of the - // constructor. - if struct_def.fields.len() > 0 && - struct_def.fields[0].node.kind == ast::unnamed_field { - let ctor_id = match struct_def.ctor_id { - Some(ctor_id) => ctor_id, - None => ecx.tcx.sess.bug(~"struct def didn't have ctor id"), - }; - - encode_info_for_struct_ctor(ecx, - ebml_w, - path, - item.ident, - ctor_id, - index); - } - - encode_name(ecx, ebml_w, item.ident); - encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); - encode_region_param(ecx, ebml_w, item); - - /* Encode def_ids for each field and method - for methods, write all the stuff get_trait_method - needs to know*/ - for struct_def.fields.each |f| { - match f.node.kind { - named_field(ident, _, vis) => { - ebml_w.start_tag(tag_item_field); - encode_struct_field_family(ebml_w, vis); - encode_name(ecx, ebml_w, ident); - encode_def_id(ebml_w, local_def(f.node.id)); - ebml_w.end_tag(); - } - unnamed_field => { - ebml_w.start_tag(tag_item_unnamed_field); - encode_def_id(ebml_w, local_def(f.node.id)); - ebml_w.end_tag(); - } - } - } - - /* Each class has its own index -- encode it */ - let bkts = create_index(idx); - encode_index(ebml_w, bkts, write_int); - ebml_w.end_tag(); - } - item_impl(ref generics, opt_trait, ty, ref methods) => { - add_to_index(); - ebml_w.start_tag(tag_items_data_item); - encode_def_id(ebml_w, local_def(item.id)); - encode_family(ebml_w, 'i'); - encode_region_param(ecx, ebml_w, item); - encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); - encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); - encode_name(ecx, ebml_w, item.ident); - encode_attributes(ebml_w, item.attrs); - match ty.node { - ast::ty_path(path, _) if path.idents.len() == 1 => { - encode_impl_type_basename(ecx, ebml_w, - ast_util::path_to_ident(path)); - } - _ => {} - } - for methods.each |m| { - ebml_w.start_tag(tag_item_impl_method); - let method_def_id = local_def(m.id); - ebml_w.writer.write(str::to_bytes(def_to_str(method_def_id))); - ebml_w.end_tag(); - } - for opt_trait.each |ast_trait_ref| { - let trait_ref = ty::node_id_to_trait_ref(ecx.tcx, ast_trait_ref.ref_id); - encode_trait_ref(ebml_w, ecx, trait_ref, tag_item_trait_ref); - } - encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); - ebml_w.end_tag(); - - // >:-< - let mut impl_path = vec::append(~[], path); - impl_path += ~[ast_map::path_name(item.ident)]; - - for methods.each |m| { - index.push(entry {val: m.id, pos: ebml_w.writer.tell()}); - encode_info_for_method(ecx, - ebml_w, - impl_path, - should_inline(m.attrs), - item.id, - *m, - generics, - &m.generics); - } - } - item_trait(ref generics, ref super_traits, ref ms) => { - add_to_index(); - ebml_w.start_tag(tag_items_data_item); - encode_def_id(ebml_w, local_def(item.id)); - encode_family(ebml_w, 'I'); - encode_region_param(ecx, ebml_w, item); - encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); - let trait_def = ty::lookup_trait_def(tcx, local_def(item.id)); - encode_trait_ref(ebml_w, ecx, trait_def.trait_ref, tag_item_trait_ref); - encode_name(ecx, ebml_w, item.ident); - encode_attributes(ebml_w, item.attrs); - for ty::trait_method_def_ids(tcx, local_def(item.id)).each |&method_def_id| { - ebml_w.start_tag(tag_item_trait_method); - encode_def_id(ebml_w, method_def_id); - ebml_w.end_tag(); - } - encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident)); - for super_traits.each |ast_trait_ref| { - let trait_ref = ty::node_id_to_trait_ref(ecx.tcx, ast_trait_ref.ref_id); - encode_trait_ref(ebml_w, ecx, trait_ref, tag_item_super_trait_ref); + } + None => { + encode_symbol(ecx, ebml_w, id); + } } ebml_w.end_tag(); +} - // Now output the method info for each method. - for ty::trait_method_def_ids(tcx, local_def(item.id)).eachi |i, &method_def_id| { - assert!(method_def_id.crate == ast::local_crate); +fn encode_info_for_struct_ctor(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + path: &[ast_map::path_elt], + name: ast::ident, + ctor_id: node_id, + index: @mut ~[entry]) { + index.push(entry { val: ctor_id, pos: ebml_w.writer.tell() }); - let method_ty: @ty::method = ty::method(tcx, method_def_id); + ebml_w.start_tag(tag_items_data_item); + encode_def_id(ebml_w, local_def(ctor_id)); + encode_family(ebml_w, 'f'); + encode_name(ecx, ebml_w, name); + encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, ctor_id)); + encode_path(ecx, ebml_w, path, ast_map::path_name(name)); - index.push(entry {val: method_def_id.node, pos: ebml_w.writer.tell()}); + if ecx.item_symbols.contains_key(&ctor_id) { + encode_symbol(ecx, ebml_w, ctor_id); + } - ebml_w.start_tag(tag_items_data_item); + ebml_w.end_tag(); +} - encode_method_ty_fields(ecx, ebml_w, method_ty); +fn encode_method_ty_fields(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + method_ty: &ty::method) { + encode_def_id(ebml_w, method_ty.def_id); + encode_name(ecx, ebml_w, method_ty.ident); + encode_ty_type_param_defs(ebml_w, ecx, + method_ty.generics.type_param_defs, + tag_item_method_tps); + encode_transformed_self_ty(ecx, ebml_w, method_ty.transformed_self_ty); + encode_method_fty(ecx, ebml_w, &method_ty.fty); + encode_visibility(ebml_w, method_ty.vis); + encode_self_type(ebml_w, method_ty.self_ty); +} - encode_parent_item(ebml_w, local_def(item.id)); +fn encode_info_for_method(ecx: @EncodeContext, + ebml_w: &mut writer::Encoder, + impl_path: &[ast_map::path_elt], + should_inline: bool, + parent_id: node_id, + m: @method, + owner_generics: &ast::Generics, + method_generics: &ast::Generics) { + debug!("encode_info_for_method: %d %s %u %u", m.id, + *ecx.tcx.sess.str_of(m.ident), + owner_generics.ty_params.len(), + method_generics.ty_params.len()); + ebml_w.start_tag(tag_items_data_item); - let mut trait_path = vec::append(~[], path); - trait_path.push(ast_map::path_name(item.ident)); - encode_path(ecx, ebml_w, trait_path, ast_map::path_name(method_ty.ident)); + let method_def_id = local_def(m.id); + let method_ty: @ty::method = ty::method(ecx.tcx, method_def_id); + encode_method_ty_fields(ecx, ebml_w, method_ty); - match method_ty.self_ty { - sty_static => { - encode_family(ebml_w, - purity_static_method_family( - method_ty.fty.purity)); + match m.self_ty.node { + ast::sty_static => { + encode_family(ebml_w, purity_static_method_family(m.purity)); + } + _ => encode_family(ebml_w, purity_fn_family(m.purity)) + } - let tpt = ty::lookup_item_type(tcx, method_def_id); - encode_ty_type_param_defs(ebml_w, ecx, - tpt.generics.type_param_defs, - tag_items_data_item_ty_param_bounds); - encode_type(ecx, ebml_w, tpt.ty); - } + let mut combined_ty_params = opt_vec::Empty; + combined_ty_params.push_all(&owner_generics.ty_params); + combined_ty_params.push_all(&method_generics.ty_params); + let len = combined_ty_params.len(); + encode_type_param_bounds(ebml_w, ecx, &combined_ty_params); - _ => { - encode_family(ebml_w, - purity_fn_family( - method_ty.fty.purity)); - } - } + encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, m.id)); + encode_path(ecx, ebml_w, impl_path, ast_map::path_name(m.ident)); - match ms[i] { - required(_) => { - encode_method_sort(ebml_w, 'r'); - } + if len > 0u || should_inline { + (ecx.encode_inlined_item)( + ecx, ebml_w, impl_path, + ii_method(local_def(parent_id), m)); + } else { + encode_symbol(ecx, ebml_w, m.id); + } - provided(m) => { - // This is obviously a bogus assert but I don't think this - // ever worked before anyhow...near as I can tell, before - // we would emit two items. - if method_ty.self_ty == sty_static { - tcx.sess.span_unimpl( - item.span, - fmt!("Method %s is both provided and static", - *tcx.sess.intr().get(method_ty.ident))); - } - encode_type_param_bounds(ebml_w, ecx, - &m.generics.ty_params); - encode_method_sort(ebml_w, 'p'); - (ecx.encode_inlined_item)( - ecx, ebml_w, path, - ii_method(local_def(item.id), m)); - } - } + ebml_w.end_tag(); +} - ebml_w.end_tag(); - } - } - item_mac(*) => fail!(~"item macros unimplemented") +fn purity_fn_family(p: purity) -> char { + match p { + unsafe_fn => 'u', + pure_fn => 'p', + impure_fn => 'f', + extern_fn => 'e' + } +} + +fn purity_static_method_family(p: purity) -> char { + match p { + unsafe_fn => 'U', + pure_fn => 'P', + impure_fn => 'F', + _ => fail!(~"extern fn can't be static") + } +} + + +fn should_inline(attrs: &[attribute]) -> bool { + match attr::find_inline_attr(attrs) { + attr::ia_none | attr::ia_never => false, + attr::ia_hint | attr::ia_always => true } } -#[cfg(not(stage0))] fn encode_info_for_item(ecx: @EncodeContext, ebml_w: &mut writer::Encoder, item: @item, @@ -1904,42 +985,6 @@ fn encode_info_for_item(ecx: @EncodeContext, } } -#[cfg(stage0)] -fn encode_info_for_foreign_item(ecx: @EncodeContext, - ebml_w: &writer::Encoder, - nitem: @foreign_item, - index: @mut ~[entry], - path: ast_map::path, - abi: AbiSet) { - if !reachable(ecx, nitem.id) { return; } - index.push(entry { val: nitem.id, pos: ebml_w.writer.tell() }); - - ebml_w.start_tag(tag_items_data_item); - match nitem.node { - foreign_item_fn(_, purity, ref generics) => { - encode_def_id(ebml_w, local_def(nitem.id)); - encode_family(ebml_w, purity_fn_family(purity)); - encode_type_param_bounds(ebml_w, ecx, &generics.ty_params); - encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, nitem.id)); - if abi.is_intrinsic() { - (ecx.encode_inlined_item)(ecx, ebml_w, path, ii_foreign(nitem)); - } else { - encode_symbol(ecx, ebml_w, nitem.id); - } - encode_path(ecx, ebml_w, path, ast_map::path_name(nitem.ident)); - } - foreign_item_const(*) => { - encode_def_id(ebml_w, local_def(nitem.id)); - encode_family(ebml_w, 'c'); - encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, nitem.id)); - encode_symbol(ecx, ebml_w, nitem.id); - encode_path(ecx, ebml_w, path, ast_map::path_name(nitem.ident)); - } - } - ebml_w.end_tag(); -} - -#[cfg(not(stage0))] fn encode_info_for_foreign_item(ecx: @EncodeContext, ebml_w: &mut writer::Encoder, nitem: @foreign_item, @@ -1974,54 +1019,6 @@ fn encode_info_for_foreign_item(ecx: @EncodeContext, ebml_w.end_tag(); } -#[cfg(stage0)] -fn encode_info_for_items(ecx: @EncodeContext, - ebml_w: &writer::Encoder, - crate: &crate) - -> ~[entry] { - let index = @mut ~[]; - ebml_w.start_tag(tag_items_data); - index.push(entry { val: crate_node_id, pos: ebml_w.writer.tell() }); - encode_info_for_mod(ecx, ebml_w, &crate.node.module, - crate_node_id, ~[], - syntax::parse::token::special_idents::invalid); - visit::visit_crate(crate, (), visit::mk_vt(@visit::Visitor { - visit_expr: |_e, _cx, _v| { }, - visit_item: { - let ebml_w = copy *ebml_w; - |i, cx, v| { - visit::visit_item(i, cx, v); - match *ecx.tcx.items.get(&i.id) { - ast_map::node_item(_, pt) => { - encode_info_for_item(ecx, &ebml_w, i, - index, *pt); - } - _ => fail!(~"bad item") - } - } - }, - visit_foreign_item: { - let ebml_w = copy *ebml_w; - |ni, cx, v| { - visit::visit_foreign_item(ni, cx, v); - match *ecx.tcx.items.get(&ni.id) { - ast_map::node_foreign_item(_, abi, _, pt) => { - encode_info_for_foreign_item(ecx, &ebml_w, ni, - index, /*bad*/copy *pt, - abi); - } - // case for separate item and foreign-item tables - _ => fail!(~"bad foreign item") - } - } - }, - ..*visit::default_visitor() - })); - ebml_w.end_tag(); - return /*bad*/copy *index; -} - -#[cfg(not(stage0))] fn encode_info_for_items(ecx: @EncodeContext, ebml_w: &mut writer::Encoder, crate: &crate) @@ -2077,51 +1074,20 @@ fn encode_info_for_items(ecx: @EncodeContext, fn create_index(index: ~[entry]) -> ~[@~[entry]] { - let mut buckets: ~[@mut ~[entry]] = ~[]; - for uint::range(0u, 256u) |_i| { buckets.push(@mut ~[]); }; - for index.each |elt| { - let h = elt.val.hash() as uint; - buckets[h % 256].push(*elt); - } - - let mut buckets_frozen = ~[]; - for buckets.each |bucket| { - buckets_frozen.push(@/*bad*/copy **bucket); - } - return buckets_frozen; -} - -#[cfg(stage0)] -fn encode_index(ebml_w: &writer::Encoder, - buckets: ~[@~[entry]], - write_fn: &fn(@io::Writer, &T)) { - let writer = ebml_w.writer; - ebml_w.start_tag(tag_index); - let mut bucket_locs: ~[uint] = ~[]; - ebml_w.start_tag(tag_index_buckets); - for buckets.each |bucket| { - bucket_locs.push(ebml_w.writer.tell()); - ebml_w.start_tag(tag_index_buckets_bucket); - for vec::each(**bucket) |elt| { - ebml_w.start_tag(tag_index_buckets_bucket_elt); - assert!(elt.pos < 0xffff_ffff); - writer.write_be_u32(elt.pos as u32); - write_fn(writer, &elt.val); - ebml_w.end_tag(); - } - ebml_w.end_tag(); + let mut buckets: ~[@mut ~[entry]] = ~[]; + for uint::range(0u, 256u) |_i| { buckets.push(@mut ~[]); }; + for index.each |elt| { + let h = elt.val.hash() as uint; + buckets[h % 256].push(*elt); } - ebml_w.end_tag(); - ebml_w.start_tag(tag_index_table); - for bucket_locs.each |pos| { - assert!(*pos < 0xffff_ffff); - writer.write_be_u32(*pos as u32); + + let mut buckets_frozen = ~[]; + for buckets.each |bucket| { + buckets_frozen.push(@/*bad*/copy **bucket); } - ebml_w.end_tag(); - ebml_w.end_tag(); + return buckets_frozen; } -#[cfg(not(stage0))] fn encode_index(ebml_w: &mut writer::Encoder, buckets: ~[@~[entry]], write_fn: &fn(@io::Writer, &T)) { @@ -2160,45 +1126,6 @@ fn write_int(writer: @io::Writer, &n: &int) { writer.write_be_u32(n as u32); } -#[cfg(stage0)] -fn encode_meta_item(ebml_w: &writer::Encoder, mi: @meta_item) { - match mi.node { - meta_word(name) => { - ebml_w.start_tag(tag_meta_item_word); - ebml_w.start_tag(tag_meta_item_name); - ebml_w.writer.write(str::to_bytes(*name)); - ebml_w.end_tag(); - ebml_w.end_tag(); - } - meta_name_value(name, value) => { - match value.node { - lit_str(value) => { - ebml_w.start_tag(tag_meta_item_name_value); - ebml_w.start_tag(tag_meta_item_name); - ebml_w.writer.write(str::to_bytes(*name)); - ebml_w.end_tag(); - ebml_w.start_tag(tag_meta_item_value); - ebml_w.writer.write(str::to_bytes(*value)); - ebml_w.end_tag(); - ebml_w.end_tag(); - } - _ => {/* FIXME (#623): encode other variants */ } - } - } - meta_list(name, ref items) => { - ebml_w.start_tag(tag_meta_item_list); - ebml_w.start_tag(tag_meta_item_name); - ebml_w.writer.write(str::to_bytes(*name)); - ebml_w.end_tag(); - for items.each |inner_item| { - encode_meta_item(ebml_w, *inner_item); - } - ebml_w.end_tag(); - } - } -} - -#[cfg(not(stage0))] fn encode_meta_item(ebml_w: &mut writer::Encoder, mi: @meta_item) { match mi.node { meta_word(name) => { @@ -2236,18 +1163,6 @@ fn encode_meta_item(ebml_w: &mut writer::Encoder, mi: @meta_item) { } } -#[cfg(stage0)] -fn encode_attributes(ebml_w: &writer::Encoder, attrs: &[attribute]) { - ebml_w.start_tag(tag_attributes); - for attrs.each |attr| { - ebml_w.start_tag(tag_attribute); - encode_meta_item(ebml_w, attr.node.value); - ebml_w.end_tag(); - } - ebml_w.end_tag(); -} - -#[cfg(not(stage0))] fn encode_attributes(ebml_w: &mut writer::Encoder, attrs: &[attribute]) { ebml_w.start_tag(tag_attributes); for attrs.each |attr| { @@ -2312,50 +1227,6 @@ fn synthesize_crate_attrs(ecx: @EncodeContext, return attrs; } -#[cfg(stage0)] -fn encode_crate_deps(ecx: @EncodeContext, - ebml_w: &writer::Encoder, - cstore: @mut cstore::CStore) { - fn get_ordered_deps(ecx: @EncodeContext, cstore: @mut cstore::CStore) - -> ~[decoder::crate_dep] { - type numdep = decoder::crate_dep; - - // Pull the cnums and name,vers,hash out of cstore - let mut deps = ~[]; - do cstore::iter_crate_data(cstore) |key, val| { - let dep = decoder::crate_dep {cnum: key, - name: ecx.tcx.sess.ident_of(/*bad*/ copy *val.name), - vers: decoder::get_crate_vers(val.data), - hash: decoder::get_crate_hash(val.data)}; - deps.push(dep); - }; - - // Sort by cnum - std::sort::quick_sort(deps, |kv1, kv2| kv1.cnum <= kv2.cnum); - - // Sanity-check the crate numbers - let mut expected_cnum = 1; - for deps.each |n| { - assert!((n.cnum == expected_cnum)); - expected_cnum += 1; - } - - // mut -> immutable hack for vec::map - deps.slice(0, deps.len()).to_owned() - } - - // We're just going to write a list of crate 'name-hash-version's, with - // the assumption that they are numbered 1 to n. - // FIXME (#2166): This is not nearly enough to support correct versioning - // but is enough to get transitive crate dependencies working. - ebml_w.start_tag(tag_crate_deps); - for get_ordered_deps(ecx, cstore).each |dep| { - encode_crate_dep(ecx, ebml_w, *dep); - } - ebml_w.end_tag(); -} - -#[cfg(not(stage0))] fn encode_crate_deps(ecx: @EncodeContext, ebml_w: &mut writer::Encoder, cstore: @mut cstore::CStore) { @@ -2398,32 +1269,6 @@ fn encode_crate_deps(ecx: @EncodeContext, ebml_w.end_tag(); } -#[cfg(stage0)] -fn encode_lang_items(ecx: @EncodeContext, ebml_w: &writer::Encoder) { - ebml_w.start_tag(tag_lang_items); - - for ecx.tcx.lang_items.each_item |def_id, i| { - if def_id.crate != local_crate { - loop; - } - - ebml_w.start_tag(tag_lang_items_item); - - ebml_w.start_tag(tag_lang_items_item_id); - ebml_w.writer.write_be_u32(i as u32); - ebml_w.end_tag(); // tag_lang_items_item_id - - ebml_w.start_tag(tag_lang_items_item_node_id); - ebml_w.writer.write_be_u32(def_id.node as u32); - ebml_w.end_tag(); // tag_lang_items_item_node_id - - ebml_w.end_tag(); // tag_lang_items_item - } - - ebml_w.end_tag(); // tag_lang_items -} - -#[cfg(not(stage0))] fn encode_lang_items(ecx: @EncodeContext, ebml_w: &mut writer::Encoder) { ebml_w.start_tag(tag_lang_items); @@ -2448,21 +1293,6 @@ fn encode_lang_items(ecx: @EncodeContext, ebml_w: &mut writer::Encoder) { ebml_w.end_tag(); // tag_lang_items } -#[cfg(stage0)] -fn encode_link_args(ecx: @EncodeContext, ebml_w: &writer::Encoder) { - ebml_w.start_tag(tag_link_args); - - let link_args = cstore::get_used_link_args(ecx.cstore); - for link_args.each |link_arg| { - ebml_w.start_tag(tag_link_args_arg); - ebml_w.writer.write_str(link_arg.to_str()); - ebml_w.end_tag(); - } - - ebml_w.end_tag(); -} - -#[cfg(not(stage0))] fn encode_link_args(ecx: @EncodeContext, ebml_w: &mut writer::Encoder) { ebml_w.start_tag(tag_link_args); @@ -2476,24 +1306,6 @@ fn encode_link_args(ecx: @EncodeContext, ebml_w: &mut writer::Encoder) { ebml_w.end_tag(); } -#[cfg(stage0)] -fn encode_crate_dep(ecx: @EncodeContext, - ebml_w: &writer::Encoder, - dep: decoder::crate_dep) { - ebml_w.start_tag(tag_crate_dep); - ebml_w.start_tag(tag_crate_dep_name); - ebml_w.writer.write(str::to_bytes(*ecx.tcx.sess.str_of(dep.name))); - ebml_w.end_tag(); - ebml_w.start_tag(tag_crate_dep_vers); - ebml_w.writer.write(str::to_bytes(*dep.vers)); - ebml_w.end_tag(); - ebml_w.start_tag(tag_crate_dep_hash); - ebml_w.writer.write(str::to_bytes(*dep.hash)); - ebml_w.end_tag(); - ebml_w.end_tag(); -} - -#[cfg(not(stage0))] fn encode_crate_dep(ecx: @EncodeContext, ebml_w: &mut writer::Encoder, dep: decoder::crate_dep) { @@ -2510,14 +1322,6 @@ fn encode_crate_dep(ecx: @EncodeContext, ebml_w.end_tag(); } -#[cfg(stage0)] -fn encode_hash(ebml_w: &writer::Encoder, hash: &str) { - ebml_w.start_tag(tag_crate_hash); - ebml_w.writer.write(str::to_bytes(hash)); - ebml_w.end_tag(); -} - -#[cfg(not(stage0))] fn encode_hash(ebml_w: &mut writer::Encoder, hash: &str) { ebml_w.start_tag(tag_crate_hash); ebml_w.writer.write(str::to_bytes(hash)); @@ -2532,114 +1336,6 @@ pub static metadata_encoding_version : &'static [u8] = 0x74, //'t' as u8, 0, 0, 0, 1 ]; -#[cfg(stage0)] -pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] { - let wr = @io::BytesWriter(); - let stats = Stats { - inline_bytes: 0, - attr_bytes: 0, - dep_bytes: 0, - lang_item_bytes: 0, - link_args_bytes: 0, - item_bytes: 0, - index_bytes: 0, - zero_bytes: 0, - total_bytes: 0, - n_inlines: 0 - }; - let EncodeParams{item_symbols, diag, tcx, reachable, reexports2, - discrim_symbols, cstore, encode_inlined_item, - link_meta, _} = parms; - let ecx = @EncodeContext { - diag: diag, - tcx: tcx, - stats: @mut stats, - reachable: reachable, - reexports2: reexports2, - item_symbols: item_symbols, - discrim_symbols: discrim_symbols, - link_meta: link_meta, - cstore: cstore, - encode_inlined_item: encode_inlined_item, - type_abbrevs: @mut HashMap::new() - }; - - let ebml_w = writer::Encoder(wr as @io::Writer); - - encode_hash(&ebml_w, ecx.link_meta.extras_hash); - - let mut i = wr.pos; - let crate_attrs = synthesize_crate_attrs(ecx, crate); - encode_attributes(&ebml_w, crate_attrs); - ecx.stats.attr_bytes = wr.pos - i; - - i = wr.pos; - encode_crate_deps(ecx, &ebml_w, ecx.cstore); - ecx.stats.dep_bytes = wr.pos - i; - - // Encode the language items. - i = wr.pos; - encode_lang_items(ecx, &ebml_w); - ecx.stats.lang_item_bytes = wr.pos - i; - - // Encode the link args. - i = wr.pos; - encode_link_args(ecx, &ebml_w); - ecx.stats.link_args_bytes = wr.pos - i; - - // Encode and index the items. - ebml_w.start_tag(tag_items); - i = wr.pos; - let items_index = encode_info_for_items(ecx, &ebml_w, crate); - ecx.stats.item_bytes = wr.pos - i; - - i = wr.pos; - let items_buckets = create_index(items_index); - encode_index(&ebml_w, items_buckets, write_int); - ecx.stats.index_bytes = wr.pos - i; - ebml_w.end_tag(); - - ecx.stats.total_bytes = wr.pos; - - if (tcx.sess.meta_stats()) { - - do wr.bytes.each |e| { - if *e == 0 { - ecx.stats.zero_bytes += 1; - } - true - } - - io::println("metadata stats:"); - io::println(fmt!(" inline bytes: %u", ecx.stats.inline_bytes)); - io::println(fmt!(" attribute bytes: %u", ecx.stats.attr_bytes)); - io::println(fmt!(" dep bytes: %u", ecx.stats.dep_bytes)); - io::println(fmt!(" lang item bytes: %u", ecx.stats.lang_item_bytes)); - io::println(fmt!(" link args bytes: %u", ecx.stats.link_args_bytes)); - io::println(fmt!(" item bytes: %u", ecx.stats.item_bytes)); - io::println(fmt!(" index bytes: %u", ecx.stats.index_bytes)); - io::println(fmt!(" zero bytes: %u", ecx.stats.zero_bytes)); - io::println(fmt!(" total bytes: %u", ecx.stats.total_bytes)); - } - - // Pad this, since something (LLVM, presumably) is cutting off the - // remaining % 4 bytes. - wr.write(&[0u8, 0u8, 0u8, 0u8]); - - // FIXME #3396: weird bug here, for reasons unclear this emits random - // looking bytes (mostly 0x1) if we use the version byte-array constant - // above; so we use a string constant inline instead. - // - // Should be: - // - // vec::from_slice(metadata_encoding_version) + - - (do str::as_bytes(&~"rust\x00\x00\x00\x01") |bytes| { - vec::slice(*bytes, 0, 8).to_vec() - }) + flate::deflate_bytes(wr.bytes) -} - -#[cfg(not(stage0))] pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] { let wr = @io::BytesWriter(); let stats = Stats { diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 2a9f19fc846..c6f01153a90 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -77,31 +77,6 @@ trait tr_intern { // ______________________________________________________________________ // Top-level methods. -#[cfg(stage0)] -pub fn encode_inlined_item(ecx: @e::EncodeContext, - ebml_w: &writer::Encoder, - path: &[ast_map::path_elt], - ii: ast::inlined_item, - maps: Maps) { - debug!("> Encoding inlined item: %s::%s (%u)", - ast_map::path_to_str(path, ecx.tcx.sess.parse_sess.interner), - *ecx.tcx.sess.str_of(ii.ident()), - ebml_w.writer.tell()); - - let id_range = ast_util::compute_id_range_for_inlined_item(&ii); - do ebml_w.wr_tag(c::tag_ast as uint) { - id_range.encode(ebml_w); - encode_ast(ebml_w, simplify_ast(&ii)); - encode_side_tables_for_ii(ecx, maps, ebml_w, &ii); - } - - debug!("< Encoded inlined fn: %s::%s (%u)", - ast_map::path_to_str(path, ecx.tcx.sess.parse_sess.interner), - *ecx.tcx.sess.str_of(ii.ident()), - ebml_w.writer.tell()); -} - -#[cfg(not(stage0))] pub fn encode_inlined_item(ecx: @e::EncodeContext, ebml_w: &mut writer::Encoder, path: &[ast_map::path_elt], @@ -126,53 +101,6 @@ pub fn encode_inlined_item(ecx: @e::EncodeContext, ebml_w.writer.tell()); } -#[cfg(stage0)] -pub fn decode_inlined_item(cdata: @cstore::crate_metadata, - tcx: ty::ctxt, - maps: Maps, - path: ast_map::path, - par_doc: ebml::Doc) - -> Option { - let dcx = @DecodeContext { - cdata: cdata, - tcx: tcx, - maps: maps - }; - match par_doc.opt_child(c::tag_ast) { - None => None, - Some(ast_doc) => { - debug!("> Decoding inlined fn: %s::?", - ast_map::path_to_str(path, tcx.sess.parse_sess.interner)); - let ast_dsr = &reader::Decoder(ast_doc); - let from_id_range = Decodable::decode(ast_dsr); - let to_id_range = reserve_id_range(dcx.tcx.sess, from_id_range); - let xcx = @ExtendedDecodeContext { - dcx: dcx, - from_id_range: from_id_range, - to_id_range: to_id_range - }; - let raw_ii = decode_ast(ast_doc); - let ii = renumber_ast(xcx, raw_ii); - debug!("Fn named: %s", *tcx.sess.str_of(ii.ident())); - debug!("< Decoded inlined fn: %s::%s", - ast_map::path_to_str(path, tcx.sess.parse_sess.interner), - *tcx.sess.str_of(ii.ident())); - ast_map::map_decoded_item(tcx.sess.diagnostic(), - dcx.tcx.items, path, &ii); - decode_side_tables(xcx, ast_doc); - match ii { - ast::ii_item(i) => { - debug!(">>> DECODED ITEM >>>\n%s\n<<< DECODED ITEM <<<", - syntax::print::pprust::item_to_str(i, tcx.sess.intr())); - } - _ => { } - } - Some(ii) - } - } -} - -#[cfg(not(stage0))] pub fn decode_inlined_item(cdata: @cstore::crate_metadata, tcx: ty::ctxt, maps: Maps, @@ -309,49 +237,20 @@ impl tr for span { } } -#[cfg(stage0)] -trait def_id_encoder_helpers { - fn emit_def_id(&self, did: ast::def_id); -} - -#[cfg(not(stage0))] trait def_id_encoder_helpers { fn emit_def_id(&mut self, did: ast::def_id); } -#[cfg(stage0)] -impl def_id_encoder_helpers for S { - fn emit_def_id(&self, did: ast::def_id) { - did.encode(self) - } -} - -#[cfg(not(stage0))] impl def_id_encoder_helpers for S { fn emit_def_id(&mut self, did: ast::def_id) { did.encode(self) } } -#[cfg(stage0)] -trait def_id_decoder_helpers { - fn read_def_id(&self, xcx: @ExtendedDecodeContext) -> ast::def_id; -} - -#[cfg(not(stage0))] trait def_id_decoder_helpers { fn read_def_id(&mut self, xcx: @ExtendedDecodeContext) -> ast::def_id; } -#[cfg(stage0)] -impl def_id_decoder_helpers for D { - fn read_def_id(&self, xcx: @ExtendedDecodeContext) -> ast::def_id { - let did: ast::def_id = Decodable::decode(self); - did.tr(xcx) - } -} - -#[cfg(not(stage0))] impl def_id_decoder_helpers for D { fn read_def_id(&mut self, xcx: @ExtendedDecodeContext) -> ast::def_id { let did: ast::def_id = Decodable::decode(self); @@ -374,14 +273,6 @@ impl def_id_decoder_helpers for D { // We also have to adjust the spans: for now we just insert a dummy span, // but eventually we should add entries to the local codemap as required. -#[cfg(stage0)] -fn encode_ast(ebml_w: &writer::Encoder, item: ast::inlined_item) { - do ebml_w.wr_tag(c::tag_tree as uint) { - item.encode(ebml_w) - } -} - -#[cfg(not(stage0))] fn encode_ast(ebml_w: &mut writer::Encoder, item: ast::inlined_item) { ebml_w.start_tag(c::tag_tree as uint); item.encode(ebml_w); @@ -439,14 +330,6 @@ fn simplify_ast(ii: &ast::inlined_item) -> ast::inlined_item { } } -#[cfg(stage0)] -fn decode_ast(par_doc: ebml::Doc) -> ast::inlined_item { - let chi_doc = par_doc.get(c::tag_tree as uint); - let d = &reader::Decoder(chi_doc); - Decodable::decode(d) -} - -#[cfg(not(stage0))] fn decode_ast(par_doc: ebml::Doc) -> ast::inlined_item { let chi_doc = par_doc.get(c::tag_tree as uint); let mut d = reader::Decoder(chi_doc); @@ -477,24 +360,10 @@ fn renumber_ast(xcx: @ExtendedDecodeContext, ii: ast::inlined_item) // ______________________________________________________________________ // Encoding and decoding of ast::def -#[cfg(stage0)] -fn encode_def(ebml_w: &writer::Encoder, def: ast::def) { - def.encode(ebml_w) -} - -#[cfg(not(stage0))] fn encode_def(ebml_w: &mut writer::Encoder, def: ast::def) { def.encode(ebml_w) } -#[cfg(stage0)] -fn decode_def(xcx: @ExtendedDecodeContext, doc: ebml::Doc) -> ast::def { - let dsr = &reader::Decoder(doc); - let def: ast::def = Decodable::decode(dsr); - def.tr(xcx) -} - -#[cfg(not(stage0))] fn decode_def(xcx: @ExtendedDecodeContext, doc: ebml::Doc) -> ast::def { let mut dsr = reader::Decoder(doc); let def: ast::def = Decodable::decode(&mut dsr); @@ -602,38 +471,15 @@ impl tr for ty::bound_region { // ______________________________________________________________________ // Encoding and decoding of freevar information -#[cfg(stage0)] -fn encode_freevar_entry(ebml_w: &writer::Encoder, fv: @freevar_entry) { - (*fv).encode(ebml_w) -} - -#[cfg(not(stage0))] fn encode_freevar_entry(ebml_w: &mut writer::Encoder, fv: @freevar_entry) { (*fv).encode(ebml_w) } -#[cfg(stage0)] -trait ebml_decoder_helper { - fn read_freevar_entry(&self, xcx: @ExtendedDecodeContext) - -> freevar_entry; -} - -#[cfg(not(stage0))] trait ebml_decoder_helper { fn read_freevar_entry(&mut self, xcx: @ExtendedDecodeContext) -> freevar_entry; } -#[cfg(stage0)] -impl ebml_decoder_helper for reader::Decoder { - fn read_freevar_entry(&self, xcx: @ExtendedDecodeContext) - -> freevar_entry { - let fv: freevar_entry = Decodable::decode(self); - fv.tr(xcx) - } -} - -#[cfg(not(stage0))] impl ebml_decoder_helper for reader::Decoder { fn read_freevar_entry(&mut self, xcx: @ExtendedDecodeContext) -> freevar_entry { @@ -654,28 +500,11 @@ impl tr for freevar_entry { // ______________________________________________________________________ // Encoding and decoding of CaptureVar information -#[cfg(stage0)] -trait capture_var_helper { - fn read_capture_var(&self, xcx: @ExtendedDecodeContext) - -> moves::CaptureVar; -} - -#[cfg(not(stage0))] trait capture_var_helper { fn read_capture_var(&mut self, xcx: @ExtendedDecodeContext) -> moves::CaptureVar; } -#[cfg(stage0)] -impl capture_var_helper for reader::Decoder { - fn read_capture_var(&self, xcx: @ExtendedDecodeContext) - -> moves::CaptureVar { - let cvar: moves::CaptureVar = Decodable::decode(self); - cvar.tr(xcx) - } -} - -#[cfg(not(stage0))] impl capture_var_helper for reader::Decoder { fn read_capture_var(&mut self, xcx: @ExtendedDecodeContext) -> moves::CaptureVar { @@ -698,35 +527,10 @@ impl tr for moves::CaptureVar { // Encoding and decoding of method_map_entry trait read_method_map_entry_helper { - #[cfg(stage0)] - fn read_method_map_entry(&self, xcx: @ExtendedDecodeContext) - -> method_map_entry; - #[cfg(not(stage0))] fn read_method_map_entry(&mut self, xcx: @ExtendedDecodeContext) -> method_map_entry; } -#[cfg(stage0)] -fn encode_method_map_entry(ecx: @e::EncodeContext, - ebml_w: &writer::Encoder, - mme: method_map_entry) { - do ebml_w.emit_struct("method_map_entry", 3) { - do ebml_w.emit_field(~"self_arg", 0u) { - ebml_w.emit_arg(ecx, mme.self_arg); - } - do ebml_w.emit_field(~"explicit_self", 2u) { - mme.explicit_self.encode(ebml_w); - } - do ebml_w.emit_field(~"origin", 1u) { - mme.origin.encode(ebml_w); - } - do ebml_w.emit_field(~"self_mode", 3) { - mme.self_mode.encode(ebml_w); - } - } -} - -#[cfg(not(stage0))] fn encode_method_map_entry(ecx: @e::EncodeContext, ebml_w: &mut writer::Encoder, mme: method_map_entry) { @@ -747,32 +551,6 @@ fn encode_method_map_entry(ecx: @e::EncodeContext, } impl read_method_map_entry_helper for reader::Decoder { - #[cfg(stage0)] - fn read_method_map_entry(&self, xcx: @ExtendedDecodeContext) - -> method_map_entry { - do self.read_struct("method_map_entry", 3) { - method_map_entry { - self_arg: self.read_field(~"self_arg", 0u, || { - self.read_arg(xcx) - }), - explicit_self: self.read_field(~"explicit_self", 2u, || { - let self_type: ast::self_ty_ = Decodable::decode(self); - self_type - }), - origin: self.read_field(~"origin", 1u, || { - let method_origin: method_origin = - Decodable::decode(self); - method_origin.tr(xcx) - }), - self_mode: self.read_field(~"self_mode", 3, || { - let self_mode: ty::SelfMode = Decodable::decode(self); - self_mode - }), - } - } - } - - #[cfg(not(stage0))] fn read_method_map_entry(&mut self, xcx: @ExtendedDecodeContext) -> method_map_entry { do self.read_struct("method_map_entry", 3) |this| { @@ -830,20 +608,6 @@ impl tr for method_origin { // ______________________________________________________________________ // Encoding and decoding vtable_res -#[cfg(stage0)] -fn encode_vtable_res(ecx: @e::EncodeContext, - ebml_w: &writer::Encoder, - dr: typeck::vtable_res) { - // can't autogenerate this code because automatic code of - // ty::t doesn't work, and there is no way (atm) to have - // hand-written encoding routines combine with auto-generated - // ones. perhaps we should fix this. - do ebml_w.emit_from_vec(*dr) |vtable_origin| { - encode_vtable_origin(ecx, ebml_w, vtable_origin) - } -} - -#[cfg(not(stage0))] fn encode_vtable_res(ecx: @e::EncodeContext, ebml_w: &mut writer::Encoder, dr: typeck::vtable_res) { @@ -856,40 +620,6 @@ fn encode_vtable_res(ecx: @e::EncodeContext, } } -#[cfg(stage0)] -fn encode_vtable_origin(ecx: @e::EncodeContext, - ebml_w: &writer::Encoder, - vtable_origin: &typeck::vtable_origin) { - do ebml_w.emit_enum(~"vtable_origin") { - match *vtable_origin { - typeck::vtable_static(def_id, ref tys, vtable_res) => { - do ebml_w.emit_enum_variant(~"vtable_static", 0u, 3u) { - do ebml_w.emit_enum_variant_arg(0u) { - ebml_w.emit_def_id(def_id) - } - do ebml_w.emit_enum_variant_arg(1u) { - ebml_w.emit_tys(ecx, /*bad*/copy *tys); - } - do ebml_w.emit_enum_variant_arg(2u) { - encode_vtable_res(ecx, ebml_w, vtable_res); - } - } - } - typeck::vtable_param(pn, bn) => { - do ebml_w.emit_enum_variant(~"vtable_param", 1u, 2u) { - do ebml_w.emit_enum_variant_arg(0u) { - ebml_w.emit_uint(pn); - } - do ebml_w.emit_enum_variant_arg(1u) { - ebml_w.emit_uint(bn); - } - } - } - } - } -} - -#[cfg(not(stage0))] fn encode_vtable_origin(ecx: @e::EncodeContext, ebml_w: &mut writer::Encoder, vtable_origin: &typeck::vtable_origin) { @@ -923,70 +653,18 @@ fn encode_vtable_origin(ecx: @e::EncodeContext, } trait vtable_decoder_helpers { - #[cfg(stage0)] - fn read_vtable_res(&self, xcx: @ExtendedDecodeContext) - -> typeck::vtable_res; - #[cfg(not(stage0))] fn read_vtable_res(&mut self, xcx: @ExtendedDecodeContext) -> typeck::vtable_res; - #[cfg(stage0)] - fn read_vtable_origin(&self, xcx: @ExtendedDecodeContext) - -> typeck::vtable_origin; - #[cfg(not(stage0))] fn read_vtable_origin(&mut self, xcx: @ExtendedDecodeContext) -> typeck::vtable_origin; } impl vtable_decoder_helpers for reader::Decoder { - #[cfg(stage0)] - fn read_vtable_res(&self, xcx: @ExtendedDecodeContext) - -> typeck::vtable_res { - @self.read_to_vec(|| self.read_vtable_origin(xcx)) - } - - #[cfg(not(stage0))] fn read_vtable_res(&mut self, xcx: @ExtendedDecodeContext) -> typeck::vtable_res { @self.read_to_vec(|this| this.read_vtable_origin(xcx)) } - #[cfg(stage0)] - fn read_vtable_origin(&self, xcx: @ExtendedDecodeContext) - -> typeck::vtable_origin { - do self.read_enum("vtable_origin") { - do self.read_enum_variant(["vtable_static", "vtable_param"]) |i| { - match i { - 0 => { - typeck::vtable_static( - do self.read_enum_variant_arg(0u) { - self.read_def_id(xcx) - }, - do self.read_enum_variant_arg(1u) { - self.read_tys(xcx) - }, - do self.read_enum_variant_arg(2u) { - self.read_vtable_res(xcx) - } - ) - } - 1 => { - typeck::vtable_param( - do self.read_enum_variant_arg(0u) { - self.read_uint() - }, - do self.read_enum_variant_arg(1u) { - self.read_uint() - } - ) - } - // hard to avoid - user input - _ => fail!(~"bad enum variant") - } - } - } - } - - #[cfg(not(stage0))] fn read_vtable_origin(&mut self, xcx: @ExtendedDecodeContext) -> typeck::vtable_origin { do self.read_enum("vtable_origin") |this| { @@ -1042,20 +720,6 @@ impl get_ty_str_ctxt for e::EncodeContext { } } -#[cfg(stage0)] -trait ebml_writer_helpers { - fn emit_arg(&self, ecx: @e::EncodeContext, arg: ty::arg); - fn emit_ty(&self, ecx: @e::EncodeContext, ty: ty::t); - fn emit_vstore(&self, ecx: @e::EncodeContext, vstore: ty::vstore); - fn emit_tys(&self, ecx: @e::EncodeContext, tys: ~[ty::t]); - fn emit_type_param_def(&self, - ecx: @e::EncodeContext, - type_param_def: &ty::TypeParameterDef); - fn emit_tpbt(&self, ecx: @e::EncodeContext, - tpbt: ty::ty_param_bounds_and_ty); -} - -#[cfg(not(stage0))] trait ebml_writer_helpers { fn emit_arg(&mut self, ecx: @e::EncodeContext, arg: ty::arg); fn emit_ty(&mut self, ecx: @e::EncodeContext, ty: ty::t); @@ -1070,73 +734,30 @@ trait ebml_writer_helpers { } impl ebml_writer_helpers for writer::Encoder { - #[cfg(stage0)] - fn emit_ty(&self, ecx: @e::EncodeContext, ty: ty::t) { - do self.emit_opaque { - e::write_type(ecx, self, ty) - } - } - - #[cfg(not(stage0))] fn emit_ty(&mut self, ecx: @e::EncodeContext, ty: ty::t) { do self.emit_opaque |this| { e::write_type(ecx, this, ty) } } - #[cfg(stage0)] - fn emit_vstore(&self, ecx: @e::EncodeContext, vstore: ty::vstore) { - do self.emit_opaque { - e::write_vstore(ecx, self, vstore) - } - } - - #[cfg(not(stage0))] fn emit_vstore(&mut self, ecx: @e::EncodeContext, vstore: ty::vstore) { do self.emit_opaque |this| { e::write_vstore(ecx, this, vstore) } } - #[cfg(stage0)] - fn emit_arg(&self, ecx: @e::EncodeContext, arg: ty::arg) { - do self.emit_opaque { - tyencode::enc_arg(self.writer, ecx.ty_str_ctxt(), arg); - } - } - - #[cfg(not(stage0))] fn emit_arg(&mut self, ecx: @e::EncodeContext, arg: ty::arg) { do self.emit_opaque |this| { tyencode::enc_arg(this.writer, ecx.ty_str_ctxt(), arg); } } - #[cfg(stage0)] - fn emit_tys(&self, ecx: @e::EncodeContext, tys: ~[ty::t]) { - do self.emit_from_vec(tys) |ty| { - self.emit_ty(ecx, *ty) - } - } - - #[cfg(not(stage0))] fn emit_tys(&mut self, ecx: @e::EncodeContext, tys: ~[ty::t]) { do self.emit_from_vec(tys) |this, ty| { this.emit_ty(ecx, *ty) } } - #[cfg(stage0)] - fn emit_type_param_def(&self, - ecx: @e::EncodeContext, - type_param_def: &ty::TypeParameterDef) { - do self.emit_opaque { - tyencode::enc_type_param_def(self.writer, ecx.ty_str_ctxt(), - type_param_def) - } - } - - #[cfg(not(stage0))] fn emit_type_param_def(&mut self, ecx: @e::EncodeContext, type_param_def: &ty::TypeParameterDef) { @@ -1147,31 +768,6 @@ impl ebml_writer_helpers for writer::Encoder { } } - #[cfg(stage0)] - fn emit_tpbt(&self, - ecx: @e::EncodeContext, - tpbt: ty::ty_param_bounds_and_ty) { - do self.emit_struct("ty_param_bounds_and_ty", 2) { - do self.emit_field(~"generics", 0) { - do self.emit_struct("Generics", 2) { - do self.emit_field(~"type_param_defs", 0) { - do self.emit_from_vec(*tpbt.generics.type_param_defs) - |type_param_def| { - self.emit_type_param_def(ecx, type_param_def); - } - } - do self.emit_field(~"region_param", 1) { - tpbt.generics.region_param.encode(self); - } - } - } - do self.emit_field(~"ty", 1) { - self.emit_ty(ecx, tpbt.ty); - } - } - } - - #[cfg(not(stage0))] fn emit_tpbt(&mut self, ecx: @e::EncodeContext, tpbt: ty::ty_param_bounds_and_ty) { @@ -1196,30 +792,11 @@ impl ebml_writer_helpers for writer::Encoder { } } -#[cfg(stage0)] -trait write_tag_and_id { - fn tag(&self, tag_id: c::astencode_tag, f: &fn()); - fn id(&self, id: ast::node_id); -} - -#[cfg(not(stage0))] trait write_tag_and_id { fn tag(&mut self, tag_id: c::astencode_tag, f: &fn(&mut Self)); fn id(&mut self, id: ast::node_id); } -#[cfg(stage0)] -impl write_tag_and_id for writer::Encoder { - fn tag(&self, tag_id: c::astencode_tag, f: &fn()) { - do self.wr_tag(tag_id as uint) { f() } - } - - fn id(&self, id: ast::node_id) { - self.wr_tagged_u64(c::tag_table_id as uint, id as u64) - } -} - -#[cfg(not(stage0))] impl write_tag_and_id for writer::Encoder { fn tag(&mut self, tag_id: c::astencode_tag, @@ -1234,26 +811,6 @@ impl write_tag_and_id for writer::Encoder { } } -#[cfg(stage0)] -fn encode_side_tables_for_ii(ecx: @e::EncodeContext, - maps: Maps, - ebml_w: &writer::Encoder, - ii: &ast::inlined_item) { - do ebml_w.wr_tag(c::tag_table as uint) { - let ebml_w = copy *ebml_w; - ast_util::visit_ids_for_inlined_item( - ii, - |id: ast::node_id| { - // Note: this will cause a copy of ebml_w, which is bad as - // it has mut fields. But I believe it's harmless since - // we generate balanced EBML. - /*let ebml_w = copy ebml_w;*/ - encode_side_tables_for_id(ecx, maps, &ebml_w, id) - }); - } -} - -#[cfg(not(stage0))] fn encode_side_tables_for_ii(ecx: @e::EncodeContext, maps: Maps, ebml_w: &mut writer::Encoder, @@ -1272,137 +829,6 @@ fn encode_side_tables_for_ii(ecx: @e::EncodeContext, ebml_w.end_tag(); } -#[cfg(stage0)] -fn encode_side_tables_for_id(ecx: @e::EncodeContext, - maps: Maps, - ebml_w: &writer::Encoder, - id: ast::node_id) { - let tcx = ecx.tcx; - - debug!("Encoding side tables for id %d", id); - - for tcx.def_map.find(&id).each |def| { - do ebml_w.tag(c::tag_table_def) { - ebml_w.id(id); - do ebml_w.tag(c::tag_table_val) { - (*def).encode(ebml_w) - } - } - } - - for tcx.node_types.find(&(id as uint)).each |&ty| { - do ebml_w.tag(c::tag_table_node_type) { - ebml_w.id(id); - do ebml_w.tag(c::tag_table_val) { - ebml_w.emit_ty(ecx, *ty); - } - } - } - - for tcx.node_type_substs.find(&id).each |tys| { - do ebml_w.tag(c::tag_table_node_type_subst) { - ebml_w.id(id); - do ebml_w.tag(c::tag_table_val) { - // FIXME(#5562): removing this copy causes a segfault - // before stage2 - ebml_w.emit_tys(ecx, /*bad*/copy **tys) - } - } - } - - for tcx.freevars.find(&id).each |&fv| { - do ebml_w.tag(c::tag_table_freevars) { - ebml_w.id(id); - do ebml_w.tag(c::tag_table_val) { - do ebml_w.emit_from_vec(**fv) |fv_entry| { - encode_freevar_entry(ebml_w, *fv_entry) - } - } - } - } - - let lid = ast::def_id { crate: ast::local_crate, node: id }; - for tcx.tcache.find(&lid).each |&tpbt| { - do ebml_w.tag(c::tag_table_tcache) { - ebml_w.id(id); - do ebml_w.tag(c::tag_table_val) { - ebml_w.emit_tpbt(ecx, *tpbt); - } - } - } - - for tcx.ty_param_defs.find(&id).each |&type_param_def| { - do ebml_w.tag(c::tag_table_param_defs) { - ebml_w.id(id); - do ebml_w.tag(c::tag_table_val) { - ebml_w.emit_type_param_def(ecx, type_param_def) - } - } - } - - if maps.mutbl_map.contains(&id) { - do ebml_w.tag(c::tag_table_mutbl) { - ebml_w.id(id); - } - } - - for maps.last_use_map.find(&id).each |&m| { - do ebml_w.tag(c::tag_table_last_use) { - ebml_w.id(id); - do ebml_w.tag(c::tag_table_val) { - do ebml_w.emit_from_vec(/*bad*/ copy **m) |id| { - id.encode(ebml_w); - } - } - } - } - - for maps.method_map.find(&id).each |&mme| { - do ebml_w.tag(c::tag_table_method_map) { - ebml_w.id(id); - do ebml_w.tag(c::tag_table_val) { - encode_method_map_entry(ecx, ebml_w, *mme) - } - } - } - - for maps.vtable_map.find(&id).each |&dr| { - do ebml_w.tag(c::tag_table_vtable_map) { - ebml_w.id(id); - do ebml_w.tag(c::tag_table_val) { - encode_vtable_res(ecx, ebml_w, *dr); - } - } - } - - for tcx.adjustments.find(&id).each |adj| { - do ebml_w.tag(c::tag_table_adjustments) { - ebml_w.id(id); - do ebml_w.tag(c::tag_table_val) { - (**adj).encode(ebml_w) - } - } - } - - if maps.moves_map.contains(&id) { - do ebml_w.tag(c::tag_table_moves_map) { - ebml_w.id(id); - } - } - - for maps.capture_map.find(&id).each |&cap_vars| { - do ebml_w.tag(c::tag_table_capture_map) { - ebml_w.id(id); - do ebml_w.tag(c::tag_table_val) { - do ebml_w.emit_from_vec(*cap_vars) |cap_var| { - cap_var.encode(ebml_w); - } - } - } - } -} - -#[cfg(not(stage0))] fn encode_side_tables_for_id(ecx: @e::EncodeContext, maps: Maps, ebml_w: &mut writer::Encoder, @@ -1544,20 +970,6 @@ impl doc_decoder_helpers for ebml::Doc { } } -#[cfg(stage0)] -trait ebml_decoder_decoder_helpers { - fn read_arg(&self, xcx: @ExtendedDecodeContext) -> ty::arg; - fn read_ty(&self, xcx: @ExtendedDecodeContext) -> ty::t; - fn read_tys(&self, xcx: @ExtendedDecodeContext) -> ~[ty::t]; - fn read_type_param_def(&self, xcx: @ExtendedDecodeContext) -> ty::TypeParameterDef; - fn read_ty_param_bounds_and_ty(&self, xcx: @ExtendedDecodeContext) - -> ty::ty_param_bounds_and_ty; - fn convert_def_id(&self, xcx: @ExtendedDecodeContext, - source: DefIdSource, - did: ast::def_id) -> ast::def_id; -} - -#[cfg(not(stage0))] trait ebml_decoder_decoder_helpers { fn read_arg(&mut self, xcx: @ExtendedDecodeContext) -> ty::arg; fn read_ty(&mut self, xcx: @ExtendedDecodeContext) -> ty::t; @@ -1574,16 +986,6 @@ trait ebml_decoder_decoder_helpers { } impl ebml_decoder_decoder_helpers for reader::Decoder { - #[cfg(stage0)] - fn read_arg(&self, xcx: @ExtendedDecodeContext) -> ty::arg { - do self.read_opaque |doc| { - tydecode::parse_arg_data( - doc.data, xcx.dcx.cdata.cnum, doc.start, xcx.dcx.tcx, - |s, a| self.convert_def_id(xcx, s, a)) - } - } - - #[cfg(not(stage0))] fn read_arg(&mut self, xcx: @ExtendedDecodeContext) -> ty::arg { do self.read_opaque |this, doc| { tydecode::parse_arg_data( @@ -1595,35 +997,6 @@ impl ebml_decoder_decoder_helpers for reader::Decoder { } } - #[cfg(stage0)] - fn read_ty(&self, xcx: @ExtendedDecodeContext) -> ty::t { - // Note: regions types embed local node ids. In principle, we - // should translate these node ids into the new decode - // context. However, we do not bother, because region types - // are not used during trans. - - return do self.read_opaque |doc| { - - let ty = tydecode::parse_ty_data( - doc.data, xcx.dcx.cdata.cnum, doc.start, xcx.dcx.tcx, - |s, a| self.convert_def_id(xcx, s, a)); - - debug!("read_ty(%s) = %s", - type_string(doc), ty_to_str(xcx.dcx.tcx, ty)); - - ty - }; - - fn type_string(doc: ebml::Doc) -> ~str { - let mut str = ~""; - for uint::range(doc.start, doc.end) |i| { - str::push_char(&mut str, doc.data[i] as char); - } - str - } - } - - #[cfg(not(stage0))] fn read_ty(&mut self, xcx: @ExtendedDecodeContext) -> ty::t { // Note: regions types embed local node ids. In principle, we // should translate these node ids into the new decode @@ -1654,27 +1027,10 @@ impl ebml_decoder_decoder_helpers for reader::Decoder { } } - #[cfg(stage0)] - fn read_tys(&self, xcx: @ExtendedDecodeContext) -> ~[ty::t] { - self.read_to_vec(|| self.read_ty(xcx) ) - } - - #[cfg(not(stage0))] fn read_tys(&mut self, xcx: @ExtendedDecodeContext) -> ~[ty::t] { self.read_to_vec(|this| this.read_ty(xcx) ) } - #[cfg(stage0)] - fn read_type_param_def(&self, xcx: @ExtendedDecodeContext) - -> ty::TypeParameterDef { - do self.read_opaque |doc| { - tydecode::parse_type_param_def_data( - doc.data, doc.start, xcx.dcx.cdata.cnum, xcx.dcx.tcx, - |s, a| self.convert_def_id(xcx, s, a)) - } - } - - #[cfg(not(stage0))] fn read_type_param_def(&mut self, xcx: @ExtendedDecodeContext) -> ty::TypeParameterDef { do self.read_opaque |this, doc| { @@ -1687,31 +1043,6 @@ impl ebml_decoder_decoder_helpers for reader::Decoder { } } - #[cfg(stage0)] - fn read_ty_param_bounds_and_ty(&self, xcx: @ExtendedDecodeContext) - -> ty::ty_param_bounds_and_ty { - do self.read_struct("ty_param_bounds_and_ty", 2) { - ty::ty_param_bounds_and_ty { - generics: do self.read_field("generics", 0) { - do self.read_struct("Generics", 2) { - ty::Generics { - type_param_defs: self.read_field("type_param_defs", 0, || { - @self.read_to_vec(|| self.read_type_param_def(xcx)) - }), - region_param: self.read_field(~"region_param", 1, || { - Decodable::decode(self) - }) - } - } - }, - ty: self.read_field(~"ty", 1, || { - self.read_ty(xcx) - }) - } - } - } - - #[cfg(not(stage0))] fn read_ty_param_bounds_and_ty(&mut self, xcx: @ExtendedDecodeContext) -> ty::ty_param_bounds_and_ty { do self.read_struct("ty_param_bounds_and_ty", 2) |this| { @@ -1742,35 +1073,6 @@ impl ebml_decoder_decoder_helpers for reader::Decoder { } } - #[cfg(stage0)] - fn convert_def_id(&self, - xcx: @ExtendedDecodeContext, - source: tydecode::DefIdSource, - did: ast::def_id) - -> ast::def_id { - /*! - * - * Converts a def-id that appears in a type. The correct - * translation will depend on what kind of def-id this is. - * This is a subtle point: type definitions are not - * inlined into the current crate, so if the def-id names - * a nominal type or type alias, then it should be - * translated to refer to the source crate. - * - * However, *type parameters* are cloned along with the function - * they are attached to. So we should translate those def-ids - * to refer to the new, cloned copy of the type parameter. - */ - - let r = match source { - NominalType | TypeWithId => xcx.tr_def_id(did), - TypeParameter => xcx.tr_intern_def_id(did) - }; - debug!("convert_def_id(source=%?, did=%?)=%?", source, did, r); - return r; - } - - #[cfg(not(stage0))] fn convert_def_id(&mut self, xcx: @ExtendedDecodeContext, source: tydecode::DefIdSource, @@ -1799,82 +1101,6 @@ impl ebml_decoder_decoder_helpers for reader::Decoder { } } -#[cfg(stage0)] -fn decode_side_tables(xcx: @ExtendedDecodeContext, - ast_doc: ebml::Doc) { - let dcx = xcx.dcx; - let tbl_doc = ast_doc.get(c::tag_table as uint); - for reader::docs(tbl_doc) |tag, entry_doc| { - let id0 = entry_doc.get(c::tag_table_id as uint).as_int(); - let id = xcx.tr_id(id0); - - debug!(">> Side table document with tag 0x%x \ - found for id %d (orig %d)", - tag, id, id0); - - if tag == (c::tag_table_mutbl as uint) { - dcx.maps.mutbl_map.insert(id); - } else if tag == (c::tag_table_moves_map as uint) { - dcx.maps.moves_map.insert(id); - } else { - let val_doc = entry_doc.get(c::tag_table_val as uint); - let val_dsr = &reader::Decoder(val_doc); - if tag == (c::tag_table_def as uint) { - let def = decode_def(xcx, val_doc); - dcx.tcx.def_map.insert(id, def); - } else if tag == (c::tag_table_node_type as uint) { - let ty = val_dsr.read_ty(xcx); - debug!("inserting ty for node %?: %s", - id, ty_to_str(dcx.tcx, ty)); - dcx.tcx.node_types.insert(id as uint, ty); - } else if tag == (c::tag_table_node_type_subst as uint) { - let tys = val_dsr.read_tys(xcx); - dcx.tcx.node_type_substs.insert(id, tys); - } else if tag == (c::tag_table_freevars as uint) { - let fv_info = @val_dsr.read_to_vec(|| { - @val_dsr.read_freevar_entry(xcx) - }); - dcx.tcx.freevars.insert(id, fv_info); - } else if tag == (c::tag_table_tcache as uint) { - let tpbt = val_dsr.read_ty_param_bounds_and_ty(xcx); - let lid = ast::def_id { crate: ast::local_crate, node: id }; - dcx.tcx.tcache.insert(lid, tpbt); - } else if tag == (c::tag_table_param_defs as uint) { - let bounds = val_dsr.read_type_param_def(xcx); - dcx.tcx.ty_param_defs.insert(id, bounds); - } else if tag == (c::tag_table_last_use as uint) { - let ids = val_dsr.read_to_vec(|| { - xcx.tr_id(val_dsr.read_int()) - }); - dcx.maps.last_use_map.insert(id, @mut ids); - } else if tag == (c::tag_table_method_map as uint) { - dcx.maps.method_map.insert( - id, - val_dsr.read_method_map_entry(xcx)); - } else if tag == (c::tag_table_vtable_map as uint) { - dcx.maps.vtable_map.insert(id, - val_dsr.read_vtable_res(xcx)); - } else if tag == (c::tag_table_adjustments as uint) { - let adj: @ty::AutoAdjustment = @Decodable::decode(val_dsr); - adj.tr(xcx); - dcx.tcx.adjustments.insert(id, adj); - } else if tag == (c::tag_table_capture_map as uint) { - let cvars = - at_vec::from_owned( - val_dsr.read_to_vec( - || val_dsr.read_capture_var(xcx))); - dcx.maps.capture_map.insert(id, cvars); - } else { - xcx.dcx.tcx.sess.bug( - fmt!("unknown tag found in side tables: %x", tag)); - } - } - - debug!(">< Side table doc loaded"); - } -} - -#[cfg(not(stage0))] fn decode_side_tables(xcx: @ExtendedDecodeContext, ast_doc: ebml::Doc) { let dcx = xcx.dcx; diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs index 67b5e5e654a..b9a09323f81 100644 --- a/src/libstd/arena.rs +++ b/src/libstd/arena.rs @@ -203,21 +203,6 @@ pub impl Arena { } #[inline(always)] - #[cfg(stage0)] - priv fn alloc_pod(&mut self, op: &fn() -> T) -> &'self T { - unsafe { - let tydesc = sys::get_type_desc::(); - let ptr = self.alloc_pod_inner((*tydesc).size, (*tydesc).align); - let ptr: *mut T = transmute(ptr); - rusti::move_val_init(&mut (*ptr), op()); - return transmute(ptr); - } - } - - #[inline(always)] - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] priv fn alloc_pod<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T { unsafe { let tydesc = sys::get_type_desc::(); @@ -265,31 +250,6 @@ pub impl Arena { } #[inline(always)] - #[cfg(stage0)] - priv fn alloc_nonpod(&mut self, op: &fn() -> T) -> &'self T { - unsafe { - let tydesc = sys::get_type_desc::(); - let (ty_ptr, ptr) = - self.alloc_nonpod_inner((*tydesc).size, (*tydesc).align); - let ty_ptr: *mut uint = transmute(ty_ptr); - let ptr: *mut T = transmute(ptr); - // Write in our tydesc along with a bit indicating that it - // has *not* been initialized yet. - *ty_ptr = transmute(tydesc); - // Actually initialize it - rusti::move_val_init(&mut(*ptr), op()); - // Now that we are done, update the tydesc to indicate that - // the object is there. - *ty_ptr = bitpack_tydesc_ptr(tydesc, true); - - return transmute(ptr); - } - } - - #[inline(always)] - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] priv fn alloc_nonpod<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T { unsafe { let tydesc = sys::get_type_desc::(); @@ -312,25 +272,6 @@ pub impl Arena { // The external interface #[inline(always)] - #[cfg(stage0)] - fn alloc(&mut self, op: &fn() -> T) -> &'self T { - unsafe { - // XXX: Borrow check - let this = transmute_mut_region(self); - if !rusti::needs_drop::() { - return this.alloc_pod(op); - } - // XXX: Borrow check - let this = transmute_mut_region(self); - this.alloc_nonpod(op) - } - } - - // The external interface - #[inline(always)] - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn alloc<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T { unsafe { // XXX: Borrow check diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index 8a310a9f52b..65e71869a1f 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -37,128 +37,6 @@ impl Mutable for Deque { } } -#[cfg(stage0)] -pub impl Deque { - /// Create an empty Deque - fn new() -> Deque { - Deque{nelts: 0, lo: 0, hi: 0, - elts: vec::from_fn(initial_capacity, |_| None)} - } - - /// Return a reference to the first element in the deque - /// - /// Fails if the deque is empty - #[cfg(stage0)] - fn peek_front(&self) -> &'self T { get(self.elts, self.lo) } - - /// Return a reference to the first element in the deque - /// - /// Fails if the deque is empty - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] - fn peek_front<'a>(&'a self) -> &'a T { get(self.elts, self.lo) } - - /// Return a reference to the last element in the deque - /// - /// Fails if the deque is empty - #[cfg(stage0)] - fn peek_back(&self) -> &'self T { get(self.elts, self.hi - 1u) } - - /// Return a reference to the last element in the deque - /// - /// Fails if the deque is empty - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] - fn peek_back<'a>(&'a self) -> &'a T { get(self.elts, self.hi - 1u) } - - /// Retrieve an element in the deque by index - /// - /// Fails if there is no element with the given index - #[cfg(stage0)] - fn get(&self, i: int) -> &'self T { - let idx = (self.lo + (i as uint)) % self.elts.len(); - get(self.elts, idx) - } - - /// Retrieve an element in the deque by index - /// - /// Fails if there is no element with the given index - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] - fn get<'a>(&'a self, i: int) -> &'a T { - let idx = (self.lo + (i as uint)) % self.elts.len(); - get(self.elts, idx) - } - - /// Iterate over the elements in the deque - fn each(&self, f: &fn(&T) -> bool) { - self.eachi(|_i, e| f(e)) - } - - /// Iterate over the elements in the deque by index - fn eachi(&self, f: &fn(uint, &T) -> bool) { - for uint::range(0, self.nelts) |i| { - if !f(i, self.get(i as int)) { return; } - } - } - - /// Remove and return the first element in the deque - /// - /// Fails if the deque is empty - fn pop_front(&mut self) -> T { - let result = self.elts[self.lo].swap_unwrap(); - self.lo = (self.lo + 1u) % self.elts.len(); - self.nelts -= 1u; - result - } - - /// Remove and return the last element in the deque - /// - /// Fails if the deque is empty - fn pop_back(&mut self) -> T { - if self.hi == 0u { - self.hi = self.elts.len() - 1u; - } else { self.hi -= 1u; } - let result = self.elts[self.hi].swap_unwrap(); - self.elts[self.hi] = None; - self.nelts -= 1u; - result - } - - /// Prepend an element to the deque - fn add_front(&mut self, t: T) { - let oldlo = self.lo; - if self.lo == 0u { - self.lo = self.elts.len() - 1u; - } else { self.lo -= 1u; } - if self.lo == self.hi { - self.elts = grow(self.nelts, oldlo, self.elts); - self.lo = self.elts.len() - 1u; - self.hi = self.nelts; - } - self.elts[self.lo] = Some(t); - self.nelts += 1u; - } - - /// Append an element to the deque - fn add_back(&mut self, t: T) { - if self.lo == self.hi && self.nelts != 0u { - self.elts = grow(self.nelts, self.lo, self.elts); - self.lo = 0u; - self.hi = self.nelts; - } - self.elts[self.hi] = Some(t); - self.hi = (self.hi + 1u) % self.elts.len(); - self.nelts += 1u; - } -} - -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] pub impl Deque { /// Create an empty Deque fn new() -> Deque { diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index 41c5a0f7690..8a4bc823fd8 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -263,13 +263,6 @@ pub mod reader { pub fn doc_as_i32(d: Doc) -> i32 { doc_as_u32(d) as i32 } pub fn doc_as_i64(d: Doc) -> i64 { doc_as_u64(d) as i64 } - #[cfg(stage0)] - pub struct Decoder { - priv mut parent: Doc, - priv mut pos: uint, - } - - #[cfg(not(stage0))] pub struct Decoder { priv parent: Doc, priv pos: uint, @@ -283,25 +276,6 @@ pub mod reader { } priv impl Decoder { - #[cfg(stage0)] - fn _check_label(&self, lbl: &str) { - if self.pos < self.parent.end { - let TaggedDoc { tag: r_tag, doc: r_doc } = - doc_at(self.parent.data, self.pos); - - if r_tag == (EsLabel as uint) { - self.pos = r_doc.end; - let str = doc_as_str(r_doc); - if lbl != str { - fail!(fmt!("Expected label %s but found %s", - lbl, - str)); - } - } - } - } - - #[cfg(not(stage0))] fn _check_label(&mut self, lbl: &str) { if self.pos < self.parent.end { let TaggedDoc { tag: r_tag, doc: r_doc } = @@ -319,30 +293,6 @@ pub mod reader { } } - #[cfg(stage0)] - fn next_doc(&self, exp_tag: EbmlEncoderTag) -> Doc { - debug!(". next_doc(exp_tag=%?)", exp_tag); - if self.pos >= self.parent.end { - fail!(~"no more documents in current node!"); - } - let TaggedDoc { tag: r_tag, doc: r_doc } = - doc_at(self.parent.data, self.pos); - debug!("self.parent=%?-%? self.pos=%? r_tag=%? r_doc=%?-%?", - copy self.parent.start, copy self.parent.end, - copy self.pos, r_tag, r_doc.start, r_doc.end); - if r_tag != (exp_tag as uint) { - fail!(fmt!("expected EBML doc with tag %? but found tag %?", - exp_tag, r_tag)); - } - if r_doc.end > self.parent.end { - fail!(fmt!("invalid EBML, child extends to 0x%x, \ - parent to 0x%x", r_doc.end, self.parent.end)); - } - self.pos = r_doc.end; - r_doc - } - - #[cfg(not(stage0))] fn next_doc(&mut self, exp_tag: EbmlEncoderTag) -> Doc { debug!(". next_doc(exp_tag=%?)", exp_tag); if self.pos >= self.parent.end { @@ -365,19 +315,6 @@ pub mod reader { r_doc } - #[cfg(stage0)] - fn push_doc(&self, d: Doc, f: &fn() -> T) -> T { - let old_parent = self.parent; - let old_pos = self.pos; - self.parent = d; - self.pos = d.start; - let r = f(); - self.parent = old_parent; - self.pos = old_pos; - r - } - - #[cfg(not(stage0))] fn push_doc(&mut self, d: Doc, f: &fn() -> T) -> T { let old_parent = self.parent; let old_pos = self.pos; @@ -389,14 +326,6 @@ pub mod reader { r } - #[cfg(stage0)] - fn _next_uint(&self, exp_tag: EbmlEncoderTag) -> uint { - let r = doc_as_u32(self.next_doc(exp_tag)); - debug!("_next_uint exp_tag=%? result=%?", exp_tag, r); - r as uint - } - - #[cfg(not(stage0))] fn _next_uint(&mut self, exp_tag: EbmlEncoderTag) -> uint { let r = doc_as_u32(self.next_doc(exp_tag)); debug!("_next_uint exp_tag=%? result=%?", exp_tag, r); @@ -405,14 +334,6 @@ pub mod reader { } pub impl Decoder { - #[cfg(stage0)] - fn read_opaque(&self, op: &fn(Doc) -> R) -> R { - do self.push_doc(self.next_doc(EsOpaque)) { - op(copy self.parent) - } - } - - #[cfg(not(stage0))] fn read_opaque(&mut self, op: &fn(&mut Decoder, Doc) -> R) -> R { let doc = self.next_doc(EsOpaque); @@ -428,188 +349,6 @@ pub mod reader { } } - #[cfg(stage0)] - impl serialize::Decoder for Decoder { - fn read_nil(&self) -> () { () } - - fn read_u64(&self) -> u64 { doc_as_u64(self.next_doc(EsU64)) } - fn read_u32(&self) -> u32 { doc_as_u32(self.next_doc(EsU32)) } - fn read_u16(&self) -> u16 { doc_as_u16(self.next_doc(EsU16)) } - fn read_u8 (&self) -> u8 { doc_as_u8 (self.next_doc(EsU8 )) } - fn read_uint(&self) -> uint { - let v = doc_as_u64(self.next_doc(EsUint)); - if v > (::core::uint::max_value as u64) { - fail!(fmt!("uint %? too large for this architecture", v)); - } - v as uint - } - - fn read_i64(&self) -> i64 { - doc_as_u64(self.next_doc(EsI64)) as i64 - } - fn read_i32(&self) -> i32 { - doc_as_u32(self.next_doc(EsI32)) as i32 - } - fn read_i16(&self) -> i16 { - doc_as_u16(self.next_doc(EsI16)) as i16 - } - fn read_i8 (&self) -> i8 { - doc_as_u8(self.next_doc(EsI8 )) as i8 - } - fn read_int(&self) -> int { - let v = doc_as_u64(self.next_doc(EsInt)) as i64; - if v > (int::max_value as i64) || v < (int::min_value as i64) { - fail!(fmt!("int %? out of range for this architecture", v)); - } - v as int - } - - fn read_bool(&self) -> bool { - doc_as_u8(self.next_doc(EsBool)) as bool - } - - fn read_f64(&self) -> f64 { fail!(~"read_f64()"); } - fn read_f32(&self) -> f32 { fail!(~"read_f32()"); } - fn read_float(&self) -> float { fail!(~"read_float()"); } - fn read_char(&self) -> char { fail!(~"read_char()"); } - fn read_str(&self) -> ~str { doc_as_str(self.next_doc(EsStr)) } - - // Compound types: - fn read_enum(&self, name: &str, f: &fn() -> T) -> T { - debug!("read_enum(%s)", name); - self._check_label(name); - self.push_doc(self.next_doc(EsEnum), f) - } - - fn read_enum_variant(&self, - _: &[&str], - f: &fn(uint) -> T) - -> T { - debug!("read_enum_variant()"); - let idx = self._next_uint(EsEnumVid); - debug!(" idx=%u", idx); - do self.push_doc(self.next_doc(EsEnumBody)) { - f(idx) - } - } - - fn read_enum_variant_arg(&self, - idx: uint, - f: &fn() -> T) -> T { - debug!("read_enum_variant_arg(idx=%u)", idx); - f() - } - - fn read_enum_struct_variant(&self, - _: &[&str], - f: &fn(uint) -> T) - -> T { - debug!("read_enum_struct_variant()"); - let idx = self._next_uint(EsEnumVid); - debug!(" idx=%u", idx); - do self.push_doc(self.next_doc(EsEnumBody)) { - f(idx) - } - } - - fn read_enum_struct_variant_field(&self, - name: &str, - idx: uint, - f: &fn() -> T) - -> T { - debug!("read_enum_struct_variant_arg(name=%?, idx=%u)", name, idx); - f() - } - - fn read_struct(&self, - name: &str, - _: uint, - f: &fn() -> T) - -> T { - debug!("read_struct(name=%s)", name); - f() - } - - fn read_field(&self, - name: &str, - idx: uint, - f: &fn() -> T) - -> T { - debug!("read_field(name=%?, idx=%u)", name, idx); - self._check_label(name); - f() - } - - fn read_tuple(&self, f: &fn(uint) -> T) -> T { - debug!("read_tuple()"); - self.read_seq(f) - } - - fn read_tuple_arg(&self, idx: uint, f: &fn() -> T) -> T { - debug!("read_tuple_arg(idx=%u)", idx); - self.read_seq_elt(idx, f) - } - - fn read_tuple_struct(&self, - name: &str, - f: &fn(uint) -> T) - -> T { - debug!("read_tuple_struct(name=%?)", name); - self.read_tuple(f) - } - - fn read_tuple_struct_arg(&self, - idx: uint, - f: &fn() -> T) - -> T { - debug!("read_tuple_struct_arg(idx=%u)", idx); - self.read_tuple_arg(idx, f) - } - - fn read_option(&self, f: &fn(bool) -> T) -> T { - debug!("read_option()"); - do self.read_enum("Option") || { - do self.read_enum_variant(["None", "Some"]) |idx| { - match idx { - 0 => f(false), - 1 => f(true), - _ => fail!(), - } - } - } - } - - fn read_seq(&self, f: &fn(uint) -> T) -> T { - debug!("read_seq()"); - do self.push_doc(self.next_doc(EsVec)) { - let len = self._next_uint(EsVecLen); - debug!(" len=%u", len); - f(len) - } - } - - fn read_seq_elt(&self, idx: uint, f: &fn() -> T) -> T { - debug!("read_seq_elt(idx=%u)", idx); - self.push_doc(self.next_doc(EsVecElt), f) - } - - fn read_map(&self, _f: &fn(uint) -> T) -> T { - debug!("read_map()"); - fail!(~"read_map is unimplemented"); - } - - fn read_map_elt_key(&self, idx: uint, _f: &fn() -> T) -> T { - debug!("read_map_elt_key(idx=%u)", idx); - fail!(~"read_map_elt_val is unimplemented"); - } - - fn read_map_elt_val(&self, idx: uint, _f: &fn() -> T) -> T { - debug!("read_map_elt_val(idx=%u)", idx); - fail!(~"read_map_elt_val is unimplemented"); - } - } - - #[cfg(not(stage0))] impl serialize::Decoder for Decoder { fn read_nil(&mut self) -> () { () } @@ -891,104 +630,6 @@ pub mod writer { } // FIXME (#2741): Provide a function to write the standard ebml header. - #[cfg(stage0)] - pub impl Encoder { - fn start_tag(&self, tag_id: uint) { - debug!("Start tag %u", tag_id); - - // Write the enum ID: - write_vuint(self.writer, tag_id); - - // Write a placeholder four-byte size. - self.size_positions.push(self.writer.tell()); - let zeroes: &[u8] = &[0u8, 0u8, 0u8, 0u8]; - self.writer.write(zeroes); - } - - fn end_tag(&self) { - let last_size_pos = self.size_positions.pop(); - let cur_pos = self.writer.tell(); - self.writer.seek(last_size_pos as int, io::SeekSet); - let size = (cur_pos - last_size_pos - 4u); - write_sized_vuint(self.writer, size, 4u); - self.writer.seek(cur_pos as int, io::SeekSet); - - debug!("End tag (size = %u)", size); - } - - fn wr_tag(&self, tag_id: uint, blk: &fn()) { - self.start_tag(tag_id); - blk(); - self.end_tag(); - } - - fn wr_tagged_bytes(&self, tag_id: uint, b: &[u8]) { - write_vuint(self.writer, tag_id); - write_vuint(self.writer, vec::len(b)); - self.writer.write(b); - } - - fn wr_tagged_u64(&self, tag_id: uint, v: u64) { - do io::u64_to_be_bytes(v, 8u) |v| { - self.wr_tagged_bytes(tag_id, v); - } - } - - fn wr_tagged_u32(&self, tag_id: uint, v: u32) { - do io::u64_to_be_bytes(v as u64, 4u) |v| { - self.wr_tagged_bytes(tag_id, v); - } - } - - fn wr_tagged_u16(&self, tag_id: uint, v: u16) { - do io::u64_to_be_bytes(v as u64, 2u) |v| { - self.wr_tagged_bytes(tag_id, v); - } - } - - fn wr_tagged_u8(&self, tag_id: uint, v: u8) { - self.wr_tagged_bytes(tag_id, &[v]); - } - - fn wr_tagged_i64(&self, tag_id: uint, v: i64) { - do io::u64_to_be_bytes(v as u64, 8u) |v| { - self.wr_tagged_bytes(tag_id, v); - } - } - - fn wr_tagged_i32(&self, tag_id: uint, v: i32) { - do io::u64_to_be_bytes(v as u64, 4u) |v| { - self.wr_tagged_bytes(tag_id, v); - } - } - - fn wr_tagged_i16(&self, tag_id: uint, v: i16) { - do io::u64_to_be_bytes(v as u64, 2u) |v| { - self.wr_tagged_bytes(tag_id, v); - } - } - - fn wr_tagged_i8(&self, tag_id: uint, v: i8) { - self.wr_tagged_bytes(tag_id, &[v as u8]); - } - - fn wr_tagged_str(&self, tag_id: uint, v: &str) { - str::byte_slice(v, |b| self.wr_tagged_bytes(tag_id, b)); - } - - fn wr_bytes(&self, b: &[u8]) { - debug!("Write %u bytes", vec::len(b)); - self.writer.write(b); - } - - fn wr_str(&self, s: &str) { - debug!("Write str: %?", s); - self.writer.write(str::to_bytes(s)); - } - } - - // FIXME (#2741): Provide a function to write the standard ebml header. - #[cfg(not(stage0))] pub impl Encoder { fn start_tag(&mut self, tag_id: uint) { debug!("Start tag %u", tag_id); @@ -1091,26 +732,6 @@ pub mod writer { // Totally lame approach. static debug: bool = true; - #[cfg(stage0)] - priv impl Encoder { - // used internally to emit things like the vector length and so on - fn _emit_tagged_uint(&self, t: EbmlEncoderTag, v: uint) { - assert!(v <= 0xFFFF_FFFF_u); - self.wr_tagged_u32(t as uint, v as u32); - } - - fn _emit_label(&self, label: &str) { - // There are various strings that we have access to, such as - // the name of a record field, which do not actually appear in - // the encoded EBML (normally). This is just for - // efficiency. When debugging, though, we can emit such - // labels and then they will be checked by decoder to - // try and check failures more quickly. - if debug { self.wr_tagged_str(EsLabel as uint, label) } - } - } - - #[cfg(not(stage0))] priv impl Encoder { // used internally to emit things like the vector length and so on fn _emit_tagged_uint(&mut self, t: EbmlEncoderTag, v: uint) { @@ -1129,16 +750,6 @@ pub mod writer { } } - #[cfg(stage0)] - pub impl Encoder { - fn emit_opaque(&self, f: &fn()) { - do self.wr_tag(EsOpaque as uint) { - f() - } - } - } - - #[cfg(not(stage0))] pub impl Encoder { fn emit_opaque(&mut self, f: &fn(&mut Encoder)) { self.start_tag(EsOpaque as uint); @@ -1147,156 +758,6 @@ pub mod writer { } } - #[cfg(stage0)] - impl ::serialize::Encoder for Encoder { - fn emit_nil(&self) {} - - fn emit_uint(&self, v: uint) { - self.wr_tagged_u64(EsUint as uint, v as u64); - } - fn emit_u64(&self, v: u64) { - self.wr_tagged_u64(EsU64 as uint, v); - } - fn emit_u32(&self, v: u32) { - self.wr_tagged_u32(EsU32 as uint, v); - } - fn emit_u16(&self, v: u16) { - self.wr_tagged_u16(EsU16 as uint, v); - } - fn emit_u8(&self, v: u8) { - self.wr_tagged_u8(EsU8 as uint, v); - } - - fn emit_int(&self, v: int) { - self.wr_tagged_i64(EsInt as uint, v as i64); - } - fn emit_i64(&self, v: i64) { - self.wr_tagged_i64(EsI64 as uint, v); - } - fn emit_i32(&self, v: i32) { - self.wr_tagged_i32(EsI32 as uint, v); - } - fn emit_i16(&self, v: i16) { - self.wr_tagged_i16(EsI16 as uint, v); - } - fn emit_i8(&self, v: i8) { - self.wr_tagged_i8(EsI8 as uint, v); - } - - fn emit_bool(&self, v: bool) { - self.wr_tagged_u8(EsBool as uint, v as u8) - } - - // FIXME (#2742): implement these - fn emit_f64(&self, _v: f64) { - fail!(~"Unimplemented: serializing an f64"); - } - fn emit_f32(&self, _v: f32) { - fail!(~"Unimplemented: serializing an f32"); - } - fn emit_float(&self, _v: float) { - fail!(~"Unimplemented: serializing a float"); - } - - fn emit_char(&self, _v: char) { - fail!(~"Unimplemented: serializing a char"); - } - - fn emit_str(&self, v: &str) { - self.wr_tagged_str(EsStr as uint, v) - } - - fn emit_enum(&self, name: &str, f: &fn()) { - self._emit_label(name); - self.wr_tag(EsEnum as uint, f) - } - - fn emit_enum_variant(&self, - _: &str, - v_id: uint, - _: uint, - f: &fn()) { - self._emit_tagged_uint(EsEnumVid, v_id); - self.wr_tag(EsEnumBody as uint, f) - } - - fn emit_enum_variant_arg(&self, _: uint, f: &fn()) { - f() - } - - fn emit_enum_struct_variant(&self, - v_name: &str, - v_id: uint, - cnt: uint, - f: &fn()) { - self.emit_enum_variant(v_name, v_id, cnt, f) - } - - fn emit_enum_struct_variant_field(&self, - _: &str, - idx: uint, - f: &fn()) { - self.emit_enum_variant_arg(idx, f) - } - - fn emit_struct(&self, _: &str, _len: uint, f: &fn()) { - f() - } - - fn emit_field(&self, name: &str, _idx: uint, f: &fn()) { - self._emit_label(name); - f() - } - - fn emit_tuple(&self, len: uint, f: &fn()) { - self.emit_seq(len, f) - } - fn emit_tuple_arg(&self, idx: uint, f: &fn()) { - self.emit_seq_elt(idx, f) - } - - fn emit_tuple_struct(&self, _name: &str, len: uint, f: &fn()) { - self.emit_seq(len, f) - } - fn emit_tuple_struct_arg(&self, idx: uint, f: &fn()) { - self.emit_seq_elt(idx, f) - } - - fn emit_option(&self, f: &fn()) { - self.emit_enum("Option", f); - } - fn emit_option_none(&self) { - self.emit_enum_variant("None", 0, 0, || ()) - } - fn emit_option_some(&self, f: &fn()) { - self.emit_enum_variant("Some", 1, 1, f) - } - - fn emit_seq(&self, len: uint, f: &fn()) { - do self.wr_tag(EsVec as uint) { - self._emit_tagged_uint(EsVecLen, len); - f() - } - } - - fn emit_seq_elt(&self, _idx: uint, f: &fn()) { - self.wr_tag(EsVecElt as uint, f) - } - - fn emit_map(&self, _len: uint, _f: &fn()) { - fail!(~"emit_map is unimplemented"); - } - - fn emit_map_elt_key(&self, _idx: uint, _f: &fn()) { - fail!(~"emit_map_elt_key is unimplemented"); - } - - fn emit_map_elt_val(&self, _idx: uint, _f: &fn()) { - fail!(~"emit_map_elt_val is unimplemented"); - } - } - - #[cfg(not(stage0))] impl ::serialize::Encoder for Encoder { fn emit_nil(&mut self) {} diff --git a/src/libstd/flatpipes.rs b/src/libstd/flatpipes.rs index 52d6afbb93e..88de53f3605 100644 --- a/src/libstd/flatpipes.rs +++ b/src/libstd/flatpipes.rs @@ -438,19 +438,6 @@ pub mod flatteners { SerializingFlattener */ - #[cfg(stage0)] - pub fn deserialize_buffer>( - buf: &[u8]) - -> T { - let buf = vec::from_slice(buf); - let buf_reader = @BufReader::new(buf); - let reader = buf_reader as @Reader; - let deser: D = FromReader::from_reader(reader); - Decodable::decode(&deser) - } - - #[cfg(not(stage0))] pub fn deserialize_buffer>( buf: &[u8]) @@ -462,18 +449,6 @@ pub mod flatteners { Decodable::decode(&mut deser) } - #[cfg(stage0)] - pub fn serialize_value>( - val: &T) - -> ~[u8] { - do io::with_bytes_writer |writer| { - let ser = FromWriter::from_writer(writer); - val.encode(&ser); - } - } - - #[cfg(not(stage0))] pub fn serialize_value>( val: &T) diff --git a/src/libstd/future.rs b/src/libstd/future.rs index a0312849a35..5e3e64b2f1c 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -54,35 +54,6 @@ pub impl Future { } pub impl Future { - #[cfg(stage0)] - fn get_ref(&self) -> &'self A { - /*! - * Executes the future's closure and then returns a borrowed - * pointer to the result. The borrowed pointer lasts as long as - * the future. - */ - unsafe { - match self.state { - Forced(ref mut v) => { return cast::transmute(v); } - Evaluating => fail!(~"Recursive forcing of future!"), - Pending(_) => {} - } - - let mut state = Evaluating; - self.state <-> state; - match state { - Forced(_) | Evaluating => fail!(~"Logic error."), - Pending(f) => { - self.state = Forced(f()); - self.get_ref() - } - } - } - } - - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn get_ref<'a>(&'a self) -> &'a A { /*! * Executes the future's closure and then returns a borrowed diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 6951ee377c9..3960a07dfce 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -77,150 +77,6 @@ pub fn Encoder(wr: @io::Writer) -> Encoder { } } -#[cfg(stage0)] -impl serialize::Encoder for Encoder { - fn emit_nil(&self) { self.wr.write_str("null") } - - fn emit_uint(&self, v: uint) { self.emit_float(v as float); } - fn emit_u64(&self, v: u64) { self.emit_float(v as float); } - fn emit_u32(&self, v: u32) { self.emit_float(v as float); } - fn emit_u16(&self, v: u16) { self.emit_float(v as float); } - fn emit_u8(&self, v: u8) { self.emit_float(v as float); } - - fn emit_int(&self, v: int) { self.emit_float(v as float); } - fn emit_i64(&self, v: i64) { self.emit_float(v as float); } - fn emit_i32(&self, v: i32) { self.emit_float(v as float); } - fn emit_i16(&self, v: i16) { self.emit_float(v as float); } - fn emit_i8(&self, v: i8) { self.emit_float(v as float); } - - fn emit_bool(&self, v: bool) { - if v { - self.wr.write_str("true"); - } else { - self.wr.write_str("false"); - } - } - - fn emit_f64(&self, v: f64) { self.emit_float(v as float); } - fn emit_f32(&self, v: f32) { self.emit_float(v as float); } - fn emit_float(&self, v: float) { - self.wr.write_str(float::to_str_digits(v, 6u)); - } - - fn emit_char(&self, v: char) { self.emit_str(str::from_char(v)) } - fn emit_str(&self, v: &str) { self.wr.write_str(escape_str(v)) } - - fn emit_enum(&self, _name: &str, f: &fn()) { f() } - - fn emit_enum_variant(&self, - name: &str, - _id: uint, - cnt: uint, - f: &fn()) { - // enums are encoded as strings or vectors: - // Bunny => "Bunny" - // Kangaroo(34,"William") => ["Kangaroo",[34,"William"]] - - if cnt == 0 { - self.wr.write_str(escape_str(name)); - } else { - self.wr.write_char('['); - self.wr.write_str(escape_str(name)); - self.wr.write_char(','); - f(); - self.wr.write_char(']'); - } - } - - fn emit_enum_variant_arg(&self, idx: uint, f: &fn()) { - if idx != 0 {self.wr.write_char(',');} - f(); - } - - fn emit_enum_struct_variant(&self, - name: &str, - id: uint, - cnt: uint, - f: &fn()) { - self.emit_enum_variant(name, id, cnt, f) - } - - fn emit_enum_struct_variant_field(&self, - _: &str, - idx: uint, - f: &fn()) { - self.emit_enum_variant_arg(idx, f) - } - - fn emit_struct(&self, _: &str, _: uint, f: &fn()) { - self.wr.write_char('{'); - f(); - self.wr.write_char('}'); - } - - #[cfg(stage0)] - fn emit_field(&self, name: &str, idx: uint, f: &fn()) { - if idx != 0 { self.wr.write_char(','); } - self.wr.write_str(escape_str(name)); - self.wr.write_char(':'); - f(); - } - - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] - fn emit_struct_field(&self, name: &str, idx: uint, f: &fn()) { - if idx != 0 { self.wr.write_char(','); } - self.wr.write_str(escape_str(name)); - self.wr.write_char(':'); - f(); - } - - fn emit_tuple(&self, len: uint, f: &fn()) { self.emit_seq(len, f) } - fn emit_tuple_arg(&self, idx: uint, f: &fn()) { - self.emit_seq_elt(idx, f) - } - - fn emit_tuple_struct(&self, _name: &str, len: uint, f: &fn()) { - self.emit_seq(len, f) - } - fn emit_tuple_struct_arg(&self, idx: uint, f: &fn()) { - self.emit_seq_elt(idx, f) - } - - fn emit_option(&self, f: &fn()) { f(); } - fn emit_option_none(&self) { self.emit_nil(); } - fn emit_option_some(&self, f: &fn()) { f(); } - - fn emit_seq(&self, _len: uint, f: &fn()) { - self.wr.write_char('['); - f(); - self.wr.write_char(']'); - } - - fn emit_seq_elt(&self, idx: uint, f: &fn()) { - if idx != 0 { self.wr.write_char(','); } - f() - } - - fn emit_map(&self, _len: uint, f: &fn()) { - self.wr.write_char('{'); - f(); - self.wr.write_char('}'); - } - - fn emit_map_elt_key(&self, idx: uint, f: &fn()) { - if idx != 0 { self.wr.write_char(','); } - f() - } - - fn emit_map_elt_val(&self, _idx: uint, f: &fn()) { - self.wr.write_char(':'); - f() - } -} - -#[cfg(not(stage0))] impl serialize::Encoder for Encoder { fn emit_nil(&mut self) { self.wr.write_str("null") } @@ -376,202 +232,6 @@ pub fn PrettyEncoder(wr: @io::Writer) -> PrettyEncoder { } } -#[cfg(stage0)] -impl serialize::Encoder for PrettyEncoder { - fn emit_nil(&self) { self.wr.write_str("null") } - - fn emit_uint(&self, v: uint) { self.emit_float(v as float); } - fn emit_u64(&self, v: u64) { self.emit_float(v as float); } - fn emit_u32(&self, v: u32) { self.emit_float(v as float); } - fn emit_u16(&self, v: u16) { self.emit_float(v as float); } - fn emit_u8(&self, v: u8) { self.emit_float(v as float); } - - fn emit_int(&self, v: int) { self.emit_float(v as float); } - fn emit_i64(&self, v: i64) { self.emit_float(v as float); } - fn emit_i32(&self, v: i32) { self.emit_float(v as float); } - fn emit_i16(&self, v: i16) { self.emit_float(v as float); } - fn emit_i8(&self, v: i8) { self.emit_float(v as float); } - - fn emit_bool(&self, v: bool) { - if v { - self.wr.write_str("true"); - } else { - self.wr.write_str("false"); - } - } - - fn emit_f64(&self, v: f64) { self.emit_float(v as float); } - fn emit_f32(&self, v: f32) { self.emit_float(v as float); } - fn emit_float(&self, v: float) { - self.wr.write_str(float::to_str_digits(v, 6u)); - } - - fn emit_char(&self, v: char) { self.emit_str(str::from_char(v)) } - fn emit_str(&self, v: &str) { self.wr.write_str(escape_str(v)); } - - fn emit_enum(&self, _name: &str, f: &fn()) { f() } - - fn emit_enum_variant(&self, - name: &str, - _: uint, - cnt: uint, - f: &fn()) { - if cnt == 0 { - self.wr.write_str(escape_str(name)); - } else { - self.wr.write_char('['); - self.indent += 2; - self.wr.write_char('\n'); - self.wr.write_str(spaces(self.indent)); - self.wr.write_str(escape_str(name)); - self.wr.write_str(",\n"); - f(); - self.wr.write_char('\n'); - self.indent -= 2; - self.wr.write_str(spaces(self.indent)); - self.wr.write_char(']'); - } - } - - fn emit_enum_variant_arg(&self, idx: uint, f: &fn()) { - if idx != 0 { - self.wr.write_str(",\n"); - } - self.wr.write_str(spaces(self.indent)); - f() - } - - fn emit_enum_struct_variant(&self, - name: &str, - id: uint, - cnt: uint, - f: &fn()) { - self.emit_enum_variant(name, id, cnt, f) - } - - fn emit_enum_struct_variant_field(&self, - _: &str, - idx: uint, - f: &fn()) { - self.emit_enum_variant_arg(idx, f) - } - - - fn emit_struct(&self, _name: &str, len: uint, f: &fn()) { - if len == 0 { - self.wr.write_str("{}"); - } else { - self.wr.write_char('{'); - self.indent += 2; - f(); - self.wr.write_char('\n'); - self.indent -= 2; - self.wr.write_str(spaces(self.indent)); - self.wr.write_char('}'); - } - } - - #[cfg(stage0)] - fn emit_field(&self, name: &str, idx: uint, f: &fn()) { - if idx == 0 { - self.wr.write_char('\n'); - } else { - self.wr.write_str(",\n"); - } - self.wr.write_str(spaces(self.indent)); - self.wr.write_str(escape_str(name)); - self.wr.write_str(": "); - f(); - } - - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] - fn emit_struct_field(&self, name: &str, idx: uint, f: &fn()) { - if idx == 0 { - self.wr.write_char('\n'); - } else { - self.wr.write_str(",\n"); - } - self.wr.write_str(spaces(self.indent)); - self.wr.write_str(escape_str(name)); - self.wr.write_str(": "); - f(); - } - - fn emit_tuple(&self, len: uint, f: &fn()) { - self.emit_seq(len, f) - } - fn emit_tuple_arg(&self, idx: uint, f: &fn()) { - self.emit_seq_elt(idx, f) - } - - fn emit_tuple_struct(&self, _name: &str, len: uint, f: &fn()) { - self.emit_seq(len, f) - } - fn emit_tuple_struct_arg(&self, idx: uint, f: &fn()) { - self.emit_seq_elt(idx, f) - } - - fn emit_option(&self, f: &fn()) { f(); } - fn emit_option_none(&self) { self.emit_nil(); } - fn emit_option_some(&self, f: &fn()) { f(); } - - fn emit_seq(&self, len: uint, f: &fn()) { - if len == 0 { - self.wr.write_str("[]"); - } else { - self.wr.write_char('['); - self.indent += 2; - f(); - self.wr.write_char('\n'); - self.indent -= 2; - self.wr.write_str(spaces(self.indent)); - self.wr.write_char(']'); - } - } - - fn emit_seq_elt(&self, idx: uint, f: &fn()) { - if idx == 0 { - self.wr.write_char('\n'); - } else { - self.wr.write_str(",\n"); - } - self.wr.write_str(spaces(self.indent)); - f() - } - - fn emit_map(&self, len: uint, f: &fn()) { - if len == 0 { - self.wr.write_str("{}"); - } else { - self.wr.write_char('{'); - self.indent += 2; - f(); - self.wr.write_char('\n'); - self.indent -= 2; - self.wr.write_str(spaces(self.indent)); - self.wr.write_char('}'); - } - } - - fn emit_map_elt_key(&self, idx: uint, f: &fn()) { - if idx == 0 { - self.wr.write_char('\n'); - } else { - self.wr.write_str(",\n"); - } - self.wr.write_str(spaces(self.indent)); - f(); - } - - fn emit_map_elt_val(&self, _idx: uint, f: &fn()) { - self.wr.write_str(": "); - f(); - } -} - -#[cfg(not(stage0))] impl serialize::Encoder for PrettyEncoder { fn emit_nil(&mut self) { self.wr.write_str("null") } @@ -765,21 +425,6 @@ impl serialize::Encoder for PrettyEncoder { } } -#[cfg(stage0)] -impl serialize::Encodable for Json { - fn encode(&self, e: &E) { - match *self { - Number(v) => v.encode(e), - String(ref v) => v.encode(e), - Boolean(v) => v.encode(e), - List(ref v) => v.encode(e), - Object(ref v) => v.encode(e), - Null => e.emit_nil(), - } - } -} - -#[cfg(not(stage0))] impl serialize::Encodable for Json { fn encode(&self, e: &mut E) { match *self { @@ -794,14 +439,6 @@ impl serialize::Encodable for Json { } /// Encodes a json value into a io::writer -#[cfg(stage0)] -pub fn to_writer(wr: @io::Writer, json: &Json) { - let encoder = Encoder(wr); - json.encode(&encoder) -} - -/// Encodes a json value into a io::writer -#[cfg(not(stage0))] pub fn to_writer(wr: @io::Writer, json: &Json) { let mut encoder = Encoder(wr); json.encode(&mut encoder) @@ -813,14 +450,6 @@ pub fn to_str(json: &Json) -> ~str { } /// Encodes a json value into a io::writer -#[cfg(stage0)] -pub fn to_pretty_writer(wr: @io::Writer, json: &Json) { - let encoder = PrettyEncoder(wr); - json.encode(&encoder) -} - -/// Encodes a json value into a io::writer -#[cfg(not(stage0))] pub fn to_pretty_writer(wr: @io::Writer, json: &Json) { let mut encoder = PrettyEncoder(wr); json.encode(&mut encoder) @@ -1219,243 +848,6 @@ pub fn Decoder(json: Json) -> Decoder { } } -#[cfg(stage0)] -impl serialize::Decoder for Decoder { - fn read_nil(&self) -> () { - debug!("read_nil"); - match self.stack.pop() { - Null => (), - value => fail!(fmt!("not a null: %?", value)) - } - } - - fn read_u64(&self) -> u64 { self.read_float() as u64 } - fn read_u32(&self) -> u32 { self.read_float() as u32 } - fn read_u16(&self) -> u16 { self.read_float() as u16 } - fn read_u8 (&self) -> u8 { self.read_float() as u8 } - fn read_uint(&self) -> uint { self.read_float() as uint } - - fn read_i64(&self) -> i64 { self.read_float() as i64 } - fn read_i32(&self) -> i32 { self.read_float() as i32 } - fn read_i16(&self) -> i16 { self.read_float() as i16 } - fn read_i8 (&self) -> i8 { self.read_float() as i8 } - fn read_int(&self) -> int { self.read_float() as int } - - fn read_bool(&self) -> bool { - debug!("read_bool"); - match self.stack.pop() { - Boolean(b) => b, - value => fail!(fmt!("not a boolean: %?", value)) - } - } - - fn read_f64(&self) -> f64 { self.read_float() as f64 } - fn read_f32(&self) -> f32 { self.read_float() as f32 } - fn read_float(&self) -> float { - debug!("read_float"); - match self.stack.pop() { - Number(f) => f, - value => fail!(fmt!("not a number: %?", value)) - } - } - - fn read_char(&self) -> char { - let mut v = ~[]; - for str::each_char(self.read_str()) |c| { v.push(c) } - if v.len() != 1 { fail!(~"string must have one character") } - v[0] - } - - fn read_str(&self) -> ~str { - debug!("read_str"); - match self.stack.pop() { - String(s) => s, - json => fail!(fmt!("not a string: %?", json)) - } - } - - fn read_enum(&self, name: &str, f: &fn() -> T) -> T { - debug!("read_enum(%s)", name); - f() - } - - fn read_enum_variant(&self, - names: &[&str], - f: &fn(uint) -> T) - -> T { - debug!("read_enum_variant(names=%?)", names); - let name = match self.stack.pop() { - String(s) => s, - List(list) => { - do vec::consume_reverse(list) |_i, v| { - self.stack.push(v); - } - match self.stack.pop() { - String(s) => s, - value => fail!(fmt!("invalid variant name: %?", value)), - } - } - ref json => fail!(fmt!("invalid variant: %?", *json)), - }; - let idx = match vec::position(names, |n| str::eq_slice(*n, name)) { - Some(idx) => idx, - None => fail!(fmt!("Unknown variant name: %?", name)), - }; - f(idx) - } - - fn read_enum_variant_arg(&self, idx: uint, f: &fn() -> T) -> T { - debug!("read_enum_variant_arg(idx=%u)", idx); - f() - } - - fn read_enum_struct_variant(&self, - names: &[&str], - f: &fn(uint) -> T) - -> T { - debug!("read_enum_struct_variant(names=%?)", names); - self.read_enum_variant(names, f) - } - - - fn read_enum_struct_variant_field(&self, - name: &str, - idx: uint, - f: &fn() -> T) - -> T { - debug!("read_enum_struct_variant_field(name=%?, idx=%u)", name, idx); - self.read_enum_variant_arg(idx, f) - } - - fn read_struct(&self, name: &str, len: uint, f: &fn() -> T) -> T { - debug!("read_struct(name=%s, len=%u)", name, len); - let value = f(); - self.stack.pop(); - value - } - - #[cfg(stage0)] - fn read_field(&self, name: &str, idx: uint, f: &fn() -> T) -> T { - debug!("read_field(name=%?, idx=%u)", name, idx); - match self.stack.pop() { - Object(obj) => { - let mut obj = obj; - let value = match obj.pop(&name.to_owned()) { - None => fail!(fmt!("no such field: %s", name)), - Some(json) => { - self.stack.push(json); - f() - } - }; - self.stack.push(Object(obj)); - value - } - value => fail!(fmt!("not an object: %?", value)) - } - } - - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] - fn read_struct_field(&self, - name: &str, - idx: uint, - f: &fn() -> T) - -> T { - debug!("read_struct_field(name=%?, idx=%u)", name, idx); - match self.stack.pop() { - Object(obj) => { - let mut obj = obj; - let value = match obj.pop(&name.to_owned()) { - None => fail!(fmt!("no such field: %s", name)), - Some(json) => { - self.stack.push(json); - f() - } - }; - self.stack.push(Object(obj)); - value - } - value => fail!(fmt!("not an object: %?", value)) - } - } - - fn read_tuple(&self, f: &fn(uint) -> T) -> T { - debug!("read_tuple()"); - self.read_seq(f) - } - - fn read_tuple_arg(&self, idx: uint, f: &fn() -> T) -> T { - debug!("read_tuple_arg(idx=%u)", idx); - self.read_seq_elt(idx, f) - } - - fn read_tuple_struct(&self, name: &str, f: &fn(uint) -> T) -> T { - debug!("read_tuple_struct(name=%?)", name); - self.read_tuple(f) - } - - fn read_tuple_struct_arg(&self, idx: uint, f: &fn() -> T) -> T { - debug!("read_tuple_struct_arg(idx=%u)", idx); - self.read_tuple_arg(idx, f) - } - - fn read_option(&self, f: &fn(bool) -> T) -> T { - match self.stack.pop() { - Null => f(false), - value => { self.stack.push(value); f(true) } - } - } - - fn read_seq(&self, f: &fn(uint) -> T) -> T { - debug!("read_seq()"); - let len = match self.stack.pop() { - List(list) => { - let len = list.len(); - do vec::consume_reverse(list) |_i, v| { - self.stack.push(v); - } - len - } - _ => fail!(~"not a list"), - }; - f(len) - } - - fn read_seq_elt(&self, idx: uint, f: &fn() -> T) -> T { - debug!("read_seq_elt(idx=%u)", idx); - f() - } - - fn read_map(&self, f: &fn(uint) -> T) -> T { - debug!("read_map()"); - let len = match self.stack.pop() { - Object(obj) => { - let mut obj = obj; - let len = obj.len(); - do obj.consume |key, value| { - self.stack.push(value); - self.stack.push(String(key)); - } - len - } - json => fail!(fmt!("not an object: %?", json)), - }; - f(len) - } - - fn read_map_elt_key(&self, idx: uint, f: &fn() -> T) -> T { - debug!("read_map_elt_key(idx=%u)", idx); - f() - } - - fn read_map_elt_val(&self, idx: uint, f: &fn() -> T) -> T { - debug!("read_map_elt_val(idx=%u)", idx); - f() - } -} - -#[cfg(not(stage0))] impl serialize::Decoder for Decoder { fn read_nil(&mut self) -> () { debug!("read_nil"); @@ -1577,29 +969,6 @@ impl serialize::Decoder for Decoder { value } - #[cfg(stage0)] - fn read_field(&mut self, name: &str, idx: uint, f: &fn() -> T) -> T { - debug!("read_field(name=%?, idx=%u)", name, idx); - match self.stack.pop() { - Object(obj) => { - let mut obj = obj; - let value = match obj.pop(&name.to_owned()) { - None => fail!(fmt!("no such field: %s", name)), - Some(json) => { - self.stack.push(json); - f() - } - }; - self.stack.push(Object(obj)); - value - } - value => fail!(fmt!("not an object: %?", value)) - } - } - - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn read_struct_field(&mut self, name: &str, idx: uint, diff --git a/src/libstd/priority_queue.rs b/src/libstd/priority_queue.rs index 47af3576c90..33fe1cfff8e 100644 --- a/src/libstd/priority_queue.rs +++ b/src/libstd/priority_queue.rs @@ -45,25 +45,9 @@ impl Mutable for PriorityQueue { pub impl PriorityQueue { /// Returns the greatest item in the queue - fails if empty - #[cfg(stage0)] - fn top(&self) -> &'self T { &self.data[0] } - - /// Returns the greatest item in the queue - fails if empty - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn top<'a>(&'a self) -> &'a T { &self.data[0] } /// Returns the greatest item in the queue - None if empty - #[cfg(stage0)] - fn maybe_top(&self) -> Option<&'self T> { - if self.is_empty() { None } else { Some(self.top()) } - } - - /// Returns the greatest item in the queue - None if empty - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn maybe_top<'a>(&'a self) -> Option<&'a T> { if self.is_empty() { None } else { Some(self.top()) } } diff --git a/src/libstd/serialize.rs b/src/libstd/serialize.rs index 39fb5a45d7e..a5d2604b6f6 100644 --- a/src/libstd/serialize.rs +++ b/src/libstd/serialize.rs @@ -20,80 +20,8 @@ use core::hashmap::{HashMap, HashSet}; use core::trie::{TrieMap, TrieSet}; use deque::Deque; use dlist::DList; -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] use treemap::{TreeMap, TreeSet}; -#[cfg(stage0)] -pub trait Encoder { - // Primitive types: - fn emit_nil(&self); - fn emit_uint(&self, v: uint); - fn emit_u64(&self, v: u64); - fn emit_u32(&self, v: u32); - fn emit_u16(&self, v: u16); - fn emit_u8(&self, v: u8); - fn emit_int(&self, v: int); - fn emit_i64(&self, v: i64); - fn emit_i32(&self, v: i32); - fn emit_i16(&self, v: i16); - fn emit_i8(&self, v: i8); - fn emit_bool(&self, v: bool); - fn emit_float(&self, v: float); - fn emit_f64(&self, v: f64); - fn emit_f32(&self, v: f32); - fn emit_char(&self, v: char); - fn emit_str(&self, v: &str); - - // Compound types: - fn emit_enum(&self, name: &str, f: &fn()); - - fn emit_enum_variant(&self, - v_name: &str, - v_id: uint, - len: uint, - f: &fn()); - fn emit_enum_variant_arg(&self, a_idx: uint, f: &fn()); - - fn emit_enum_struct_variant(&self, - v_name: &str, - v_id: uint, - len: uint, - f: &fn()); - fn emit_enum_struct_variant_field(&self, - f_name: &str, - f_idx: uint, - f: &fn()); - - fn emit_struct(&self, name: &str, len: uint, f: &fn()); - #[cfg(stage0)] - fn emit_field(&self, f_name: &str, f_idx: uint, f: &fn()); - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] - fn emit_struct_field(&self, f_name: &str, f_idx: uint, f: &fn()); - - fn emit_tuple(&self, len: uint, f: &fn()); - fn emit_tuple_arg(&self, idx: uint, f: &fn()); - - fn emit_tuple_struct(&self, name: &str, len: uint, f: &fn()); - fn emit_tuple_struct_arg(&self, f_idx: uint, f: &fn()); - - // Specialized types: - fn emit_option(&self, f: &fn()); - fn emit_option_none(&self); - fn emit_option_some(&self, f: &fn()); - - fn emit_seq(&self, len: uint, f: &fn()); - fn emit_seq_elt(&self, idx: uint, f: &fn()); - - fn emit_map(&self, len: uint, f: &fn()); - fn emit_map_elt_key(&self, idx: uint, f: &fn()); - fn emit_map_elt_val(&self, idx: uint, f: &fn()); -} - -#[cfg(not(stage0))] pub trait Encoder { // Primitive types: fn emit_nil(&mut self); @@ -159,80 +87,6 @@ pub trait Encoder { fn emit_map_elt_val(&mut self, idx: uint, f: &fn(&mut Self)); } -#[cfg(stage0)] -pub trait Decoder { - // Primitive types: - fn read_nil(&self) -> (); - fn read_uint(&self) -> uint; - fn read_u64(&self) -> u64; - fn read_u32(&self) -> u32; - fn read_u16(&self) -> u16; - fn read_u8(&self) -> u8; - fn read_int(&self) -> int; - fn read_i64(&self) -> i64; - fn read_i32(&self) -> i32; - fn read_i16(&self) -> i16; - fn read_i8(&self) -> i8; - fn read_bool(&self) -> bool; - fn read_f64(&self) -> f64; - fn read_f32(&self) -> f32; - fn read_float(&self) -> float; - fn read_char(&self) -> char; - fn read_str(&self) -> ~str; - - // Compound types: - fn read_enum(&self, name: &str, f: &fn() -> T) -> T; - - fn read_enum_variant(&self, - names: &[&str], - f: &fn(uint) -> T) - -> T; - fn read_enum_variant_arg(&self, a_idx: uint, f: &fn() -> T) -> T; - - fn read_enum_struct_variant(&self, - names: &[&str], - f: &fn(uint) -> T) - -> T; - fn read_enum_struct_variant_field(&self, - &f_name: &str, - f_idx: uint, - f: &fn() -> T) - -> T; - - fn read_struct(&self, s_name: &str, len: uint, f: &fn() -> T) -> T; - #[cfg(stage0)] - fn read_field(&self, - f_name: &str, - f_idx: uint, - f: &fn() -> T) - -> T; - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] - fn read_struct_field(&self, - f_name: &str, - f_idx: uint, - f: &fn() -> T) - -> T; - - fn read_tuple(&self, f: &fn(uint) -> T) -> T; - fn read_tuple_arg(&self, a_idx: uint, f: &fn() -> T) -> T; - - fn read_tuple_struct(&self, s_name: &str, f: &fn(uint) -> T) -> T; - fn read_tuple_struct_arg(&self, a_idx: uint, f: &fn() -> T) -> T; - - // Specialized types: - fn read_option(&self, f: &fn(bool) -> T) -> T; - - fn read_seq(&self, f: &fn(uint) -> T) -> T; - fn read_seq_elt(&self, idx: uint, f: &fn() -> T) -> T; - - fn read_map(&self, f: &fn(uint) -> T) -> T; - fn read_map_elt_key(&self, idx: uint, f: &fn() -> T) -> T; - fn read_map_elt_val(&self, idx: uint, f: &fn() -> T) -> T; -} - -#[cfg(not(stage0))] pub trait Decoder { // Primitive types: fn read_nil(&mut self) -> (); @@ -280,15 +134,6 @@ pub trait Decoder { len: uint, f: &fn(&mut Self) -> T) -> T; - #[cfg(stage0)] - fn read_field(&mut self, - f_name: &str, - f_idx: uint, - f: &fn() -> T) - -> T; - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn read_struct_field(&mut self, f_name: &str, f_idx: uint, @@ -318,598 +163,254 @@ pub trait Decoder { fn read_map_elt_val(&mut self, idx: uint, f: &fn(&mut Self) -> T) -> T; } -#[cfg(stage0)] -pub trait Encodable { - fn encode(&self, s: &S); -} - -#[cfg(not(stage0))] pub trait Encodable { fn encode(&self, s: &mut S); } -#[cfg(stage0)] -pub trait Decodable { - fn decode(d: &D) -> Self; -} - -#[cfg(not(stage0))] pub trait Decodable { fn decode(d: &mut D) -> Self; } -#[cfg(stage0)] -impl Encodable for uint { - fn encode(&self, s: &S) { - s.emit_uint(*self) - } -} - -#[cfg(not(stage0))] impl Encodable for uint { fn encode(&self, s: &mut S) { s.emit_uint(*self) } } -#[cfg(stage0)] -impl Decodable for uint { - fn decode(d: &D) -> uint { - d.read_uint() - } -} - -#[cfg(not(stage0))] impl Decodable for uint { fn decode(d: &mut D) -> uint { d.read_uint() } } -#[cfg(stage0)] -impl Encodable for u8 { - fn encode(&self, s: &S) { - s.emit_u8(*self) - } -} - -#[cfg(not(stage0))] impl Encodable for u8 { fn encode(&self, s: &mut S) { s.emit_u8(*self) } } -#[cfg(stage0)] -impl Decodable for u8 { - fn decode(d: &D) -> u8 { - d.read_u8() - } -} - -#[cfg(not(stage0))] impl Decodable for u8 { fn decode(d: &mut D) -> u8 { d.read_u8() } } -#[cfg(stage0)] -impl Encodable for u16 { - fn encode(&self, s: &S) { - s.emit_u16(*self) - } -} - -#[cfg(not(stage0))] impl Encodable for u16 { fn encode(&self, s: &mut S) { s.emit_u16(*self) } } -#[cfg(stage0)] -impl Decodable for u16 { - fn decode(d: &D) -> u16 { - d.read_u16() - } -} - -#[cfg(not(stage0))] impl Decodable for u16 { fn decode(d: &mut D) -> u16 { d.read_u16() } } -#[cfg(stage0)] -impl Encodable for u32 { - fn encode(&self, s: &S) { - s.emit_u32(*self) - } -} - -#[cfg(not(stage0))] impl Encodable for u32 { fn encode(&self, s: &mut S) { s.emit_u32(*self) } } -#[cfg(stage0)] -impl Decodable for u32 { - fn decode(d: &D) -> u32 { - d.read_u32() - } -} - -#[cfg(not(stage0))] impl Decodable for u32 { fn decode(d: &mut D) -> u32 { d.read_u32() } } -#[cfg(stage0)] -impl Encodable for u64 { - fn encode(&self, s: &S) { - s.emit_u64(*self) - } -} - -#[cfg(not(stage0))] impl Encodable for u64 { fn encode(&self, s: &mut S) { s.emit_u64(*self) } } -#[cfg(stage0)] -impl Decodable for u64 { - fn decode(d: &D) -> u64 { - d.read_u64() - } -} - -#[cfg(not(stage0))] impl Decodable for u64 { fn decode(d: &mut D) -> u64 { d.read_u64() } } -#[cfg(stage0)] -impl Encodable for int { - fn encode(&self, s: &S) { - s.emit_int(*self) - } -} - -#[cfg(not(stage0))] impl Encodable for int { fn encode(&self, s: &mut S) { s.emit_int(*self) } } -#[cfg(stage0)] -impl Decodable for int { - fn decode(d: &D) -> int { - d.read_int() - } -} - -#[cfg(not(stage0))] impl Decodable for int { fn decode(d: &mut D) -> int { d.read_int() } } -#[cfg(stage0)] -impl Encodable for i8 { - fn encode(&self, s: &S) { - s.emit_i8(*self) - } -} - -#[cfg(not(stage0))] impl Encodable for i8 { fn encode(&self, s: &mut S) { s.emit_i8(*self) } } -#[cfg(stage0)] -impl Decodable for i8 { - fn decode(d: &D) -> i8 { - d.read_i8() - } -} - -#[cfg(not(stage0))] impl Decodable for i8 { fn decode(d: &mut D) -> i8 { d.read_i8() } } -#[cfg(stage0)] -impl Encodable for i16 { - fn encode(&self, s: &S) { - s.emit_i16(*self) - } -} - -#[cfg(not(stage0))] impl Encodable for i16 { fn encode(&self, s: &mut S) { s.emit_i16(*self) } } -#[cfg(stage0)] -impl Decodable for i16 { - fn decode(d: &D) -> i16 { - d.read_i16() - } -} - -#[cfg(not(stage0))] impl Decodable for i16 { fn decode(d: &mut D) -> i16 { d.read_i16() } } -#[cfg(stage0)] -impl Encodable for i32 { - fn encode(&self, s: &S) { - s.emit_i32(*self) - } -} - -#[cfg(not(stage0))] impl Encodable for i32 { fn encode(&self, s: &mut S) { s.emit_i32(*self) } } -#[cfg(stage0)] -impl Decodable for i32 { - fn decode(d: &D) -> i32 { - d.read_i32() - } -} - -#[cfg(not(stage0))] impl Decodable for i32 { fn decode(d: &mut D) -> i32 { d.read_i32() } } -#[cfg(stage0)] -impl Encodable for i64 { - fn encode(&self, s: &S) { - s.emit_i64(*self) - } -} - -#[cfg(not(stage0))] impl Encodable for i64 { fn encode(&self, s: &mut S) { s.emit_i64(*self) } } -#[cfg(stage0)] -impl Decodable for i64 { - fn decode(d: &D) -> i64 { - d.read_i64() - } -} - -#[cfg(not(stage0))] impl Decodable for i64 { fn decode(d: &mut D) -> i64 { d.read_i64() } } -#[cfg(stage0)] -impl<'self, S:Encoder> Encodable for &'self str { - fn encode(&self, s: &S) { - s.emit_str(*self) - } -} - -#[cfg(not(stage0))] impl<'self, S:Encoder> Encodable for &'self str { fn encode(&self, s: &mut S) { s.emit_str(*self) } } -#[cfg(stage0)] -impl Encodable for ~str { - fn encode(&self, s: &S) { - s.emit_str(*self) - } -} - -#[cfg(not(stage0))] impl Encodable for ~str { fn encode(&self, s: &mut S) { s.emit_str(*self) } } -#[cfg(stage0)] -impl Decodable for ~str { - fn decode(d: &D) -> ~str { - d.read_str() - } -} - -#[cfg(not(stage0))] impl Decodable for ~str { fn decode(d: &mut D) -> ~str { d.read_str() } } -#[cfg(stage0)] -impl Encodable for @str { - fn encode(&self, s: &S) { - s.emit_str(*self) - } -} - -#[cfg(not(stage0))] impl Encodable for @str { fn encode(&self, s: &mut S) { s.emit_str(*self) } } -#[cfg(stage0)] -impl Decodable for @str { - fn decode(d: &D) -> @str { - d.read_str().to_managed() - } -} - -#[cfg(not(stage0))] impl Decodable for @str { fn decode(d: &mut D) -> @str { d.read_str().to_managed() } } -#[cfg(stage0)] -impl Encodable for float { - fn encode(&self, s: &S) { - s.emit_float(*self) - } -} - -#[cfg(not(stage0))] impl Encodable for float { fn encode(&self, s: &mut S) { s.emit_float(*self) } } -#[cfg(stage0)] -impl Decodable for float { - fn decode(d: &D) -> float { - d.read_float() - } -} - -#[cfg(not(stage0))] impl Decodable for float { fn decode(d: &mut D) -> float { d.read_float() } } -#[cfg(stage0)] -impl Encodable for f32 { - fn encode(&self, s: &S) { - s.emit_f32(*self) - } -} - -#[cfg(not(stage0))] impl Encodable for f32 { fn encode(&self, s: &mut S) { s.emit_f32(*self) } } -#[cfg(stage0)] -impl Decodable for f32 { - fn decode(d: &D) -> f32 { - d.read_f32() - } -} - -#[cfg(not(stage0))] impl Decodable for f32 { fn decode(d: &mut D) -> f32 { d.read_f32() } } -#[cfg(stage0)] -impl Encodable for f64 { - fn encode(&self, s: &S) { - s.emit_f64(*self) - } -} - -#[cfg(not(stage0))] impl Encodable for f64 { fn encode(&self, s: &mut S) { s.emit_f64(*self) } } -#[cfg(stage0)] -impl Decodable for f64 { - fn decode(d: &D) -> f64 { - d.read_f64() - } -} - -#[cfg(not(stage0))] impl Decodable for f64 { fn decode(d: &mut D) -> f64 { d.read_f64() } } -#[cfg(stage0)] -impl Encodable for bool { - fn encode(&self, s: &S) { - s.emit_bool(*self) - } -} - -#[cfg(not(stage0))] impl Encodable for bool { fn encode(&self, s: &mut S) { s.emit_bool(*self) } } -#[cfg(stage0)] -impl Decodable for bool { - fn decode(d: &D) -> bool { - d.read_bool() - } -} - -#[cfg(not(stage0))] impl Decodable for bool { fn decode(d: &mut D) -> bool { d.read_bool() } } -#[cfg(stage0)] -impl Encodable for () { - fn encode(&self, s: &S) { - s.emit_nil() - } -} - -#[cfg(not(stage0))] impl Encodable for () { fn encode(&self, s: &mut S) { s.emit_nil() } } -#[cfg(stage0)] -impl Decodable for () { - fn decode(d: &D) -> () { - d.read_nil() - } -} - -#[cfg(not(stage0))] impl Decodable for () { fn decode(d: &mut D) -> () { d.read_nil() } } -#[cfg(stage0)] -impl<'self, S:Encoder,T:Encodable> Encodable for &'self T { - fn encode(&self, s: &S) { - (**self).encode(s) - } -} - -#[cfg(not(stage0))] impl<'self, S:Encoder,T:Encodable> Encodable for &'self T { fn encode(&self, s: &mut S) { (**self).encode(s) } } -#[cfg(stage0)] -impl> Encodable for ~T { - fn encode(&self, s: &S) { - (**self).encode(s) - } -} - -#[cfg(not(stage0))] impl> Encodable for ~T { fn encode(&self, s: &mut S) { (**self).encode(s) } } -#[cfg(stage0)] -impl> Decodable for ~T { - fn decode(d: &D) -> ~T { - ~Decodable::decode(d) - } -} - -#[cfg(not(stage0))] impl> Decodable for ~T { fn decode(d: &mut D) -> ~T { ~Decodable::decode(d) } } -#[cfg(stage0)] -impl> Encodable for @T { - fn encode(&self, s: &S) { - (**self).encode(s) - } -} - -#[cfg(not(stage0))] impl> Encodable for @T { fn encode(&self, s: &mut S) { (**self).encode(s) } } -#[cfg(stage0)] -impl> Decodable for @T { - fn decode(d: &D) -> @T { - @Decodable::decode(d) - } -} - -#[cfg(not(stage0))] impl> Decodable for @T { fn decode(d: &mut D) -> @T { @Decodable::decode(d) } } -#[cfg(stage0)] -impl<'self, S:Encoder,T:Encodable> Encodable for &'self [T] { - fn encode(&self, s: &S) { - do s.emit_seq(self.len()) { - for self.eachi |i, e| { - s.emit_seq_elt(i, || e.encode(s)) - } - } - } -} - -#[cfg(not(stage0))] impl<'self, S:Encoder,T:Encodable> Encodable for &'self [T] { fn encode(&self, s: &mut S) { do s.emit_seq(self.len()) |s| { @@ -920,18 +421,6 @@ impl<'self, S:Encoder,T:Encodable> Encodable for &'self [T] { } } -#[cfg(stage0)] -impl> Encodable for ~[T] { - fn encode(&self, s: &S) { - do s.emit_seq(self.len()) { - for self.eachi |i, e| { - s.emit_seq_elt(i, || e.encode(s)) - } - } - } -} - -#[cfg(not(stage0))] impl> Encodable for ~[T] { fn encode(&self, s: &mut S) { do s.emit_seq(self.len()) |s| { @@ -942,18 +431,6 @@ impl> Encodable for ~[T] { } } -#[cfg(stage0)] -impl> Decodable for ~[T] { - fn decode(d: &D) -> ~[T] { - do d.read_seq |len| { - do vec::from_fn(len) |i| { - d.read_seq_elt(i, || Decodable::decode(d)) - } - } - } -} - -#[cfg(not(stage0))] impl> Decodable for ~[T] { fn decode(d: &mut D) -> ~[T] { do d.read_seq |d, len| { @@ -964,18 +441,6 @@ impl> Decodable for ~[T] { } } -#[cfg(stage0)] -impl> Encodable for @[T] { - fn encode(&self, s: &S) { - do s.emit_seq(self.len()) { - for self.eachi |i, e| { - s.emit_seq_elt(i, || e.encode(s)) - } - } - } -} - -#[cfg(not(stage0))] impl> Encodable for @[T] { fn encode(&self, s: &mut S) { do s.emit_seq(self.len()) |s| { @@ -986,18 +451,6 @@ impl> Encodable for @[T] { } } -#[cfg(stage0)] -impl> Decodable for @[T] { - fn decode(d: &D) -> @[T] { - do d.read_seq |len| { - do at_vec::from_fn(len) |i| { - d.read_seq_elt(i, || Decodable::decode(d)) - } - } - } -} - -#[cfg(not(stage0))] impl> Decodable for @[T] { fn decode(d: &mut D) -> @[T] { do d.read_seq |d, len| { @@ -1008,19 +461,6 @@ impl> Decodable for @[T] { } } -#[cfg(stage0)] -impl> Encodable for Option { - fn encode(&self, s: &S) { - do s.emit_option { - match *self { - None => s.emit_option_none(), - Some(ref v) => s.emit_option_some(|| v.encode(s)), - } - } - } -} - -#[cfg(not(stage0))] impl> Encodable for Option { fn encode(&self, s: &mut S) { do s.emit_option |s| { @@ -1032,47 +472,18 @@ impl> Encodable for Option { } } -#[cfg(stage0)] -impl> Decodable for Option { - fn decode(d: &D) -> Option { - do d.read_option |b| { - if b { - Some(Decodable::decode(d)) - } else { - None - } - } - } -} - -#[cfg(not(stage0))] impl> Decodable for Option { - fn decode(d: &mut D) -> Option { - do d.read_option |d, b| { - if b { - Some(Decodable::decode(d)) - } else { - None - } - } - } -} - -#[cfg(stage0)] -impl,T1:Encodable> Encodable for (T0, T1) { - fn encode(&self, s: &S) { - match *self { - (ref t0, ref t1) => { - do s.emit_seq(2) { - s.emit_seq_elt(0, || t0.encode(s)); - s.emit_seq_elt(1, || t1.encode(s)); - } + fn decode(d: &mut D) -> Option { + do d.read_option |d, b| { + if b { + Some(Decodable::decode(d)) + } else { + None } } } } -#[cfg(not(stage0))] impl,T1:Encodable> Encodable for (T0, T1) { fn encode(&self, s: &mut S) { match *self { @@ -1086,20 +497,6 @@ impl,T1:Encodable> Encodable for (T0, T1) { } } -#[cfg(stage0)] -impl,T1:Decodable> Decodable for (T0, T1) { - fn decode(d: &D) -> (T0, T1) { - do d.read_seq |len| { - assert!(len == 2); - ( - d.read_seq_elt(0, || Decodable::decode(d)), - d.read_seq_elt(1, || Decodable::decode(d)) - ) - } - } -} - -#[cfg(not(stage0))] impl,T1:Decodable> Decodable for (T0, T1) { fn decode(d: &mut D) -> (T0, T1) { do d.read_seq |d, len| { @@ -1112,27 +509,6 @@ impl,T1:Decodable> Decodable for (T0, T1) { } } -#[cfg(stage0)] -impl< - S: Encoder, - T0: Encodable, - T1: Encodable, - T2: Encodable -> Encodable for (T0, T1, T2) { - fn encode(&self, s: &S) { - match *self { - (ref t0, ref t1, ref t2) => { - do s.emit_seq(3) { - s.emit_seq_elt(0, || t0.encode(s)); - s.emit_seq_elt(1, || t1.encode(s)); - s.emit_seq_elt(2, || t2.encode(s)); - } - } - } - } -} - -#[cfg(not(stage0))] impl< S: Encoder, T0: Encodable, @@ -1152,26 +528,6 @@ impl< } } -#[cfg(stage0)] -impl< - D: Decoder, - T0: Decodable, - T1: Decodable, - T2: Decodable -> Decodable for (T0, T1, T2) { - fn decode(d: &D) -> (T0, T1, T2) { - do d.read_seq |len| { - assert!(len == 3); - ( - d.read_seq_elt(0, || Decodable::decode(d)), - d.read_seq_elt(1, || Decodable::decode(d)), - d.read_seq_elt(2, || Decodable::decode(d)) - ) - } - } -} - -#[cfg(not(stage0))] impl< D: Decoder, T0: Decodable, @@ -1190,29 +546,6 @@ impl< } } -#[cfg(stage0)] -impl< - S: Encoder, - T0: Encodable, - T1: Encodable, - T2: Encodable, - T3: Encodable -> Encodable for (T0, T1, T2, T3) { - fn encode(&self, s: &S) { - match *self { - (ref t0, ref t1, ref t2, ref t3) => { - do s.emit_seq(4) { - s.emit_seq_elt(0, || t0.encode(s)); - s.emit_seq_elt(1, || t1.encode(s)); - s.emit_seq_elt(2, || t2.encode(s)); - s.emit_seq_elt(3, || t3.encode(s)); - } - } - } - } -} - -#[cfg(not(stage0))] impl< S: Encoder, T0: Encodable, @@ -1234,28 +567,6 @@ impl< } } -#[cfg(stage0)] -impl< - D: Decoder, - T0: Decodable, - T1: Decodable, - T2: Decodable, - T3: Decodable -> Decodable for (T0, T1, T2, T3) { - fn decode(d: &D) -> (T0, T1, T2, T3) { - do d.read_seq |len| { - assert!(len == 4); - ( - d.read_seq_elt(0, || Decodable::decode(d)), - d.read_seq_elt(1, || Decodable::decode(d)), - d.read_seq_elt(2, || Decodable::decode(d)), - d.read_seq_elt(3, || Decodable::decode(d)) - ) - } - } -} - -#[cfg(not(stage0))] impl< D: Decoder, T0: Decodable, @@ -1276,31 +587,6 @@ impl< } } -#[cfg(stage0)] -impl< - S: Encoder, - T0: Encodable, - T1: Encodable, - T2: Encodable, - T3: Encodable, - T4: Encodable -> Encodable for (T0, T1, T2, T3, T4) { - fn encode(&self, s: &S) { - match *self { - (ref t0, ref t1, ref t2, ref t3, ref t4) => { - do s.emit_seq(5) { - s.emit_seq_elt(0, || t0.encode(s)); - s.emit_seq_elt(1, || t1.encode(s)); - s.emit_seq_elt(2, || t2.encode(s)); - s.emit_seq_elt(3, || t3.encode(s)); - s.emit_seq_elt(4, || t4.encode(s)); - } - } - } - } -} - -#[cfg(not(stage0))] impl< S: Encoder, T0: Encodable, @@ -1324,30 +610,6 @@ impl< } } -#[cfg(stage0)] -impl< - D: Decoder, - T0: Decodable, - T1: Decodable, - T2: Decodable, - T3: Decodable, - T4: Decodable -> Decodable for (T0, T1, T2, T3, T4) { - fn decode(d: &D) -> (T0, T1, T2, T3, T4) { - do d.read_seq |len| { - assert!(len == 5); - ( - d.read_seq_elt(0, || Decodable::decode(d)), - d.read_seq_elt(1, || Decodable::decode(d)), - d.read_seq_elt(2, || Decodable::decode(d)), - d.read_seq_elt(3, || Decodable::decode(d)), - d.read_seq_elt(4, || Decodable::decode(d)) - ) - } - } -} - -#[cfg(not(stage0))] impl< D: Decoder, T0: Decodable, @@ -1370,23 +632,6 @@ impl< } } -#[cfg(stage0)] -impl< - S: Encoder, - T: Encodable + Copy -> Encodable for @mut DList { - fn encode(&self, s: &S) { - do s.emit_seq(self.size) { - let mut i = 0; - for self.each |e| { - s.emit_seq_elt(i, || e.encode(s)); - i += 1; - } - } - } -} - -#[cfg(not(stage0))] impl< S: Encoder, T: Encodable + Copy @@ -1402,20 +647,6 @@ impl< } } -#[cfg(stage0)] -impl> Decodable for @mut DList { - fn decode(d: &D) -> @mut DList { - let list = DList(); - do d.read_seq |len| { - for uint::range(0, len) |i| { - list.push(d.read_seq_elt(i, || Decodable::decode(d))); - } - } - list - } -} - -#[cfg(not(stage0))] impl> Decodable for @mut DList { fn decode(d: &mut D) -> @mut DList { let list = DList(); @@ -1428,21 +659,6 @@ impl> Decodable for @mut DList { } } -#[cfg(stage0)] -impl< - S: Encoder, - T: Encodable -> Encodable for Deque { - fn encode(&self, s: &S) { - do s.emit_seq(self.len()) { - for self.eachi |i, e| { - s.emit_seq_elt(i, || e.encode(s)); - } - } - } -} - -#[cfg(not(stage0))] impl< S: Encoder, T: Encodable @@ -1456,20 +672,6 @@ impl< } } -#[cfg(stage0)] -impl> Decodable for Deque { - fn decode(d: &D) -> Deque { - let mut deque = Deque::new(); - do d.read_seq |len| { - for uint::range(0, len) |i| { - deque.add_back(d.read_seq_elt(i, || Decodable::decode(d))); - } - } - deque - } -} - -#[cfg(not(stage0))] impl> Decodable for Deque { fn decode(d: &mut D) -> Deque { let mut deque = Deque::new(); @@ -1482,25 +684,6 @@ impl> Decodable for Deque { } } -#[cfg(stage0)] -impl< - E: Encoder, - K: Encodable + Hash + IterBytes + Eq, - V: Encodable -> Encodable for HashMap { - fn encode(&self, e: &E) { - do e.emit_map(self.len()) { - let mut i = 0; - for self.each |key, val| { - e.emit_map_elt_key(i, || key.encode(e)); - e.emit_map_elt_val(i, || val.encode(e)); - i += 1; - } - } - } -} - -#[cfg(not(stage0))] impl< E: Encoder, K: Encodable + Hash + IterBytes + Eq, @@ -1518,26 +701,6 @@ impl< } } -#[cfg(stage0)] -impl< - D: Decoder, - K: Decodable + Hash + IterBytes + Eq, - V: Decodable -> Decodable for HashMap { - fn decode(d: &D) -> HashMap { - do d.read_map |len| { - let mut map = HashMap::with_capacity(len); - for uint::range(0, len) |i| { - let key = d.read_map_elt_key(i, || Decodable::decode(d)); - let val = d.read_map_elt_val(i, || Decodable::decode(d)); - map.insert(key, val); - } - map - } - } -} - -#[cfg(not(stage0))] impl< D: Decoder, K: Decodable + Hash + IterBytes + Eq, @@ -1556,23 +719,6 @@ impl< } } -#[cfg(stage0)] -impl< - S: Encoder, - T: Encodable + Hash + IterBytes + Eq -> Encodable for HashSet { - fn encode(&self, s: &S) { - do s.emit_seq(self.len()) { - let mut i = 0; - for self.each |e| { - s.emit_seq_elt(i, || e.encode(s)); - i += 1; - } - } - } -} - -#[cfg(not(stage0))] impl< S: Encoder, T: Encodable + Hash + IterBytes + Eq @@ -1588,23 +734,6 @@ impl< } } -#[cfg(stage0)] -impl< - D: Decoder, - T: Decodable + Hash + IterBytes + Eq -> Decodable for HashSet { - fn decode(d: &D) -> HashSet { - do d.read_seq |len| { - let mut set = HashSet::with_capacity(len); - for uint::range(0, len) |i| { - set.insert(d.read_seq_elt(i, || Decodable::decode(d))); - } - set - } - } -} - -#[cfg(not(stage0))] impl< D: Decoder, T: Decodable + Hash + IterBytes + Eq @@ -1620,24 +749,6 @@ impl< } } -#[cfg(stage0)] -impl< - E: Encoder, - V: Encodable -> Encodable for TrieMap { - fn encode(&self, e: &E) { - do e.emit_map(self.len()) { - let mut i = 0; - for self.each |key, val| { - e.emit_map_elt_key(i, || key.encode(e)); - e.emit_map_elt_val(i, || val.encode(e)); - i += 1; - } - } - } -} - -#[cfg(not(stage0))] impl< E: Encoder, V: Encodable @@ -1654,25 +765,6 @@ impl< } } -#[cfg(stage0)] -impl< - D: Decoder, - V: Decodable -> Decodable for TrieMap { - fn decode(d: &D) -> TrieMap { - do d.read_map |len| { - let mut map = TrieMap::new(); - for uint::range(0, len) |i| { - let key = d.read_map_elt_key(i, || Decodable::decode(d)); - let val = d.read_map_elt_val(i, || Decodable::decode(d)); - map.insert(key, val); - } - map - } - } -} - -#[cfg(not(stage0))] impl< D: Decoder, V: Decodable @@ -1690,20 +782,6 @@ impl< } } -#[cfg(stage0)] -impl Encodable for TrieSet { - fn encode(&self, s: &S) { - do s.emit_seq(self.len()) { - let mut i = 0; - for self.each |e| { - s.emit_seq_elt(i, || e.encode(s)); - i += 1; - } - } - } -} - -#[cfg(not(stage0))] impl Encodable for TrieSet { fn encode(&self, s: &mut S) { do s.emit_seq(self.len()) |s| { @@ -1716,20 +794,6 @@ impl Encodable for TrieSet { } } -#[cfg(stage0)] -impl Decodable for TrieSet { - fn decode(d: &D) -> TrieSet { - do d.read_seq |len| { - let mut set = TrieSet::new(); - for uint::range(0, len) |i| { - set.insert(d.read_seq_elt(i, || Decodable::decode(d))); - } - set - } - } -} - -#[cfg(not(stage0))] impl Decodable for TrieSet { fn decode(d: &mut D) -> TrieSet { do d.read_seq |d, len| { @@ -1742,7 +806,6 @@ impl Decodable for TrieSet { } } -#[cfg(not(stage0))] impl< E: Encoder, K: Encodable + Eq + TotalOrd, @@ -1760,7 +823,6 @@ impl< } } -#[cfg(not(stage0))] impl< D: Decoder, K: Decodable + Eq + TotalOrd, @@ -1779,7 +841,6 @@ impl< } } -#[cfg(not(stage0))] impl< S: Encoder, T: Encodable + Eq + TotalOrd @@ -1795,7 +856,6 @@ impl< } } -#[cfg(not(stage0))] impl< D: Decoder, T: Decodable + Eq + TotalOrd @@ -1816,30 +876,10 @@ impl< // // In some cases, these should eventually be coded as traits. -#[cfg(stage0)] -pub trait EncoderHelpers { - fn emit_from_vec(&self, v: &[T], f: &fn(v: &T)); -} - -#[cfg(not(stage0))] pub trait EncoderHelpers { fn emit_from_vec(&mut self, v: &[T], f: &fn(&mut Self, v: &T)); } -#[cfg(stage0)] -impl EncoderHelpers for S { - fn emit_from_vec(&self, v: &[T], f: &fn(v: &T)) { - do self.emit_seq(v.len()) { - for v.eachi |i, e| { - do self.emit_seq_elt(i) { - f(e) - } - } - } - } -} - -#[cfg(not(stage0))] impl EncoderHelpers for S { fn emit_from_vec(&mut self, v: &[T], f: &fn(&mut S, &T)) { do self.emit_seq(v.len()) |this| { @@ -1852,28 +892,10 @@ impl EncoderHelpers for S { } } -#[cfg(stage0)] -pub trait DecoderHelpers { - fn read_to_vec(&self, f: &fn() -> T) -> ~[T]; -} - -#[cfg(not(stage0))] pub trait DecoderHelpers { fn read_to_vec(&mut self, f: &fn(&mut Self) -> T) -> ~[T]; } -#[cfg(stage0)] -impl DecoderHelpers for D { - fn read_to_vec(&self, f: &fn() -> T) -> ~[T] { - do self.read_seq |len| { - do vec::from_fn(len) |i| { - self.read_seq_elt(i, || f()) - } - } - } -} - -#[cfg(not(stage0))] impl DecoderHelpers for D { fn read_to_vec(&mut self, f: &fn(&mut D) -> T) -> ~[T] { do self.read_seq |this, len| { diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index fb17d4e5090..1b72300a178 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -50,20 +50,6 @@ impl Map for SmallIntMap { } /// Visit all key-value pairs in order - #[cfg(stage0)] - fn each(&self, it: &fn(&uint, &'self V) -> bool) { - for uint::range(0, self.v.len()) |i| { - match self.v[i] { - Some(ref elt) => if !it(&i, elt) { break }, - None => () - } - } - } - - /// Visit all key-value pairs in order - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn each<'a>(&'a self, it: &fn(&uint, &'a V) -> bool) { for uint::range(0, self.v.len()) |i| { match self.v[i] { @@ -79,15 +65,6 @@ impl Map for SmallIntMap { } /// Visit all values in order - #[cfg(stage0)] - fn each_value(&self, blk: &fn(value: &V) -> bool) { - self.each(|_, v| blk(v)) - } - - /// Visit all values in order - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn each_value<'a>(&'a self, blk: &fn(value: &'a V) -> bool) { self.each(|_, v| blk(v)) } @@ -103,22 +80,6 @@ impl Map for SmallIntMap { } /// Return a reference to the value corresponding to the key - #[cfg(stage0)] - fn find(&self, key: &uint) -> Option<&'self V> { - if *key < self.v.len() { - match self.v[*key] { - Some(ref value) => Some(value), - None => None - } - } else { - None - } - } - - /// Return a reference to the value corresponding to the key - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn find<'a>(&'a self, key: &uint) -> Option<&'a V> { if *key < self.v.len() { match self.v[*key] { @@ -131,22 +92,6 @@ impl Map for SmallIntMap { } /// Return a mutable reference to the value corresponding to the key - #[cfg(stage0)] - fn find_mut(&mut self, key: &uint) -> Option<&'self mut V> { - if *key < self.v.len() { - match self.v[*key] { - Some(ref mut value) => Some(value), - None => None - } - } else { - None - } - } - - /// Return a mutable reference to the value corresponding to the key - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn find_mut<'a>(&'a mut self, key: &uint) -> Option<&'a mut V> { if *key < self.v.len() { match self.v[*key] { @@ -188,20 +133,6 @@ pub impl SmallIntMap { fn new() -> SmallIntMap { SmallIntMap{v: ~[]} } /// Visit all key-value pairs in reverse order - #[cfg(stage0)] - fn each_reverse(&self, it: &fn(uint, &'self V) -> bool) { - for uint::range_rev(self.v.len(), 0) |i| { - match self.v[i - 1] { - Some(ref elt) => if !it(i - 1, elt) { break }, - None => () - } - } - } - - /// Visit all key-value pairs in reverse order - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn each_reverse<'a>(&'a self, it: &fn(uint, &'a V) -> bool) { for uint::range_rev(self.v.len(), 0) |i| { match self.v[i - 1] { @@ -211,14 +142,6 @@ pub impl SmallIntMap { } } - #[cfg(stage0)] - fn get(&self, key: &uint) -> &'self V { - self.find(key).expect("key not present") - } - - #[cfg(stage1)] - #[cfg(stage2)] - #[cfg(stage3)] fn get<'a>(&'a self, key: &uint) -> &'a V { self.find(key).expect("key not present") } diff --git a/src/libstd/std.rc b/src/libstd/std.rc index ea099090eba..4f9de29e726 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -71,7 +71,6 @@ pub mod rope; pub mod smallintmap; pub mod sort; pub mod dlist; -#[cfg(not(stage0))] pub mod treemap; // And ... other stuff @@ -91,13 +90,10 @@ pub mod cmp; pub mod base64; pub mod rl; pub mod workcache; -#[cfg(not(stage0))] #[path="num/bigint.rs"] pub mod bigint; -#[cfg(not(stage0))] #[path="num/rational.rs"] pub mod rational; -#[cfg(not(stage0))] #[path="num/complex.rs"] pub mod complex; pub mod stats; diff --git a/src/libstd/workcache.rs b/src/libstd/workcache.rs index f44d143004e..e681382ffc8 100644 --- a/src/libstd/workcache.rs +++ b/src/libstd/workcache.rs @@ -138,19 +138,6 @@ impl WorkMap { fn new() -> WorkMap { WorkMap(HashMap::new()) } } -#[cfg(stage0)] -impl Encodable for WorkMap { - fn encode(&self, s: &S) { - let mut d = ~[]; - for self.each |k, v| { - d.push((copy *k, copy *v)) - } - sort::tim_sort(d); - d.encode(s) - } -} - -#[cfg(not(stage0))] impl Encodable for WorkMap { fn encode(&self, s: &mut S) { let mut d = ~[]; @@ -162,19 +149,6 @@ impl Encodable for WorkMap { } } -#[cfg(stage0)] -impl Decodable for WorkMap { - fn decode(d: &D) -> WorkMap { - let v : ~[(WorkKey,~str)] = Decodable::decode(d); - let mut w = WorkMap::new(); - for v.each |&(k, v)| { - w.insert(copy k, copy v); - } - w - } -} - -#[cfg(not(stage0))] impl Decodable for WorkMap { fn decode(d: &mut D) -> WorkMap { let v : ~[(WorkKey,~str)] = Decodable::decode(d); @@ -253,14 +227,6 @@ struct Work { res: Option>> } -#[cfg(stage0)] -fn json_encode>(t: &T) -> ~str { - do io::with_str_writer |wr| { - t.encode(&json::Encoder(wr)); - } -} - -#[cfg(not(stage0))] fn json_encode>(t: &T) -> ~str { do io::with_str_writer |wr| { let mut encoder = json::Encoder(wr); @@ -269,17 +235,6 @@ fn json_encode>(t: &T) -> ~str { } // FIXME(#5121) -#[cfg(stage0)] -fn json_decode>(s: &str) -> T { - do io::with_str_reader(s) |rdr| { - let j = result::unwrap(json::from_reader(rdr)); - let decoder = json::Decoder(j); - Decodable::decode(&decoder) - } -} - -// FIXME(#5121) -#[cfg(not(stage0))] fn json_decode>(s: &str) -> T { do io::with_str_reader(s) |rdr| { let j = result::unwrap(json::from_reader(rdr)); diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 77e79866160..2216226ecb3 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -70,22 +70,6 @@ pub type Name = uint; // with a macro expansion pub type Mrk = uint; -#[cfg(stage0)] -impl Encodable for ident { - fn encode(&self, s: &S) { - unsafe { - let intr = - match task::local_data::local_data_get(interner_key!()) { - None => fail!(~"encode: TLS interner not set up"), - Some(intr) => intr - }; - - s.emit_str(*(*intr).get(*self)); - } - } -} - -#[cfg(not(stage0))] impl Encodable for ident { fn encode(&self, s: &mut S) { unsafe { @@ -100,21 +84,6 @@ impl Encodable for ident { } } -#[cfg(stage0)] -impl Decodable for ident { - fn decode(d: &D) -> ident { - let intr = match unsafe { - task::local_data::local_data_get(interner_key!()) - } { - None => fail!(~"decode: TLS interner not set up"), - Some(intr) => intr - }; - - (*intr).intern(@d.read_str()) - } -} - -#[cfg(not(stage0))] impl Decodable for ident { fn decode(d: &mut D) -> ident { let intr = match unsafe { diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index bbb390e9dc9..66ed52f0352 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -125,13 +125,6 @@ impl cmp::Eq for span { fn ne(&self, other: &span) -> bool { !(*self).eq(other) } } -#[cfg(stage0)] -impl Encodable for span { - /* Note #1972 -- spans are encoded but not decoded */ - fn encode(&self, _s: &S) { _s.emit_nil() } -} - -#[cfg(not(stage0))] impl Encodable for span { /* Note #1972 -- spans are encoded but not decoded */ fn encode(&self, s: &mut S) { @@ -139,14 +132,6 @@ impl Encodable for span { } } -#[cfg(stage0)] -impl Decodable for span { - fn decode(_d: &D) -> span { - dummy_sp() - } -} - -#[cfg(not(stage0))] impl Decodable for span { fn decode(_d: &mut D) -> span { dummy_sp() diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index db4912d2131..e56dab6db20 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -451,17 +451,6 @@ impl MapChain{ // ugh: can't get this to compile with mut because of the // lack of flow sensitivity. - #[cfg(stage0)] - fn get_map(&self) -> &'self HashMap { - match *self { - BaseMapChain (~ref map) => map, - ConsMapChain (~ref map,_) => map - } - } - - // ugh: can't get this to compile with mut because of the - // lack of flow sensitivity. - #[cfg(not(stage0))] fn get_map<'a>(&'a self) -> &'a HashMap { match *self { BaseMapChain (~ref map) => map, diff --git a/src/libsyntax/opt_vec.rs b/src/libsyntax/opt_vec.rs index 6cf7bba600e..600ab964e52 100644 --- a/src/libsyntax/opt_vec.rs +++ b/src/libsyntax/opt_vec.rs @@ -61,15 +61,6 @@ impl OptVec { } } - #[cfg(stage0)] - fn get(&self, i: uint) -> &'self T { - match *self { - Empty => fail!(fmt!("Invalid index %u", i)), - Vec(ref v) => &v[i] - } - } - - #[cfg(not(stage0))] fn get<'a>(&'a self, i: uint) -> &'a T { match *self { Empty => fail!(fmt!("Invalid index %u", i)), diff --git a/src/snapshots.txt b/src/snapshots.txt index 00cabe90d84..c643b4dd25d 100644 --- a/src/snapshots.txt +++ b/src/snapshots.txt @@ -1,3 +1,11 @@ +S 2013-05-03 213f7b2 + macos-i386 0bf8b88ea01cc4cdd81ac4db1d301ea9b3371f13 + macos-x86_64 2da3990639ab5a9c9d51b3478c437cb459de84e3 + linux-i386 094500e587bfac27d7be752b635c242e07774c0d + linux-x86_64 75733a5a58f53aa783253c8cfd56923b78676705 + winnt-i386 bd07c935a917c0796d4dc803d973b864d4794ade + freebsd-x86_64 b95d648d9bfeacdd04cc5213bdc803b0fd94add7 + S 2013-03-28 f7a2371 macos-i386 2e05a33716fc4982db53946c3b0dccf0194826fe macos-x86_64 fbd3feec8dd17a6b6c8df114e6e9b4cd17cc6172 -- cgit 1.4.1-3-g733a5