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 util::ppaux;
use core::dvec::DVec;
use core::option;
use std::oldmap::HashMap;
use syntax::ast::*;
@ -212,20 +211,20 @@ pub fn check_item_recursion(sess: Session,
ast_map: ast_map::map,
def_map: resolve::DefMap,
it: @item) {
type env = {
struct env {
root_it: @item,
sess: Session,
ast_map: ast_map::map,
def_map: resolve::DefMap,
idstack: @DVec<node_id>,
};
idstack: @mut ~[node_id]
}
let env = {
let env = env {
root_it: it,
sess: sess,
ast_map: ast_map,
def_map: def_map,
idstack: @DVec()
idstack: @mut ~[]
};
let visitor = visit::mk_vt(@visit::Visitor {
@ -236,12 +235,12 @@ pub fn check_item_recursion(sess: Session,
(visitor.visit_item)(it, env, visitor);
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.idstack).push(it.id);
env.idstack.push(it.id);
visit::visit_item(it, env, v);
(*env.idstack).pop();
env.idstack.pop();
}
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.
#[test]
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 encoder = (@Encoder(bww) as @serialize::Encoder);
do encoder.emit_enum(~"animal") {
@ -1319,7 +1319,7 @@ mod tests {
#[test]
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 encoder = (@Encoder(bww) as @serialize::Encoder);
do encoder.emit_enum(~"Option") {
@ -1335,7 +1335,7 @@ mod tests {
#[test]
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 encoder = (@Encoder(bww) as @serialize::Encoder);
do encoder.emit_enum(~"Option") {

View file

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

View file

@ -227,12 +227,11 @@ mod test {
use super::*;
use std::serialize::Encodable;
use std;
use core::dvec;
use core::str;
use util::testing::*;
#[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));
str::from_bytes(bw.bytes.data)
}

View file

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