librustc: Fix errors arising from the automated ~[T]
conversion
This commit is contained in:
parent
198cc3d850
commit
c1ed4d7d41
44 changed files with 528 additions and 299 deletions
|
@ -519,7 +519,7 @@ pub fn crate_id_hash(crate_id: &CrateId) -> ~str {
|
|||
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);
|
||||
|
|
|
@ -35,6 +35,8 @@ use std::io::fs;
|
|||
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;
|
||||
|
@ -101,15 +103,15 @@ pub fn default_configuration(sess: Session) ->
|
|||
};
|
||||
|
||||
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,
|
||||
|
@ -119,8 +121,7 @@ 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);
|
||||
|
@ -135,7 +136,8 @@ pub fn build_configuration(sess: Session) ->
|
|||
} 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
|
||||
|
@ -143,7 +145,10 @@ fn parse_cfgspecs(cfgspecs: ~[~str])
|
|||
-> 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>()
|
||||
}
|
||||
|
||||
|
@ -193,7 +198,9 @@ pub fn phase_2_configure_and_expand(sess: Session,
|
|||
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));
|
||||
|
@ -472,7 +479,7 @@ fn write_out_deps(sess: Session,
|
|||
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() {
|
||||
|
@ -546,8 +553,11 @@ pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &Input,
|
|||
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();
|
||||
|
||||
|
@ -1180,7 +1190,7 @@ mod test {
|
|||
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
|
||||
|
|
|
@ -27,6 +27,7 @@ use syntax::{abi, ast, codemap};
|
|||
use syntax;
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::vec_ng::Vec;
|
||||
use collections::{HashMap,HashSet};
|
||||
|
||||
pub struct Config {
|
||||
|
@ -319,7 +320,7 @@ pub fn basic_options() -> @Options {
|
|||
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,
|
||||
|
@ -451,7 +452,8 @@ pub fn building_library(options: &Options, krate: &ast::Crate) -> bool {
|
|||
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")) ||
|
||||
|
|
|
@ -21,7 +21,7 @@ struct Context<'a> {
|
|||
// 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> {
|
||||
|
@ -117,7 +117,7 @@ fn fold_item_underscore(cx: &mut Context, item: &ast::Item_) -> ast::Item_ {
|
|||
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 {
|
||||
|
@ -147,7 +147,7 @@ fn fold_item_underscore(cx: &mut Context, item: &ast::Item_) -> ast::Item_ {
|
|||
|
||||
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(),
|
||||
|
@ -189,25 +189,25 @@ fn fold_block(cx: &mut Context, b: ast::P<ast::Block>) -> ast::P<ast::Block> {
|
|||
}
|
||||
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -171,7 +171,7 @@ impl Visitor<()> for Context {
|
|||
}
|
||||
|
||||
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 \
|
||||
|
@ -180,7 +180,7 @@ impl Visitor<()> for Context {
|
|||
}
|
||||
|
||||
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");
|
||||
|
@ -188,7 +188,7 @@ impl Visitor<()> for Context {
|
|||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
|
||||
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;
|
||||
|
@ -43,11 +44,11 @@ pub fn maybe_inject_prelude(sess: Session, krate: ast::Crate) -> ast::Crate {
|
|||
}
|
||||
|
||||
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 {
|
||||
|
@ -72,28 +73,27 @@ pub fn with_version(krate: &str) -> Option<(InternedString, ast::StrStyle)> {
|
|||
|
||||
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
|
||||
});
|
||||
|
@ -101,13 +101,13 @@ impl fold::Folder for StandardLibraryInjector {
|
|||
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()
|
||||
|
@ -134,7 +134,7 @@ struct PreludeInjector {
|
|||
|
||||
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 {
|
||||
|
@ -147,7 +147,7 @@ impl fold::Folder for PreludeInjector {
|
|||
}
|
||||
|
||||
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
|
||||
|
@ -161,7 +161,7 @@ impl fold::Folder for PreludeInjector {
|
|||
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,
|
||||
|
@ -171,19 +171,18 @@ impl fold::Folder for PreludeInjector {
|
|||
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 {
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
// 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;
|
||||
|
@ -18,6 +20,8 @@ use metadata::creader::Loader;
|
|||
|
||||
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;
|
||||
|
@ -57,7 +61,7 @@ pub fn modify_for_testing(sess: session::Session,
|
|||
// 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)
|
||||
|
@ -189,13 +193,13 @@ fn strip_test_functions(krate: ast::Crate) -> ast::Crate {
|
|||
// 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 {
|
||||
|
@ -224,7 +228,7 @@ fn is_test_fn(cx: &TestCtxt, i: @ast::Item) -> bool {
|
|||
}
|
||||
|
||||
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 {
|
||||
|
@ -251,20 +255,22 @@ fn is_ignored(cx: &TestCtxt, i: @ast::Item) -> bool {
|
|||
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()
|
||||
}
|
||||
}
|
||||
|
@ -291,9 +297,9 @@ fn mk_std(cx: &TestCtxt) -> ast::ViewItem {
|
|||
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"),
|
||||
|
@ -301,16 +307,21 @@ fn mk_std(cx: &TestCtxt) -> ast::ViewItem {
|
|||
};
|
||||
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);
|
||||
|
@ -326,7 +337,7 @@ fn mk_test_module(cx: &TestCtxt) -> @ast::Item {
|
|||
|
||||
let testmod = ast::Mod {
|
||||
view_items: view_items,
|
||||
items: ~[mainfn, tests],
|
||||
items: vec!(mainfn, tests),
|
||||
};
|
||||
let item_ = ast::ItemMod(testmod);
|
||||
|
||||
|
@ -337,7 +348,7 @@ fn mk_test_module(cx: &TestCtxt) -> @ast::Item {
|
|||
|
||||
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,
|
||||
|
@ -377,6 +388,12 @@ fn path_node_global(ids: ~[ast::Ident]) -> ast::Path {
|
|||
}
|
||||
}
|
||||
|
||||
#[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);
|
||||
|
@ -389,14 +406,14 @@ fn mk_tests(cx: &TestCtxt) -> @ast::Item {
|
|||
}
|
||||
|
||||
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());
|
||||
|
@ -418,6 +435,12 @@ fn mk_test_descs(cx: &TestCtxt) -> @ast::Expr {
|
|||
}
|
||||
}
|
||||
|
||||
#[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();
|
||||
|
|
|
@ -54,6 +54,7 @@ use std::os;
|
|||
use std::str;
|
||||
use std::task;
|
||||
use std::vec;
|
||||
use std::vec_ng::Vec;
|
||||
use syntax::ast;
|
||||
use syntax::diagnostic::Emitter;
|
||||
use syntax::diagnostic;
|
||||
|
@ -334,19 +335,22 @@ pub fn run_compiler(args: &[~str]) {
|
|||
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
|
||||
|
|
|
@ -23,6 +23,7 @@ use metadata::loader;
|
|||
use metadata::loader::Os;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::vec_ng::Vec;
|
||||
use collections::HashMap;
|
||||
use syntax::ast;
|
||||
use syntax::abi;
|
||||
|
@ -140,7 +141,7 @@ fn visit_view_item(e: &mut Env, i: &ast::ViewItem) {
|
|||
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")
|
||||
})
|
||||
});
|
||||
|
||||
|
@ -420,8 +421,9 @@ impl CrateLoader for Loader {
|
|||
}
|
||||
}
|
||||
|
||||
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> {
|
||||
|
|
|
@ -1057,7 +1057,7 @@ fn get_meta_items(md: ebml::Doc) -> ~[@ast::MetaItem] {
|
|||
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;
|
||||
|
|
|
@ -349,7 +349,7 @@ fn encode_enum_variant_info(ecx: &EncodeContext,
|
|||
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 => {
|
||||
|
@ -357,7 +357,10 @@ fn encode_enum_variant_info(ecx: &EncodeContext,
|
|||
}
|
||||
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);
|
||||
|
@ -516,7 +519,7 @@ fn each_auxiliary_node_id(item: @Item, callback: |NodeId| -> bool) -> bool {
|
|||
// 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);
|
||||
}
|
||||
|
@ -799,13 +802,17 @@ fn encode_info_for_method(ecx: &EncodeContext,
|
|||
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 {
|
||||
|
@ -930,8 +937,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
|||
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);
|
||||
|
@ -986,7 +993,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
|||
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));
|
||||
}
|
||||
|
@ -1002,7 +1009,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
|||
encode_enum_variant_info(ecx,
|
||||
ebml_w,
|
||||
item.id,
|
||||
(*enum_definition).variants,
|
||||
(*enum_definition).variants.as_slice(),
|
||||
index,
|
||||
generics);
|
||||
}
|
||||
|
@ -1012,7 +1019,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
|||
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);
|
||||
|
@ -1025,7 +1032,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
|||
|
||||
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);
|
||||
|
||||
|
@ -1065,7 +1072,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
|||
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 => {
|
||||
|
@ -1097,7 +1104,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
|||
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 };
|
||||
|
||||
{
|
||||
|
@ -1129,7 +1136,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
|||
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);
|
||||
|
@ -1195,14 +1202,14 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
|||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
|
|
|
@ -36,6 +36,7 @@ use std::libc;
|
|||
use std::cast;
|
||||
use std::io::Seek;
|
||||
use std::rc::Rc;
|
||||
use std::vec_ng::Vec;
|
||||
|
||||
use serialize::ebml::reader;
|
||||
use serialize::ebml;
|
||||
|
@ -334,8 +335,8 @@ impl Folder for NestedItemsDropper {
|
|||
}
|
||||
}).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,
|
||||
|
@ -396,7 +397,10 @@ fn renumber_and_map_ast(xcx: @ExtendedDecodeContext,
|
|||
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"))
|
||||
|
@ -1436,7 +1440,9 @@ trait fake_ext_ctxt {
|
|||
|
||||
#[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 {
|
||||
|
|
|
@ -831,10 +831,10 @@ fn check_loans_in_expr<'a>(this: &mut CheckLoanCtxt<'a>,
|
|||
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) => {
|
||||
|
|
|
@ -298,7 +298,8 @@ impl CFGBuilder {
|
|||
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
|
||||
}
|
||||
|
@ -348,15 +349,15 @@ impl CFGBuilder {
|
|||
}
|
||||
|
||||
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) |
|
||||
|
@ -369,7 +370,7 @@ impl CFGBuilder {
|
|||
}
|
||||
|
||||
ast::ExprTup(ref exprs) => {
|
||||
self.straightline(expr, pred, *exprs)
|
||||
self.straightline(expr, pred, exprs.as_slice())
|
||||
}
|
||||
|
||||
ast::ExprStruct(_, ref fields, base) => {
|
||||
|
|
|
@ -76,10 +76,10 @@ fn check_expr(v: &mut CheckMatchVisitor,
|
|||
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.
|
||||
|
@ -104,11 +104,15 @@ fn check_expr(v: &mut CheckMatchVisitor,
|
|||
}
|
||||
_ => { /* 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);
|
||||
}
|
||||
}
|
||||
_ => ()
|
||||
|
@ -671,7 +675,7 @@ fn specialize(cx: &MatchCheckCtxt,
|
|||
}
|
||||
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()))
|
||||
|
@ -682,7 +686,9 @@ fn specialize(cx: &MatchCheckCtxt,
|
|||
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()))
|
||||
|
@ -741,7 +747,9 @@ fn specialize(cx: &MatchCheckCtxt,
|
|||
}
|
||||
}
|
||||
}
|
||||
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()))
|
||||
}
|
||||
|
@ -804,20 +812,32 @@ fn specialize(cx: &MatchCheckCtxt,
|
|||
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
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ pub fn lookup_variant_by_id(tcx: ty::ctxt,
|
|||
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
|
||||
},
|
||||
|
@ -144,7 +144,7 @@ pub fn lookup_variant_by_id(tcx: ty::ctxt,
|
|||
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
|
||||
},
|
||||
|
@ -509,7 +509,9 @@ pub fn eval_const_expr_partial<T: ty::ExprTyProvider>(tcx: &T, e: &Expr)
|
|||
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),
|
||||
|
|
|
@ -531,7 +531,9 @@ impl<'a, O:DataFlowOperator> PropagationContext<'a, O> {
|
|||
// 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);
|
||||
}
|
||||
|
@ -562,7 +564,7 @@ impl<'a, O:DataFlowOperator> PropagationContext<'a, O> {
|
|||
}
|
||||
|
||||
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, _) => {
|
||||
|
@ -579,11 +581,11 @@ impl<'a, O:DataFlowOperator> PropagationContext<'a, O> {
|
|||
|
||||
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) |
|
||||
|
@ -596,7 +598,7 @@ impl<'a, O:DataFlowOperator> PropagationContext<'a, O> {
|
|||
}
|
||||
|
||||
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) => {
|
||||
|
|
|
@ -198,7 +198,7 @@ impl Visitor<()> for MarkSymbolVisitor {
|
|||
|
||||
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
|
||||
|
@ -220,7 +220,7 @@ struct LifeSeeder {
|
|||
|
||||
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 {
|
||||
|
@ -240,7 +240,7 @@ impl Visitor<()> for LifeSeeder {
|
|||
// 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ pub fn find_entry_point(session: Session, krate: &Crate, ast_map: &ast_map::Map)
|
|||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ fn find_item(item: &Item, ctxt: &mut EntryContext) {
|
|||
});
|
||||
}
|
||||
|
||||
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 {
|
||||
|
@ -105,7 +105,7 @@ fn find_item(item: &Item, ctxt: &mut EntryContext) {
|
|||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
|
|
|
@ -160,7 +160,7 @@ fn check_impl_of_trait(cx: &mut Context, it: &Item, trait_ref: &TraitRef, self_t
|
|||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -114,7 +114,7 @@ struct LanguageItemVisitor<'a> {
|
|||
|
||||
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);
|
||||
|
||||
|
|
|
@ -548,7 +548,9 @@ impl<'a> Context<'a> {
|
|||
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")
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1070,7 +1072,8 @@ fn check_unused_result(cx: &Context, s: &ast::Stmt) {
|
|||
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;
|
||||
|
@ -1234,8 +1237,9 @@ fn check_unused_mut_pat(cx: &Context, p: &ast::Pat) {
|
|||
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 \
|
||||
|
@ -1353,7 +1357,11 @@ fn check_missing_doc_item(cx: &Context, it: &ast::Item) {
|
|||
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) {
|
||||
|
@ -1386,24 +1394,39 @@ 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
|
||||
|
@ -1500,13 +1523,13 @@ fn check_stability(cx: &Context, e: &ast::Expr) {
|
|||
|
||||
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, ()));
|
||||
|
||||
|
@ -1515,15 +1538,15 @@ impl<'a> Visitor<()> for Context<'a> {
|
|||
}
|
||||
|
||||
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, ());
|
||||
})
|
||||
}
|
||||
|
@ -1579,9 +1602,9 @@ impl<'a> Visitor<()> for Context<'a> {
|
|||
|
||||
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, ());
|
||||
|
@ -1595,9 +1618,9 @@ impl<'a> Visitor<()> for Context<'a> {
|
|||
|
||||
|
||||
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, ());
|
||||
})
|
||||
|
@ -1616,18 +1639,18 @@ impl<'a> Visitor<()> for Context<'a> {
|
|||
}
|
||||
|
||||
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, ());
|
||||
})
|
||||
|
@ -1675,17 +1698,21 @@ pub fn check_crate(tcx: ty::ctxt,
|
|||
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, ());
|
||||
});
|
||||
|
|
|
@ -1129,7 +1129,8 @@ impl Liveness {
|
|||
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;
|
||||
};
|
||||
|
@ -1194,7 +1195,7 @@ impl Liveness {
|
|||
}
|
||||
|
||||
ExprVec(ref exprs, _) => {
|
||||
self.propagate_through_exprs(*exprs, succ)
|
||||
self.propagate_through_exprs(exprs.as_slice(), succ)
|
||||
}
|
||||
|
||||
ExprRepeat(element, count, _) => {
|
||||
|
@ -1215,7 +1216,7 @@ impl Liveness {
|
|||
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)
|
||||
}
|
||||
|
||||
|
@ -1225,11 +1226,11 @@ impl Liveness {
|
|||
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) => {
|
||||
|
@ -1493,7 +1494,7 @@ fn check_local(this: &mut Liveness, local: &Local) {
|
|||
}
|
||||
|
||||
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, ());
|
||||
|
|
|
@ -409,11 +409,11 @@ impl VisitContext {
|
|||
}
|
||||
}
|
||||
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) => {
|
||||
|
@ -468,7 +468,7 @@ impl VisitContext {
|
|||
}
|
||||
|
||||
ExprTup(ref exprs) => {
|
||||
self.consume_exprs(*exprs);
|
||||
self.consume_exprs(exprs.as_slice());
|
||||
}
|
||||
|
||||
ExprIf(cond_expr, then_blk, opt_else_expr) => {
|
||||
|
@ -497,7 +497,7 @@ impl VisitContext {
|
|||
}
|
||||
|
||||
ExprVec(ref exprs, _) => {
|
||||
self.consume_exprs(*exprs);
|
||||
self.consume_exprs(exprs.as_slice());
|
||||
}
|
||||
|
||||
ExprAddrOf(_, base) => { // &base
|
||||
|
|
|
@ -759,7 +759,7 @@ impl<'a> Visitor<()> for PrivacyVisitor<'a> {
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -788,7 +788,8 @@ impl<'a> Visitor<()> for PrivacyVisitor<'a> {
|
|||
}
|
||||
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) {
|
||||
|
@ -857,7 +858,7 @@ impl<'a> Visitor<()> for PrivacyVisitor<'a> {
|
|||
lifetimes: opt_vec::Empty,
|
||||
types: opt_vec::Empty,
|
||||
};
|
||||
let segs = ~[seg];
|
||||
let segs = vec!(seg);
|
||||
let path = ast::Path {
|
||||
global: false,
|
||||
span: pid.span,
|
||||
|
|
|
@ -44,7 +44,7 @@ fn generics_require_inlining(generics: &ast::Generics) -> bool {
|
|||
// 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
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ fn item_might_be_inlined(item: &ast::Item) -> bool {
|
|||
|
||||
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
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ impl ReachableContext {
|
|||
}
|
||||
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);
|
||||
|
@ -324,7 +324,7 @@ impl ReachableContext {
|
|||
// 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();
|
||||
|
|
|
@ -3690,7 +3690,7 @@ impl Resolver {
|
|||
generics,
|
||||
implemented_traits,
|
||||
self_type,
|
||||
*methods);
|
||||
methods.as_slice());
|
||||
}
|
||||
|
||||
ItemTrait(ref generics, ref traits, ref methods) => {
|
||||
|
@ -3764,7 +3764,7 @@ impl Resolver {
|
|||
ItemStruct(ref struct_def, ref generics) => {
|
||||
self.resolve_struct(item.id,
|
||||
generics,
|
||||
struct_def.fields);
|
||||
struct_def.fields.as_slice());
|
||||
}
|
||||
|
||||
ItemMod(ref module_) => {
|
||||
|
@ -4187,8 +4187,10 @@ impl Resolver {
|
|||
// 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);
|
||||
|
||||
|
@ -4408,7 +4410,7 @@ impl Resolver {
|
|||
// 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) {
|
||||
|
|
|
@ -652,7 +652,9 @@ fn enter_opt<'r,'b>(
|
|||
// 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
|
||||
|
@ -719,8 +721,15 @@ fn enter_opt<'r,'b>(
|
|||
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
|
||||
}
|
||||
|
@ -728,7 +737,11 @@ fn enter_opt<'r,'b>(
|
|||
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
|
||||
}
|
||||
|
@ -811,7 +824,13 @@ fn enter_tup<'r,'b>(
|
|||
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))
|
||||
|
@ -838,7 +857,9 @@ fn enter_tuple_struct<'r,'b>(
|
|||
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))
|
||||
|
@ -1094,7 +1115,7 @@ fn collect_record_or_struct_fields<'a>(
|
|||
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;
|
||||
}
|
||||
_ => ()
|
||||
|
@ -1866,7 +1887,7 @@ fn trans_match_inner<'a>(scope_cx: &'a Block<'a>,
|
|||
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,
|
||||
|
@ -2172,7 +2193,7 @@ fn bind_irrefutable_pat<'a>(
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -100,13 +100,20 @@ pub fn trans_inline_asm<'a>(bcx: &'a Block<'a>, ia: &ast::InlineAsm)
|
|||
|
||||
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);
|
||||
|
|
|
@ -1473,7 +1473,11 @@ pub fn trans_closure<'a>(ccx: @CrateContext,
|
|||
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);
|
||||
|
||||
|
@ -1637,7 +1641,7 @@ pub fn trans_enum_def(ccx: @CrateContext, enum_definition: &ast::EnumDef,
|
|||
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(_) => {
|
||||
|
@ -1667,10 +1671,16 @@ pub fn trans_item(ccx: @CrateContext, item: &ast::Item) {
|
|||
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.
|
||||
|
@ -1679,7 +1689,7 @@ pub fn trans_item(ccx: @CrateContext, item: &ast::Item) {
|
|||
}
|
||||
}
|
||||
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);
|
||||
|
@ -1695,7 +1705,7 @@ pub fn trans_item(ccx: @CrateContext, item: &ast::Item) {
|
|||
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 \
|
||||
|
@ -1738,7 +1748,7 @@ pub fn trans_struct_def(ccx: @CrateContext, struct_def: @ast::StructDef) {
|
|||
// 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 => {}
|
||||
|
@ -1925,7 +1935,7 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::NodeId) -> ValueRef {
|
|||
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) => {
|
||||
|
@ -1974,7 +1984,7 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::NodeId) -> ValueRef {
|
|||
|
||||
// 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 =
|
||||
|
@ -2006,7 +2016,8 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::NodeId) -> ValueRef {
|
|||
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);
|
||||
}
|
||||
|
||||
|
@ -2034,14 +2045,16 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::NodeId) -> ValueRef {
|
|||
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);
|
||||
|
@ -2087,7 +2100,8 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::NodeId) -> ValueRef {
|
|||
// 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 {
|
||||
|
@ -2126,7 +2140,10 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::NodeId) -> ValueRef {
|
|||
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(_, _) => {
|
||||
|
@ -2154,7 +2171,11 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::NodeId) -> ValueRef {
|
|||
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);
|
||||
|
@ -2190,10 +2211,10 @@ fn register_method(ccx: @CrateContext, id: ast::NodeId,
|
|||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,9 @@ pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: ast::Lit)
|
|||
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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -529,7 +531,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: &ast::Expr,
|
|||
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) => {
|
||||
|
@ -564,7 +566,10 @@ fn const_expr_unadjusted(cx: @CrateContext, e: &ast::Expr,
|
|||
})
|
||||
}
|
||||
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) => {
|
||||
|
@ -576,7 +581,10 @@ fn const_expr_unadjusted(cx: @CrateContext, e: &ast::Expr,
|
|||
}
|
||||
}
|
||||
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)
|
||||
|
@ -657,7 +665,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: &ast::Expr,
|
|||
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, _)) => {
|
||||
|
@ -666,7 +674,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: &ast::Expr,
|
|||
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)
|
||||
}
|
||||
|
|
|
@ -690,7 +690,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
|
|||
{
|
||||
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());
|
||||
|
@ -2650,7 +2650,7 @@ fn populate_scope_map(cx: &CrateContext,
|
|||
// 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,
|
||||
|
|
|
@ -731,13 +731,18 @@ fn trans_rvalue_dps_unadjusted<'a>(bcx: &'a Block<'a>,
|
|||
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));
|
||||
|
@ -777,10 +782,19 @@ fn trans_rvalue_dps_unadjusted<'a>(bcx: &'a Block<'a>,
|
|||
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
|
||||
|
|
|
@ -713,7 +713,8 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: @CrateContext,
|
|||
// 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(),
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ pub fn maybe_instantiate_inline(ccx: @CrateContext, fn_id: ast::DefId)
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ pub fn monomorphic_fn(ccx: @CrateContext,
|
|||
..
|
||||
} => {
|
||||
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
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ pub fn monomorphic_fn(ccx: @CrateContext,
|
|||
trans_enum_variant(ccx,
|
||||
parent,
|
||||
v,
|
||||
(*args).clone(),
|
||||
args.as_slice(),
|
||||
this_tv.disr_val,
|
||||
Some(psubsts),
|
||||
d);
|
||||
|
@ -244,7 +244,7 @@ pub fn monomorphic_fn(ccx: @CrateContext,
|
|||
}
|
||||
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
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ pub fn monomorphic_fn(ccx: @CrateContext,
|
|||
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
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ pub fn monomorphic_fn(ccx: @CrateContext,
|
|||
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),
|
||||
|
|
|
@ -3730,8 +3730,11 @@ pub fn provided_trait_methods(cx: ctxt, id: ast::DefId) -> ~[@Method] {
|
|||
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: \
|
||||
|
@ -3947,7 +3950,7 @@ impl VariantInfo {
|
|||
},
|
||||
ast::StructVariantKind(ref struct_def) => {
|
||||
|
||||
let fields: &[StructField] = struct_def.fields;
|
||||
let fields: &[StructField] = struct_def.fields.as_slice();
|
||||
|
||||
assert!(fields.len() > 0);
|
||||
|
||||
|
@ -4280,7 +4283,7 @@ pub fn lookup_struct_fields(cx: ctxt, did: ast::DefId) -> ~[field_ty] {
|
|||
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")
|
||||
}
|
||||
|
@ -4288,7 +4291,7 @@ pub fn lookup_struct_fields(cx: ctxt, did: ast::DefId) -> ~[field_ty] {
|
|||
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 \
|
||||
|
|
|
@ -60,7 +60,7 @@ use middle::typeck::rscope::{RegionScope};
|
|||
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;
|
||||
|
@ -186,8 +186,8 @@ fn ast_path_substs<AC:AstConv,RS:RegionScope>(
|
|||
}
|
||||
|
||||
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
|
||||
}
|
||||
};
|
||||
|
@ -519,7 +519,9 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
|
|||
|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) => {
|
||||
|
|
|
@ -20,6 +20,7 @@ use middle::typeck::infer;
|
|||
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;
|
||||
|
@ -40,7 +41,7 @@ pub fn check_match(fcx: @FnCtxt,
|
|||
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);}
|
||||
|
@ -108,13 +109,13 @@ pub struct pat_ctxt {
|
|||
}
|
||||
|
||||
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.
|
||||
|
@ -174,8 +175,10 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: &ast::Pat, path: &ast::Path,
|
|||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -223,8 +226,10 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: &ast::Pat, path: &ast::Path,
|
|||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -509,7 +514,7 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) {
|
|||
}
|
||||
}
|
||||
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);
|
||||
|
@ -521,12 +526,18 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) {
|
|||
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
|
||||
|
@ -540,9 +551,19 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) {
|
|||
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
|
||||
}
|
||||
|
|
|
@ -387,7 +387,7 @@ impl Visitor<()> for GatherLocalsVisitor {
|
|||
{
|
||||
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)));
|
||||
}
|
||||
|
@ -554,7 +554,7 @@ pub fn check_item(ccx: @CrateCtxt, it: &ast::Item) {
|
|||
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) => {
|
||||
|
@ -588,7 +588,7 @@ pub fn check_item(ccx: @CrateCtxt, it: &ast::Item) {
|
|||
&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 => { }
|
||||
|
@ -1397,9 +1397,12 @@ pub fn impl_self_ty(vcx: &VtableContext,
|
|||
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 }
|
||||
|
@ -1453,7 +1456,7 @@ fn check_type_parameter_positions_in_path(function_context: @FnCtxt,
|
|||
// 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,
|
||||
|
@ -1462,7 +1465,7 @@ fn check_type_parameter_positions_in_path(function_context: @FnCtxt,
|
|||
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,
|
||||
|
@ -1493,7 +1496,7 @@ fn check_type_parameter_positions_in_path(function_context: @FnCtxt,
|
|||
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.
|
||||
|
@ -1567,7 +1570,7 @@ fn check_type_parameter_positions_in_path(function_context: @FnCtxt,
|
|||
_ => {
|
||||
// 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
|
||||
|
@ -2415,7 +2418,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
|
|||
// 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)),
|
||||
|
@ -2473,7 +2476,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
|
|||
// 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)),
|
||||
|
@ -2866,7 +2869,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
|
|||
}
|
||||
}
|
||||
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,
|
||||
|
@ -2891,7 +2894,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
|
|||
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| {
|
||||
|
@ -2907,7 +2910,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
|
|||
}
|
||||
}
|
||||
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| {
|
||||
|
@ -3093,11 +3096,11 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
|
|||
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,
|
||||
|
@ -3106,7 +3109,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
|
|||
}
|
||||
}
|
||||
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);
|
||||
|
@ -3670,7 +3673,7 @@ pub fn instantiate_path(fcx: @FnCtxt,
|
|||
|
||||
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);
|
||||
|
||||
|
|
|
@ -437,13 +437,18 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
|
|||
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, ());
|
||||
|
@ -545,7 +550,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
|
|||
}
|
||||
|
||||
ast::ExprMatch(discr, ref arms) => {
|
||||
link_match(rcx, discr, *arms);
|
||||
link_match(rcx, discr, arms.as_slice());
|
||||
|
||||
visit::walk_expr(rcx, expr, ());
|
||||
}
|
||||
|
|
|
@ -524,7 +524,8 @@ impl CoherenceChecker {
|
|||
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
|
||||
};
|
||||
|
|
|
@ -149,7 +149,7 @@ pub fn get_enum_variant_types(ccx: &CrateCtxt,
|
|||
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(_) => {
|
||||
|
@ -166,7 +166,7 @@ pub fn get_enum_variant_types(ccx: &CrateCtxt,
|
|||
|
||||
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)
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -235,8 +235,11 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt, trait_id: ast::NodeId) {
|
|||
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.
|
||||
}
|
||||
|
@ -575,7 +578,7 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::Item) {
|
|||
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) => {
|
||||
|
@ -604,7 +607,7 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::Item) {
|
|||
|
||||
convert_methods(ccx,
|
||||
ImplContainer(local_def(it.id)),
|
||||
*ms,
|
||||
ms.as_slice(),
|
||||
selfty,
|
||||
&i_ty_generics,
|
||||
generics,
|
||||
|
@ -626,11 +629,11 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::Item) {
|
|||
|
||||
// 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,
|
||||
|
@ -701,7 +704,8 @@ pub fn convert_struct(ccx: &CrateCtxt,
|
|||
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();
|
||||
|
@ -709,7 +713,10 @@ pub fn convert_struct(ccx: &CrateCtxt,
|
|||
|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();
|
||||
|
@ -802,7 +809,10 @@ pub fn trait_def_of_item(ccx: &CrateCtxt, it: &ast::Item) -> @ty::TraitDef {
|
|||
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,
|
||||
|
@ -980,7 +990,7 @@ pub fn ty_generics(ccx: &CrateCtxt,
|
|||
def
|
||||
}
|
||||
}
|
||||
}))
|
||||
}).move_iter().collect())
|
||||
};
|
||||
|
||||
fn compute_bounds(
|
||||
|
@ -1032,7 +1042,10 @@ pub fn ty_of_foreign_fn_decl(ccx: &CrateCtxt,
|
|||
-> 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(
|
||||
|
|
|
@ -603,7 +603,7 @@ impl<T:Repr> Repr for OptVec<T> {
|
|||
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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue