Skip to content

vec: convert append and append_one to methods #13221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/compiletest/procsrv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use std::os;
use std::str;
use std::io::process::{ProcessExit, Process, ProcessConfig, ProcessOutput};
use std::vec;

#[cfg(target_os = "win32")]
fn target_env(lib_path: &str, prog: &str) -> Vec<(~str,~str)> {
Expand Down Expand Up @@ -66,8 +65,7 @@ pub fn run(lib_path: &str,
env: Vec<(~str, ~str)> ,
input: Option<~str>) -> Option<Result> {

let env = vec::append(env.clone(),
target_env(lib_path, prog).as_slice());
let env = env.clone().append(target_env(lib_path, prog).as_slice());
let mut opt_process = Process::configure(ProcessConfig {
program: prog,
args: args,
Expand Down Expand Up @@ -98,8 +96,7 @@ pub fn run_background(lib_path: &str,
env: Vec<(~str, ~str)> ,
input: Option<~str>) -> Option<Process> {

let env = vec::append(env.clone(),
target_env(lib_path, prog).as_slice());
let env = env.clone().append(target_env(lib_path, prog).as_slice());
let opt_process = Process::configure(ProcessConfig {
program: prog,
args: args,
Expand Down
9 changes: 3 additions & 6 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ use std::os;
use std::str;
use std::task;
use std::slice;
use std::vec;
use test::MetricMap;

pub fn run(config: config, testfile: ~str) {
Expand Down Expand Up @@ -683,7 +682,7 @@ fn compile_test_(config: &config, props: &TestProps,
let link_args = vec!(~"-L", aux_dir.as_str().unwrap().to_owned());
let args = make_compile_args(config,
props,
vec::append(link_args, extra_args),
link_args.append(extra_args),
|a, b| ThisFile(make_exe_name(a, b)), testfile);
compose_and_run_compiler(config, props, testfile, args, None)
}
Expand Down Expand Up @@ -734,8 +733,7 @@ fn compose_and_run_compiler(
let aux_args =
make_compile_args(config,
&aux_props,
vec::append(crate_type,
extra_link_args.as_slice()),
crate_type.append(extra_link_args.as_slice()),
|a,b| {
let f = make_lib_name(a, b, testfile);
ThisDirectory(f.dir_path())
Expand Down Expand Up @@ -1108,8 +1106,7 @@ fn compile_test_and_save_bitcode(config: &config, props: &TestProps,
let llvm_args = vec!(~"--emit=obj", ~"--crate-type=lib", ~"-C", ~"save-temps");
let args = make_compile_args(config,
props,
vec::append(link_args,
llvm_args.as_slice()),
link_args.append(llvm_args.as_slice()),
|a, b| ThisFile(make_o_name(a, b)), testfile);
compose_and_run_compiler(config, props, testfile, args, None)
}
Expand Down
4 changes: 1 addition & 3 deletions src/libnum/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ use rand::Rng;
use std::str;
use std::uint;
use std::{i64, u64};
use std::vec;

/**
A `BigDigit` is a `BigUint`'s composing element.
Expand Down Expand Up @@ -747,8 +746,7 @@ impl BigUint {
fn shl_unit(&self, n_unit: uint) -> BigUint {
if n_unit == 0 || self.is_zero() { return (*self).clone(); }

return BigUint::new(vec::append(Vec::from_elem(n_unit, ZERO_BIG_DIGIT),
self.data.as_slice()));
BigUint::new(Vec::from_elem(n_unit, ZERO_BIG_DIGIT).append(self.data.as_slice()))
}

#[inline]
Expand Down
8 changes: 2 additions & 6 deletions src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ use std::io::fs;
use std::io::MemReader;
use std::mem::drop;
use std::os;
use std::vec;
use getopts::{optopt, optmulti, optflag, optflagopt};
use getopts;
use syntax::ast;
Expand Down Expand Up @@ -137,8 +136,7 @@ pub fn build_configuration(sess: &Session) -> ast::CrateConfig {
} else {
InternedString::new("nogc")
});
return vec::append(user_cfg.move_iter().collect(),
default_cfg.as_slice());
user_cfg.move_iter().collect::<Vec<_>>().append(default_cfg.as_slice())
}

// Convert strings provided as --cfg [cfgspec] into a crate_cfg
Expand Down Expand Up @@ -836,9 +834,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> session::Options {

let level_short = level_name.slice_chars(0, 1);
let level_short = level_short.to_ascii().to_upper().into_str();
let flags = vec::append(matches.opt_strs(level_short)
.move_iter()
.collect(),
let flags = matches.opt_strs(level_short).move_iter().collect::<Vec<_>>().append(
matches.opt_strs(level_name).as_slice());
for lint_name in flags.iter() {
let lint_name = lint_name.replace("-", "_");
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/front/std_inject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

use driver::session::Session;

use std::vec;
use syntax::ast;
use syntax::attr;
use syntax::codemap::DUMMY_SP;
Expand Down Expand Up @@ -173,7 +172,7 @@ impl<'a> fold::Folder for PreludeInjector<'a> {
span: DUMMY_SP,
};

let vis = vec::append(vec!(vi2), module.view_items.as_slice());
let vis = (vec!(vi2)).append(module.view_items.as_slice());

// FIXME #2543: Bad copy.
let new_module = ast::Mod {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/front/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ fn should_fail(i: @ast::Item) -> bool {
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: m.items.clone().append_one(testmod),
..(*m).clone()
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ use std::io;
use std::os;
use std::str;
use std::task;
use std::vec;
use syntax::ast;
use syntax::diagnostic::Emitter;
use syntax::diagnostic;
Expand Down Expand Up @@ -239,9 +238,7 @@ pub fn run_compiler(args: &[~str]) {
return;
}

let lint_flags = vec::append(matches.opt_strs("W")
.move_iter()
.collect(),
let lint_flags = matches.opt_strs("W").move_iter().collect::<Vec<_>>().append(
matches.opt_strs("warn").as_slice());
if lint_flags.iter().any(|x| x == &~"help") {
describe_warnings();
Expand Down
4 changes: 1 addition & 3 deletions src/librustc/metadata/csearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use middle::typeck;

use reader = serialize::ebml::reader;
use std::rc::Rc;
use std::vec;
use syntax::ast;
use syntax::ast_map;
use syntax::diagnostic::expect;
Expand Down Expand Up @@ -93,8 +92,7 @@ pub fn get_item_path(tcx: &ty::ctxt, def: ast::DefId) -> Vec<ast_map::PathElem>

// FIXME #1920: This path is not always correct if the crate is not linked
// into the root namespace.
vec::append(vec!(ast_map::PathMod(token::intern(cdata.name))),
path.as_slice())
(vec!(ast_map::PathMod(token::intern(cdata.name)))).append(path.as_slice())
}

pub enum found_ast {
Expand Down
7 changes: 1 addition & 6 deletions src/librustc/middle/borrowck/gather_loans/restrictions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* Computes the restrictions that result from a borrow.
*/

use std::vec;
use middle::borrowck::*;
use mc = middle::mem_categorization;
use middle::ty;
Expand Down Expand Up @@ -173,11 +172,7 @@ impl<'a> RestrictionsContext<'a> {
Safe => Safe,
SafeIf(base_lp, base_vec) => {
let lp = @LpExtend(base_lp, mc, elem);
SafeIf(lp, vec::append_one(base_vec,
Restriction {
loan_path: lp,
set: restrictions
}))
SafeIf(lp, base_vec.append_one(Restriction { loan_path: lp, set: restrictions }))
}
}
}
Expand Down
29 changes: 11 additions & 18 deletions src/librustc/middle/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use util::ppaux::ty_to_str;

use std::cmp;
use std::iter;
use std::vec;
use syntax::ast::*;
use syntax::ast_util::{unguarded_pat, walk_pat};
use syntax::codemap::{DUMMY_SP, Span};
Expand Down Expand Up @@ -560,11 +559,10 @@ fn specialize(cx: &MatchCheckCtxt,
Pat{id: pat_id, node: n, span: pat_span} =>
match n {
PatWild => {
Some(vec::append(Vec::from_elem(arity, wild()), r.tail()))
Some(Vec::from_elem(arity, wild()).append(r.tail()))
}
PatWildMulti => {
Some(vec::append(Vec::from_elem(arity, wild_multi()),
r.tail()))
Some(Vec::from_elem(arity, wild_multi()).append(r.tail()))
}
PatIdent(_, _, _) => {
let opt_def = cx.tcx.def_map.borrow().find_copy(&pat_id);
Expand Down Expand Up @@ -615,12 +613,7 @@ fn specialize(cx: &MatchCheckCtxt,
}
}
_ => {
Some(
vec::append(
Vec::from_elem(arity, wild()),
r.tail()
)
)
Some(Vec::from_elem(arity, wild()).append(r.tail()))
}
}
}
Expand Down Expand Up @@ -667,7 +660,7 @@ fn specialize(cx: &MatchCheckCtxt,
Some(args) => args.iter().map(|x| *x).collect(),
None => Vec::from_elem(arity, wild())
};
Some(vec::append(args, r.tail()))
Some(args.append(r.tail()))
}
DefVariant(_, _, _) => None,

Expand All @@ -680,7 +673,7 @@ fn specialize(cx: &MatchCheckCtxt,
}
None => new_args = Vec::from_elem(arity, wild())
}
Some(vec::append(new_args, r.tail()))
Some(new_args.append(r.tail()))
}
_ => None
}
Expand All @@ -697,8 +690,8 @@ fn specialize(cx: &MatchCheckCtxt,
Some(f) => f.pat,
_ => wild()
}
}).collect();
Some(vec::append(args, r.tail()))
}).collect::<Vec<_>>();
Some(args.append(r.tail()))
} else {
None
}
Expand Down Expand Up @@ -728,16 +721,16 @@ fn specialize(cx: &MatchCheckCtxt,
Some(f) => f.pat,
_ => wild()
}
}).collect();
Some(vec::append(args, r.tail()))
}).collect::<Vec<_>>();
Some(args.append(r.tail()))
}
}
}
PatTup(args) => {
Some(vec::append(args.iter().map(|x| *x).collect(), r.tail()))
Some(args.iter().map(|x| *x).collect::<Vec<_>>().append(r.tail()))
}
PatUniq(a) | PatRegion(a) => {
Some(vec::append(vec!(a), r.tail()))
Some((vec!(a)).append(r.tail()))
}
PatLit(expr) => {
let e_v = eval_const_expr(cx.tcx, expr);
Expand Down
37 changes: 13 additions & 24 deletions src/librustc/middle/trans/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ use util::ppaux::{Repr, vec_map_to_str};

use collections::HashMap;
use std::cell::Cell;
use std::vec;
use syntax::ast;
use syntax::ast::Ident;
use syntax::ast_util::path_to_ident;
Expand Down Expand Up @@ -478,11 +477,9 @@ fn expand_nested_bindings<'r,'b>(
m.iter().map(|br| {
match br.pats.get(col).node {
ast::PatIdent(_, ref path, Some(inner)) => {
let pats = vec::append(
Vec::from_slice(br.pats.slice(0u, col)),
vec::append(vec!(inner),
br.pats.slice(col + 1u,
br.pats.len())).as_slice());
let pats = Vec::from_slice(br.pats.slice(0u, col))
.append((vec!(inner))
.append(br.pats.slice(col + 1u, br.pats.len())).as_slice());

let mut res = Match {
pats: pats,
Expand Down Expand Up @@ -527,10 +524,8 @@ fn enter_match<'r,'b>(
for br in m.iter() {
match e(*br.pats.get(col)) {
Some(sub) => {
let pats =
vec::append(
vec::append(sub, br.pats.slice(0u, col)),
br.pats.slice(col + 1u, br.pats.len()));
let pats = sub.append(br.pats.slice(0u, col))
.append(br.pats.slice(col + 1u, br.pats.len()));

let this = *br.pats.get(col);
let mut bound_ptrs = br.bound_ptrs.clone();
Expand Down Expand Up @@ -1557,8 +1552,7 @@ fn compile_submatch_continue<'r,
let tcx = bcx.tcx();
let dm = tcx.def_map;

let vals_left = vec::append(Vec::from_slice(vals.slice(0u, col)),
vals.slice(col + 1u, vals.len()));
let vals_left = Vec::from_slice(vals.slice(0u, col)).append(vals.slice(col + 1u, vals.len()));
let ccx = bcx.fcx.ccx;
let mut pat_id = 0;
for br in m.iter() {
Expand All @@ -1581,7 +1575,7 @@ fn compile_submatch_continue<'r,
let rec_vals = rec_fields.iter().map(|field_name| {
let ix = ty::field_idx_strict(tcx, field_name.name, field_tys);
adt::trans_field_ptr(bcx, pat_repr, val, discr, ix)
}).collect();
}).collect::<Vec<_>>();
compile_submatch(
bcx,
enter_rec_or_struct(bcx,
Expand All @@ -1590,8 +1584,7 @@ fn compile_submatch_continue<'r,
col,
rec_fields.as_slice(),
val).as_slice(),
vec::append(rec_vals,
vals_left.as_slice()).as_slice(),
rec_vals.append(vals_left.as_slice()).as_slice(),
chk);
});
return;
Expand All @@ -1616,8 +1609,7 @@ fn compile_submatch_continue<'r,
col,
val,
n_tup_elts).as_slice(),
vec::append(tup_vals,
vals_left.as_slice()).as_slice(),
tup_vals.append(vals_left.as_slice()).as_slice(),
chk);
return;
}
Expand All @@ -1642,8 +1634,7 @@ fn compile_submatch_continue<'r,
compile_submatch(bcx,
enter_tuple_struct(bcx, dm, m, col, val,
struct_element_count).as_slice(),
vec::append(llstructvals,
vals_left.as_slice()).as_slice(),
llstructvals.append(vals_left.as_slice()).as_slice(),
chk);
return;
}
Expand All @@ -1652,8 +1643,7 @@ fn compile_submatch_continue<'r,
let llbox = Load(bcx, val);
compile_submatch(bcx,
enter_uniq(bcx, dm, m, col, val).as_slice(),
vec::append(vec!(llbox),
vals_left.as_slice()).as_slice(),
(vec!(llbox)).append(vals_left.as_slice()).as_slice(),
chk);
return;
}
Expand All @@ -1662,8 +1652,7 @@ fn compile_submatch_continue<'r,
let loaded_val = Load(bcx, val);
compile_submatch(bcx,
enter_region(bcx, dm, m, col, val).as_slice(),
vec::append(vec!(loaded_val),
vals_left.as_slice()).as_slice(),
(vec!(loaded_val)).append(vals_left.as_slice()).as_slice(),
chk);
return;
}
Expand Down Expand Up @@ -1844,7 +1833,7 @@ fn compile_submatch_continue<'r,
lit(_) | range(_, _) => ()
}
let opt_ms = enter_opt(opt_cx, m, opt, col, size, val);
let opt_vals = vec::append(unpacked, vals_left.as_slice());
let opt_vals = unpacked.append(vals_left.as_slice());

match branch_chk {
None => {
Expand Down
Loading