Skip to content

Commit 6d4d6a5

Browse files
committed
---
yaml --- r: 63423 b: refs/heads/snap-stage3 c: 4efb17f h: refs/heads/master i: 63421: 35ab70d 63419: f68ebb1 63415: 95e59dc 63407: b0d3d9d 63391: dc72069 63359: 6183ed3 v: v3
1 parent b166a07 commit 6d4d6a5

File tree

7 files changed

+27
-137
lines changed

7 files changed

+27
-137
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: c9e7bb7d4a3fa8d33d40eb6ca0e357f4bd7c39ce
4+
refs/heads/snap-stage3: 4efb17fcf5c04bb4d991fc52f8aefadb3a23e098
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/mk/tests.mk

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,7 @@ CFG_ADB_TEST_DIR=/data/tmp
122122
$(info check: android device test dir $(CFG_ADB_TEST_DIR) ready \
123123
$(shell adb remount 1>/dev/null) \
124124
$(shell adb shell mkdir $(CFG_ADB_TEST_DIR) 1>/dev/null) \
125-
$(shell adb shell rm $(CFG_ADB_TEST_DIR)/*.so 1>/dev/null) \
126-
$(shell adb shell rm $(CFG_ADB_TEST_DIR)/*-arm-linux-androideabi 1>/dev/null) \
127-
$(shell adb shell rm $(CFG_ADB_TEST_DIR)/*-arm-linux-androideabi.* 1>/dev/null) \
125+
$(shell adb shell rm -rf $(CFG_ADB_TEST_DIR)/* 1>/dev/null) \
128126
$(shell adb push $(S)src/etc/adb_run_wrapper.sh $(CFG_ADB_TEST_DIR) 1>/dev/null) \
129127
$(shell adb push $(CFG_ANDROID_CROSS_PATH)/arm-linux-androideabi/lib/armv7-a/libgnustl_shared.so \
130128
$(CFG_ADB_TEST_DIR) 1>/dev/null) \

branches/snap-stage3/src/libstd/prelude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub use path::Path;
6161
pub use path::PosixPath;
6262
pub use path::WindowsPath;
6363
pub use ptr::RawPtr;
64-
pub use ascii::{Ascii, AsciiCast, OwnedAsciiCast, AsciiStr, ToBytesConsume};
64+
pub use ascii::{Ascii, AsciiCast, OwnedAsciiCast, AsciiStr};
6565
pub use str::{Str, StrVector, StrSlice, OwnedStr, StrUtil, NullTerminatedStr};
6666
pub use from_str::{FromStr};
6767
pub use to_bytes::IterBytes;

branches/snap-stage3/src/libstd/str.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2202,12 +2202,6 @@ impl<'self> Iterator<u8> for StrBytesRevIterator<'self> {
22022202
}
22032203
}
22042204
2205-
// This works because every lifetime is a sub-lifetime of 'static
2206-
impl<'self> Zero for &'self str {
2207-
fn zero() -> &'self str { "" }
2208-
fn is_zero(&self) -> bool { self.is_empty() }
2209-
}
2210-
22112205
impl Zero for ~str {
22122206
fn zero() -> ~str { ~"" }
22132207
fn is_zero(&self) -> bool { self.len() == 0 }
@@ -3323,18 +3317,4 @@ mod tests {
33233317
t("zzz", "zz", ~["","z"]);
33243318
t("zzzzz", "zz", ~["","","z"]);
33253319
}
3326-
3327-
#[test]
3328-
fn test_str_zero() {
3329-
use num::Zero;
3330-
fn t<S: Zero + Str>() {
3331-
let s: S = Zero::zero();
3332-
assert_eq!(s.as_slice(), "");
3333-
assert!(s.is_zero());
3334-
}
3335-
3336-
t::<&str>();
3337-
t::<@str>();
3338-
t::<~str>();
3339-
}
33403320
}

branches/snap-stage3/src/libstd/str/ascii.rs

Lines changed: 23 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ use cast;
1717
use old_iter::BaseIter;
1818
use iterator::IteratorUtil;
1919
use vec::{CopyableVector, ImmutableVector, OwnedVector};
20-
use to_bytes::IterBytes;
2120

22-
/// Datatype to hold one ascii character. It wraps a `u8`, with the highest bit always zero.
21+
/// Datatype to hold one ascii character. It is 8 bit long.
2322
#[deriving(Clone, Eq)]
2423
pub struct Ascii { priv chr: u8 }
2524

@@ -73,9 +72,6 @@ pub trait AsciiCast<T> {
7372
/// Convert to an ascii type
7473
fn to_ascii(&self) -> T;
7574

76-
/// Convert to an ascii type, not doing any range asserts
77-
unsafe fn to_ascii_nocheck(&self) -> T;
78-
7975
/// Check if convertible to ascii
8076
fn is_ascii(&self) -> bool;
8177
}
@@ -84,12 +80,7 @@ impl<'self> AsciiCast<&'self[Ascii]> for &'self [u8] {
8480
#[inline(always)]
8581
fn to_ascii(&self) -> &'self[Ascii] {
8682
assert!(self.is_ascii());
87-
unsafe {self.to_ascii_nocheck()}
88-
}
89-
90-
#[inline(always)]
91-
unsafe fn to_ascii_nocheck(&self) -> &'self[Ascii] {
92-
cast::transmute(*self)
83+
unsafe{ cast::transmute(*self) }
9384
}
9485

9586
#[inline(always)]
@@ -105,13 +96,8 @@ impl<'self> AsciiCast<&'self[Ascii]> for &'self str {
10596
#[inline(always)]
10697
fn to_ascii(&self) -> &'self[Ascii] {
10798
assert!(self.is_ascii());
108-
unsafe {self.to_ascii_nocheck()}
109-
}
110-
111-
#[inline(always)]
112-
unsafe fn to_ascii_nocheck(&self) -> &'self[Ascii] {
113-
let (p,len): (*u8, uint) = cast::transmute(*self);
114-
cast::transmute((p, len - 1))
99+
let (p,len): (*u8, uint) = unsafe{ cast::transmute(*self) };
100+
unsafe{ cast::transmute((p, len - 1))}
115101
}
116102

117103
#[inline(always)]
@@ -124,11 +110,6 @@ impl AsciiCast<Ascii> for u8 {
124110
#[inline(always)]
125111
fn to_ascii(&self) -> Ascii {
126112
assert!(self.is_ascii());
127-
unsafe {self.to_ascii_nocheck()}
128-
}
129-
130-
#[inline(always)]
131-
unsafe fn to_ascii_nocheck(&self) -> Ascii {
132113
Ascii{ chr: *self }
133114
}
134115

@@ -142,11 +123,6 @@ impl AsciiCast<Ascii> for char {
142123
#[inline(always)]
143124
fn to_ascii(&self) -> Ascii {
144125
assert!(self.is_ascii());
145-
unsafe {self.to_ascii_nocheck()}
146-
}
147-
148-
#[inline(always)]
149-
unsafe fn to_ascii_nocheck(&self) -> Ascii {
150126
Ascii{ chr: *self as u8 }
151127
}
152128

@@ -159,38 +135,26 @@ impl AsciiCast<Ascii> for char {
159135
/// Trait for copyless casting to an ascii vector.
160136
pub trait OwnedAsciiCast {
161137
/// Take ownership and cast to an ascii vector without trailing zero element.
162-
fn into_ascii(self) -> ~[Ascii];
163-
164-
/// Take ownership and cast to an ascii vector without trailing zero element.
165-
/// Does not perform validation checks.
166-
unsafe fn into_ascii_nocheck(self) -> ~[Ascii];
138+
fn to_ascii_consume(self) -> ~[Ascii];
167139
}
168140

169141
impl OwnedAsciiCast for ~[u8] {
170142
#[inline(always)]
171-
fn into_ascii(self) -> ~[Ascii] {
143+
fn to_ascii_consume(self) -> ~[Ascii] {
172144
assert!(self.is_ascii());
173-
unsafe {self.into_ascii_nocheck()}
174-
}
175-
176-
#[inline(always)]
177-
unsafe fn into_ascii_nocheck(self) -> ~[Ascii] {
178-
cast::transmute(self)
145+
unsafe {cast::transmute(self)}
179146
}
180147
}
181148

182149
impl OwnedAsciiCast for ~str {
183150
#[inline(always)]
184-
fn into_ascii(self) -> ~[Ascii] {
151+
fn to_ascii_consume(self) -> ~[Ascii] {
185152
assert!(self.is_ascii());
186-
unsafe {self.into_ascii_nocheck()}
187-
}
188-
189-
#[inline(always)]
190-
unsafe fn into_ascii_nocheck(self) -> ~[Ascii] {
191-
let mut r: ~[Ascii] = cast::transmute(self);
192-
r.pop();
193-
r
153+
let mut s = self;
154+
unsafe {
155+
str::raw::pop_byte(&mut s);
156+
cast::transmute(s)
157+
}
194158
}
195159
}
196160

@@ -205,8 +169,6 @@ pub trait AsciiStr {
205169
/// Convert to vector representing a upper cased ascii string.
206170
fn to_upper(&self) -> ~[Ascii];
207171

208-
/// Compares two Ascii strings ignoring case
209-
fn eq_ignore_case(self, other: &[Ascii]) -> bool;
210172
}
211173

212174
impl<'self> AsciiStr for &'self [Ascii] {
@@ -226,45 +188,20 @@ impl<'self> AsciiStr for &'self [Ascii] {
226188
fn to_upper(&self) -> ~[Ascii] {
227189
self.map(|a| a.to_upper())
228190
}
229-
230-
#[inline(always)]
231-
fn eq_ignore_case(self, other: &[Ascii]) -> bool {
232-
do self.iter().zip(other.iter()).all |(&a, &b)| { a.eq_ignore_case(b) }
233-
}
234191
}
235192

236193
impl ToStrConsume for ~[Ascii] {
237194
#[inline(always)]
238-
fn into_str(self) -> ~str {
195+
fn to_str_consume(self) -> ~str {
239196
let mut cpy = self;
240197
cpy.push(0u8.to_ascii());
241198
unsafe {cast::transmute(cpy)}
242199
}
243200
}
244201

245-
impl IterBytes for Ascii {
246-
#[inline(always)]
247-
fn iter_bytes(&self, _lsb0: bool, f: &fn(buf: &[u8]) -> bool) -> bool {
248-
f([self.to_byte()])
249-
}
250-
}
251-
252-
/// Trait to convert to a owned byte array by consuming self
253-
pub trait ToBytesConsume {
254-
/// Converts to a owned byte array by consuming self
255-
fn into_bytes(self) -> ~[u8];
256-
}
257-
258-
impl ToBytesConsume for ~[Ascii] {
259-
fn into_bytes(self) -> ~[u8] {
260-
unsafe {cast::transmute(self)}
261-
}
262-
}
263-
264202
#[cfg(test)]
265203
mod tests {
266204
use super::*;
267-
use to_bytes::ToBytes;
268205

269206
macro_rules! v2ascii (
270207
( [$($e:expr),*]) => ( [$(Ascii{chr:$e}),*]);
@@ -308,8 +245,6 @@ mod tests {
308245
assert_eq!("YMCA".to_ascii().to_lower().to_str_ascii(), ~"ymca");
309246
assert_eq!("abcDEFxyz:.;".to_ascii().to_upper().to_str_ascii(), ~"ABCDEFXYZ:.;");
310247
311-
assert!("aBcDeF&?#".to_ascii().eq_ignore_case("AbCdEf&?#".to_ascii()));
312-
313248
assert!("".is_ascii());
314249
assert!("a".is_ascii());
315250
assert!(!"\u2009".is_ascii());
@@ -318,22 +253,21 @@ mod tests {
318253

319254
#[test]
320255
fn test_owned_ascii_vec() {
321-
assert_eq!((~"( ;").into_ascii(), v2ascii!(~[40, 32, 59]));
322-
assert_eq!((~[40u8, 32u8, 59u8]).into_ascii(), v2ascii!(~[40, 32, 59]));
256+
// FIXME: #4318 Compiler crashes on moving self
257+
//assert_eq!(~"( ;".to_ascii_consume(), v2ascii!(~[40, 32, 59]));
258+
//assert_eq!(~[40u8, 32u8, 59u8].to_ascii_consume(), v2ascii!(~[40, 32, 59]));
259+
//assert_eq!(~"( ;".to_ascii_consume_with_null(), v2ascii!(~[40, 32, 59, 0]));
260+
//assert_eq!(~[40u8, 32u8, 59u8].to_ascii_consume_with_null(),
261+
// v2ascii!(~[40, 32, 59, 0]));
323262
}
324263

325264
#[test]
326265
fn test_ascii_to_str() { assert_eq!(v2ascii!([40, 32, 59]).to_str_ascii(), ~"( ;"); }
327266
328267
#[test]
329-
fn test_ascii_into_str() {
330-
assert_eq!(v2ascii!(~[40, 32, 59]).into_str(), ~"( ;");
331-
}
332-
333-
#[test]
334-
fn test_ascii_to_bytes() {
335-
assert_eq!(v2ascii!(~[40, 32, 59]).to_bytes(false), ~[40u8, 32u8, 59u8]);
336-
assert_eq!(v2ascii!(~[40, 32, 59]).into_bytes(), ~[40u8, 32u8, 59u8]);
268+
fn test_ascii_to_str_consume() {
269+
// FIXME: #4318 Compiler crashes on moving self
270+
//assert_eq!(v2ascii!(~[40, 32, 59]).to_str_consume(), ~"( ;");
337271
}
338272
339273
#[test] #[should_fail]

branches/snap-stage3/src/libstd/to_str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub trait ToStr {
3131
/// Trait for converting a type to a string, consuming it in the process.
3232
pub trait ToStrConsume {
3333
/// Cosume and convert to a string.
34-
fn into_str(self) -> ~str;
34+
fn to_str_consume(self) -> ~str;
3535
}
3636

3737
impl ToStr for () {

branches/snap-stage3/src/libstd/vec.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2629,12 +2629,6 @@ impl<A:Clone> Clone for ~[A] {
26292629
}
26302630
}
26312631

2632-
// This works because every lifetime is a sub-lifetime of 'static
2633-
impl<'self, A> Zero for &'self [A] {
2634-
fn zero() -> &'self [A] { &'self [] }
2635-
fn is_zero(&self) -> bool { self.is_empty() }
2636-
}
2637-
26382632
impl<A> Zero for ~[A] {
26392633
fn zero() -> ~[A] { ~[] }
26402634
fn is_zero(&self) -> bool { self.len() == 0 }
@@ -4299,20 +4293,4 @@ mod tests {
42994293
}
43004294
assert_eq!(v, ~[~[1,2,3],~[1,3,2],~[2,1,3],~[2,3,1],~[3,1,2],~[3,2,1]]);
43014295
}
4302-
4303-
#[test]
4304-
fn test_vec_zero() {
4305-
use num::Zero;
4306-
macro_rules! t (
4307-
($ty:ty) => {
4308-
let v: $ty = Zero::zero();
4309-
assert!(v.is_empty());
4310-
assert!(v.is_zero());
4311-
}
4312-
);
4313-
4314-
t!(&[int]);
4315-
t!(@[int]);
4316-
t!(~[int]);
4317-
}
43184296
}

0 commit comments

Comments
 (0)