Skip to content

Commit 58fd6ab

Browse files
committed
libsyntax: Mechanically change ~[T] to Vec<T>
1 parent df40aec commit 58fd6ab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+934
-979
lines changed

src/libsyntax/abi.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
use std::fmt;
12+
use std::vec_ng::Vec;
1213
use std::fmt::Show;
1314

1415
#[deriving(Eq)]
@@ -117,7 +118,7 @@ pub fn lookup(name: &str) -> Option<Abi> {
117118
res
118119
}
119120

120-
pub fn all_names() -> ~[&'static str] {
121+
pub fn all_names() -> Vec<&'static str> {
121122
AbiDatas.map(|d| d.name)
122123
}
123124

@@ -232,7 +233,7 @@ impl AbiSet {
232233
}
233234

234235
pub fn check_valid(&self) -> Option<(Abi, Abi)> {
235-
let mut abis = ~[];
236+
let mut abis = Vec::new();
236237
self.each(|abi| { abis.push(abi); true });
237238

238239
for (i, abi) in abis.iter().enumerate() {

src/libsyntax/ast.rs

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub type SyntaxContext = u32;
9898
// it should cut down on memory use *a lot*; applying a mark
9999
// to a tree containing 50 identifiers would otherwise generate
100100
pub struct SCTable {
101-
table: RefCell<~[SyntaxContext_]>,
101+
table: RefCell<Vec<SyntaxContext_> >,
102102
mark_memo: RefCell<HashMap<(SyntaxContext,Mrk),SyntaxContext>>,
103103
rename_memo: RefCell<HashMap<(SyntaxContext,Ident,Name),SyntaxContext>>,
104104
}
@@ -164,7 +164,7 @@ pub struct Path {
164164
/// module (like paths in an import).
165165
global: bool,
166166
/// The segments in the path: the things separated by `::`.
167-
segments: ~[PathSegment],
167+
segments: Vec<PathSegment> ,
168168
}
169169

170170
/// A segment of a path: an identifier, an optional lifetime, and a set of
@@ -288,12 +288,12 @@ pub enum DefRegion {
288288

289289
// The set of MetaItems that define the compilation environment of the crate,
290290
// used to drive conditional compilation
291-
pub type CrateConfig = ~[@MetaItem];
291+
pub type CrateConfig = Vec<@MetaItem> ;
292292

293293
#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
294294
pub struct Crate {
295295
module: Mod,
296-
attrs: ~[Attribute],
296+
attrs: Vec<Attribute> ,
297297
config: CrateConfig,
298298
span: Span,
299299
}
@@ -303,7 +303,7 @@ pub type MetaItem = Spanned<MetaItem_>;
303303
#[deriving(Clone, Encodable, Decodable, Hash)]
304304
pub enum MetaItem_ {
305305
MetaWord(InternedString),
306-
MetaList(InternedString, ~[@MetaItem]),
306+
MetaList(InternedString, Vec<@MetaItem> ),
307307
MetaNameValue(InternedString, Lit),
308308
}
309309

@@ -334,8 +334,8 @@ impl Eq for MetaItem_ {
334334

335335
#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
336336
pub struct Block {
337-
view_items: ~[ViewItem],
338-
stmts: ~[@Stmt],
337+
view_items: Vec<ViewItem> ,
338+
stmts: Vec<@Stmt> ,
339339
expr: Option<@Expr>,
340340
id: NodeId,
341341
rules: BlockCheckMode,
@@ -373,17 +373,17 @@ pub enum Pat_ {
373373
// records this pattern's NodeId in an auxiliary
374374
// set (of "pat_idents that refer to nullary enums")
375375
PatIdent(BindingMode, Path, Option<@Pat>),
376-
PatEnum(Path, Option<~[@Pat]>), /* "none" means a * pattern where
376+
PatEnum(Path, Option<Vec<@Pat> >), /* "none" means a * pattern where
377377
* we don't bind the fields to names */
378-
PatStruct(Path, ~[FieldPat], bool),
379-
PatTup(~[@Pat]),
378+
PatStruct(Path, Vec<FieldPat> , bool),
379+
PatTup(Vec<@Pat> ),
380380
PatUniq(@Pat),
381381
PatRegion(@Pat), // reference pattern
382382
PatLit(@Expr),
383383
PatRange(@Expr, @Expr),
384384
// [a, b, ..i, y, z] is represented as
385385
// PatVec(~[a, b], Some(i), ~[y, z])
386-
PatVec(~[@Pat], Option<@Pat>, ~[@Pat])
386+
PatVec(Vec<@Pat> , Option<@Pat>, Vec<@Pat> )
387387
}
388388

389389
#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
@@ -488,7 +488,7 @@ pub enum Decl_ {
488488

489489
#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
490490
pub struct Arm {
491-
pats: ~[@Pat],
491+
pats: Vec<@Pat> ,
492492
guard: Option<@Expr>,
493493
body: P<Block>,
494494
}
@@ -526,10 +526,10 @@ pub enum Expr_ {
526526
ExprVstore(@Expr, ExprVstore),
527527
// First expr is the place; second expr is the value.
528528
ExprBox(@Expr, @Expr),
529-
ExprVec(~[@Expr], Mutability),
530-
ExprCall(@Expr, ~[@Expr]),
531-
ExprMethodCall(Ident, ~[P<Ty>], ~[@Expr]),
532-
ExprTup(~[@Expr]),
529+
ExprVec(Vec<@Expr> , Mutability),
530+
ExprCall(@Expr, Vec<@Expr> ),
531+
ExprMethodCall(Ident, Vec<P<Ty>> , Vec<@Expr> ),
532+
ExprTup(Vec<@Expr> ),
533533
ExprBinary(BinOp, @Expr, @Expr),
534534
ExprUnary(UnOp, @Expr),
535535
ExprLit(@Lit),
@@ -541,14 +541,14 @@ pub enum Expr_ {
541541
// Conditionless loop (can be exited with break, cont, or ret)
542542
// FIXME #6993: change to Option<Name>
543543
ExprLoop(P<Block>, Option<Ident>),
544-
ExprMatch(@Expr, ~[Arm]),
544+
ExprMatch(@Expr, Vec<Arm> ),
545545
ExprFnBlock(P<FnDecl>, P<Block>),
546546
ExprProc(P<FnDecl>, P<Block>),
547547
ExprBlock(P<Block>),
548548

549549
ExprAssign(@Expr, @Expr),
550550
ExprAssignOp(BinOp, @Expr, @Expr),
551-
ExprField(@Expr, Ident, ~[P<Ty>]),
551+
ExprField(@Expr, Ident, Vec<P<Ty>> ),
552552
ExprIndex(@Expr, @Expr),
553553

554554
/// Expression that looks like a "name". For example,
@@ -569,7 +569,7 @@ pub enum Expr_ {
569569
ExprMac(Mac),
570570

571571
// A struct literal expression.
572-
ExprStruct(Path, ~[Field], Option<@Expr> /* base */),
572+
ExprStruct(Path, Vec<Field> , Option<@Expr> /* base */),
573573

574574
// A vector literal constructed from one repeated element.
575575
ExprRepeat(@Expr /* element */, @Expr /* count */, Mutability),
@@ -600,14 +600,14 @@ pub enum TokenTree {
600600
TTTok(Span, ::parse::token::Token),
601601
// a delimited sequence (the delimiters appear as the first
602602
// and last elements of the vector)
603-
TTDelim(@~[TokenTree]),
603+
TTDelim(@Vec<TokenTree> ),
604604

605605
// These only make sense for right-hand-sides of MBE macros:
606606

607607
// a kleene-style repetition sequence with a span, a TTForest,
608608
// an optional separator, and a boolean where true indicates
609609
// zero or more (..), and false indicates one or more (+).
610-
TTSeq(Span, @~[TokenTree], Option<::parse::token::Token>, bool),
610+
TTSeq(Span, @Vec<TokenTree> , Option<::parse::token::Token>, bool),
611611

612612
// a syntactic variable that will be filled in by macro expansion.
613613
TTNonterminal(Span, Ident)
@@ -673,7 +673,7 @@ pub enum Matcher_ {
673673
MatchTok(::parse::token::Token),
674674
// match repetitions of a sequence: body, separator, zero ok?,
675675
// lo, hi position-in-match-array used:
676-
MatchSeq(~[Matcher], Option<::parse::token::Token>, bool, uint, uint),
676+
MatchSeq(Vec<Matcher> , Option<::parse::token::Token>, bool, uint, uint),
677677
// parse a Rust NT: name to bind, name of NT, position in match array:
678678
MatchNonterminal(Ident, Ident, uint)
679679
}
@@ -686,7 +686,7 @@ pub type Mac = Spanned<Mac_>;
686686
// There's only one flavor, now, so this could presumably be simplified.
687687
#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
688688
pub enum Mac_ {
689-
MacInvocTT(Path, ~[TokenTree], SyntaxContext), // new macro-invocation
689+
MacInvocTT(Path, Vec<TokenTree> , SyntaxContext), // new macro-invocation
690690
}
691691

692692
#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
@@ -700,7 +700,7 @@ pub type Lit = Spanned<Lit_>;
700700
#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
701701
pub enum Lit_ {
702702
LitStr(InternedString, StrStyle),
703-
LitBinary(Rc<~[u8]>),
703+
LitBinary(Rc<Vec<u8> >),
704704
LitChar(u32),
705705
LitInt(i64, IntTy),
706706
LitUint(u64, UintTy),
@@ -729,7 +729,7 @@ pub struct TypeField {
729729
#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
730730
pub struct TypeMethod {
731731
ident: Ident,
732-
attrs: ~[Attribute],
732+
attrs: Vec<Attribute> ,
733733
purity: Purity,
734734
decl: P<FnDecl>,
735735
generics: Generics,
@@ -858,7 +858,7 @@ pub enum Ty_ {
858858
TyRptr(Option<Lifetime>, MutTy),
859859
TyClosure(@ClosureTy),
860860
TyBareFn(@BareFnTy),
861-
TyTup(~[P<Ty>]),
861+
TyTup(Vec<P<Ty>> ),
862862
TyPath(Path, Option<OptVec<TyParamBound>>, NodeId), // for #7264; see above
863863
TyTypeof(@Expr),
864864
// TyInfer means the type should be inferred instead of it having been
@@ -878,8 +878,8 @@ pub struct InlineAsm {
878878
asm: InternedString,
879879
asm_str_style: StrStyle,
880880
clobbers: InternedString,
881-
inputs: ~[(InternedString, @Expr)],
882-
outputs: ~[(InternedString, @Expr)],
881+
inputs: Vec<(InternedString, @Expr)> ,
882+
outputs: Vec<(InternedString, @Expr)> ,
883883
volatile: bool,
884884
alignstack: bool,
885885
dialect: AsmDialect
@@ -914,7 +914,7 @@ impl Arg {
914914

915915
#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
916916
pub struct FnDecl {
917-
inputs: ~[Arg],
917+
inputs: Vec<Arg> ,
918918
output: P<Ty>,
919919
cf: RetStyle,
920920
variadic: bool
@@ -957,7 +957,7 @@ pub type ExplicitSelf = Spanned<ExplicitSelf_>;
957957
#[deriving(Eq, Encodable, Decodable, Hash)]
958958
pub struct Method {
959959
ident: Ident,
960-
attrs: ~[Attribute],
960+
attrs: Vec<Attribute> ,
961961
generics: Generics,
962962
explicit_self: ExplicitSelf,
963963
purity: Purity,
@@ -970,15 +970,15 @@ pub struct Method {
970970

971971
#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
972972
pub struct Mod {
973-
view_items: ~[ViewItem],
974-
items: ~[@Item],
973+
view_items: Vec<ViewItem> ,
974+
items: Vec<@Item> ,
975975
}
976976

977977
#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
978978
pub struct ForeignMod {
979979
abis: AbiSet,
980-
view_items: ~[ViewItem],
981-
items: ~[@ForeignItem],
980+
view_items: Vec<ViewItem> ,
981+
items: Vec<@ForeignItem> ,
982982
}
983983

984984
#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
@@ -989,19 +989,19 @@ pub struct VariantArg {
989989

990990
#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
991991
pub enum VariantKind {
992-
TupleVariantKind(~[VariantArg]),
992+
TupleVariantKind(Vec<VariantArg> ),
993993
StructVariantKind(@StructDef),
994994
}
995995

996996
#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
997997
pub struct EnumDef {
998-
variants: ~[P<Variant>],
998+
variants: Vec<P<Variant>> ,
999999
}
10001000

10011001
#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
10021002
pub struct Variant_ {
10031003
name: Ident,
1004-
attrs: ~[Attribute],
1004+
attrs: Vec<Attribute> ,
10051005
kind: VariantKind,
10061006
id: NodeId,
10071007
disr_expr: Option<@Expr>,
@@ -1034,13 +1034,13 @@ pub enum ViewPath_ {
10341034
ViewPathGlob(Path, NodeId),
10351035

10361036
// foo::bar::{a,b,c}
1037-
ViewPathList(Path, ~[PathListIdent], NodeId)
1037+
ViewPathList(Path, Vec<PathListIdent> , NodeId)
10381038
}
10391039

10401040
#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
10411041
pub struct ViewItem {
10421042
node: ViewItem_,
1043-
attrs: ~[Attribute],
1043+
attrs: Vec<Attribute> ,
10441044
vis: Visibility,
10451045
span: Span,
10461046
}
@@ -1052,7 +1052,7 @@ pub enum ViewItem_ {
10521052
// (containing arbitrary characters) from which to fetch the crate sources
10531053
// For example, extern crate whatever = "github.com/mozilla/rust"
10541054
ViewItemExternMod(Ident, Option<(InternedString,StrStyle)>, NodeId),
1055-
ViewItemUse(~[@ViewPath]),
1055+
ViewItemUse(Vec<@ViewPath> ),
10561056
}
10571057

10581058
// Meta-data associated with an item
@@ -1109,7 +1109,7 @@ pub struct StructField_ {
11091109
kind: StructFieldKind,
11101110
id: NodeId,
11111111
ty: P<Ty>,
1112-
attrs: ~[Attribute],
1112+
attrs: Vec<Attribute> ,
11131113
}
11141114

11151115
pub type StructField = Spanned<StructField_>;
@@ -1122,7 +1122,7 @@ pub enum StructFieldKind {
11221122

11231123
#[deriving(Eq, Encodable, Decodable, Hash)]
11241124
pub struct StructDef {
1125-
fields: ~[StructField], /* fields, not including ctor */
1125+
fields: Vec<StructField> , /* fields, not including ctor */
11261126
/* ID of the constructor. This is only used for tuple- or enum-like
11271127
* structs. */
11281128
ctor_id: Option<NodeId>
@@ -1135,7 +1135,7 @@ pub struct StructDef {
11351135
#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
11361136
pub struct Item {
11371137
ident: Ident,
1138-
attrs: ~[Attribute],
1138+
attrs: Vec<Attribute> ,
11391139
id: NodeId,
11401140
node: Item_,
11411141
vis: Visibility,
@@ -1151,19 +1151,19 @@ pub enum Item_ {
11511151
ItemTy(P<Ty>, Generics),
11521152
ItemEnum(EnumDef, Generics),
11531153
ItemStruct(@StructDef, Generics),
1154-
ItemTrait(Generics, ~[TraitRef], ~[TraitMethod]),
1154+
ItemTrait(Generics, Vec<TraitRef> , Vec<TraitMethod> ),
11551155
ItemImpl(Generics,
11561156
Option<TraitRef>, // (optional) trait this impl implements
11571157
P<Ty>, // self
1158-
~[@Method]),
1158+
Vec<@Method> ),
11591159
// a macro invocation (which includes macro definition)
11601160
ItemMac(Mac),
11611161
}
11621162

11631163
#[deriving(Eq, Encodable, Decodable, Hash)]
11641164
pub struct ForeignItem {
11651165
ident: Ident,
1166-
attrs: ~[Attribute],
1166+
attrs: Vec<Attribute> ,
11671167
node: ForeignItem_,
11681168
id: NodeId,
11691169
span: Span,
@@ -1205,9 +1205,9 @@ mod test {
12051205
#[test]
12061206
fn check_asts_encodable() {
12071207
let e = Crate {
1208-
module: Mod {view_items: ~[], items: ~[]},
1209-
attrs: ~[],
1210-
config: ~[],
1208+
module: Mod {view_items: Vec::new(), items: Vec::new()},
1209+
attrs: Vec::new(),
1210+
config: Vec::new(),
12111211
span: Span {
12121212
lo: BytePos(10),
12131213
hi: BytePos(20),

0 commit comments

Comments
 (0)