auto merge of #4927 : sanxiyn/rust/remove-dvec, r=catamorphism

This commit is contained in:
bors 2013-02-14 17:23:18 -08:00
commit af2f0ef088
5 changed files with 21 additions and 27 deletions

View file

@ -16,7 +16,6 @@ use middle::ty;
use middle::typeck; use middle::typeck;
use util::ppaux; use util::ppaux;
use core::dvec::DVec;
use core::option; use core::option;
use std::oldmap::HashMap; use std::oldmap::HashMap;
use syntax::ast::*; use syntax::ast::*;
@ -212,20 +211,20 @@ pub fn check_item_recursion(sess: Session,
ast_map: ast_map::map, ast_map: ast_map::map,
def_map: resolve::DefMap, def_map: resolve::DefMap,
it: @item) { it: @item) {
type env = { struct env {
root_it: @item, root_it: @item,
sess: Session, sess: Session,
ast_map: ast_map::map, ast_map: ast_map::map,
def_map: resolve::DefMap, def_map: resolve::DefMap,
idstack: @DVec<node_id>, idstack: @mut ~[node_id]
}; }
let env = { let env = env {
root_it: it, root_it: it,
sess: sess, sess: sess,
ast_map: ast_map, ast_map: ast_map,
def_map: def_map, def_map: def_map,
idstack: @DVec() idstack: @mut ~[]
}; };
let visitor = visit::mk_vt(@visit::Visitor { let visitor = visit::mk_vt(@visit::Visitor {
@ -236,12 +235,12 @@ pub fn check_item_recursion(sess: Session,
(visitor.visit_item)(it, env, visitor); (visitor.visit_item)(it, env, visitor);
fn visit_item(it: @item, &&env: env, v: visit::vt<env>) { fn visit_item(it: @item, &&env: env, v: visit::vt<env>) {
if (*env.idstack).contains(&(it.id)) { if env.idstack.contains(&(it.id)) {
env.sess.span_fatal(env.root_it.span, ~"recursive constant"); env.sess.span_fatal(env.root_it.span, ~"recursive constant");
} }
(*env.idstack).push(it.id); env.idstack.push(it.id);
visit::visit_item(it, env, v); visit::visit_item(it, env, v);
(*env.idstack).pop(); env.idstack.pop();
} }
fn visit_expr(e: @expr, &&env: env, v: visit::vt<env>) { fn visit_expr(e: @expr, &&env: env, v: visit::vt<env>) {

View file

@ -1298,7 +1298,7 @@ mod tests {
// and json... not sure where to put these tests. // and json... not sure where to put these tests.
#[test] #[test]
fn test_write_enum () { fn test_write_enum () {
let bw = @io::BytesWriter {bytes: dvec::DVec(), pos: 0}; let bw = @io::BytesWriter();
let bww : @io::Writer = (bw as @io::Writer); let bww : @io::Writer = (bw as @io::Writer);
let encoder = (@Encoder(bww) as @serialize::Encoder); let encoder = (@Encoder(bww) as @serialize::Encoder);
do encoder.emit_enum(~"animal") { do encoder.emit_enum(~"animal") {
@ -1319,7 +1319,7 @@ mod tests {
#[test] #[test]
fn test_write_some () { fn test_write_some () {
let bw = @io::BytesWriter {bytes: dvec::DVec(), pos: 0}; let bw = @io::BytesWriter();
let bww : @io::Writer = (bw as @io::Writer); let bww : @io::Writer = (bw as @io::Writer);
let encoder = (@Encoder(bww) as @serialize::Encoder); let encoder = (@Encoder(bww) as @serialize::Encoder);
do encoder.emit_enum(~"Option") { do encoder.emit_enum(~"Option") {
@ -1335,7 +1335,7 @@ mod tests {
#[test] #[test]
fn test_write_none () { fn test_write_none () {
let bw = @io::BytesWriter {bytes: dvec::DVec(), pos: 0}; let bw = @io::BytesWriter();
let bww : @io::Writer = (bw as @io::Writer); let bww : @io::Writer = (bw as @io::Writer);
let encoder = (@Encoder(bww) as @serialize::Encoder); let encoder = (@Encoder(bww) as @serialize::Encoder);
do encoder.emit_enum(~"Option") { do encoder.emit_enum(~"Option") {

View file

@ -16,7 +16,6 @@ use serialize::{Encoder, Encodable, Decoder, Decodable};
use sort; use sort;
use core::cmp; use core::cmp;
use core::dvec;
use core::either::{Either, Left, Right}; use core::either::{Either, Left, Right};
use core::io; use core::io;
use core::option; use core::option;
@ -141,13 +140,12 @@ type WorkMap = LinearMap<WorkKey, ~str>;
pub impl<S: Encoder> WorkMap: Encodable<S> { pub impl<S: Encoder> WorkMap: Encodable<S> {
fn encode(&self, s: &S) { fn encode(&self, s: &S) {
let d = dvec::DVec(); let mut d = ~[];
for self.each |&(k, v)| { for self.each |&(k, v)| {
d.push((copy *k, copy *v)) d.push((copy *k, copy *v))
} }
let mut v = d.get(); sort::tim_sort(d);
sort::tim_sort(v); d.encode(s)
v.encode(s)
} }
} }

View file

@ -227,12 +227,11 @@ mod test {
use super::*; use super::*;
use std::serialize::Encodable; use std::serialize::Encodable;
use std; use std;
use core::dvec;
use core::str; use core::str;
use util::testing::*; use util::testing::*;
#[test] fn to_json_str (val: Encodable<std::json::Encoder>) -> ~str { #[test] fn to_json_str (val: Encodable<std::json::Encoder>) -> ~str {
let bw = @io::BytesWriter {bytes: dvec::DVec(), pos: 0}; let bw = @io::BytesWriter();
val.encode(~std::json::Encoder(bw as io::Writer)); val.encode(~std::json::Encoder(bw as io::Writer));
str::from_bytes(bw.bytes.data) str::from_bytes(bw.bytes.data)
} }

View file

@ -84,8 +84,6 @@ use print::pprust::expr_to_str;
use util::interner::Interner; use util::interner::Interner;
use core::cmp; use core::cmp;
use core::dvec::DVec;
use core::dvec;
use core::either::{Either, Left, Right}; use core::either::{Either, Left, Right};
use core::either; use core::either;
use core::result::Result; use core::result::Result;
@ -1323,11 +1321,11 @@ pub impl Parser {
} }
fn parse_all_token_trees() -> ~[token_tree] { fn parse_all_token_trees() -> ~[token_tree] {
let tts = DVec(); let mut tts = ~[];
while self.token != token::EOF { while self.token != token::EOF {
tts.push(self.parse_token_tree()); tts.push(self.parse_token_tree());
} }
tts.get() tts
} }
fn parse_matchers() -> ~[matcher] { fn parse_matchers() -> ~[matcher] {
@ -3954,7 +3952,7 @@ pub impl Parser {
VIEW_ITEMS_AND_ITEMS_ALLOWED | IMPORTS_AND_ITEMS_ALLOWED => false VIEW_ITEMS_AND_ITEMS_ALLOWED | IMPORTS_AND_ITEMS_ALLOWED => false
}; };
let (view_items, items, foreign_items) = (DVec(), DVec(), DVec()); let mut (view_items, items, foreign_items) = (~[], ~[], ~[]);
loop { loop {
match self.parse_item_or_view_item(attrs, items_allowed, match self.parse_item_or_view_item(attrs, items_allowed,
foreign_items_allowed, foreign_items_allowed,
@ -3986,9 +3984,9 @@ pub impl Parser {
} }
{attrs_remaining: attrs, {attrs_remaining: attrs,
view_items: dvec::unwrap(move view_items), view_items: view_items,
items: dvec::unwrap(move items), items: items,
foreign_items: dvec::unwrap(move foreign_items)} foreign_items: foreign_items}
} }
// Parses a source module as a crate // Parses a source module as a crate