Skip to content

Commit 2a72099

Browse files
committed
rustc: Remove uses of DVec
1 parent 87f8642 commit 2a72099

File tree

16 files changed

+191
-206
lines changed

16 files changed

+191
-206
lines changed

src/librustc/metadata/csearch.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use metadata::decoder;
1919
use metadata;
2020
use middle::{ty, resolve};
2121

22-
use core::dvec::DVec;
2322
use core::vec;
2423
use reader = std::ebml::reader;
2524
use syntax::ast;
@@ -136,7 +135,7 @@ pub fn get_supertraits(tcx: ty::ctxt, def: ast::def_id) -> ~[ty::t] {
136135

137136
pub fn get_method_names_if_trait(cstore: @mut cstore::CStore,
138137
def: ast::def_id)
139-
-> Option<@DVec<(ast::ident, ast::self_ty_)>> {
138+
-> Option<~[(ast::ident, ast::self_ty_)]> {
140139
let cdata = cstore::get_crate_data(cstore, def.crate);
141140
return decoder::get_method_names_if_trait(cstore.intr, cdata, def.node);
142141
}

src/librustc/metadata/decoder.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ use metadata::decoder;
2222
use metadata::tydecode::{parse_ty_data, parse_def_id, parse_bounds_data};
2323
use middle::{ty, resolve};
2424

25-
use core::dvec;
26-
use core::dvec::DVec;
2725
use core::hash::{Hash, HashUtil};
2826
use core::int;
2927
use core::io::WriterUtil;
@@ -766,27 +764,27 @@ pub fn get_provided_trait_methods(intr: @ident_interner, cdata: cmd,
766764
/// Returns the supertraits of the given trait.
767765
pub fn get_supertraits(cdata: cmd, id: ast::node_id, tcx: ty::ctxt)
768766
-> ~[ty::t] {
769-
let results = dvec::DVec();
767+
let mut results = ~[];
770768
let item_doc = lookup_item(id, cdata.data);
771769
for reader::tagged_docs(item_doc, tag_impl_trait) |trait_doc| {
772770
results.push(doc_type(trait_doc, tcx, cdata));
773771
}
774-
return dvec::unwrap(results);
772+
return results;
775773
}
776774

777775
// If the item in question is a trait, returns its set of methods and
778776
// their self types. Otherwise, returns none. This overlaps in an
779777
// annoying way with get_trait_methods.
780778
pub fn get_method_names_if_trait(intr: @ident_interner, cdata: cmd,
781779
node_id: ast::node_id)
782-
-> Option<@DVec<(ast::ident, ast::self_ty_)>> {
780+
-> Option<~[(ast::ident, ast::self_ty_)]> {
783781

784782
let item = lookup_item(node_id, cdata.data);
785783
if item_family(item) != Trait {
786784
return None;
787785
}
788786

789-
let resulting_methods = @DVec();
787+
let mut resulting_methods = ~[];
790788
for reader::tagged_docs(item, tag_item_trait_method) |method| {
791789
resulting_methods.push(
792790
(item_name(intr, method), get_self_ty(method)));
@@ -823,12 +821,12 @@ pub fn get_static_methods_if_impl(intr: @ident_interner,
823821
return None;
824822
}
825823

826-
let impl_method_ids = DVec();
824+
let mut impl_method_ids = ~[];
827825
for reader::tagged_docs(item, tag_item_impl_method) |impl_method_doc| {
828826
impl_method_ids.push(parse_def_id(reader::doc_data(impl_method_doc)));
829827
}
830828

831-
let static_impl_methods = DVec();
829+
let mut static_impl_methods = ~[];
832830
for impl_method_ids.each |impl_method_id| {
833831
let impl_method_doc = lookup_item(impl_method_id.node, cdata.data);
834832
let family = item_family(impl_method_doc);
@@ -852,7 +850,7 @@ pub fn get_static_methods_if_impl(intr: @ident_interner,
852850
}
853851
}
854852

855-
return Some(dvec::unwrap(static_impl_methods));
853+
return Some(static_impl_methods);
856854
}
857855

858856
pub fn get_item_attrs(cdata: cmd,

src/librustc/metadata/encoder.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use middle::ty;
2222
use middle;
2323
use util::ppaux::ty_to_str;
2424

25-
use core::dvec;
2625
use core::flate;
2726
use core::hash::{Hash, HashUtil};
2827
use core::int;
@@ -857,7 +856,7 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
857856
}
858857
}
859858
item_trait(ref generics, ref traits, ref ms) => {
860-
let provided_methods = dvec::DVec();
859+
let mut provided_methods = ~[];
861860
862861
add_to_index();
863862
ebml_w.start_tag(tag_items_data_item);
@@ -1366,13 +1365,11 @@ pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] {
13661365
13671366
if (parms.tcx.sess.meta_stats()) {
13681367
1369-
do wr.bytes.borrow |v| {
1370-
do v.each |e| {
1371-
if *e == 0 {
1372-
ecx.stats.zero_bytes += 1;
1373-
}
1374-
true
1368+
do wr.bytes.each |e| {
1369+
if *e == 0 {
1370+
ecx.stats.zero_bytes += 1;
13751371
}
1372+
true
13761373
}
13771374
13781375
io::println("metadata stats:");
@@ -1401,7 +1398,7 @@ pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] {
14011398
14021399
(do str::as_bytes(&~"rust\x00\x00\x00\x01") |bytes| {
14031400
vec::slice(*bytes, 0, 8).to_vec()
1404-
}) + flate::deflate_bytes(wr.bytes.check_out(|buf| buf))
1401+
}) + flate::deflate_bytes(wr.bytes)
14051402
}
14061403

14071404
// Get the encoded string for a type

src/librustc/middle/astencode.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use middle::{ty, typeck, moves};
2525
use middle;
2626
use util::ppaux::ty_to_str;
2727

28-
use core::{dvec, io, option, vec};
28+
use core::{io, option, vec};
2929
use std::ebml::reader;
3030
use std::ebml;
3131
use std::serialize;
@@ -912,11 +912,11 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
912912
}
913913
}
914914
915-
for maps.last_use_map.find(&id).each |m| {
915+
for maps.last_use_map.find(&id).each |&m| {
916916
do ebml_w.tag(c::tag_table_last_use) {
917917
ebml_w.id(id);
918918
do ebml_w.tag(c::tag_table_val) {
919-
do ebml_w.emit_from_vec((*m).get()) |id| {
919+
do ebml_w.emit_from_vec(/*bad*/ copy *m) |id| {
920920
id.encode(&ebml_w);
921921
}
922922
}
@@ -1131,8 +1131,7 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext,
11311131
let ids = val_dsr.read_to_vec(|| {
11321132
xcx.tr_id(val_dsr.read_int())
11331133
});
1134-
let dvec = @dvec::from_vec(ids);
1135-
dcx.maps.last_use_map.insert(id, dvec);
1134+
dcx.maps.last_use_map.insert(id, @mut ids);
11361135
} else if tag == (c::tag_table_method_map as uint) {
11371136
dcx.maps.method_map.insert(
11381137
id,

src/librustc/middle/borrowck/gather_loans.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ use middle::ty;
3232
use util::common::indenter;
3333
use util::ppaux::{expr_repr, region_to_str};
3434

35-
use core::dvec;
3635
use core::hashmap::linear::LinearSet;
3736
use core::vec;
3837
use std::oldmap::HashMap;
@@ -575,9 +574,8 @@ pub impl GatherLoanCtxt {
575574
req_loans.push_all(loans);
576575
}
577576
None => {
578-
let dvec = @dvec::from_vec(loans);
579577
let req_loan_map = self.req_maps.req_loan_map;
580-
req_loan_map.insert(scope_id, dvec);
578+
req_loan_map.insert(scope_id, @mut loans);
581579
}
582580
}
583581
}

src/librustc/middle/borrowck/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ use middle::moves;
234234
use util::common::{indenter, stmt_set};
235235
use util::ppaux::note_and_explain_region;
236236

237-
use core::dvec::DVec;
238237
use core::io;
239238
use core::result::{Result, Ok, Err};
240239
use core::to_bytes;
@@ -406,7 +405,7 @@ pub struct Loan {
406405
/// - `pure_map`: map from block/expr that must be pure to the error message
407406
/// that should be reported if they are not pure
408407
pub struct ReqMaps {
409-
req_loan_map: HashMap<ast::node_id, @DVec<Loan>>,
408+
req_loan_map: HashMap<ast::node_id, @mut ~[Loan]>,
410409
pure_map: HashMap<ast::node_id, bckerr>
411410
}
412411

src/librustc/middle/liveness.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ use middle::moves;
112112
use util::ppaux::ty_to_str;
113113

114114
use core::cmp;
115-
use core::dvec::DVec;
116115
use core::io::WriterUtil;
117116
use core::io;
118117
use core::ptr;
@@ -136,7 +135,7 @@ use syntax::{visit, ast_util};
136135
//
137136
// Very subtle (#2633): borrowck will remove entries from this table
138137
// if it detects an outstanding loan (that is, the addr is taken).
139-
pub type last_use_map = HashMap<node_id, @DVec<node_id>>;
138+
pub type last_use_map = HashMap<node_id, @mut ~[node_id]>;
140139

141140
enum Variable = uint;
142141
enum LiveNode = uint;
@@ -419,13 +418,13 @@ pub impl IrMaps {
419418
let v = match self.last_use_map.find(&expr_id) {
420419
Some(v) => v,
421420
None => {
422-
let v = @DVec();
421+
let v = @mut ~[];
423422
self.last_use_map.insert(expr_id, v);
424423
v
425424
}
426425
};
427426

428-
(*v).push(id);
427+
v.push(id);
429428
}
430429
Arg(_, _, by_ref) |
431430
Arg(_, _, by_val) | ImplicitRet => {
@@ -667,7 +666,7 @@ struct Liveness {
667666
users: @mut ~[Users],
668667
// The list of node IDs for the nested loop scopes
669668
// we're in.
670-
loop_scope: DVec<node_id>,
669+
loop_scope: @mut ~[node_id],
671670
// mappings from loop node ID to LiveNode
672671
// ("break" label should map to loop node ID,
673672
// it probably doesn't now)
@@ -683,7 +682,7 @@ fn Liveness(ir: @mut IrMaps, specials: Specials) -> Liveness {
683682
successors: @mut vec::from_elem(ir.num_live_nodes, invalid_node()),
684683
users: @mut vec::from_elem(ir.num_live_nodes * ir.num_vars,
685684
invalid_users()),
686-
loop_scope: DVec(),
685+
loop_scope: @mut ~[],
687686
break_ln: HashMap(),
688687
cont_ln: HashMap()
689688
}
@@ -856,11 +855,16 @@ pub impl Liveness {
856855
self.tcx.sess.span_bug(sp, ~"break outside loop");
857856
}
858857
else {
859-
self.loop_scope.last()
858+
// FIXME(#5275): this shouldn't have to be a method...
859+
self.last_loop_scope()
860860
}
861861
}
862862
}
863863

864+
fn last_loop_scope(&self) -> node_id {
865+
*self.loop_scope.last()
866+
}
867+
864868
fn ln_str(&self, ln: LiveNode) -> ~str {
865869
do io::with_str_writer |wr| {
866870
wr.write_str(~"[ln(");

src/librustc/middle/privacy.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use middle::typeck::{method_map, method_origin, method_param, method_self};
2121
use middle::typeck::{method_super};
2222
use middle::typeck::{method_static, method_trait};
2323

24-
use core::dvec::DVec;
2524
use core::util::ignore;
2625
use syntax::ast::{def_variant, expr_field, expr_method_call, expr_struct};
2726
use syntax::ast::{expr_unary, ident, item_struct, item_enum, item_impl};
@@ -38,7 +37,7 @@ use syntax::visit;
3837
pub fn check_crate(tcx: ty::ctxt,
3938
method_map: &method_map,
4039
crate: @ast::crate) {
41-
let privileged_items = @DVec();
40+
let privileged_items = @mut ~[];
4241

4342
// Adds structs that are privileged to this scope.
4443
let add_privileged_items: @fn(&[@ast::item]) -> uint = |items| {

src/librustc/middle/region.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use middle::ty::{region_variance, rv_covariant, rv_invariant};
2626
use middle::ty::{rv_contravariant};
2727
use middle::ty;
2828

29-
use core::dvec::DVec;
3029
use core::vec;
3130
use std::oldmap::HashMap;
3231
use syntax::ast_map;
@@ -395,7 +394,7 @@ pub struct region_dep {
395394
id: ast::node_id
396395
}
397396

398-
pub type dep_map = HashMap<ast::node_id, @DVec<region_dep>>;
397+
pub type dep_map = HashMap<ast::node_id, @mut ~[region_dep]>;
399398

400399
pub struct DetermineRpCtxt {
401400
sess: Session,
@@ -498,7 +497,7 @@ pub impl DetermineRpCtxt {
498497
let vec = match self.dep_map.find(&from) {
499498
Some(vec) => vec,
500499
None => {
501-
let vec = @DVec();
500+
let vec = @mut ~[];
502501
let dep_map = self.dep_map;
503502
dep_map.insert(from, vec);
504503
vec

0 commit comments

Comments
 (0)