Skip to content

Commit bd953df

Browse files
committed
---
yaml --- r: 190127 b: refs/heads/auto c: 82bcc55 h: refs/heads/master i: 190125: f77c88f 190123: 120f3f3 190119: 158bae9 190111: dfe9adb v: v3
1 parent 1d0924b commit bd953df

File tree

14 files changed

+82
-81
lines changed

14 files changed

+82
-81
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: 766a4e1acc06061a30cf456840a9915526fb681e
13+
refs/heads/auto: 82bcc552327e1cb0b82d35caf04c4a3d07769561
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/libcollections/btree/node.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,14 @@ impl<K, V> Node<K, V> {
348348
#[inline]
349349
pub fn as_slices<'a>(&'a self) -> (&'a [K], &'a [V]) {
350350
unsafe {(
351-
slice::from_raw_parts(*self.keys, self.len()),
352-
slice::from_raw_parts(*self.vals, self.len()),
351+
mem::transmute(raw::Slice {
352+
data: *self.keys as *const K,
353+
len: self.len()
354+
}),
355+
mem::transmute(raw::Slice {
356+
data: *self.vals as *const V,
357+
len: self.len()
358+
})
353359
)}
354360
}
355361

branches/auto/src/libcollections/string.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use core::iter::{IntoIterator, FromIterator};
2424
use core::mem;
2525
use core::ops::{self, Deref, Add, Index};
2626
use core::ptr;
27-
use core::slice;
27+
use core::raw::Slice as RawSlice;
2828
use unicode::str as unicode_str;
2929
use unicode::str::Utf16Item;
3030

@@ -468,11 +468,11 @@ impl String {
468468
unsafe {
469469
// Attempt to not use an intermediate buffer by just pushing bytes
470470
// directly onto this string.
471-
let slice = slice::from_raw_parts_mut (
472-
self.vec.as_mut_ptr().offset(cur_len as isize),
473-
4
474-
);
475-
let used = ch.encode_utf8(slice).unwrap_or(0);
471+
let slice = RawSlice {
472+
data: self.vec.as_ptr().offset(cur_len as isize),
473+
len: 4,
474+
};
475+
let used = ch.encode_utf8(mem::transmute(slice)).unwrap_or(0);
476476
self.vec.set_len(cur_len + used);
477477
}
478478
}

branches/auto/src/libcollections/vec.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ use core::ops::{Index, IndexMut, Deref, Add};
6464
use core::ops;
6565
use core::ptr;
6666
use core::ptr::Unique;
67+
use core::raw::Slice as RawSlice;
6768
use core::slice;
6869
use core::usize;
6970

@@ -434,7 +435,10 @@ impl<T> Vec<T> {
434435
unsafe {
435436
let ptr = *self.ptr;
436437
assume(!ptr.is_null());
437-
slice::from_raw_parts_mut(ptr, self.len)
438+
mem::transmute(RawSlice {
439+
data: ptr,
440+
len: self.len,
441+
})
438442
}
439443
}
440444

@@ -1556,7 +1560,10 @@ impl<T> AsSlice<T> for Vec<T> {
15561560
unsafe {
15571561
let p = *self.ptr;
15581562
assume(p != 0 as *mut T);
1559-
slice::from_raw_parts(p, self.len)
1563+
mem::transmute(RawSlice {
1564+
data: p,
1565+
len: self.len
1566+
})
15601567
}
15611568
}
15621569
}

branches/auto/src/libcollections/vec_deque.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use core::num::{Int, UnsignedInt};
2929
use core::num::wrapping::WrappingOps;
3030
use core::ops::{Index, IndexMut};
3131
use core::ptr::{self, Unique};
32-
use core::slice;
32+
use core::raw::Slice as RawSlice;
3333

3434
use core::hash::{Hash, Hasher};
3535
use core::cmp;
@@ -91,13 +91,13 @@ impl<T> VecDeque<T> {
9191
/// Turn ptr into a slice
9292
#[inline]
9393
unsafe fn buffer_as_slice(&self) -> &[T] {
94-
slice::from_raw_parts(*self.ptr, self.cap)
94+
mem::transmute(RawSlice { data: *self.ptr as *const T, len: self.cap })
9595
}
9696

9797
/// Turn ptr into a mut slice
9898
#[inline]
9999
unsafe fn buffer_as_mut_slice(&mut self) -> &mut [T] {
100-
slice::from_raw_parts_mut(*self.ptr, self.cap)
100+
mem::transmute(RawSlice { data: *self.ptr as *const T, len: self.cap })
101101
}
102102

103103
/// Moves an element out of the buffer

branches/auto/src/libcore/panicking.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,8 @@ use fmt;
3535
#[cold] #[inline(never)] // this is the slow path, always
3636
#[lang="panic"]
3737
pub fn panic(expr_file_line: &(&'static str, &'static str, u32)) -> ! {
38-
// Use Arguments::new_v1 instead of format_args!("{}", expr) to potentially
39-
// reduce size overhead. The format_args! macro uses str's Display trait to
40-
// write expr, which calls Formatter::pad, which must accommodate string
41-
// truncation and padding (even though none is used here). Using
42-
// Arguments::new_v1 may allow the compiler to omit Formatter::pad from the
43-
// output binary, saving up to a few kilobytes.
4438
let (expr, file, line) = *expr_file_line;
45-
panic_fmt(fmt::Arguments::new_v1(&[expr], &[]), &(file, line))
39+
panic_fmt(format_args!("{}", expr), &(file, line))
4640
}
4741

4842
#[cold] #[inline(never)]

branches/auto/src/libcore/slice.rs

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -520,10 +520,10 @@ impl<T> ops::Index<ops::Range<usize>> for [T] {
520520
assert!(index.start <= index.end);
521521
assert!(index.end <= self.len());
522522
unsafe {
523-
from_raw_parts (
524-
self.as_ptr().offset(index.start as isize),
525-
index.end - index.start
526-
)
523+
transmute(RawSlice {
524+
data: self.as_ptr().offset(index.start as isize),
525+
len: index.end - index.start
526+
})
527527
}
528528
}
529529
}
@@ -559,10 +559,10 @@ impl<T> ops::IndexMut<ops::Range<usize>> for [T] {
559559
assert!(index.start <= index.end);
560560
assert!(index.end <= self.len());
561561
unsafe {
562-
from_raw_parts_mut(
563-
self.as_mut_ptr().offset(index.start as isize),
564-
index.end - index.start
565-
)
562+
transmute(RawSlice {
563+
data: self.as_ptr().offset(index.start as isize),
564+
len: index.end - index.start
565+
})
566566
}
567567
}
568568
}
@@ -731,21 +731,7 @@ macro_rules! make_slice {
731731
diff / mem::size_of::<$t>()
732732
};
733733
unsafe {
734-
from_raw_parts($start, len)
735-
}
736-
}}
737-
}
738-
739-
macro_rules! make_mut_slice {
740-
($t: ty => $result: ty: $start: expr, $end: expr) => {{
741-
let diff = $end as usize - $start as usize;
742-
let len = if mem::size_of::<T>() == 0 {
743-
diff
744-
} else {
745-
diff / mem::size_of::<$t>()
746-
};
747-
unsafe {
748-
from_raw_parts_mut($start, len)
734+
transmute::<_, $result>(RawSlice { data: $start, len: len })
749735
}
750736
}}
751737
}
@@ -912,7 +898,7 @@ impl<'a, T> ops::IndexMut<ops::RangeFrom<usize>> for IterMut<'a, T> {
912898
impl<'a, T> ops::IndexMut<RangeFull> for IterMut<'a, T> {
913899
#[inline]
914900
fn index_mut(&mut self, _index: &RangeFull) -> &mut [T] {
915-
make_mut_slice!(T => &mut [T]: self.ptr, self.end)
901+
make_slice!(T => &mut [T]: self.ptr, self.end)
916902
}
917903
}
918904

@@ -926,7 +912,7 @@ impl<'a, T> IterMut<'a, T> {
926912
/// restricted lifetimes that do not consume the iterator.
927913
#[unstable(feature = "core")]
928914
pub fn into_slice(self) -> &'a mut [T] {
929-
make_mut_slice!(T => &'a mut [T]: self.ptr, self.end)
915+
make_slice!(T => &'a mut [T]: self.ptr, self.end)
930916
}
931917
}
932918

@@ -1418,15 +1404,16 @@ impl<'a, T> ExactSizeIterator for ChunksMut<'a, T> {}
14181404
#[unstable(feature = "core")]
14191405
pub fn ref_slice<'a, A>(s: &'a A) -> &'a [A] {
14201406
unsafe {
1421-
from_raw_parts(s, 1)
1407+
transmute(RawSlice { data: s, len: 1 })
14221408
}
14231409
}
14241410

14251411
/// Converts a pointer to A into a slice of length 1 (without copying).
14261412
#[unstable(feature = "core")]
14271413
pub fn mut_ref_slice<'a, A>(s: &'a mut A) -> &'a mut [A] {
14281414
unsafe {
1429-
from_raw_parts_mut(s, 1)
1415+
let ptr: *const A = transmute(s);
1416+
transmute(RawSlice { data: ptr, len: 1 })
14301417
}
14311418
}
14321419

branches/auto/src/librustc_llvm/archive_ro.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ use libc;
1414
use ArchiveRef;
1515

1616
use std::ffi::CString;
17-
use std::slice;
17+
use std::mem;
18+
use std::raw;
1819
use std::path::Path;
1920

2021
pub struct ArchiveRO {
@@ -61,7 +62,10 @@ impl ArchiveRO {
6162
if ptr.is_null() {
6263
None
6364
} else {
64-
Some(slice::from_raw_parts(ptr as *const u8, size as uint))
65+
Some(mem::transmute(raw::Slice {
66+
data: ptr,
67+
len: size as uint,
68+
}))
6569
}
6670
}
6771
}

branches/auto/src/librustc_llvm/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#![feature(box_syntax)]
2828
#![feature(collections)]
29+
#![feature(core)]
2930
#![feature(int_uint)]
3031
#![feature(libc)]
3132
#![feature(link_args)]
@@ -57,7 +58,7 @@ pub use self::Linkage::*;
5758

5859
use std::ffi::CString;
5960
use std::cell::RefCell;
60-
use std::{slice, mem};
61+
use std::{raw, mem};
6162
use libc::{c_uint, c_ushort, uint64_t, c_int, size_t, c_char};
6263
use libc::{c_longlong, c_ulonglong, c_void};
6364
use debuginfo::{DIBuilderRef, DIDescriptor,
@@ -2225,7 +2226,10 @@ type RustStringRepr = *mut RefCell<Vec<u8>>;
22252226
pub unsafe extern "C" fn rust_llvm_string_write_impl(sr: RustStringRef,
22262227
ptr: *const c_char,
22272228
size: size_t) {
2228-
let slice = slice::from_raw_parts(ptr as *const u8, size as uint);
2229+
let slice: &[u8] = mem::transmute(raw::Slice {
2230+
data: ptr as *const u8,
2231+
len: size as uint,
2232+
});
22292233

22302234
let sr: RustStringRepr = mem::transmute(sr);
22312235
(*sr).borrow_mut().push_all(slice);

branches/auto/src/libstd/old_io/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -931,15 +931,15 @@ impl<'a> Reader for &'a mut (Reader+'a) {
931931
// Private function here because we aren't sure if we want to expose this as
932932
// API yet. If so, it should be a method on Vec.
933933
unsafe fn slice_vec_capacity<'a, T>(v: &'a mut Vec<T>, start: uint, end: uint) -> &'a mut [T] {
934-
use slice;
934+
use raw::Slice;
935935
use ptr::PtrExt;
936936

937937
assert!(start <= end);
938938
assert!(end <= v.capacity());
939-
slice::from_raw_parts_mut(
940-
v.as_mut_ptr().offset(start as int),
941-
end - start
942-
)
939+
transmute(Slice {
940+
data: v.as_ptr().offset(start as int),
941+
len: end - start
942+
})
943943
}
944944

945945
/// A `RefReader` is a struct implementing `Reader` which contains a reference

branches/auto/src/libstd/sys/common/wtf8.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use core::prelude::*;
2929

3030
use core::char::{encode_utf8_raw, encode_utf16_raw};
3131
use core::str::{char_range_at_raw, next_code_point};
32+
use core::raw::Slice as RawSlice;
3233

3334
use ascii::*;
3435
use borrow::Cow;
@@ -213,10 +214,10 @@ impl Wtf8Buf {
213214
unsafe {
214215
// Attempt to not use an intermediate buffer by just pushing bytes
215216
// directly onto this string.
216-
let slice = slice::from_raw_parts_mut(
217-
self.bytes.as_mut_ptr().offset(cur_len as int),
218-
4
219-
);
217+
let slice = RawSlice {
218+
data: self.bytes.as_ptr().offset(cur_len as int),
219+
len: 4,
220+
};
220221
let used = encode_utf8_raw(code_point.value, mem::transmute(slice))
221222
.unwrap_or(0);
222223
self.bytes.set_len(cur_len + used);
@@ -724,11 +725,10 @@ pub fn is_code_point_boundary(slice: &Wtf8, index: uint) -> bool {
724725
/// Copied from core::str::raw::slice_unchecked
725726
#[inline]
726727
pub unsafe fn slice_unchecked(s: &Wtf8, begin: uint, end: uint) -> &Wtf8 {
727-
// memory layout of an &[u8] and &Wtf8 are the same
728-
mem::transmute(slice::from_raw_parts(
729-
s.bytes.as_ptr().offset(begin as int),
730-
end - begin
731-
))
728+
mem::transmute(RawSlice {
729+
data: s.bytes.as_ptr().offset(begin as int),
730+
len: end - begin,
731+
})
732732
}
733733

734734
/// Copied from core::str::raw::slice_error_fail

branches/auto/src/libtest/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ impl fmt::Display for TestName {
123123
#[derive(Clone, Copy)]
124124
enum NamePadding {
125125
PadNone,
126-
#[allow(dead_code)]
127126
PadOnLeft,
128127
PadOnRight,
129128
}

branches/auto/src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// type is `&mut [u8]`, passes in a pointer to the lvalue and not a
1313
// temporary. Issue #19147.
1414

15+
use std::raw;
1516
use std::mem;
1617
use std::slice;
1718
use std::old_io::IoResult;
@@ -26,10 +27,10 @@ impl<'a> MyWriter for &'a mut [u8] {
2627

2728
let write_len = buf.len();
2829
unsafe {
29-
*self = slice::from_raw_parts_mut(
30-
self.as_mut_ptr().offset(write_len as isize),
31-
self.len() - write_len
32-
);
30+
*self = mem::transmute(raw::Slice {
31+
data: self.as_ptr().offset(write_len as int),
32+
len: self.len() - write_len,
33+
});
3334
}
3435

3536
Ok(())

0 commit comments

Comments
 (0)