pub fn build_link_meta(krate: &ast::Crate,
output: &OutputFilenames) -> LinkMeta {
let r = LinkMeta {
- crateid: find_crate_id(krate.attrs, output),
+ crateid: find_crate_id(krate.attrs.as_slice(), output),
crate_hash: Svh::calculate(krate),
};
info!("{}", r);
use std::io::MemReader;
use std::os;
use std::vec;
+use std::vec_ng::Vec;
+use std::vec_ng;
use collections::{HashMap, HashSet};
use getopts::{optopt, optmulti, optflag, optflagopt};
use getopts;
};
let mk = attr::mk_name_value_item_str;
- return ~[ // Target bindings.
+ return vec!(// Target bindings.
attr::mk_word_item(fam.clone()),
mk(InternedString::new("target_os"), tos),
mk(InternedString::new("target_family"), fam),
mk(InternedString::new("target_arch"), InternedString::new(arch)),
mk(InternedString::new("target_endian"), InternedString::new(end)),
mk(InternedString::new("target_word_size"),
- InternedString::new(wordsz)),
- ];
+ InternedString::new(wordsz))
+ );
}
pub fn append_configuration(cfg: &mut ast::CrateConfig,
}
}
-pub fn build_configuration(sess: Session) ->
- ast::CrateConfig {
+pub fn build_configuration(sess: Session) -> ast::CrateConfig {
// Combine the configuration requested by the session (command line) with
// some default and generated configuration items
let default_cfg = default_configuration(sess);
} else {
InternedString::new("nogc")
});
- return vec::append(user_cfg, default_cfg);
+ return vec_ng::append(user_cfg.move_iter().collect(),
+ default_cfg.as_slice());
}
// Convert strings provided as --cfg [cfgspec] into a crate_cfg
-> ast::CrateConfig {
cfgspecs.move_iter().map(|s| {
let sess = parse::new_parse_sess();
- parse::parse_meta_from_source_str("cfgspec".to_str(), s, ~[], sess)
+ parse::parse_meta_from_source_str("cfgspec".to_str(),
+ s,
+ Vec::new(),
+ sess)
}).collect::<ast::CrateConfig>()
}
let time_passes = sess.time_passes();
sess.building_library.set(session::building_library(sess.opts, &krate));
- sess.crate_types.set(session::collect_crate_types(&sess, krate.attrs));
+ sess.crate_types.set(session::collect_crate_types(&sess,
+ krate.attrs
+ .as_slice()));
time(time_passes, "gated feature checking", (), |_|
front::feature_gate::check_crate(sess, &krate));
input: &Input,
outputs: &OutputFilenames,
krate: &ast::Crate) -> io::IoResult<()> {
- let id = link::find_crate_id(krate.attrs, outputs);
+ let id = link::find_crate_id(krate.attrs.as_slice(), outputs);
let mut out_filenames = ~[];
for output_type in sess.opts.output_types.iter() {
let loader = &mut Loader::new(sess);
phase_2_configure_and_expand(sess, loader, krate)
};
- let outputs = build_output_filenames(input, outdir, output,
- expanded_crate.attrs, sess);
+ let outputs = build_output_filenames(input,
+ outdir,
+ output,
+ expanded_crate.attrs.as_slice(),
+ sess);
write_out_deps(sess, input, &outputs, &expanded_crate).unwrap();
let sessopts = build_session_options(matches);
let sess = build_session(sessopts, None);
let cfg = build_configuration(sess);
- assert!((attr::contains_name(cfg, "test")));
+ assert!((attr::contains_name(cfg.as_slice(), "test")));
}
// When the user supplies --test and --cfg test, don't implicitly add
use syntax;
use std::cell::{Cell, RefCell};
+use std::vec_ng::Vec;
use collections::{HashMap,HashSet};
pub struct Config {
addl_lib_search_paths: @RefCell::new(HashSet::new()),
maybe_sysroot: None,
target_triple: host_triple(),
- cfg: ~[],
+ cfg: Vec::new(),
test: false,
parse_only: false,
no_trans: false,
CrateTypeStaticlib | CrateTypeDylib | CrateTypeRlib => return true
}
}
- match syntax::attr::first_attr_value_str_by_name(krate.attrs, "crate_type") {
+ match syntax::attr::first_attr_value_str_by_name(krate.attrs.as_slice(),
+ "crate_type") {
Some(s) => {
s.equiv(&("lib")) ||
s.equiv(&("rlib")) ||
// any items that do not belong in the current configuration
pub fn strip_unconfigured_items(krate: ast::Crate) -> ast::Crate {
let config = krate.config.clone();
- strip_items(krate, |attrs| in_cfg(config, attrs))
+ strip_items(krate, |attrs| in_cfg(config.as_slice(), attrs))
}
impl<'a> fold::Folder for Context<'a> {
ast::ItemEnum(ref def, ref generics) => {
let mut variants = def.variants.iter().map(|c| c.clone()).
filter_map(|v| {
- if !(cx.in_cfg)(v.node.attrs) {
+ if !(cx.in_cfg)(v.node.attrs.as_slice()) {
None
} else {
Some(match v.node.kind {
fn fold_struct(cx: &Context, def: &ast::StructDef) -> @ast::StructDef {
let mut fields = def.fields.iter().map(|c| c.clone()).filter(|m| {
- (cx.in_cfg)(m.node.attrs)
+ (cx.in_cfg)(m.node.attrs.as_slice())
});
@ast::StructDef {
fields: fields.collect(),
}
fn item_in_cfg(cx: &Context, item: &ast::Item) -> bool {
- return (cx.in_cfg)(item.attrs);
+ return (cx.in_cfg)(item.attrs.as_slice());
}
fn foreign_item_in_cfg(cx: &Context, item: &ast::ForeignItem) -> bool {
- return (cx.in_cfg)(item.attrs);
+ return (cx.in_cfg)(item.attrs.as_slice());
}
fn view_item_in_cfg(cx: &Context, item: &ast::ViewItem) -> bool {
- return (cx.in_cfg)(item.attrs);
+ return (cx.in_cfg)(item.attrs.as_slice());
}
fn method_in_cfg(cx: &Context, meth: &ast::Method) -> bool {
- return (cx.in_cfg)(meth.attrs);
+ return (cx.in_cfg)(meth.attrs.as_slice());
}
fn trait_method_in_cfg(cx: &Context, meth: &ast::TraitMethod) -> bool {
match *meth {
- ast::Required(ref meth) => (cx.in_cfg)(meth.attrs),
- ast::Provided(meth) => (cx.in_cfg)(meth.attrs)
+ ast::Required(ref meth) => (cx.in_cfg)(meth.attrs.as_slice()),
+ ast::Provided(meth) => (cx.in_cfg)(meth.attrs.as_slice())
}
}
}
ast::ItemForeignMod(..) => {
- if attr::contains_name(i.attrs, "link_args") {
+ if attr::contains_name(i.attrs.as_slice(), "link_args") {
self.gate_feature("link_args", i.span,
"the `link_args` attribute is not portable \
across platforms, it is recommended to \
}
ast::ItemFn(..) => {
- if attr::contains_name(i.attrs, "macro_registrar") {
+ if attr::contains_name(i.attrs.as_slice(), "macro_registrar") {
self.gate_feature("macro_registrar", i.span,
"cross-crate macro exports are \
experimental and possibly buggy");
}
ast::ItemStruct(..) => {
- if attr::contains_name(i.attrs, "simd") {
+ if attr::contains_name(i.attrs.as_slice(), "simd") {
self.gate_feature("simd", i.span,
"SIMD types are experimental and possibly buggy");
}
use driver::session::Session;
-use std::vec;
+use std::vec_ng::Vec;
+use std::vec_ng;
use syntax::ast;
use syntax::attr;
use syntax::codemap::DUMMY_SP;
}
fn use_std(krate: &ast::Crate) -> bool {
- !attr::contains_name(krate.attrs, "no_std")
+ !attr::contains_name(krate.attrs.as_slice(), "no_std")
}
fn use_uv(krate: &ast::Crate) -> bool {
- !attr::contains_name(krate.attrs, "no_uv")
+ !attr::contains_name(krate.attrs.as_slice(), "no_uv")
}
fn no_prelude(attrs: &[ast::Attribute]) -> bool {
impl fold::Folder for StandardLibraryInjector {
fn fold_crate(&mut self, krate: ast::Crate) -> ast::Crate {
- let mut vis = ~[ast::ViewItem {
+ let mut vis = vec!(ast::ViewItem {
node: ast::ViewItemExternMod(token::str_to_ident("std"),
with_version("std"),
ast::DUMMY_NODE_ID),
- attrs: ~[
+ attrs: vec!(
attr::mk_attr(attr::mk_list_item(
InternedString::new("phase"),
- ~[
+ vec!(
attr::mk_word_item(InternedString::new("syntax")),
attr::mk_word_item(InternedString::new("link")
- )]))
- ],
+ ))))),
vis: ast::Inherited,
span: DUMMY_SP
- }];
+ });
if use_uv(&krate) && !self.sess.building_library.get() {
vis.push(ast::ViewItem {
node: ast::ViewItemExternMod(token::str_to_ident("green"),
with_version("green"),
ast::DUMMY_NODE_ID),
- attrs: ~[],
+ attrs: Vec::new(),
vis: ast::Inherited,
span: DUMMY_SP
});
node: ast::ViewItemExternMod(token::str_to_ident("rustuv"),
with_version("rustuv"),
ast::DUMMY_NODE_ID),
- attrs: ~[],
+ attrs: Vec::new(),
vis: ast::Inherited,
span: DUMMY_SP
});
}
- vis.push_all(krate.module.view_items);
+ vis.push_all_move(krate.module.view_items.clone());
let new_module = ast::Mod {
view_items: vis,
..krate.module.clone()
impl fold::Folder for PreludeInjector {
fn fold_crate(&mut self, krate: ast::Crate) -> ast::Crate {
- if !no_prelude(krate.attrs) {
+ if !no_prelude(krate.attrs.as_slice()) {
// only add `use std::prelude::*;` if there wasn't a
// `#[no_implicit_prelude];` at the crate level.
ast::Crate {
}
fn fold_item(&mut self, item: @ast::Item) -> SmallVector<@ast::Item> {
- if !no_prelude(item.attrs) {
+ if !no_prelude(item.attrs.as_slice()) {
// only recur if there wasn't `#[no_implicit_prelude];`
// on this item, i.e. this means that the prelude is not
// implicitly imported though the whole subtree
let prelude_path = ast::Path {
span: DUMMY_SP,
global: false,
- segments: ~[
+ segments: vec!(
ast::PathSegment {
identifier: token::str_to_ident("std"),
lifetimes: opt_vec::Empty,
identifier: token::str_to_ident("prelude"),
lifetimes: opt_vec::Empty,
types: opt_vec::Empty,
- },
- ],
+ }),
};
let vp = @codemap::dummy_spanned(ast::ViewPathGlob(prelude_path, ast::DUMMY_NODE_ID));
let vi2 = ast::ViewItem {
- node: ast::ViewItemUse(~[vp]),
- attrs: ~[],
+ node: ast::ViewItemUse(vec!(vp)),
+ attrs: Vec::new(),
vis: ast::Inherited,
span: DUMMY_SP,
};
- let vis = vec::append(~[vi2], module.view_items);
+ let vis = vec_ng::append(vec!(vi2), module.view_items.as_slice());
// FIXME #2543: Bad copy.
let new_module = ast::Mod {
// Code that generates a test runner to run all the tests in a crate
+#[allow(dead_code)];
+#[allow(unused_imports)];
use driver::session;
use front::config;
use std::cell::RefCell;
use std::vec;
+use std::vec_ng::Vec;
+use std::vec_ng;
use syntax::ast_util::*;
use syntax::attr::AttrMetaMethods;
use syntax::attr;
// We generate the test harness when building in the 'test'
// configuration, either with the '--test' or '--cfg test'
// command line options.
- let should_test = attr::contains_name(krate.config, "test");
+ let should_test = attr::contains_name(krate.config.as_slice(), "test");
if should_test {
generate_test_harness(sess, krate)
// When not compiling with --test we should not compile the
// #[test] functions
config::strip_items(krate, |attrs| {
- !attr::contains_name(attrs, "test") &&
- !attr::contains_name(attrs, "bench")
+ !attr::contains_name(attrs.as_slice(), "test") &&
+ !attr::contains_name(attrs.as_slice(), "bench")
})
}
fn is_test_fn(cx: &TestCtxt, i: @ast::Item) -> bool {
- let has_test_attr = attr::contains_name(i.attrs, "test");
+ let has_test_attr = attr::contains_name(i.attrs.as_slice(), "test");
fn has_test_signature(i: @ast::Item) -> bool {
match &i.node {
}
fn is_bench_fn(i: @ast::Item) -> bool {
- let has_bench_attr = attr::contains_name(i.attrs, "bench");
+ let has_bench_attr = attr::contains_name(i.attrs.as_slice(), "bench");
fn has_test_signature(i: @ast::Item) -> bool {
match i.node {
i.attrs.iter().any(|attr| {
// check ignore(cfg(foo, bar))
attr.name().equiv(&("ignore")) && match attr.meta_item_list() {
- Some(ref cfgs) => attr::test_cfg(cx.config, cfgs.iter().map(|x| *x)),
+ Some(ref cfgs) => {
+ attr::test_cfg(cx.config.as_slice(), cfgs.iter().map(|x| *x))
+ }
None => true
}
})
}
fn should_fail(i: @ast::Item) -> bool {
- attr::contains_name(i.attrs, "should_fail")
+ attr::contains_name(i.attrs.as_slice(), "should_fail")
}
fn add_test_module(cx: &TestCtxt, m: &ast::Mod) -> ast::Mod {
let testmod = mk_test_module(cx);
ast::Mod {
- items: vec::append_one(m.items.clone(), testmod),
+ items: vec_ng::append_one(m.items.clone(), testmod),
..(*m).clone()
}
}
let id_test = token::str_to_ident("test");
let vi = if cx.is_test_crate {
ast::ViewItemUse(
- ~[@nospan(ast::ViewPathSimple(id_test,
- path_node(~[id_test]),
- ast::DUMMY_NODE_ID))])
+ vec!(@nospan(ast::ViewPathSimple(id_test,
+ path_node(~[id_test]),
+ ast::DUMMY_NODE_ID))))
} else {
ast::ViewItemExternMod(id_test,
with_version("test"),
};
ast::ViewItem {
node: vi,
- attrs: ~[],
+ attrs: Vec::new(),
vis: ast::Inherited,
span: DUMMY_SP
}
}
-fn mk_test_module(cx: &TestCtxt) -> @ast::Item {
+#[cfg(stage0)]
+fn mk_test_module(_: &TestCtxt) -> @ast::Item {
+ fail!("test disabled in this stage due to quasiquoter")
+}
+#[cfg(not(stage0))]
+fn mk_test_module(cx: &TestCtxt) -> @ast::Item {
// Link to test crate
- let view_items = ~[mk_std(cx)];
+ let view_items = vec!(mk_std(cx));
// A constant vector of test descriptors.
let tests = mk_tests(cx);
let testmod = ast::Mod {
view_items: view_items,
- items: ~[mainfn, tests],
+ items: vec!(mainfn, tests),
};
let item_ = ast::ItemMod(testmod);
let item = ast::Item {
ident: token::str_to_ident("__test"),
- attrs: ~[resolve_unexported_attr],
+ attrs: vec!(resolve_unexported_attr),
id: ast::DUMMY_NODE_ID,
node: item_,
vis: ast::Public,
}
}
+#[cfg(stage0)]
+fn mk_tests(_: &TestCtxt) -> @ast::Item {
+ fail!("tests disabled in this stage due to quasiquoter")
+}
+
+#[cfg(not(stage0))]
fn mk_tests(cx: &TestCtxt) -> @ast::Item {
// The vector of test_descs for this crate
let test_descs = mk_test_descs(cx);
}
fn is_test_crate(krate: &ast::Crate) -> bool {
- match attr::find_crateid(krate.attrs) {
+ match attr::find_crateid(krate.attrs.as_slice()) {
Some(ref s) if "test" == s.name => true,
_ => false
}
}
fn mk_test_descs(cx: &TestCtxt) -> @ast::Expr {
- let mut descs = ~[];
+ let mut descs = Vec::new();
{
let testfns = cx.testfns.borrow();
debug!("building test vector from {} tests", testfns.get().len());
}
}
+#[cfg(stage0)]
+fn mk_test_desc_and_fn_rec(_: &TestCtxt, _: &Test) -> @ast::Expr {
+ fail!("tests disabled in this stage due to quasiquoter")
+}
+
+#[cfg(not(stage0))]
fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> @ast::Expr {
let span = test.span;
let path = test.path.clone();
use std::str;
use std::task;
use std::vec;
+use std::vec_ng::Vec;
use syntax::ast;
use syntax::diagnostic::Emitter;
use syntax::diagnostic;
d::compile_input(sess, cfg, &input, &odir, &ofile);
}
-fn parse_crate_attrs(sess: session::Session,
- input: &d::Input) -> ~[ast::Attribute] {
- match *input {
+fn parse_crate_attrs(sess: session::Session, input: &d::Input) ->
+ ~[ast::Attribute] {
+ let result = match *input {
d::FileInput(ref ifile) => {
- parse::parse_crate_attrs_from_file(ifile, ~[], sess.parse_sess)
+ parse::parse_crate_attrs_from_file(ifile,
+ Vec::new(),
+ sess.parse_sess)
}
d::StrInput(ref src) => {
parse::parse_crate_attrs_from_source_str(d::anon_src(),
(*src).clone(),
- ~[],
+ Vec::new(),
sess.parse_sess)
}
- }
+ };
+ result.move_iter().collect()
}
/// Run a procedure which will detect failures in the compiler and print nicer
use metadata::loader::Os;
use std::cell::RefCell;
+use std::vec_ng::Vec;
use collections::HashMap;
use syntax::ast;
use syntax::abi;
let should_load = i.attrs.iter().all(|attr| {
attr.name().get() != "phase" ||
attr.meta_item_list().map_or(false, |phases| {
- attr::contains_name(phases, "link")
+ attr::contains_name(phases.as_slice(), "link")
})
});
}
}
- fn get_exported_macros(&mut self, cnum: ast::CrateNum) -> ~[~str] {
- csearch::get_exported_macros(self.env.sess.cstore, cnum)
+ fn get_exported_macros(&mut self, cnum: ast::CrateNum) -> Vec<~str> {
+ csearch::get_exported_macros(self.env.sess.cstore, cnum).move_iter()
+ .collect()
}
fn get_registrar_symbol(&mut self, cnum: ast::CrateNum) -> Option<~str> {
let nd = reader::get_doc(meta_item_doc, tag_meta_item_name);
let n = token::intern_and_get_ident(nd.as_str_slice());
let subitems = get_meta_items(meta_item_doc);
- items.push(attr::mk_list_item(n, subitems));
+ items.push(attr::mk_list_item(n, subitems.move_iter().collect()));
true
});
return items;
encode_name(ebml_w, variant.node.name.name);
encode_parent_item(ebml_w, local_def(id));
encode_visibility(ebml_w, variant.node.vis);
- encode_attributes(ebml_w, variant.node.attrs);
+ encode_attributes(ebml_w, variant.node.attrs.as_slice());
match variant.node.kind {
ast::TupleVariantKind(ref args)
if args.len() > 0 && generics.ty_params.len() == 0 => {
}
ast::TupleVariantKind(_) => {},
ast::StructVariantKind(def) => {
- let idx = encode_info_for_struct(ecx, ebml_w, def.fields, index);
+ let idx = encode_info_for_struct(ecx,
+ ebml_w,
+ def.fields.as_slice(),
+ index);
encode_struct_fields(ebml_w, def);
let bkts = create_index(idx);
encode_index(ebml_w, bkts, write_i64);
// If this is a newtype struct, return the constructor.
match struct_def.ctor_id {
Some(ctor_id) if struct_def.fields.len() > 0 &&
- struct_def.fields[0].node.kind ==
+ struct_def.fields.get(0).node.kind ==
ast::UnnamedField => {
continue_ = callback(ctor_id);
}
let elem = ast_map::PathName(m.ident.name);
encode_path(ebml_w, impl_path.chain(Some(elem).move_iter()));
match ast_method_opt {
- Some(ast_method) => encode_attributes(ebml_w, ast_method.attrs),
+ Some(ast_method) => {
+ encode_attributes(ebml_w, ast_method.attrs.as_slice())
+ }
None => ()
}
for &ast_method in ast_method_opt.iter() {
let num_params = tpt.generics.type_param_defs().len();
- if num_params > 0u || is_default_impl || should_inline(ast_method.attrs) {
+ if num_params > 0u ||
+ is_default_impl ||
+ should_inline(ast_method.attrs.as_slice()) {
(ecx.encode_inlined_item)(
ecx, ebml_w, IIMethodRef(local_def(parent_id), false, ast_method));
} else {
encode_bounds_and_type(ebml_w, ecx, &lookup_item_type(tcx, def_id));
encode_name(ebml_w, item.ident.name);
encode_path(ebml_w, path);
- encode_attributes(ebml_w, item.attrs);
- if tps_len > 0u || should_inline(item.attrs) {
+ encode_attributes(ebml_w, item.attrs.as_slice());
+ if tps_len > 0u || should_inline(item.attrs.as_slice()) {
(ecx.encode_inlined_item)(ecx, ebml_w, IIItemRef(item));
} else {
encode_symbol(ecx, ebml_w, item.id);
encode_item_variances(ebml_w, ecx, item.id);
encode_bounds_and_type(ebml_w, ecx, &lookup_item_type(tcx, def_id));
encode_name(ebml_w, item.ident.name);
- encode_attributes(ebml_w, item.attrs);
+ encode_attributes(ebml_w, item.attrs.as_slice());
for v in (*enum_definition).variants.iter() {
encode_variant_id(ebml_w, local_def(v.node.id));
}
encode_enum_variant_info(ecx,
ebml_w,
item.id,
- (*enum_definition).variants,
+ (*enum_definition).variants.as_slice(),
index,
generics);
}
the index, and the index needs to be in the item for the
class itself */
let idx = encode_info_for_struct(ecx, ebml_w,
- struct_def.fields, index);
+ struct_def.fields.as_slice(), index);
/* Index the class*/
add_to_index(item, ebml_w, index);
encode_item_variances(ebml_w, ecx, item.id);
encode_name(ebml_w, item.ident.name);
- encode_attributes(ebml_w, item.attrs);
+ encode_attributes(ebml_w, item.attrs.as_slice());
encode_path(ebml_w, path.clone());
encode_visibility(ebml_w, vis);
encode_family(ebml_w, 'i');
encode_bounds_and_type(ebml_w, ecx, &lookup_item_type(tcx, def_id));
encode_name(ebml_w, item.ident.name);
- encode_attributes(ebml_w, item.attrs);
+ encode_attributes(ebml_w, item.attrs.as_slice());
match ty.node {
ast::TyPath(ref path, ref bounds, _) if path.segments
.len() == 1 => {
let num_implemented_methods = ast_methods.len();
for (i, m) in imp.methods.iter().enumerate() {
let ast_method = if i < num_implemented_methods {
- Some(ast_methods[i])
+ Some(*ast_methods.get(i))
} else { None };
{
encode_region_param_defs(ebml_w, trait_def.generics.region_param_defs());
encode_trait_ref(ebml_w, ecx, trait_def.trait_ref, tag_item_trait_ref);
encode_name(ebml_w, item.ident.name);
- encode_attributes(ebml_w, item.attrs);
+ encode_attributes(ebml_w, item.attrs.as_slice());
encode_visibility(ebml_w, vis);
for &method_def_id in ty::trait_method_def_ids(tcx, def_id).iter() {
ebml_w.start_tag(tag_item_trait_method);
}
}
- match ms[i] {
- Required(ref tm) => {
- encode_attributes(ebml_w, tm.attrs);
+ match ms.get(i) {
+ &Required(ref tm) => {
+ encode_attributes(ebml_w, tm.attrs.as_slice());
encode_method_sort(ebml_w, 'r');
}
- Provided(m) => {
- encode_attributes(ebml_w, m.attrs);
+ &Provided(m) => {
+ encode_attributes(ebml_w, m.attrs.as_slice());
// If this is a static method, we've already encoded
// this.
if method_ty.explicit_self != SelfStatic {
use std::cast;
use std::io::Seek;
use std::rc::Rc;
+use std::vec_ng::Vec;
use serialize::ebml::reader;
use serialize::ebml;
}
}).collect();
let blk_sans_items = ast::P(ast::Block {
- view_items: ~[], // I don't know if we need the view_items here,
- // but it doesn't break tests!
+ view_items: Vec::new(), // I don't know if we need the view_items
+ // here, but it doesn't break tests!
stmts: stmts_sans_items,
expr: blk.expr,
id: blk.id,
map: &ast_map::Map,
path: ~[ast_map::PathElem],
ii: ast::InlinedItem) -> ast::InlinedItem {
- ast_map::map_decoded_item(map, path, AstRenumberer { xcx: xcx }, |fld| {
+ ast_map::map_decoded_item(map,
+ path.move_iter().collect(),
+ AstRenumberer { xcx: xcx },
+ |fld| {
match ii {
ast::IIItem(i) => {
ast::IIItem(fld.fold_item(i).expect_one("expected one item"))
#[cfg(test)]
impl fake_ext_ctxt for @parse::ParseSess {
- fn cfg(&self) -> ast::CrateConfig { ~[] }
+ fn cfg(&self) -> ast::CrateConfig {
+ Vec::new()
+ }
fn parse_sess(&self) -> @parse::ParseSess { *self }
fn call_site(&self) -> Span {
codemap::Span {
this.check_assignment(dest);
}
ast::ExprCall(f, ref args) => {
- this.check_call(expr, Some(f), f.span, *args);
+ this.check_call(expr, Some(f), f.span, args.as_slice());
}
ast::ExprMethodCall(_, _, ref args) => {
- this.check_call(expr, None, expr.span, *args);
+ this.check_call(expr, None, expr.span, args.as_slice());
}
ast::ExprIndex(_, rval) | ast::ExprBinary(_, _, rval)
if method_map.get().contains_key(&expr.id) => {
let mut guard_exit = discr_exit;
for arm in arms.iter() {
guard_exit = self.opt_expr(arm.guard, guard_exit); // 2
- let pats_exit = self.pats_any(arm.pats, guard_exit); // 3
+ let pats_exit = self.pats_any(arm.pats.as_slice(),
+ guard_exit); // 3
let body_exit = self.block(arm.body, pats_exit); // 4
self.add_contained_edge(body_exit, expr_exit); // 5
}
}
ast::ExprVec(ref elems, _) => {
- self.straightline(expr, pred, *elems)
+ self.straightline(expr, pred, elems.as_slice())
}
ast::ExprCall(func, ref args) => {
- self.call(expr, pred, func, *args)
+ self.call(expr, pred, func, args.as_slice())
}
ast::ExprMethodCall(_, _, ref args) => {
- self.call(expr, pred, args[0], args.slice_from(1))
+ self.call(expr, pred, *args.get(0), args.slice_from(1))
}
ast::ExprIndex(l, r) |
}
ast::ExprTup(ref exprs) => {
- self.straightline(expr, pred, *exprs)
+ self.straightline(expr, pred, exprs.as_slice())
}
ast::ExprStruct(_, ref fields, base) => {
for arm in arms.iter() {
check_legality_of_move_bindings(cx,
arm.guard.is_some(),
- arm.pats);
+ arm.pats.as_slice());
}
- check_arms(cx, *arms);
+ check_arms(cx, arms.as_slice());
/* Check for exhaustiveness */
// Check for empty enum, because is_useful only works on inhabited
// types.
}
_ => { /* We assume only enum types can be uninhabited */ }
}
- let arms = arms.iter().filter_map(unguarded_pat).collect::<~[~[@Pat]]>().concat_vec();
- if arms.is_empty() {
+
+ let pats: ~[@Pat] = arms.iter()
+ .filter_map(unguarded_pat)
+ .flat_map(|pats| pats.move_iter())
+ .collect();
+ if pats.is_empty() {
cx.tcx.sess.span_err(ex.span, "non-exhaustive patterns");
} else {
- check_exhaustive(cx, ex.span, arms);
+ check_exhaustive(cx, ex.span, pats);
}
}
_ => ()
}
DefVariant(_, id, _) if variant(id) == *ctor_id => {
let args = match args {
- Some(args) => args,
+ Some(args) => args.iter().map(|x| *x).collect(),
None => vec::from_elem(arity, wild())
};
Some(vec::append(args, r.tail()))
DefStruct(..) => {
let new_args;
match args {
- Some(args) => new_args = args,
+ Some(args) => {
+ new_args = args.iter().map(|x| *x).collect()
+ }
None => new_args = vec::from_elem(arity, wild())
}
Some(vec::append(new_args, r.tail()))
}
}
}
- PatTup(args) => Some(vec::append(args, r.tail())),
+ PatTup(args) => {
+ Some(vec::append(args.iter().map(|x| *x).collect(), r.tail()))
+ }
PatUniq(a) | PatRegion(a) => {
Some(vec::append(~[a], r.tail()))
}
vec(_) => {
let num_elements = before.len() + after.len();
if num_elements < arity && slice.is_some() {
- Some(vec::append(
- [
- before,
- vec::from_elem(
- arity - num_elements, wild()),
- after
- ].concat_vec(),
- r.tail()
- ))
+ let mut result = ~[];
+ for pat in before.iter() {
+ result.push((*pat).clone());
+ }
+ for _ in iter::range(0, arity - num_elements) {
+ result.push(wild())
+ }
+ for pat in after.iter() {
+ result.push((*pat).clone());
+ }
+ for pat in r.tail().iter() {
+ result.push((*pat).clone());
+ }
+ Some(result)
} else if num_elements == arity {
- Some(vec::append(
- vec::append(before, after),
- r.tail()
- ))
+ let mut result = ~[];
+ for pat in before.iter() {
+ result.push((*pat).clone());
+ }
+ for pat in after.iter() {
+ result.push((*pat).clone());
+ }
+ for pat in r.tail().iter() {
+ result.push((*pat).clone());
+ }
+ Some(result)
} else {
None
}
None => None,
Some(ast_map::NodeItem(it)) => match it.node {
ItemEnum(ast::EnumDef { variants: ref variants }, _) => {
- variant_expr(*variants, variant_def.node)
+ variant_expr(variants.as_slice(), variant_def.node)
}
_ => None
},
c, d)) {
csearch::found(ast::IIItem(item)) => match item.node {
ItemEnum(ast::EnumDef { variants: ref variants }, _) => {
- variant_expr(*variants, variant_def.node)
+ variant_expr(variants.as_slice(), variant_def.node)
}
_ => None
},
pub fn lit_to_const(lit: &Lit) -> const_val {
match lit.node {
LitStr(ref s, _) => const_str((*s).clone()),
- LitBinary(ref data) => const_binary(data.clone()),
+ LitBinary(ref data) => {
+ const_binary(Rc::new(data.borrow().iter().map(|x| *x).collect()))
+ }
LitChar(n) => const_uint(n as u64),
LitInt(n, _) => const_int(n),
LitUint(n, _) => const_uint(n),
// determine the bits for the body and then union
// them into `in_out`, which reflects all bodies to date
let mut body = guards.to_owned();
- self.walk_pat_alternatives(arm.pats, body, loop_scopes);
+ self.walk_pat_alternatives(arm.pats.as_slice(),
+ body,
+ loop_scopes);
self.walk_block(arm.body, body, loop_scopes);
join_bits(&self.dfcx.oper, body, in_out);
}
}
ast::ExprVec(ref exprs, _) => {
- self.walk_exprs(*exprs, in_out, loop_scopes)
+ self.walk_exprs(exprs.as_slice(), in_out, loop_scopes)
}
ast::ExprRepeat(l, r, _) => {
ast::ExprCall(f, ref args) => {
self.walk_expr(f, in_out, loop_scopes);
- self.walk_call(expr.id, *args, in_out, loop_scopes);
+ self.walk_call(expr.id, args.as_slice(), in_out, loop_scopes);
}
ast::ExprMethodCall(_, _, ref args) => {
- self.walk_call(expr.id, *args, in_out, loop_scopes);
+ self.walk_call(expr.id, args.as_slice(), in_out, loop_scopes);
}
ast::ExprIndex(l, r) |
}
ast::ExprTup(ref exprs) => {
- self.walk_exprs(*exprs, in_out, loop_scopes);
+ self.walk_exprs(exprs.as_slice(), in_out, loop_scopes);
}
ast::ExprBinary(op, l, r) if ast_util::lazy_binop(op) => {
fn has_allow_dead_code_or_lang_attr(attrs: &[ast::Attribute]) -> bool {
contains_lint(attrs, allow, DEAD_CODE_LINT_STR)
- || attr::contains_name(attrs, "lang")
+ || attr::contains_name(attrs.as_slice(), "lang")
}
// This visitor seeds items that
impl Visitor<()> for LifeSeeder {
fn visit_item(&mut self, item: &ast::Item, _: ()) {
- if has_allow_dead_code_or_lang_attr(item.attrs) {
+ if has_allow_dead_code_or_lang_attr(item.attrs.as_slice()) {
self.worklist.push(item.id);
}
match item.node {
// Check for method here because methods are not ast::Item
match *fk {
visit::FkMethod(_, _, method) => {
- if has_allow_dead_code_or_lang_attr(method.attrs) {
+ if has_allow_dead_code_or_lang_attr(method.attrs.as_slice()) {
self.worklist.push(id);
}
}
}
// If the user wants no main function at all, then stop here.
- if attr::contains_name(krate.attrs, "no_main") {
+ if attr::contains_name(krate.attrs.as_slice(), "no_main") {
session.entry_type.set(Some(session::EntryNone));
return
}
});
}
- if attr::contains_name(item.attrs, "main") {
+ if attr::contains_name(item.attrs.as_slice(), "main") {
if ctxt.attr_main_fn.is_none() {
ctxt.attr_main_fn = Some((item.id, item.span));
} else {
}
}
- if attr::contains_name(item.attrs, "start") {
+ if attr::contains_name(item.attrs.as_slice(), "start") {
if ctxt.start_fn.is_none() {
ctxt.start_fn = Some((item.id, item.span));
} else {
}
fn check_item(cx: &mut Context, item: &Item) {
- if !attr::contains_name(item.attrs, "unsafe_destructor") {
+ if !attr::contains_name(item.attrs.as_slice(), "unsafe_destructor") {
match item.node {
ItemImpl(_, Some(ref trait_ref), self_type, _) => {
check_impl_of_trait(cx, item, trait_ref, self_type);
impl<'a> Visitor<()> for LanguageItemVisitor<'a> {
fn visit_item(&mut self, item: &ast::Item, _: ()) {
- match extract(item.attrs) {
+ match extract(item.attrs.as_slice()) {
Some(value) => {
let item_index = self.this.item_refs.find_equiv(&value).map(|x| *x);
attr.name().equiv(&("doc")) &&
match attr.meta_item_list() {
None => false,
- Some(l) => attr::contains_name(l, "hidden")
+ Some(l) => {
+ attr::contains_name(l.as_slice(), "hidden")
+ }
}
});
if ast_util::is_local(did) {
match cx.tcx.map.get(did.node) {
ast_map::NodeItem(it) => {
- if attr::contains_name(it.attrs, "must_use") {
+ if attr::contains_name(it.attrs.as_slice(),
+ "must_use") {
cx.span_lint(UnusedMustUse, s.span,
"unused result which must be used");
warned = true;
ref path, _) if pat_util::pat_is_binding(cx.tcx.def_map, p)=> {
// `let mut _a = 1;` doesn't need a warning.
let initial_underscore = if path.segments.len() == 1 {
- token::get_ident(path.segments[0].identifier).get()
- .starts_with("_")
+ token::get_ident(path.segments
+ .get(0)
+ .identifier).get().starts_with("_")
} else {
cx.tcx.sess.span_bug(p.span,
"mutable binding that doesn't consist \
ast::ItemTrait(..) => "a trait",
_ => return
};
- check_missing_doc_attrs(cx, Some(it.id), it.attrs, it.span, desc);
+ check_missing_doc_attrs(cx,
+ Some(it.id),
+ it.attrs.as_slice(),
+ it.span,
+ desc);
}
fn check_missing_doc_method(cx: &Context, m: &ast::Method) {
}
}
}
- check_missing_doc_attrs(cx, Some(m.id), m.attrs, m.span, "a method");
+ check_missing_doc_attrs(cx,
+ Some(m.id),
+ m.attrs.as_slice(),
+ m.span,
+ "a method");
}
fn check_missing_doc_ty_method(cx: &Context, tm: &ast::TypeMethod) {
- check_missing_doc_attrs(cx, Some(tm.id), tm.attrs, tm.span, "a type method");
+ check_missing_doc_attrs(cx,
+ Some(tm.id),
+ tm.attrs.as_slice(),
+ tm.span,
+ "a type method");
}
fn check_missing_doc_struct_field(cx: &Context, sf: &ast::StructField) {
match sf.node.kind {
ast::NamedField(_, vis) if vis != ast::Private =>
- check_missing_doc_attrs(cx, Some(cx.cur_struct_def_id), sf.node.attrs,
- sf.span, "a struct field"),
+ check_missing_doc_attrs(cx,
+ Some(cx.cur_struct_def_id),
+ sf.node.attrs.as_slice(),
+ sf.span,
+ "a struct field"),
_ => {}
}
}
fn check_missing_doc_variant(cx: &Context, v: &ast::Variant) {
- check_missing_doc_attrs(cx, Some(v.node.id), v.node.attrs, v.span, "a variant");
+ check_missing_doc_attrs(cx,
+ Some(v.node.id),
+ v.node.attrs.as_slice(),
+ v.span,
+ "a variant");
}
/// Checks for use of items with #[deprecated], #[experimental] and
impl<'a> Visitor<()> for Context<'a> {
fn visit_item(&mut self, it: &ast::Item, _: ()) {
- self.with_lint_attrs(it.attrs, |cx| {
+ self.with_lint_attrs(it.attrs.as_slice(), |cx| {
check_item_ctypes(cx, it);
check_item_non_camel_case_types(cx, it);
check_item_non_uppercase_statics(cx, it);
check_heap_item(cx, it);
check_missing_doc_item(cx, it);
- check_attrs_usage(cx, it.attrs);
+ check_attrs_usage(cx, it.attrs.as_slice());
cx.visit_ids(|v| v.visit_item(it, ()));
}
fn visit_foreign_item(&mut self, it: &ast::ForeignItem, _: ()) {
- self.with_lint_attrs(it.attrs, |cx| {
- check_attrs_usage(cx, it.attrs);
+ self.with_lint_attrs(it.attrs.as_slice(), |cx| {
+ check_attrs_usage(cx, it.attrs.as_slice());
visit::walk_foreign_item(cx, it, ());
})
}
fn visit_view_item(&mut self, i: &ast::ViewItem, _: ()) {
- self.with_lint_attrs(i.attrs, |cx| {
- check_attrs_usage(cx, i.attrs);
+ self.with_lint_attrs(i.attrs.as_slice(), |cx| {
+ check_attrs_usage(cx, i.attrs.as_slice());
visit::walk_view_item(cx, i, ());
})
}
match *fk {
visit::FkMethod(_, _, m) => {
- self.with_lint_attrs(m.attrs, |cx| {
+ self.with_lint_attrs(m.attrs.as_slice(), |cx| {
check_missing_doc_method(cx, m);
- check_attrs_usage(cx, m.attrs);
+ check_attrs_usage(cx, m.attrs.as_slice());
cx.visit_ids(|v| {
v.visit_fn(fk, decl, body, span, id, ());
fn visit_ty_method(&mut self, t: &ast::TypeMethod, _: ()) {
- self.with_lint_attrs(t.attrs, |cx| {
+ self.with_lint_attrs(t.attrs.as_slice(), |cx| {
check_missing_doc_ty_method(cx, t);
- check_attrs_usage(cx, t.attrs);
+ check_attrs_usage(cx, t.attrs.as_slice());
visit::walk_ty_method(cx, t, ());
})
}
fn visit_struct_field(&mut self, s: &ast::StructField, _: ()) {
- self.with_lint_attrs(s.node.attrs, |cx| {
+ self.with_lint_attrs(s.node.attrs.as_slice(), |cx| {
check_missing_doc_struct_field(cx, s);
- check_attrs_usage(cx, s.node.attrs);
+ check_attrs_usage(cx, s.node.attrs.as_slice());
visit::walk_struct_field(cx, s, ());
})
}
fn visit_variant(&mut self, v: &ast::Variant, g: &ast::Generics, _: ()) {
- self.with_lint_attrs(v.node.attrs, |cx| {
+ self.with_lint_attrs(v.node.attrs.as_slice(), |cx| {
check_missing_doc_variant(cx, v);
- check_attrs_usage(cx, v.node.attrs);
+ check_attrs_usage(cx, v.node.attrs.as_slice());
visit::walk_variant(cx, v, g, ());
})
for &(lint, level) in tcx.sess.opts.lint_opts.iter() {
cx.set_level(lint, level, CommandLine);
}
- cx.with_lint_attrs(krate.attrs, |cx| {
+ cx.with_lint_attrs(krate.attrs.as_slice(), |cx| {
cx.visit_id(ast::CRATE_NODE_ID);
cx.visit_ids(|v| {
v.visited_outermost = true;
visit::walk_crate(v, krate, ());
});
- check_crate_attrs_usage(cx, krate.attrs);
+ check_crate_attrs_usage(cx, krate.attrs.as_slice());
// since the root module isn't visited as an item (because it isn't an item), warn for it
// here.
- check_missing_doc_attrs(cx, None, krate.attrs, krate.span, "crate");
+ check_missing_doc_attrs(cx,
+ None,
+ krate.attrs.as_slice(),
+ krate.span,
+ "crate");
visit::walk_crate(cx, krate, ());
});
let guard_succ =
self.propagate_through_opt_expr(arm.guard, body_succ);
let arm_succ =
- self.define_bindings_in_arm_pats(arm.pats, guard_succ);
+ self.define_bindings_in_arm_pats(arm.pats.as_slice(),
+ guard_succ);
self.merge_from_succ(ln, arm_succ, first_merge);
first_merge = false;
};
}
ExprVec(ref exprs, _) => {
- self.propagate_through_exprs(*exprs, succ)
+ self.propagate_through_exprs(exprs.as_slice(), succ)
}
ExprRepeat(element, count, _) => {
let t_ret = ty::ty_fn_ret(ty::expr_ty(self.tcx, f));
let succ = if ty::type_is_bot(t_ret) {self.s.exit_ln}
else {succ};
- let succ = self.propagate_through_exprs(*args, succ);
+ let succ = self.propagate_through_exprs(args.as_slice(), succ);
self.propagate_through_expr(f, succ)
}
let t_ret = ty::node_id_to_type(self.tcx, expr.id);
let succ = if ty::type_is_bot(t_ret) {self.s.exit_ln}
else {succ};
- self.propagate_through_exprs(*args, succ)
+ self.propagate_through_exprs(args.as_slice(), succ)
}
ExprTup(ref exprs) => {
- self.propagate_through_exprs(*exprs, succ)
+ self.propagate_through_exprs(exprs.as_slice(), succ)
}
ExprBinary(op, l, r) if ast_util::lazy_binop(op) => {
}
fn check_arm(this: &mut Liveness, arm: &Arm) {
- this.arm_pats_bindings(arm.pats, |ln, var, sp, id| {
+ this.arm_pats_bindings(arm.pats.as_slice(), |ln, var, sp, id| {
this.warn_about_unused(sp, id, ln, var);
});
visit::walk_arm(this, arm, ());
}
}
self.use_expr(callee, mode);
- self.use_fn_args(*args);
+ self.use_fn_args(args.as_slice());
}
ExprMethodCall(_, _, ref args) => { // callee.m(args)
- self.use_fn_args(*args);
+ self.use_fn_args(args.as_slice());
}
ExprStruct(_, ref fields, opt_with) => {
}
ExprTup(ref exprs) => {
- self.consume_exprs(*exprs);
+ self.consume_exprs(exprs.as_slice());
}
ExprIf(cond_expr, then_blk, opt_else_expr) => {
}
ExprVec(ref exprs, _) => {
- self.consume_exprs(*exprs);
+ self.consume_exprs(exprs.as_slice());
}
ExprAddrOf(_, base) => { // &base
fn visit_item(&mut self, item: &ast::Item, _: ()) {
// Do not check privacy inside items with the resolve_unexported
// attribute. This is used for the test runner.
- if attr::contains_name(item.attrs, "!resolve_unexported") {
+ if attr::contains_name(item.attrs.as_slice(), "!resolve_unexported") {
return;
}
}
ast::ExprMethodCall(ident, _, ref args) => {
// see above
- let t = ty::type_autoderef(ty::expr_ty(self.tcx, args[0]));
+ let t = ty::type_autoderef(ty::expr_ty(self.tcx,
+ *args.get(0)));
match ty::get(t).sty {
ty::ty_enum(_, _) | ty::ty_struct(_, _) => {
match self.method_map.borrow().get().find(&expr.id) {
lifetimes: opt_vec::Empty,
types: opt_vec::Empty,
};
- let segs = ~[seg];
+ let segs = vec!(seg);
let path = ast::Path {
global: false,
span: pid.span,
// monomorphized or it was marked with `#[inline]`. This will only return
// true for functions.
fn item_might_be_inlined(item: &ast::Item) -> bool {
- if attributes_specify_inlining(item.attrs) {
+ if attributes_specify_inlining(item.attrs.as_slice()) {
return true
}
fn method_might_be_inlined(tcx: ty::ctxt, method: &ast::Method,
impl_src: ast::DefId) -> bool {
- if attributes_specify_inlining(method.attrs) ||
+ if attributes_specify_inlining(method.attrs.as_slice()) ||
generics_require_inlining(&method.generics) {
return true
}
}
Some(ast_map::NodeMethod(method)) => {
if generics_require_inlining(&method.generics) ||
- attributes_specify_inlining(method.attrs) {
+ attributes_specify_inlining(method.attrs.as_slice()) {
true
} else {
let impl_did = tcx.map.get_parent_did(node_id);
// Statics with insignificant addresses are not reachable
// because they're inlined specially into all other crates.
ast::ItemStatic(..) => {
- if attr::contains_name(item.attrs,
+ if attr::contains_name(item.attrs.as_slice(),
"address_insignificant") {
let mut reachable_symbols =
self.reachable_symbols.borrow_mut();
generics,
implemented_traits,
self_type,
- *methods);
+ methods.as_slice());
}
ItemTrait(ref generics, ref traits, ref methods) => {
ItemStruct(ref struct_def, ref generics) => {
self.resolve_struct(item.id,
generics,
- struct_def.fields);
+ struct_def.fields.as_slice());
}
ItemMod(ref module_) => {
// check that all of the arms in an or-pattern have exactly the
// same set of bindings, with the same binding modes for each.
fn check_consistent_bindings(&mut self, arm: &Arm) {
- if arm.pats.len() == 0 { return; }
- let map_0 = self.binding_mode_map(arm.pats[0]);
+ if arm.pats.len() == 0 {
+ return
+ }
+ let map_0 = self.binding_mode_map(*arm.pats.get(0));
for (i, p) in arm.pats.iter().enumerate() {
let map_i = self.binding_mode_map(*p);
// such a value is simply disallowed (since it's rarely
// what you want).
- let ident = path.segments[0].identifier;
+ let ident = path.segments.get(0).identifier;
let renamed = mtwt_resolve(ident);
match self.resolve_bare_identifier_pattern(ident) {
// FIXME: Must we clone?
match *subpats {
None => Some(vec::from_elem(variant_size, dummy)),
- _ => (*subpats).clone(),
+ Some(ref subpats) => {
+ Some((*subpats).iter().map(|x| *x).collect())
+ }
}
} else {
None
let this_opt = vec_len(n, vec_len_ge(before.len()),
(lo, hi));
if opt_eq(tcx, &this_opt, opt) {
- Some(vec::append_one((*before).clone(), slice) +
- *after)
+ let mut new_before = ~[];
+ for pat in before.iter() {
+ new_before.push(*pat);
+ }
+ new_before.push(slice);
+ for pat in after.iter() {
+ new_before.push(*pat);
+ }
+ Some(new_before)
} else {
None
}
None if i >= lo && i <= hi => {
let n = before.len();
if opt_eq(tcx, &vec_len(n, vec_len_eq, (lo,hi)), opt) {
- Some((*before).clone())
+ let mut new_before = ~[];
+ for pat in before.iter() {
+ new_before.push(*pat);
+ }
+ Some(new_before)
} else {
None
}
let dummy = @ast::Pat {id: 0, node: ast::PatWild, span: DUMMY_SP};
enter_match(bcx, dm, m, col, val, |p| {
match p.node {
- ast::PatTup(ref elts) => Some((*elts).clone()),
+ ast::PatTup(ref elts) => {
+ let mut new_elts = ~[];
+ for elt in elts.iter() {
+ new_elts.push((*elt).clone())
+ }
+ Some(new_elts)
+ }
_ => {
assert_is_binding_or_wild(bcx, p);
Some(vec::from_elem(n_elts, dummy))
let dummy = @ast::Pat {id: 0, node: ast::PatWild, span: DUMMY_SP};
enter_match(bcx, dm, m, col, val, |p| {
match p.node {
- ast::PatEnum(_, Some(ref elts)) => Some((*elts).clone()),
+ ast::PatEnum(_, Some(ref elts)) => {
+ Some(elts.iter().map(|x| (*x)).collect())
+ }
_ => {
assert_is_binding_or_wild(bcx, p);
Some(vec::from_elem(n_elts, dummy))
ast::PatStruct(_, ref fs, _) => {
match ty::get(node_id_type(bcx, br.pats[col].id)).sty {
ty::ty_struct(..) => {
- extend(&mut fields, *fs);
+ extend(&mut fields, fs.as_slice());
found = true;
}
_ => ()
let mut matches = ~[];
for arm in arms.iter() {
let body = fcx.new_id_block("case_body", arm.body.id);
- let bindings_map = create_bindings_map(bcx, arm.pats[0]);
+ let bindings_map = create_bindings_map(bcx, *arm.pats.get(0));
let arm_data = ArmData {
bodycx: body,
arm: arm,
val);
for sub_pat in sub_pats.iter() {
for (i, argval) in args.vals.iter().enumerate() {
- bcx = bind_irrefutable_pat(bcx, sub_pat[i],
+ bcx = bind_irrefutable_pat(bcx, *sub_pat.get(i),
*argval, binding_mode,
cleanup_scope);
}
let r = ia.asm.get().with_c_str(|a| {
constraints.with_c_str(|c| {
- InlineAsmCall(bcx, a, c, inputs, output_type, ia.volatile, ia.alignstack, dialect)
+ InlineAsmCall(bcx,
+ a,
+ c,
+ inputs.as_slice(),
+ output_type,
+ ia.volatile,
+ ia.alignstack,
+ dialect)
})
});
// Again, based on how many outputs we have
if numOutputs == 1 {
- Store(bcx, r, outputs[0]);
+ Store(bcx, r, *outputs.get(0));
} else {
for (i, o) in outputs.iter().enumerate() {
let v = ExtractValue(bcx, r, i);
let arg_tys = ty::ty_fn_args(node_id_type(bcx, id));
let arg_datums = create_datums_for_fn_args(&fcx, arg_tys);
- bcx = copy_args_to_allocas(&fcx, arg_scope, bcx, decl.inputs, arg_datums);
+ bcx = copy_args_to_allocas(&fcx,
+ arg_scope,
+ bcx,
+ decl.inputs.as_slice(),
+ arg_datums);
bcx = maybe_load_env(bcx);
match variant.node.kind {
ast::TupleVariantKind(ref args) if args.len() > 0 => {
let llfn = get_item_val(ccx, variant.node.id);
- trans_enum_variant(ccx, id, variant, *args,
+ trans_enum_variant(ccx, id, variant, args.as_slice(),
disr_val, None, llfn);
}
ast::TupleVariantKind(_) => {
if purity == ast::ExternFn {
let llfndecl = get_item_val(ccx, item.id);
foreign::trans_rust_fn_with_foreign_abi(
- ccx, decl, body, item.attrs, llfndecl, item.id);
+ ccx, decl, body, item.attrs.as_slice(), llfndecl, item.id);
} else if !generics.is_type_parameterized() {
let llfn = get_item_val(ccx, item.id);
- trans_fn(ccx, decl, body, llfn, None, item.id, item.attrs);
+ trans_fn(ccx,
+ decl,
+ body,
+ llfn,
+ None,
+ item.id,
+ item.attrs.as_slice());
} else {
// Be sure to travel more than just one layer deep to catch nested
// items in blocks and such.
}
}
ast::ItemImpl(ref generics, _, _, ref ms) => {
- meth::trans_impl(ccx, item.ident, *ms, generics, item.id);
+ meth::trans_impl(ccx, item.ident, ms.as_slice(), generics, item.id);
}
ast::ItemMod(ref m) => {
trans_mod(ccx, m);
consts::trans_const(ccx, m, item.id);
// Do static_assert checking. It can't really be done much earlier
// because we need to get the value of the bool out of LLVM
- if attr::contains_name(item.attrs, "static_assert") {
+ if attr::contains_name(item.attrs.as_slice(), "static_assert") {
if m == ast::MutMutable {
ccx.sess.span_fatal(expr.span,
"cannot have static_assert on a mutable \
// otherwise this is a unit-like struct.
Some(ctor_id) if struct_def.fields.len() > 0 => {
let llfndecl = get_item_val(ccx, ctor_id);
- trans_tuple_struct(ccx, struct_def.fields,
+ trans_tuple_struct(ccx, struct_def.fields.as_slice(),
ctor_id, None, llfndecl);
}
Some(_) | None => {}
let val = match item {
ast_map::NodeItem(i) => {
let ty = ty::node_id_to_type(ccx.tcx, i.id);
- let sym = exported_name(ccx, id, ty, i.attrs);
+ let sym = exported_name(ccx, id, ty, i.attrs.as_slice());
let v = match i.node {
ast::ItemStatic(_, _, expr) => {
// Apply the `unnamed_addr` attribute if
// requested
- if attr::contains_name(i.attrs,
+ if attr::contains_name(i.attrs.as_slice(),
"address_insignificant"){
{
let reachable =
inlineable = true;
}
- if attr::contains_name(i.attrs, "thread_local") {
+ if attr::contains_name(i.attrs.as_slice(),
+ "thread_local") {
lib::llvm::set_thread_local(g, true);
}
sym,
i.id)
};
- set_llvm_fn_attrs(i.attrs, llfn);
+ set_llvm_fn_attrs(i.attrs.as_slice(), llfn);
llfn
}
_ => fail!("get_item_val: weird result in table")
};
- match attr::first_attr_value_str_by_name(i.attrs, "link_section") {
+ match attr::first_attr_value_str_by_name(i.attrs
+ .as_slice(),
+ "link_section") {
Some(sect) => unsafe {
sect.get().with_c_str(|buf| {
llvm::LLVMSetSection(v, buf);
// with weak linkage, but if we're building a
// library then we've already declared the crate map
// so use that instead.
- if attr::contains_name(ni.attrs, "crate_map") {
+ if attr::contains_name(ni.attrs.as_slice(),
+ "crate_map") {
if ccx.sess.building_library.get() {
let s = "_rust_crate_map_toplevel";
let g = unsafe {
let ty = ty::node_id_to_type(ccx.tcx, id);
let parent = ccx.tcx.map.get_parent(id);
let enm = ccx.tcx.map.expect_item(parent);
- let sym = exported_name(ccx, id, ty, enm.attrs);
+ let sym = exported_name(ccx,
+ id,
+ ty,
+ enm.attrs.as_slice());
llfn = match enm.node {
ast::ItemEnum(_, _) => {
let parent = ccx.tcx.map.get_parent(id);
let struct_item = ccx.tcx.map.expect_item(parent);
let ty = ty::node_id_to_type(ccx.tcx, ctor_id);
- let sym = exported_name(ccx, id, ty, struct_item.attrs);
+ let sym = exported_name(ccx,
+ id,
+ ty,
+ struct_item.attrs
+ .as_slice());
let llfn = register_fn(ccx, struct_item.span,
sym, ctor_id, ty);
set_inline_hint(llfn);
m: &ast::Method) -> ValueRef {
let mty = ty::node_id_to_type(ccx.tcx, id);
- let sym = exported_name(ccx, id, mty, m.attrs);
+ let sym = exported_name(ccx, id, mty, m.attrs.as_slice());
let llfn = register_fn(ccx, m.span, sym, id, mty);
- set_llvm_fn_attrs(m.attrs, llfn);
+ set_llvm_fn_attrs(m.attrs.as_slice(), llfn);
llfn
}
ast::LitBool(b) => C_bool(b),
ast::LitNil => C_nil(),
ast::LitStr(ref s, _) => C_str_slice(cx, (*s).clone()),
- ast::LitBinary(ref data) => C_binary_slice(cx, *data.borrow()),
+ ast::LitBinary(ref data) => {
+ C_binary_slice(cx, data.borrow().as_slice())
+ }
}
}
ast::ExprTup(ref es) => {
let ety = ty::expr_ty(cx.tcx, e);
let repr = adt::represent_type(cx, ety);
- let (vals, inlineable) = map_list(*es);
+ let (vals, inlineable) = map_list(es.as_slice());
(adt::trans_const(cx, repr, 0, vals), inlineable)
}
ast::ExprStruct(_, ref fs, ref base_opt) => {
})
}
ast::ExprVec(ref es, ast::MutImmutable) => {
- let (v, _, inlineable) = const_vec(cx, e, *es, is_local);
+ let (v, _, inlineable) = const_vec(cx,
+ e,
+ es.as_slice(),
+ is_local);
(v, inlineable)
}
ast::ExprVstore(sub, ast::ExprVstoreSlice) => {
}
}
ast::ExprVec(ref es, ast::MutImmutable) => {
- let (cv, llunitty, _) = const_vec(cx, e, *es, is_local);
+ let (cv, llunitty, _) = const_vec(cx,
+ e,
+ es.as_slice(),
+ is_local);
let llty = val_ty(cv);
let gv = "const".with_c_str(|name| {
llvm::LLVMAddGlobal(cx.llmod, llty.to_ref(), name)
Some(ast::DefStruct(_)) => {
let ety = ty::expr_ty(cx.tcx, e);
let repr = adt::represent_type(cx, ety);
- let (arg_vals, inlineable) = map_list(*args);
+ let (arg_vals, inlineable) = map_list(args.as_slice());
(adt::trans_const(cx, repr, 0, arg_vals), inlineable)
}
Some(ast::DefVariant(enum_did, variant_did, _)) => {
let vinfo = ty::enum_variant_with_id(cx.tcx,
enum_did,
variant_did);
- let (arg_vals, inlineable) = map_list(*args);
+ let (arg_vals, inlineable) = map_list(args.as_slice());
(adt::trans_const(cx, repr, vinfo.disr_val, arg_vals),
inlineable)
}
{
let mut scope_map = fn_debug_context.scope_map.borrow_mut();
populate_scope_map(cx,
- arg_pats,
+ arg_pats.as_slice(),
top_level_block,
fn_metadata,
scope_map.get());
// they all must contain the same binding names
for arm_ref in arms.iter() {
- let arm_span = arm_ref.pats[0].span;
+ let arm_span = arm_ref.pats.get(0).span;
with_new_scope(cx,
arm_span,
controlflow::trans_if(bcx, expr.id, cond, thn, els, dest)
}
ast::ExprMatch(discr, ref arms) => {
- _match::trans_match(bcx, expr, discr, *arms, dest)
+ _match::trans_match(bcx, expr, discr, arms.as_slice(), dest)
}
ast::ExprBlock(blk) => {
controlflow::trans_block(bcx, blk, dest)
}
ast::ExprStruct(_, ref fields, base) => {
- trans_rec_or_struct(bcx, (*fields), base, expr.span, expr.id, dest)
+ trans_rec_or_struct(bcx,
+ fields.as_slice(),
+ base,
+ expr.span,
+ expr.id,
+ dest)
}
ast::ExprTup(ref args) => {
let repr = adt::represent_type(bcx.ccx(), expr_ty(bcx, expr));
closure::trans_expr_fn(bcx, sigil, decl, body, expr.id, dest)
}
ast::ExprCall(f, ref args) => {
- callee::trans_call(bcx, expr, f, callee::ArgExprs(*args), expr.id, dest)
+ callee::trans_call(bcx,
+ expr,
+ f,
+ callee::ArgExprs(args.as_slice()),
+ expr.id,
+ dest)
}
ast::ExprMethodCall(_, _, ref args) => {
- callee::trans_method_call(bcx, expr, args[0], callee::ArgExprs(*args), dest)
+ callee::trans_method_call(bcx,
+ expr,
+ *args.get(0),
+ callee::ArgExprs(args.as_slice()),
+ dest)
}
ast::ExprBinary(_, lhs, rhs) => {
// if not overloaded, would be RvalueDatumExpr
// the massive simplifications that have occurred.
pub fn link_name(i: @ast::ForeignItem) -> InternedString {
- match attr::first_attr_value_str_by_name(i.attrs, "link_name") {
+ match attr::first_attr_value_str_by_name(i.attrs.as_slice(),
+ "link_name") {
None => token::get_ident(i.ident),
Some(ln) => ln.clone(),
}
let g = get_item_val(ccx, item.id);
// see the comment in get_item_val() as to why this check is
// performed here.
- if !attr::contains_name(item.attrs,
+ if !attr::contains_name(item.attrs.as_slice(),
"address_insignificant") {
SetLinkage(g, AvailableExternallyLinkage);
}
..
} => {
let d = mk_lldecl();
- set_llvm_fn_attrs(i.attrs, d);
+ set_llvm_fn_attrs(i.attrs.as_slice(), d);
trans_fn(ccx, decl, body, d, Some(psubsts), fn_id.node, []);
d
}
trans_enum_variant(ccx,
parent,
v,
- (*args).clone(),
+ args.as_slice(),
this_tv.disr_val,
Some(psubsts),
d);
}
ast_map::NodeMethod(mth) => {
let d = mk_lldecl();
- set_llvm_fn_attrs(mth.attrs, d);
+ set_llvm_fn_attrs(mth.attrs.as_slice(), d);
trans_fn(ccx, mth.decl, mth.body, d, Some(psubsts), mth.id, []);
d
}
match *method {
ast::Provided(mth) => {
let d = mk_lldecl();
- set_llvm_fn_attrs(mth.attrs, d);
+ set_llvm_fn_attrs(mth.attrs.as_slice(), d);
trans_fn(ccx, mth.decl, mth.body, d, Some(psubsts), mth.id, []);
d
}
let d = mk_lldecl();
set_inline_hint(d);
base::trans_tuple_struct(ccx,
- struct_def.fields,
+ struct_def.fields.as_slice(),
struct_def.ctor_id.expect("ast-mapped tuple struct \
didn't have a ctor id"),
Some(psubsts),
Some(ast_map::NodeItem(item)) => {
match item.node {
ItemTrait(_, _, ref ms) => {
- let (_, p) = ast_util::split_trait_methods(*ms);
- p.map(|m| method(cx, ast_util::local_def(m.id)))
+ let (_, p) =
+ ast_util::split_trait_methods(ms.as_slice());
+ p.iter()
+ .map(|m| method(cx, ast_util::local_def(m.id)))
+ .collect()
}
_ => {
cx.sess.bug(format!("provided_trait_methods: \
},
ast::StructVariantKind(ref struct_def) => {
- let fields: &[StructField] = struct_def.fields;
+ let fields: &[StructField] = struct_def.fields.as_slice();
assert!(fields.len() > 0);
Some(ast_map::NodeItem(i)) => {
match i.node {
ast::ItemStruct(struct_def, _) => {
- struct_field_tys(struct_def.fields)
+ struct_field_tys(struct_def.fields.as_slice())
}
_ => cx.sess.bug("struct ID bound to non-struct")
}
Some(ast_map::NodeVariant(ref variant)) => {
match (*variant).node.kind {
ast::StructVariantKind(struct_def) => {
- struct_field_tys(struct_def.fields)
+ struct_field_tys(struct_def.fields.as_slice())
}
_ => {
cx.sess.bug("struct ID bound to enum variant that isn't \
use middle::typeck::lookup_def_tcx;
use util::ppaux::Repr;
-use std::vec;
+use std::vec_ng::Vec;
use syntax::abi::AbiSet;
use syntax::{ast, ast_util};
use syntax::codemap::Span;
}
match anon_regions {
- Ok(v) => opt_vec::from(v),
- Err(()) => opt_vec::from(vec::from_fn(expected_num_region_params,
+ Ok(v) => opt_vec::from(v.move_iter().collect()),
+ Err(()) => opt_vec::from(Vec::from_fn(expected_num_region_params,
|_| ty::ReStatic)) // hokey
}
};
|tmt| ty::mk_rptr(tcx, r, tmt))
}
ast::TyTup(ref fields) => {
- let flds = fields.map(|&t| ast_ty_to_ty(this, rscope, t));
+ let flds = fields.iter()
+ .map(|&t| ast_ty_to_ty(this, rscope, t))
+ .collect();
ty::mk_tup(tcx, flds)
}
ast::TyBareFn(ref bf) => {
use middle::typeck::require_same_types;
use collections::{HashMap, HashSet};
+use std::vec_ng::Vec;
use syntax::ast;
use syntax::ast_util;
use syntax::parse::token;
for arm in arms.iter() {
let mut pcx = pat_ctxt {
fcx: fcx,
- map: pat_id_map(tcx.def_map, arm.pats[0]),
+ map: pat_id_map(tcx.def_map, *arm.pats.get(0)),
};
for p in arm.pats.iter() { check_pat(&mut pcx, *p, discrim_ty);}
}
pub fn check_pat_variant(pcx: &pat_ctxt, pat: &ast::Pat, path: &ast::Path,
- subpats: &Option<~[@ast::Pat]>, expected: ty::t) {
+ subpats: &Option<Vec<@ast::Pat>>, expected: ty::t) {
// Typecheck the path.
let fcx = pcx.fcx;
let tcx = pcx.fcx.ccx.tcx;
- let arg_types;
+ let arg_types: ~[ty::t];
let kind_name;
// structure_of requires type variables to be resolved.
fcx.write_error(pat.id);
kind_name = "[error]";
arg_types = subpats.clone()
- .unwrap_or_default()
- .map(|_| ty::mk_err());
+ .unwrap_or_default()
+ .move_iter()
+ .map(|_| ty::mk_err())
+ .collect();
}
}
}
fcx.write_error(pat.id);
kind_name = "[error]";
arg_types = subpats.clone()
- .unwrap_or_default()
- .map(|_| ty::mk_err());
+ .unwrap_or_default()
+ .iter()
+ .map(|_| ty::mk_err())
+ .collect();
}
}
}
}
ast::PatIdent(_, ref path, _) => {
- check_pat_variant(pcx, pat, path, &Some(~[]), expected);
+ check_pat_variant(pcx, pat, path, &Some(Vec::new()), expected);
}
ast::PatEnum(ref path, ref subpats) => {
check_pat_variant(pcx, pat, path, subpats, expected);
match *structure {
ty::ty_struct(cid, ref substs) => {
check_struct_pat(pcx, pat.id, pat.span, expected, path,
- *fields, etc, cid, substs);
+ fields.as_slice(), etc, cid, substs);
}
ty::ty_enum(eid, ref substs) => {
- check_struct_like_enum_variant_pat(
- pcx, pat.id, pat.span, expected, path, *fields, etc, eid,
- substs);
+ check_struct_like_enum_variant_pat(pcx,
+ pat.id,
+ pat.span,
+ expected,
+ path,
+ fields.as_slice(),
+ etc,
+ eid,
+ substs);
}
_ => {
// See [Note-Type-error-reporting] in middle/typeck/infer/mod.rs
let def_map = tcx.def_map.borrow();
match def_map.get().find(&pat.id) {
Some(&ast::DefStruct(supplied_def_id)) => {
- check_struct_pat(pcx, pat.id, pat.span, ty::mk_err(), path, *fields, etc,
- supplied_def_id,
- &ty::substs { self_ty: None, tps: ~[], regions: ty::ErasedRegions} );
+ check_struct_pat(pcx,
+ pat.id,
+ pat.span,
+ ty::mk_err(),
+ path,
+ fields.as_slice(),
+ etc,
+ supplied_def_id,
+ &ty::substs {
+ self_ty: None,
+ tps: ~[],
+ regions: ty::ErasedRegions,
+ });
}
_ => () // Error, but we're already in an error case
}
{
let locals = self.fcx.inh.locals.borrow();
debug!("Pattern binding {} is assigned to {}",
- token::get_ident(path.segments[0].identifier),
+ token::get_ident(path.segments.get(0).identifier),
self.fcx.infcx().ty_to_str(
locals.get().get_copy(&p.id)));
}
ast::ItemEnum(ref enum_definition, _) => {
check_enum_variants(ccx,
it.span,
- enum_definition.variants,
+ enum_definition.variants.as_slice(),
it.id);
}
ast::ItemFn(decl, _, _, _, body) => {
&impl_tpt.generics,
ast_trait_ref,
impl_trait_ref,
- *ms);
+ ms.as_slice());
vtable::resolve_impl(ccx.tcx, it, &impl_tpt.generics, impl_trait_ref);
}
None => { }
n_rps);
let tps = vcx.infcx.next_ty_vars(n_tps);
- let substs = substs {regions: ty::NonerasedRegions(opt_vec::from(rps)),
- self_ty: None,
- tps: tps};
+ let substs = substs {
+ regions: ty::NonerasedRegions(opt_vec::from(rps.move_iter()
+ .collect())),
+ self_ty: None,
+ tps: tps,
+ };
let substd_ty = ty::subst(tcx, &substs, raw_ty);
ty_param_substs_and_ty { substs: substs, ty: substd_ty }
// Verify that no lifetimes or type parameters are present anywhere
// except the final two elements of the path.
for i in range(0, path.segments.len() - 2) {
- for lifetime in path.segments[i].lifetimes.iter() {
+ for lifetime in path.segments.get(i).lifetimes.iter() {
function_context.tcx()
.sess
.span_err(lifetime.span,
break;
}
- for typ in path.segments[i].types.iter() {
+ for typ in path.segments.get(i).types.iter() {
function_context.tcx()
.sess
.span_err(typ.span,
ast::FromImpl(_) => "impl",
};
- let trait_segment = &path.segments[path.segments.len() - 2];
+ let trait_segment = &path.segments.get(path.segments.len() - 2);
// Make sure lifetime parameterization agrees with the trait or
// implementation type.
_ => {
// Verify that no lifetimes or type parameters are present on
// the penultimate segment of the path.
- let segment = &path.segments[path.segments.len() - 2];
+ let segment = &path.segments.get(path.segments.len() - 2);
for lifetime in segment.lifetimes.iter() {
function_context.tcx()
.sess
// Generate the struct type.
let regions = fcx.infcx().next_region_vars(
infer::BoundRegionInTypeOrImpl(span),
- region_parameter_count);
+ region_parameter_count).move_iter().collect();
let type_parameters = fcx.infcx().next_ty_vars(type_parameter_count);
let substitutions = substs {
regions: ty::NonerasedRegions(opt_vec::from(regions)),
// Generate the enum type.
let regions = fcx.infcx().next_region_vars(
infer::BoundRegionInTypeOrImpl(span),
- region_parameter_count);
+ region_parameter_count).move_iter().collect();
let type_parameters = fcx.infcx().next_ty_vars(type_parameter_count);
let substitutions = substs {
regions: ty::NonerasedRegions(opt_vec::from(regions)),
}
}
ast::ExprMatch(discrim, ref arms) => {
- _match::check_match(fcx, expr, discrim, *arms);
+ _match::check_match(fcx, expr, discrim, arms.as_slice());
}
ast::ExprFnBlock(decl, body) => {
check_expr_fn(fcx,
fcx.write_ty(id, fcx.node_ty(b.id));
}
ast::ExprCall(f, ref args) => {
- check_call(fcx, expr, f, *args);
+ check_call(fcx, expr, f, args.as_slice());
let f_ty = fcx.expr_ty(f);
let (args_bot, args_err) = args.iter().fold((false, false),
|(rest_bot, rest_err), a| {
}
}
ast::ExprMethodCall(ident, ref tps, ref args) => {
- check_method_call(fcx, expr, ident, *args, *tps);
+ check_method_call(fcx, expr, ident, args.as_slice(), tps.as_slice());
let arg_tys = args.map(|a| fcx.expr_ty(*a));
let (args_bot, args_err) = arg_tys.iter().fold((false, false),
|(rest_bot, rest_err), a| {
match def_map.get().find(&id) {
Some(&ast::DefStruct(type_def_id)) => {
check_struct_constructor(fcx, id, expr.span, type_def_id,
- *fields, base_expr);
+ fields.as_slice(), base_expr);
}
Some(&ast::DefVariant(enum_id, variant_id, _)) => {
check_struct_enum_variant(fcx, id, expr.span, enum_id,
- variant_id, *fields);
+ variant_id, fields.as_slice());
}
_ => {
tcx.sess.span_bug(path.span,
}
}
ast::ExprField(base, field, ref tys) => {
- check_field(fcx, expr, base, field.name, *tys);
+ check_field(fcx, expr, base, field.name, tys.as_slice());
}
ast::ExprIndex(base, idx) => {
check_expr(fcx, base);
opt_vec::from(fcx.infcx().next_region_vars(
infer::BoundRegionInTypeOrImpl(span),
- num_expected_regions))
+ num_expected_regions).move_iter().collect())
};
let regions = ty::NonerasedRegions(regions);
match expr.node {
ast::ExprCall(callee, ref args) => {
constrain_callee(rcx, callee.id, expr, callee);
- constrain_call(rcx, Some(callee.id), expr, None, *args, false);
+ constrain_call(rcx,
+ Some(callee.id),
+ expr,
+ None,
+ args.as_slice(),
+ false);
visit::walk_expr(rcx, expr, ());
}
ast::ExprMethodCall(_, _, ref args) => {
- constrain_call(rcx, None, expr, Some(args[0]),
+ constrain_call(rcx, None, expr, Some(*args.get(0)),
args.slice_from(1), false);
visit::walk_expr(rcx, expr, ());
}
ast::ExprMatch(discr, ref arms) => {
- link_match(rcx, discr, *arms);
+ link_match(rcx, discr, arms.as_slice());
visit::walk_expr(rcx, expr, ());
}
let type_parameters = self.inference_context.next_ty_vars(bounds_count);
let substitutions = substs {
- regions: ty::NonerasedRegions(opt_vec::from(region_parameters)),
+ regions: ty::NonerasedRegions(opt_vec::from(
+ region_parameters.move_iter().collect())),
self_ty: None,
tps: type_parameters
};
ast::TupleVariantKind(ref args) if args.len() > 0 => {
let rs = ExplicitRscope;
let input_tys = args.map(|va| ccx.to_ty(&rs, va.ty));
- ty::mk_ctor_fn(tcx, scope, input_tys, enum_ty)
+ ty::mk_ctor_fn(tcx, scope, input_tys.as_slice(), enum_ty)
}
ast::TupleVariantKind(_) => {
let input_tys = struct_def.fields.map(
|f| ty::node_id_to_type(ccx.tcx, f.node.id));
- ty::mk_ctor_fn(tcx, scope, input_tys, enum_ty)
+ ty::mk_ctor_fn(tcx, scope, input_tys.as_slice(), enum_ty)
}
};
let trait_def_id = local_def(trait_id);
let mut trait_method_def_ids = tcx.trait_method_def_ids
.borrow_mut();
- trait_method_def_ids.get().insert(trait_def_id,
- method_def_ids);
+ trait_method_def_ids.get()
+ .insert(trait_def_id,
+ @method_def_ids.iter()
+ .map(|x| *x)
+ .collect());
}
_ => {} // Ignore things that aren't traits.
}
write_ty_to_tcx(tcx, it.id, tpt.ty);
get_enum_variant_types(ccx,
tpt.ty,
- enum_definition.variants,
+ enum_definition.variants.as_slice(),
generics);
},
ast::ItemImpl(ref generics, ref opt_trait_ref, selfty, ref ms) => {
convert_methods(ccx,
ImplContainer(local_def(it.id)),
- *ms,
+ ms.as_slice(),
selfty,
&i_ty_generics,
generics,
// Run convert_methods on the provided methods.
let (_, provided_methods) =
- split_trait_methods(*trait_methods);
+ split_trait_methods(trait_methods.as_slice());
let untransformed_rcvr_ty = ty::mk_self(tcx, local_def(it.id));
convert_methods(ccx,
TraitContainer(local_def(it.id)),
- provided_methods,
+ provided_methods.as_slice(),
untransformed_rcvr_ty,
&trait_def.generics,
generics,
let mut tcache = tcx.tcache.borrow_mut();
tcache.get().insert(local_def(ctor_id), tpt);
}
- } else if struct_def.fields[0].node.kind == ast::UnnamedField {
+ } else if struct_def.fields.get(0).node.kind ==
+ ast::UnnamedField {
// Tuple-like.
let inputs = {
let tcache = tcx.tcache.borrow();
|field| tcache.get().get(
&local_def(field.node.id)).ty)
};
- let ctor_fn_ty = ty::mk_ctor_fn(tcx, ctor_id, inputs, selfty);
+ let ctor_fn_ty = ty::mk_ctor_fn(tcx,
+ ctor_id,
+ inputs.as_slice(),
+ selfty);
write_ty_to_tcx(tcx, ctor_id, ctor_fn_ty);
{
let mut tcache = tcx.tcache.borrow_mut();
let self_ty = ty::mk_self(tcx, def_id);
let ty_generics = ty_generics(ccx, generics, 0);
let substs = mk_item_substs(ccx, &ty_generics, Some(self_ty));
- let bounds = ensure_supertraits(ccx, it.id, it.span, *supertraits);
+ let bounds = ensure_supertraits(ccx,
+ it.id,
+ it.span,
+ supertraits.as_slice());
let trait_ref = @ty::TraitRef {def_id: def_id,
substs: substs};
let trait_def = @ty::TraitDef {generics: ty_generics,
def
}
}
- }))
+ }).move_iter().collect())
};
fn compute_bounds(
-> ty::ty_param_bounds_and_ty {
let ty_generics = ty_generics(ccx, ast_generics, 0);
let rb = BindingRscope::new(def_id.node);
- let input_tys = decl.inputs.map(|a| ty_of_arg(ccx, &rb, a, None) );
+ let input_tys = decl.inputs
+ .iter()
+ .map(|a| ty_of_arg(ccx, &rb, a, None))
+ .collect();
let output_ty = ast_ty_to_ty(ccx, &rb, decl.output);
let t_fn = ty::mk_bare_fn(
fn repr(&self, tcx: ctxt) -> ~str {
match *self {
opt_vec::Empty => ~"[]",
- opt_vec::Vec(ref v) => repr_vec(tcx, *v)
+ opt_vec::Vec(ref v) => repr_vec(tcx, v.as_slice())
}
}
}