Skip to content

Commit 7f99a02

Browse files
committed
syntax: Remove uses of DVec
1 parent 2a72099 commit 7f99a02

File tree

6 files changed

+29
-39
lines changed

6 files changed

+29
-39
lines changed

src/libsyntax/codemap.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ source code snippets, etc.
2424
use core::prelude::*;
2525

2626
use core::cmp;
27-
use core::dvec::DVec;
2827
use core::str;
2928
use core::to_bytes;
3029
use core::uint;
@@ -242,7 +241,7 @@ pub struct FileMap {
242241
/// Locations of lines beginnings in the source code
243242
lines: @mut ~[BytePos],
244243
/// Locations of multi-byte characters in the source code
245-
multibyte_chars: DVec<MultiByteChar>
244+
multibyte_chars: @mut ~[MultiByteChar],
246245
}
247246

248247
pub impl FileMap {
@@ -282,13 +281,13 @@ pub impl FileMap {
282281
}
283282

284283
pub struct CodeMap {
285-
files: DVec<@FileMap>
284+
files: @mut ~[@FileMap]
286285
}
287286

288287
pub impl CodeMap {
289288
static pub fn new() -> CodeMap {
290289
CodeMap {
291-
files: DVec()
290+
files: @mut ~[],
292291
}
293292
}
294293

@@ -315,7 +314,7 @@ pub impl CodeMap {
315314
name: filename, substr: substr, src: src,
316315
start_pos: BytePos(start_pos),
317316
lines: @mut ~[],
318-
multibyte_chars: DVec()
317+
multibyte_chars: @mut ~[],
319318
};
320319

321320
self.files.push(filemap);

src/libsyntax/diagnostic.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use core::io;
1818
use core::option;
1919
use core::str;
2020
use core::vec;
21-
use core::dvec::DVec;
2221

2322
use std::term;
2423

@@ -203,7 +202,7 @@ fn print_diagnostic(topic: ~str, lvl: level, msg: &str) {
203202
io::stderr().write_str(fmt!(" %s\n", msg));
204203
}
205204

206-
pub fn collect(messages: @DVec<~str>)
205+
pub fn collect(messages: @mut ~[~str])
207206
-> @fn(Option<(@codemap::CodeMap, span)>, &str, level) {
208207
let f: @fn(Option<(@codemap::CodeMap, span)>, &str, level) =
209208
|_o, msg: &str, _l| { messages.push(msg.to_str()); };

src/libsyntax/ext/deriving.rs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use parse::token::special_idents::clownshoes_extensions;
2929
use ast_util;
3030
use opt_vec;
3131

32-
use core::dvec;
3332
use core::uint;
3433

3534
enum Junction {
@@ -99,7 +98,7 @@ fn expand_deriving(cx: ext_ctxt,
9998
expand_deriving_struct_def: ExpandDerivingStructDefFn,
10099
expand_deriving_enum_def: ExpandDerivingEnumDefFn)
101100
-> ~[@item] {
102-
let result = dvec::DVec();
101+
let mut result = ~[];
103102
for in_items.each |item| {
104103
result.push(copy *item);
105104
match item.node {
@@ -120,7 +119,7 @@ fn expand_deriving(cx: ext_ctxt,
120119
_ => ()
121120
}
122121
}
123-
dvec::unwrap(result)
122+
result
124123
}
125124

126125
fn create_impl_item(cx: ext_ctxt, span: span, +item: item_) -> @item {
@@ -202,14 +201,13 @@ fn create_self_type_with_params(cx: ext_ctxt,
202201
generics: &Generics)
203202
-> @Ty {
204203
// Create the type parameters on the `self` path.
205-
let self_ty_params = dvec::DVec();
204+
let mut self_ty_params = ~[];
206205
for generics.ty_params.each |ty_param| {
207206
let self_ty_param = build::mk_simple_ty_path(cx,
208207
span,
209208
ty_param.ident);
210209
self_ty_params.push(self_ty_param);
211210
}
212-
let self_ty_params = dvec::unwrap(self_ty_params);
213211

214212
// Create the type of `self`.
215213
let self_type = build::mk_raw_path_(span,
@@ -433,7 +431,7 @@ fn create_subpatterns(cx: ext_ctxt,
433431
prefix: ~str,
434432
n: uint)
435433
-> ~[@pat] {
436-
let subpats = dvec::DVec();
434+
let mut subpats = ~[];
437435
for uint::range(0, n) |_i| {
438436
// Create the subidentifier.
439437
let index = subpats.len().to_str();
@@ -445,7 +443,7 @@ fn create_subpatterns(cx: ext_ctxt,
445443
let subpat = build::mk_pat(cx, span, subpat);
446444
subpats.push(subpat);
447445
}
448-
return dvec::unwrap(subpats);
446+
return subpats;
449447
}
450448

451449
fn is_struct_tuple(struct_def: &struct_def) -> bool {
@@ -809,7 +807,7 @@ fn expand_deriving_iter_bytes_struct_method(cx: ext_ctxt,
809807
let self_ident = cx.ident_of(~"self");
810808

811809
// Create the body of the method.
812-
let statements = dvec::DVec();
810+
let mut statements = ~[];
813811
for struct_def.fields.each |struct_field| {
814812
match struct_field.node.kind {
815813
named_field(ident, _, _) => {
@@ -833,7 +831,6 @@ fn expand_deriving_iter_bytes_struct_method(cx: ext_ctxt,
833831
}
834832

835833
// Create the method itself.
836-
let statements = dvec::unwrap(statements);
837834
return create_iter_bytes_method(cx, span, statements);
838835
}
839836

@@ -942,9 +939,9 @@ fn expand_deriving_eq_enum_method(cx: ext_ctxt,
942939
}
943940

944941
// Create the arms of the self match in the method body.
945-
let self_arms = dvec::DVec();
942+
let mut self_arms = ~[];
946943
for enum_definition.variants.each |self_variant| {
947-
let other_arms = dvec::DVec();
944+
let mut other_arms = ~[];
948945

949946
// Create the matching pattern.
950947
let matching_pat = create_enum_variant_pattern(cx,
@@ -1026,7 +1023,6 @@ fn expand_deriving_eq_enum_method(cx: ext_ctxt,
10261023
// Create the self pattern body.
10271024
let other_expr = build::mk_path(cx, span, ~[ other_ident ]);
10281025
let other_expr = build::mk_unary(cx, span, deref, other_expr);
1029-
let other_arms = dvec::unwrap(other_arms);
10301026
let other_match_expr = expr_match(other_expr, other_arms);
10311027
let other_match_expr = build::mk_expr(cx,
10321028
span,
@@ -1047,7 +1043,6 @@ fn expand_deriving_eq_enum_method(cx: ext_ctxt,
10471043
// Create the method body.
10481044
let self_expr = build::mk_path(cx, span, ~[ self_ident ]);
10491045
let self_expr = build::mk_unary(cx, span, deref, self_expr);
1050-
let self_arms = dvec::unwrap(self_arms);
10511046
let self_match_expr = expr_match(self_expr, self_arms);
10521047
let self_match_expr = build::mk_expr(cx, span, self_match_expr);
10531048

@@ -1148,7 +1143,7 @@ fn expand_deriving_iter_bytes_enum_method(cx: ext_ctxt,
11481143
}
11491144

11501145
// Feed the discriminant to the byte iteration function.
1151-
let stmts = dvec::DVec();
1146+
let mut stmts = ~[];
11521147
let discrim_stmt = call_substructure_iter_bytes_method(cx,
11531148
span,
11541149
discriminant);
@@ -1167,7 +1162,6 @@ fn expand_deriving_iter_bytes_enum_method(cx: ext_ctxt,
11671162
}
11681163

11691164
// Create the pattern body.
1170-
let stmts = dvec::unwrap(stmts);
11711165
let match_body_block = build::mk_block_(cx, span, stmts);
11721166

11731167
// Create the arm.

src/libsyntax/ext/tt/macro_parser.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ use parse::parser::Parser;
1919
use parse::token::{Token, EOF, to_str, nonterminal};
2020
use parse::token;
2121

22-
use core::dvec::DVec;
23-
use core::dvec;
2422
use core::option::{Option, Some, None};
2523
use core::str;
2624
use core::uint;
@@ -115,7 +113,7 @@ pub struct MatcherPos {
115113
sep: Option<Token>,
116114
idx: uint,
117115
up: matcher_pos_up, // mutable for swapping only
118-
matches: ~[DVec<@named_match>],
116+
matches: ~[~[@named_match]],
119117
match_lo: uint, match_hi: uint,
120118
sp_lo: BytePos,
121119
}
@@ -151,7 +149,7 @@ pub fn initial_matcher_pos(+ms: ~[matcher], +sep: Option<Token>, lo: BytePos)
151149
}
152150
}
153151
}
154-
let matches = vec::from_fn(count_names(ms), |_i| dvec::DVec());
152+
let matches = vec::from_fn(count_names(ms), |_i| ~[]);
155153
~MatcherPos {
156154
elts: ms,
157155
sep: sep,
@@ -283,7 +281,7 @@ pub fn parse(
283281

284282
// Only touch the binders we have actually bound
285283
for uint::range(ei.match_lo, ei.match_hi) |idx| {
286-
let sub = ei.matches[idx].get();
284+
let sub = ei.matches[idx];
287285
new_pos.matches[idx]
288286
.push(@matched_seq(sub,
289287
mk_sp(ei.sp_lo,
@@ -331,7 +329,7 @@ pub fn parse(
331329
}
332330

333331
let matches = vec::map(ei.matches, // fresh, same size:
334-
|_m| DVec::<@named_match>());
332+
|_m| ~[]);
335333
let ei_t = ei;
336334
cur_eis.push(~MatcherPos {
337335
elts: copy *matchers,
@@ -358,9 +356,11 @@ pub fn parse(
358356
/* error messages here could be improved with links to orig. rules */
359357
if tok == EOF {
360358
if eof_eis.len() == 1u {
361-
return success(
362-
nameize(sess, ms,
363-
eof_eis[0u].matches.map(|dv| dv.pop())));
359+
let mut v = ~[];
360+
for vec::each_mut(eof_eis[0u].matches) |dv| {
361+
v.push(dv.pop());
362+
}
363+
return success(nameize(sess, ms, v));
364364
} else if eof_eis.len() > 1u {
365365
return error(sp, ~"Ambiguity: multiple successful parses");
366366
} else {

src/libsyntax/print/pprust.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use print::pp;
2828
use print::pprust;
2929

3030
use core::char;
31-
use core::dvec::DVec;
3231
use core::io;
3332
use core::str;
3433
use core::u64;
@@ -63,7 +62,7 @@ pub struct ps {
6362
comments: Option<~[comments::cmnt]>,
6463
literals: Option<~[comments::lit]>,
6564
cur_cmnt_and_lit: @mut CurrentCommentAndLiteral,
66-
boxes: DVec<pp::breaks>,
65+
boxes: @mut ~[pp::breaks],
6766
ann: pp_ann
6867
}
6968

@@ -88,7 +87,7 @@ pub fn rust_printer(writer: io::Writer, intr: @ident_interner) -> @ps {
8887
cur_cmnt: 0,
8988
cur_lit: 0
9089
},
91-
boxes: DVec(),
90+
boxes: @mut ~[],
9291
ann: no_ann()
9392
};
9493
}
@@ -123,7 +122,7 @@ pub fn print_crate(cm: @CodeMap, intr: @ident_interner,
123122
cur_cmnt: 0,
124123
cur_lit: 0
125124
},
126-
boxes: DVec(),
125+
boxes: @mut ~[],
127126
ann: ann
128127
};
129128
print_crate_(s, crate);

src/libsyntax/util/interner.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,19 @@
1313
// type, and vice versa.
1414

1515
use core::prelude::*;
16-
use core::dvec::DVec;
1716
use core::hashmap::linear::LinearMap;
1817

1918
pub struct Interner<T> {
2019
priv map: @mut LinearMap<T, uint>,
21-
priv vect: DVec<T>,
20+
priv vect: @mut ~[T],
2221
}
2322

2423
// when traits can extend traits, we should extend index<uint,T> to get []
2524
pub impl<T:Eq + IterBytes + Hash + Const + Copy> Interner<T> {
2625
static fn new() -> Interner<T> {
2726
Interner {
2827
map: @mut LinearMap::new(),
29-
vect: DVec(),
28+
vect: @mut ~[],
3029
}
3130
}
3231

@@ -58,7 +57,7 @@ pub impl<T:Eq + IterBytes + Hash + Const + Copy> Interner<T> {
5857
// this isn't "pure" in the traditional sense, because it can go from
5958
// failing to returning a value as items are interned. But for typestate,
6059
// where we first check a pred and then rely on it, ceasing to fail is ok.
61-
pure fn get(&self, idx: uint) -> T { self.vect.get_elt(idx) }
60+
pure fn get(&self, idx: uint) -> T { self.vect[idx] }
6261

6362
fn len(&self) -> uint { self.vect.len() }
6463
}

0 commit comments

Comments
 (0)