Skip to content

Commit 0169218

Browse files
committed
Fix fallout from Vec stabilization
1 parent 087b928 commit 0169218

File tree

29 files changed

+141
-156
lines changed

29 files changed

+141
-156
lines changed

src/compiletest/runtest.rs

+30-29
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
273273
format!("--target={}", config.target),
274274
"-L".to_string(),
275275
aux_dir.as_str().unwrap().to_string());
276-
args.push_all_move(split_maybe_args(&config.target_rustcflags));
277-
args.push_all_move(split_maybe_args(&props.compile_flags));
276+
args.extend(split_maybe_args(&config.target_rustcflags).into_iter());
277+
args.extend(split_maybe_args(&props.compile_flags).into_iter());
278278
return ProcArgs {
279279
prog: config.rustc_path.as_str().unwrap().to_string(),
280280
args: args,
@@ -321,8 +321,8 @@ actual:\n\
321321
config.build_base.as_str().unwrap().to_string(),
322322
"-L".to_string(),
323323
aux_dir.as_str().unwrap().to_string());
324-
args.push_all_move(split_maybe_args(&config.target_rustcflags));
325-
args.push_all_move(split_maybe_args(&props.compile_flags));
324+
args.extend(split_maybe_args(&config.target_rustcflags).into_iter());
325+
args.extend(split_maybe_args(&props.compile_flags).into_iter());
326326
// FIXME (#9639): This needs to handle non-utf8 paths
327327
return ProcArgs {
328328
prog: config.rustc_path.as_str().unwrap().to_string(),
@@ -1095,11 +1095,12 @@ fn compile_test_(config: &Config, props: &TestProps,
10951095
testfile: &Path, extra_args: &[String]) -> ProcRes {
10961096
let aux_dir = aux_output_dir_name(config, testfile);
10971097
// FIXME (#9639): This needs to handle non-utf8 paths
1098-
let link_args = vec!("-L".to_string(),
1099-
aux_dir.as_str().unwrap().to_string());
1098+
let mut link_args = vec!("-L".to_string(),
1099+
aux_dir.as_str().unwrap().to_string());
1100+
link_args.extend(extra_args.iter().map(|s| s.clone()));
11001101
let args = make_compile_args(config,
11011102
props,
1102-
link_args.append(extra_args),
1103+
link_args,
11031104
|a, b| ThisFile(make_exe_name(a, b)), testfile);
11041105
compose_and_run_compiler(config, props, testfile, args, None)
11051106
}
@@ -1146,16 +1147,16 @@ fn compose_and_run_compiler(
11461147
for rel_ab in props.aux_builds.iter() {
11471148
let abs_ab = config.aux_base.join(rel_ab.as_slice());
11481149
let aux_props = header::load_props(&abs_ab);
1149-
let crate_type = if aux_props.no_prefer_dynamic {
1150+
let mut crate_type = if aux_props.no_prefer_dynamic {
11501151
Vec::new()
11511152
} else {
11521153
vec!("--crate-type=dylib".to_string())
11531154
};
1155+
crate_type.extend(extra_link_args.clone().into_iter());
11541156
let aux_args =
11551157
make_compile_args(config,
11561158
&aux_props,
1157-
crate_type.append(
1158-
extra_link_args.as_slice()),
1159+
crate_type,
11591160
|a,b| {
11601161
let f = make_lib_name(a, b, testfile);
11611162
ThisDirectory(f.dir_path())
@@ -1246,11 +1247,11 @@ fn make_compile_args(config: &Config,
12461247
};
12471248
args.push(path.as_str().unwrap().to_string());
12481249
if props.force_host {
1249-
args.push_all_move(split_maybe_args(&config.host_rustcflags));
1250+
args.extend(split_maybe_args(&config.host_rustcflags).into_iter());
12501251
} else {
1251-
args.push_all_move(split_maybe_args(&config.target_rustcflags));
1252+
args.extend(split_maybe_args(&config.target_rustcflags).into_iter());
12521253
}
1253-
args.push_all_move(split_maybe_args(&props.compile_flags));
1254+
args.extend(split_maybe_args(&props.compile_flags).into_iter());
12541255
return ProcArgs {
12551256
prog: config.rustc_path.as_str().unwrap().to_string(),
12561257
args: args,
@@ -1267,10 +1268,9 @@ fn make_lib_name(config: &Config, auxfile: &Path, testfile: &Path) -> Path {
12671268
fn make_exe_name(config: &Config, testfile: &Path) -> Path {
12681269
let mut f = output_base_name(config, testfile);
12691270
if !os::consts::EXE_SUFFIX.is_empty() {
1270-
match f.filename().map(|s| Vec::from_slice(s).append(os::consts::EXE_SUFFIX.as_bytes())) {
1271-
Some(v) => f.set_filename(v),
1272-
None => ()
1273-
}
1271+
let mut fname = f.filename().unwrap().to_vec();
1272+
fname.extend(os::consts::EXE_SUFFIX.bytes());
1273+
f.set_filename(fname);
12741274
}
12751275
f
12761276
}
@@ -1286,7 +1286,7 @@ fn make_run_args(config: &Config, props: &TestProps, testfile: &Path) ->
12861286
args.push(exe_file.as_str().unwrap().to_string());
12871287

12881288
// Add the arguments in the run_flags directive
1289-
args.push_all_move(split_maybe_args(&props.run_flags));
1289+
args.extend(split_maybe_args(&props.run_flags).into_iter());
12901290

12911291
let prog = args.remove(0).unwrap();
12921292
return ProcArgs {
@@ -1381,12 +1381,10 @@ fn make_out_name(config: &Config, testfile: &Path, extension: &str) -> Path {
13811381
}
13821382

13831383
fn aux_output_dir_name(config: &Config, testfile: &Path) -> Path {
1384-
let mut f = output_base_name(config, testfile);
1385-
match f.filename().map(|s| Vec::from_slice(s).append(b".libaux")) {
1386-
Some(v) => f.set_filename(v),
1387-
None => ()
1388-
}
1389-
f
1384+
let f = output_base_name(config, testfile);
1385+
let mut fname = f.filename().unwrap().to_vec();
1386+
fname.extend("libaux".bytes());
1387+
f.with_filename(fname)
13901388
}
13911389

13921390
fn output_testname(testfile: &Path) -> Path {
@@ -1598,22 +1596,25 @@ fn append_suffix_to_stem(p: &Path, suffix: &str) -> Path {
15981596
if suffix.len() == 0 {
15991597
(*p).clone()
16001598
} else {
1601-
let stem = p.filestem().unwrap();
1602-
p.with_filename(Vec::from_slice(stem).append(b"-").append(suffix.as_bytes()))
1599+
let mut stem = p.filestem().unwrap().to_vec();
1600+
stem.extend("-".bytes());
1601+
stem.extend(suffix.bytes());
1602+
p.with_filename(stem)
16031603
}
16041604
}
16051605

16061606
fn compile_test_and_save_bitcode(config: &Config, props: &TestProps,
16071607
testfile: &Path) -> ProcRes {
16081608
let aux_dir = aux_output_dir_name(config, testfile);
16091609
// FIXME (#9639): This needs to handle non-utf8 paths
1610-
let link_args = vec!("-L".to_string(),
1611-
aux_dir.as_str().unwrap().to_string());
1610+
let mut link_args = vec!("-L".to_string(),
1611+
aux_dir.as_str().unwrap().to_string());
16121612
let llvm_args = vec!("--emit=bc,obj".to_string(),
16131613
"--crate-type=lib".to_string());
1614+
link_args.extend(llvm_args.into_iter());
16141615
let args = make_compile_args(config,
16151616
props,
1616-
link_args.append(llvm_args.as_slice()),
1617+
link_args,
16171618
|a, b| ThisDirectory(output_base_name(a, b).dir_path()),
16181619
testfile);
16191620
compose_and_run_compiler(config, props, testfile, args, None)

src/doc/rust.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -3833,8 +3833,9 @@ fn map<A: Clone, B: Clone>(f: |A| -> B, xs: &[A]) -> Vec<B> {
38333833
return vec![];
38343834
}
38353835
let first: B = f(xs[0].clone());
3836-
let rest: Vec<B> = map(f, xs.slice(1, xs.len()));
3837-
return vec![first].append(rest.as_slice());
3836+
let mut rest: Vec<B> = map(f, xs.slice(1, xs.len()));
3837+
rest.insert(0, first);
3838+
return rest;
38383839
}
38393840
~~~~
38403841

src/libcollections/bitv.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ impl Bitv {
631631
let old_size = self.storage.len();
632632
let size = (size + uint::BITS - 1) / uint::BITS;
633633
if old_size < size {
634-
self.storage.grow(size - old_size, &0);
634+
self.storage.grow(size - old_size, 0);
635635
}
636636
}
637637

@@ -687,7 +687,7 @@ impl Bitv {
687687
// Allocate new words, if needed
688688
if new_nwords > self.storage.len() {
689689
let to_add = new_nwords - self.storage.len();
690-
self.storage.grow(to_add, &full_value);
690+
self.storage.grow(to_add, full_value);
691691
}
692692
// Adjust internal bit count
693693
self.nbits = new_nbits;

src/libcollections/slice.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,11 @@ pub trait CloneableVector<T> {
283283
impl<'a, T: Clone> CloneableVector<T> for &'a [T] {
284284
/// Returns a copy of `v`.
285285
#[inline]
286-
fn to_vec(&self) -> Vec<T> { Vec::from_slice(*self) }
286+
fn to_vec(&self) -> Vec<T> {
287+
let mut vector = Vec::with_capacity(self.len());
288+
vector.push_all(*self);
289+
vector
290+
}
287291

288292
#[inline(always)]
289293
fn into_vec(self) -> Vec<T> { self.to_vec() }
@@ -1039,7 +1043,7 @@ mod tests {
10391043
fn test_grow() {
10401044
// Test on-stack grow().
10411045
let mut v = vec![];
1042-
v.grow(2u, &1i);
1046+
v.grow(2u, 1i);
10431047
{
10441048
let v = v.as_slice();
10451049
assert_eq!(v.len(), 2u);
@@ -1048,7 +1052,7 @@ mod tests {
10481052
}
10491053

10501054
// Test on-heap grow().
1051-
v.grow(3u, &2i);
1055+
v.grow(3u, 2i);
10521056
{
10531057
let v = v.as_slice();
10541058
assert_eq!(v.len(), 5u);

src/libcollections/str.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ use core::prelude::{range};
6767
use {Deque, MutableSeq};
6868
use hash;
6969
use ringbuf::RingBuf;
70+
use slice::CloneableVector;
7071
use string::String;
7172
use unicode;
7273
use vec::Vec;
@@ -754,7 +755,7 @@ pub trait StrAllocating: Str {
754755
#[inline]
755756
fn to_owned(&self) -> String {
756757
unsafe {
757-
mem::transmute(Vec::from_slice(self.as_slice().as_bytes()))
758+
mem::transmute(self.as_slice().as_bytes().to_vec())
758759
}
759760
}
760761

src/libcollections/string.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use core::raw::Slice as RawSlice;
2323

2424
use {Mutable, MutableSeq};
2525
use hash;
26+
use slice::CloneableVector;
2627
use str;
2728
use str::{CharRange, StrAllocating, MaybeOwned, Owned};
2829
use str::Slice as MaybeOwnedSlice; // So many `Slice`s...
@@ -75,9 +76,7 @@ impl String {
7576
/// ```
7677
#[inline]
7778
pub fn from_str(string: &str) -> String {
78-
String {
79-
vec: Vec::from_slice(string.as_bytes())
80-
}
79+
String { vec: string.as_bytes().to_vec() }
8180
}
8281

8382
/// Deprecated. Replaced by `string::raw::from_parts`

src/libcollections/vec.rs

+10-39
Original file line numberDiff line numberDiff line change
@@ -273,38 +273,18 @@ impl<T> Vec<T> {
273273
}
274274

275275
impl<T: Clone> Vec<T> {
276-
/// Iterates over the `second` vector, copying each element and appending it to
277-
/// the `first`. Afterwards, the `first` is then returned for use again.
278-
///
279-
/// # Example
280-
///
281-
/// ```
282-
/// let vec = vec![1i, 2i];
283-
/// let vec = vec.append([3i, 4i]);
284-
/// assert_eq!(vec, vec![1, 2, 3, 4]);
285-
/// ```
276+
/// Deprecated, call `extend` instead.
286277
#[inline]
287278
#[deprecated = "this function has been deprecated in favor of extend()"]
288279
pub fn append(mut self, second: &[T]) -> Vec<T> {
289280
self.push_all(second);
290281
self
291282
}
292283

293-
/// Constructs a `Vec` by cloning elements of a slice.
294-
///
295-
/// # Example
296-
///
297-
/// ```
298-
/// let slice = [1i, 2, 3];
299-
/// let vec = Vec::from_slice(slice);
300-
/// ```
284+
/// Deprecated, call `to_vec()` instead
301285
#[inline]
302286
#[deprecated = "this function has been deprecated in favor of to_vec()"]
303-
pub fn from_slice(values: &[T]) -> Vec<T> {
304-
let mut vector = Vec::new();
305-
vector.push_all(values);
306-
vector
307-
}
287+
pub fn from_slice(values: &[T]) -> Vec<T> { values.to_vec() }
308288

309289
/// Constructs a `Vec` with copies of a value.
310290
///
@@ -442,9 +422,7 @@ impl<T: Clone> Vec<T> {
442422

443423
#[unstable]
444424
impl<T:Clone> Clone for Vec<T> {
445-
fn clone(&self) -> Vec<T> {
446-
Vec::from_slice(self.as_slice())
447-
}
425+
fn clone(&self) -> Vec<T> { self.as_slice().to_vec() }
448426

449427
fn clone_from(&mut self, other: &Vec<T>) {
450428
// drop anything in self that will not be overwritten
@@ -736,16 +714,7 @@ impl<T> Vec<T> {
736714
}
737715
}
738716

739-
/// Appends one element to the vector provided. The vector itself is then
740-
/// returned for use again.
741-
///
742-
/// # Example
743-
///
744-
/// ```
745-
/// let vec = vec![1i, 2];
746-
/// let vec = vec.append_one(3);
747-
/// assert_eq!(vec, vec![1, 2, 3]);
748-
/// ```
717+
/// Deprecated, call `push` instead
749718
#[inline]
750719
#[deprecated = "call .push() instead"]
751720
pub fn append_one(mut self, x: T) -> Vec<T> {
@@ -765,7 +734,7 @@ impl<T> Vec<T> {
765734
/// vec.truncate(2);
766735
/// assert_eq!(vec, vec![1, 2]);
767736
/// ```
768-
#[stable]
737+
#[unstable = "waiting on failure semantics"]
769738
pub fn truncate(&mut self, len: uint) {
770739
unsafe {
771740
// drop any extra elements
@@ -1123,7 +1092,7 @@ impl<T> Vec<T> {
11231092
/// vec.insert(4, 5);
11241093
/// assert_eq!(vec, vec![1, 4, 2, 3, 5]);
11251094
/// ```
1126-
#[stable]
1095+
#[unstable = "failure semantics need settling"]
11271096
pub fn insert(&mut self, index: uint, element: T) {
11281097
let len = self.len();
11291098
assert!(index <= len);
@@ -1160,7 +1129,7 @@ impl<T> Vec<T> {
11601129
/// // v is unchanged:
11611130
/// assert_eq!(v, vec![1, 3]);
11621131
/// ```
1163-
#[stable]
1132+
#[unstable = "failure semantics need settling"]
11641133
pub fn remove(&mut self, index: uint) -> Option<T> {
11651134
let len = self.len();
11661135
if index < len {
@@ -1192,11 +1161,13 @@ impl<T> Vec<T> {
11921161
/// # Example
11931162
///
11941163
/// ```
1164+
/// # #![allow(deprecated)]
11951165
/// let mut vec = vec![box 1i];
11961166
/// vec.push_all_move(vec![box 2, box 3, box 4]);
11971167
/// assert_eq!(vec, vec![box 1, box 2, box 3, box 4]);
11981168
/// ```
11991169
#[inline]
1170+
#[deprecated = "use .extend(other.into_iter())"]
12001171
pub fn push_all_move(&mut self, other: Vec<T>) {
12011172
self.extend(other.into_iter());
12021173
}

src/libgraphviz/maybe_owned_vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ impl<'a,T:Clone> MaybeOwnedVector<'a,T> {
170170
pub fn into_vec(self) -> Vec<T> {
171171
match self {
172172
Growable(v) => v,
173-
Borrowed(v) => Vec::from_slice(v),
173+
Borrowed(v) => v.to_vec(),
174174
}
175175
}
176176
}

src/librbml/io.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl Writer for SeekableMemWriter {
8787
// currently are
8888
let difference = self.pos as i64 - self.buf.len() as i64;
8989
if difference > 0 {
90-
self.buf.grow(difference as uint, &0);
90+
self.buf.grow(difference as uint, 0);
9191
}
9292

9393
// Figure out what bytes will be used to overwrite what's currently

src/libregex/compile.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl<'r> Compiler<'r> {
156156
Capture(cap, name, x) => {
157157
let len = self.names.len();
158158
if cap >= len {
159-
self.names.grow(10 + cap - len, &None)
159+
self.names.grow(10 + cap - len, None)
160160
}
161161
*self.names.get_mut(cap) = name;
162162

0 commit comments

Comments
 (0)